#include "openbox.h"
#include "config.h"
#include "obt/prop.h"
+#include "obt/keyboard.h"
#include "obrender/theme.h"
#define PADDING 2
RrVisual(ob_rr_inst), mask, attrib);
}
+static void client_dest(ObClient *client, gpointer data)
+{
+ GList *it;
+
+ /* menus can be associated with a client, so null those refs since
+ we are disappearing now */
+ for (it = menu_frame_visible; it; it = g_list_next(it)) {
+ ObMenuFrame *f = it->data;
+ if (f->client == client)
+ f->client = NULL;
+ }
+}
+
void menu_frame_startup(gboolean reconfig)
{
gint i;
if (reconfig) return;
+ client_add_destroy_notify(client_dest, NULL);
menu_frame_map = g_hash_table_new(g_int_hash, g_int_equal);
}
if (reconfig) return;
+ client_remove_destroy_notify(client_dest);
g_hash_table_destroy(menu_frame_map);
}
ObMenuFrame *self;
XSetWindowAttributes attr;
- self = g_new0(ObMenuFrame, 1);
+ self = g_slice_new0(ObMenuFrame);
self->obwin.type = OB_WINDOW_CLASS_MENUFRAME;
self->menu = menu;
self->selected = NULL;
XDestroyWindow(obt_display, self->window);
- g_free(self);
+ g_slice_free(ObMenuFrame, self);
}
}
+ObtIC* menu_frame_ic(ObMenuFrame *self)
+{
+ /* menus are always used through a grab right now, so they can always use
+ the grab input context */
+ return grab_input_context();
+}
+
static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
ObMenuFrame *frame)
{
ObMenuEntryFrame *self;
XSetWindowAttributes attr;
- self = g_new0(ObMenuEntryFrame, 1);
+ self = g_slice_new0(ObMenuEntryFrame);
self->entry = entry;
self->frame = frame;
g_hash_table_remove(menu_frame_map, &self->bullet);
}
- g_free(self);
+ g_slice_free(ObMenuEntryFrame, self);
}
}
void menu_frame_move_on_screen(ObMenuFrame *self, gint x, gint y,
gint *dx, gint *dy)
{
- Rect *a = NULL;
+ Rect const *a = NULL;
gint pos, half;
*dx = *dy = 0;
*dx = MAX(*dx, a->x - x);
*dy = MAX(*dy, a->y - y);
}
-
- g_free(a);
}
static void menu_entry_frame_render(ObMenuEntryFrame *self)
static void menu_frame_update(ObMenuFrame *self)
{
GList *mit, *fit;
- Rect *a;
+ Rect const *a;
gint h;
menu_pipe_execute(self->menu);
}
}
- g_free(a);
-
menu_frame_render(self);
}
menu_frame_hide(it->data);
}
-void menu_frame_hide_all_client(ObClient *client)
-{
- GList *it = g_list_last(menu_frame_visible);
- if (it) {
- ObMenuFrame *f = it->data;
- if (f->client == client) {
- if (config_submenu_show_delay) {
- /* remove any submenu open requests */
- obt_main_loop_timeout_remove(ob_main_loop,
- submenu_show_timeout);
- }
- menu_frame_hide(f);
- }
- }
-}
-
ObMenuFrame* menu_frame_under(gint x, gint y)
{
ObMenuFrame *ret = NULL;
GSList *acts = self->entry->data.normal.actions;
ObClient *client = self->frame->client;
ObMenuFrame *frame = self->frame;
+ guint mods = obt_keyboard_only_modmasks(state);
/* release grabs before executing the shit */
- if (!(state & ControlMask)) {
- menu_frame_hide_all();
+ if (!(mods & ControlMask)) {
+ event_cancel_all_key_grabs();
frame = NULL;
}