diff options
| author | Scott Moynes <smoynes@nexus.carleton.ca> | 2003-05-21 23:58:40 +0000 |
|---|---|---|
| committer | Scott Moynes <smoynes@nexus.carleton.ca> | 2003-05-21 23:58:40 +0000 |
| commit | 71d2605e1c24732e923333419d829f1c5f867fed (patch) | |
| tree | d5f25de1dfd118a80f0c139199b280d584dc5a69 /openbox | |
| parent | 955d9d8e3048d04edb8986bfe7693e659204eae3 (diff) | |
Client menus
Add "client_menu" to pluginrc to use.
Diffstat (limited to 'openbox')
| -rw-r--r-- | openbox/client.c | 12 | ||||
| -rw-r--r-- | openbox/event.c | 6 | ||||
| -rw-r--r-- | openbox/menu.c | 38 | ||||
| -rw-r--r-- | openbox/menu.h | 5 |
4 files changed, 28 insertions, 33 deletions
diff --git a/openbox/client.c b/openbox/client.c index 75a3bc25..cb592b02 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -14,6 +14,7 @@ #include "openbox.h" #include "group.h" #include "config.h" +#include "menu.h" #include "render/render.h" #include <glib.h> @@ -311,6 +312,13 @@ void client_unmanage_all() client_unmanage(client_list->data); } +/* called by client_unmanage() to close any menus referencing this client */ +void client_close_menus(gpointer key, gpointer value, gpointer self) +{ + if (((Menu *)value)->client == (Client *)self) + menu_hide((Menu *)value); +} + void client_unmanage(Client *self) { int j; @@ -364,6 +372,10 @@ void client_unmanage(Client *self) if (moveresize_client == self) moveresize_end(TRUE); + /* close any windows that are attached to this window */ + g_hash_table_foreach(menu_hash, client_close_menus, self); + + if (focus_client == self) { XEvent e; diff --git a/openbox/event.c b/openbox/event.c index b0048e37..900cb943 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -34,7 +34,7 @@ static void event_handle_root(XEvent *e); static void event_handle_dock(Dock *s, XEvent *e); static void event_handle_dockapp(DockApp *app, XEvent *e); static void event_handle_client(Client *c, XEvent *e); -static void event_handle_menu(Menu *menu, XEvent *e); +static void event_handle_menu(Menu *menu, Client *c, XEvent *e); #define INVALID_FOCUSIN(e) ((e)->xfocus.detail == NotifyInferior || \ (e)->xfocus.detail > NotifyNonlinearVirtual) @@ -436,7 +436,7 @@ static void event_process(XEvent *e) /* deal with it in the kernel */ if (menu) { - event_handle_menu(menu, e); + event_handle_menu(menu, client, e); return; } else if (client) event_handle_client(client, e); @@ -909,7 +909,7 @@ static void event_handle_client(Client *client, XEvent *e) } } -static void event_handle_menu(Menu *menu, XEvent *e) +static void event_handle_menu(Menu *menu, Client *client, XEvent *e) { MenuEntry *entry; diff --git a/openbox/menu.c b/openbox/menu.c index 98f5fed1..3143c911 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -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) @@ -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,19 +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)); - } - - t = (Menu *)plugin_create("fifo_menu"); - if (t) { - menu_add_entry(m, menu_entry_new_submenu("fifo", t)); - } - s = menu_new("empty", "chub", m); menu_add_entry(m, menu_entry_new_submenu("empty", s)); @@ -124,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() @@ -395,7 +374,8 @@ void menu_control_mouseover(MenuEntry *self, gboolean enter) { theme_bevel; menu_show_full(self->submenu, x, - self->parent->location.y + self->y, NULL); + self->parent->location.y + self->y, + self->parent->client); } } } diff --git a/openbox/menu.h b/openbox/menu.h index 2d811c12..49a79fb4 100644 --- a/openbox/menu.h +++ b/openbox/menu.h @@ -12,9 +12,11 @@ struct MenuEntry; typedef void(*menu_controller_show)(struct Menu *self, int x, int y, Client *); typedef void(*menu_controller_update)(struct Menu *self); -typedef void(*menu_controller_mouseover)(struct MenuEntry *self, +typedef void(*menu_controller_mouseover)(struct MenuEntry *self, gboolean enter); +extern GHashTable *menu_hash; + typedef struct Menu { ObWindow obwin; @@ -135,6 +137,7 @@ void menu_entry_render(MenuEntry *self); void menu_entry_fire(MenuEntry *self); void menu_render(Menu *self); +void menu_render_full(Menu *self); void menu_control_mouseover(MenuEntry *entry, gboolean enter); #endif |
