]> Dogcows Code - chaz/openbox/blobdiff - openbox/menu.c
put the render theme into a struct
[chaz/openbox] / openbox / menu.c
index 3373616fef026758c2789ffe8bbe6872eefcc9e8..8e2a8583f88f52085aedcfd4b2570fa5177c4958 100644 (file)
@@ -7,7 +7,7 @@
 #include "geom.h"
 #include "plugin.h"
 
-static GHashTable *menu_hash = NULL;
+GHashTable *menu_hash = NULL;
 
 #define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask | \
                         LeaveWindowMask)
@@ -17,9 +17,9 @@ static GHashTable *menu_hash = NULL;
 
 void menu_control_show(Menu *self, int x, int y, Client *client);
 
-void menu_destroy_hash_key(gpointer data)
+void menu_destroy_hash_key(Menu *menu)
 {
-    g_free(data);
+    g_free(menu);
 }
 
 void menu_destroy_hash_value(Menu *self)
@@ -39,7 +39,7 @@ void menu_destroy_hash_value(Menu *self)
 
     stacking_remove(self);
 
-    appearance_free(self->a_title);
+    RrAppearanceFree(self->a_title);
     XDestroyWindow(ob_display, self->title);
     XDestroyWindow(ob_display, self->frame);
     XDestroyWindow(ob_display, self->items);
@@ -54,9 +54,9 @@ void menu_entry_free(MenuEntry *self)
 
     g_hash_table_remove(window_map, &self->item);
 
-    appearance_free(self->a_item);
-    appearance_free(self->a_disabled);
-    appearance_free(self->a_hilite);
+    RrAppearanceFree(self->a_item);
+    RrAppearanceFree(self->a_disabled);
+    RrAppearanceFree(self->a_hilite);
     XDestroyWindow(ob_display, self->item);
 
     g_free(self);
@@ -73,7 +73,7 @@ void menu_startup()
                                       menu_destroy_hash_key,
                                       (GDestroyNotify)menu_destroy_hash_value);
 
-    m = menu_new(NULL, "root", NULL);
+    m = menu_new("sex menu", "root", NULL);
  
     a = action_from_string("execute");
     a->data.execute.path = g_strdup("xterm");
@@ -83,6 +83,8 @@ void menu_startup()
     menu_add_entry(m, menu_entry_new_separator("--"));
     a = action_from_string("exit");
     menu_add_entry(m, menu_entry_new("exit", a));
+
+    /*
     s = menu_new("subsex menu", "submenu", m);
     a = action_from_string("execute");
     a->data.execute.path = g_strdup("xclock");
@@ -90,14 +92,6 @@ void menu_startup()
 
     menu_add_entry(m, menu_entry_new_submenu("subz", s));
 
-    t = (Menu *)plugin_create("timed_menu");
-    if (t) {
-        a = action_from_string("execute");
-        a->data.execute.path = g_strdup("xeyes");
-        menu_add_entry(t, menu_entry_new("xeyes", a));
-        menu_add_entry(m, menu_entry_new_submenu("timed", t));
-    }
-    
     s = menu_new("empty", "chub", m);
     menu_add_entry(m, menu_entry_new_submenu("empty", s));
 
@@ -119,17 +113,7 @@ void menu_startup()
     menu_add_entry(s, menu_entry_new("exit", a));
 
     menu_add_entry(m, menu_entry_new_submenu("long", s));
-    
-    m = menu_new(NULL, "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()
@@ -141,8 +125,8 @@ static Window createWindow(Window parent, unsigned long mask,
                           XSetWindowAttributes *attrib)
 {
     return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
-                        render_depth, InputOutput, render_visual,
-                        mask, attrib);
+                        RrDepth(ob_rr_inst), InputOutput,
+                         RrVisual(ob_rr_inst), mask, attrib);
                        
 }
 
@@ -180,17 +164,17 @@ Menu *menu_new_full(char *label, char *name, Menu *parent,
     self->title = createWindow(self->frame, CWEventMask, &attrib);
     self->items = createWindow(self->frame, 0, &attrib);
 
-    XSetWindowBorderWidth(ob_display, self->frame, theme_bwidth);
-    XSetWindowBackground(ob_display, self->frame, theme_b_color->pixel);
-    XSetWindowBorderWidth(ob_display, self->title, theme_bwidth);
-    XSetWindowBorder(ob_display, self->frame, theme_b_color->pixel);
-    XSetWindowBorder(ob_display, self->title, theme_b_color->pixel);
+    XSetWindowBorderWidth(ob_display, self->frame, ob_rr_theme->bwidth);
+    XSetWindowBackground(ob_display, self->frame, ob_rr_theme->b_color->pixel);
+    XSetWindowBorderWidth(ob_display, self->title, ob_rr_theme->bwidth);
+    XSetWindowBorder(ob_display, self->frame, ob_rr_theme->b_color->pixel);
+    XSetWindowBorder(ob_display, self->title, ob_rr_theme->b_color->pixel);
 
     XMapWindow(ob_display, self->title);
     XMapWindow(ob_display, self->items);
 
-    self->a_title = appearance_copy(theme_a_menu_title);
-    self->a_items = appearance_copy(theme_a_menu);
+    self->a_title = RrAppearanceCopy(ob_rr_theme->a_menu_title);
+    self->a_items = RrAppearanceCopy(ob_rr_theme->a_menu);
 
     g_hash_table_insert(window_map, &self->frame, self);
     g_hash_table_insert(window_map, &self->title, self);
@@ -250,9 +234,9 @@ void menu_add_entry(Menu *menu, MenuEntry *entry)
     attrib.event_mask = ENTRY_EVENTMASK;
     entry->item = createWindow(menu->items, CWEventMask, &attrib);
     XMapWindow(ob_display, entry->item);
-    entry->a_item = appearance_copy(theme_a_menu_item);
-    entry->a_disabled = appearance_copy(theme_a_menu_disabled);
-    entry->a_hilite = appearance_copy(theme_a_menu_hilite);
+    entry->a_item = RrAppearanceCopy(ob_rr_theme->a_menu_item);
+    entry->a_disabled = RrAppearanceCopy(ob_rr_theme->a_menu_disabled);
+    entry->a_hilite = RrAppearanceCopy(ob_rr_theme->a_menu_hilite);
 
     menu->invalid = TRUE;
 
@@ -288,7 +272,6 @@ void menu_show_full(Menu *self, int x, int y, Client *client)
     }
 }
 
-
 void menu_hide(Menu *self) {
     if (self->shown) {
         XUnmapWindow(ob_display, self->frame);
@@ -380,17 +363,18 @@ void menu_control_mouseover(MenuEntry *self, gboolean enter) {
            /* TODO: I don't understand why these bevels should be here.
               Something must be wrong in the width calculation */
            x = self->parent->location.x + self->parent->size.width + 
-               theme_bevel;
+               ob_rr_theme->bevel;
 
            /* need to get the width. is this bad?*/
            menu_render(self->submenu);
 
            if (self->submenu->size.width + x > screen_physical_size.width)
                x = self->parent->location.x - self->submenu->size.width - 
-                   theme_bevel;
+                   ob_rr_theme->bevel;
            
            menu_show_full(self->submenu, x,
-                          self->parent->location.y + self->y, NULL);
+                          self->parent->location.y + self->y,
+                           self->parent->client);
        } 
     }
 }
This page took 0.028998 seconds and 4 git commands to generate.