]> Dogcows Code - chaz/openbox/blobdiff - openbox/menu.c
all my changes while i was offline.
[chaz/openbox] / openbox / menu.c
index 314c2f5e6413ab24f93a2e5ffff9345b7ef92c71..88eef9c558d5278ef51625daf0d8100494b5b003 100644 (file)
@@ -12,6 +12,8 @@ GHashTable *menu_map = NULL;
 #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);
@@ -74,6 +76,16 @@ void menu_startup()
     menu_add_entry(m, menu_entry_new("--", NULL));
     a = action_from_string("exit");
     menu_add_entry(m, menu_entry_new("exit", a));
+
+    m = menu_new("client menu", "client", NULL);
+    a = action_from_string("iconify");
+    menu_add_entry(m, menu_entry_new("iconify", a));
+    a = action_from_string("toggleshade");
+    menu_add_entry(m, menu_entry_new("(un)shade", a));
+    a = action_from_string("togglemaximizefull");
+    menu_add_entry(m, menu_entry_new("(un)maximize", a));
+    a = action_from_string("close");
+    menu_add_entry(m, menu_entry_new("close", a));
 }
 
 void menu_shutdown()
@@ -91,7 +103,8 @@ static Window createWindow(Window parent, unsigned long mask,
                        
 }
 
-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;
@@ -105,6 +118,12 @@ Menu *menu_new(char *label, char *name, Menu *parent)
     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;
@@ -195,20 +214,21 @@ void menu_show(char *name, int x, int y, Client *client)
                   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);
     }
 }
 
@@ -268,3 +288,17 @@ void menu_entry_fire(MenuEntry *self)
         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;
+  }
+}
This page took 0.021838 seconds and 4 git commands to generate.