#define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
ButtonPressMask | ButtonReleaseMask)
+void menu_control_show(Menu *self, int x, int y, Client *client);
+
void menu_destroy_hash_key(gpointer data)
{
g_free(data);
}
-Menu *menu_new(char *label, char *name, Menu *parent)
+Menu *menu_new_full(char *label, char *name, Menu *parent,
+ menu_controller_show show, menu_controller_update update)
{
XSetWindowAttributes attrib;
Menu *self;
self->shown = FALSE;
self->invalid = FALSE;
/* default controllers? */
+
+ self->show = show;
+ self->hide = NULL;
+ self->update = update;
+ self->mouseover = NULL;
+ self->selected = NULL;
attrib.override_redirect = TRUE;
attrib.event_mask = FRAME_EVENTMASK;
name);
return;
}
-
- if(self->invalid) {
- menu_render(self);
- }
-
- XMoveWindow(ob_display, self->frame, x, y);
+ if (self->invalid) {
+ if (self->update) {
+ self->update(self);
+ } else {
+ menu_render(self);
+ }
+ }
+
self->client = client;
- if (!self->shown) {
- stacking_raise_internal(self->frame);
- XMapWindow(ob_display, self->frame);
-/* grab_pointer_window(TRUE, None, self->frame);*/
- self->shown = TRUE;
+ if (self->show) {
+ self->show(self, x, y, client);
+ } else {
+ menu_control_show(self, x, y, client);
}
}
menu_hide(m);
}
}
+
+/*
+ Default menu controller action for showing.
+*/
+
+void menu_control_show(Menu *self, int x, int y, Client *client) {
+ XMoveWindow(ob_display, self->frame, x, y);
+
+ if (!self->shown) {
+ stacking_raise_internal(self->frame);
+ XMapWindow(ob_display, self->frame);
+ self->shown = TRUE;
+ }
+}