raise menus above clients. hilight menu entries as the cursor passes over them.
Dana Jansens danakj@orodu.net
7 files changed,
204 insertions(+),
102 deletions(-)
M
openbox/event.c
→
openbox/event.c
@@ -5,6 +5,7 @@ #include "prop.h"
#include "config.h" #include "screen.h" #include "frame.h" +#include "menu.h" #include "framerender.h" #include "focus.h" #include "stacking.h"@@ -22,6 +23,7 @@
static void event_process(XEvent *e); static void event_handle_root(XEvent *e); static void event_handle_client(Client *c, XEvent *e); +static void event_handle_menu(Menu *menu, XEvent *e); Time event_lasttime = 0;@@ -310,16 +312,20 @@ static void event_process(XEvent *e)
{ Window window; Client *client; + Menu *menu = NULL; window = event_get_window(e); - client = g_hash_table_lookup(client_map, &window); + if (!(client = g_hash_table_lookup(client_map, &window))) + menu = g_hash_table_lookup(menu_map, &window); event_set_lasttime(e); event_hack_mods(e); if (event_ignore(e, client)) return; /* deal with it in the kernel */ - if (client) + if (menu) + event_handle_menu(menu, e); + else if (client) event_handle_client(client, e); else if (window == ob_root) event_handle_root(e);@@ -700,3 +706,20 @@ }
#endif } } + +static void event_handle_menu(Menu *menu, XEvent *e) +{ + MenuEntry *entry; + + switch (e->type) { + case EnterNotify: + case LeaveNotify: + g_message("enter/leave"); + entry = menu_find_entry(menu, e->xcrossing.window); + if (entry) { + entry->hilite = e->type == EnterNotify; + menu_entry_render(entry); + } + break; + } +}
M
openbox/focus.c
→
openbox/focus.c
@@ -9,6 +9,7 @@ #include "prop.h"
#include "dispatch.h" #include "focus.h" #include "parse.h" +#include "stacking.h" #include <X11/Xlib.h> #include <glib.h>@@ -35,7 +36,8 @@ focus_backup = XCreateWindow(ob_display, ob_root,
-100, -100, 1, 1, 0, CopyFromParent, InputOutput, CopyFromParent, CWOverrideRedirect, &attrib); - XMapRaised(ob_display, focus_backup); + XMapWindow(ob_display, focus_backup); + stacking_raise_internal(focus_backup); /* start with nothing focused */ focus_set_client(NULL);
M
openbox/openbox.c
→
openbox/openbox.c
@@ -181,6 +181,7 @@ if (!theme) return 1;
menu_startup(); frame_startup(); + stacking_startup(); focus_startup(); screen_startup(); group_startup();@@ -204,6 +205,7 @@ client_shutdown();
group_shutdown(); screen_shutdown(); focus_shutdown(); + stacking_shutdown(); frame_shutdown(); menu_shutdown(); grab_shutdown();
M
openbox/stacking.c
→
openbox/stacking.c
@@ -8,6 +8,24 @@ #include <glib.h>
GList *stacking_list = NULL; +static Window top_window = None; + +void stacking_startup() +{ + XSetWindowAttributes attrib; + attrib.override_redirect = TRUE; + top_window = XCreateWindow(ob_display, ob_root, + -100, -100, 1, 1, 0, + CopyFromParent, InputOutput, CopyFromParent, + CWOverrideRedirect, &attrib); + XMapWindow(ob_display, top_window); +} + +void stacking_shutdown() +{ + XDestroyWindow(ob_display, top_window); +} + void stacking_set_list() { Window *windows, *win_it;@@ -30,7 +48,8 @@ *win_it = ((Client*)it->data)->window;
} else windows = NULL; - PROP_SETA32(ob_root, net_client_list_stacking, window, windows, size); + PROP_SETA32(ob_root, net_client_list_stacking, window, + (guint32*)windows, size); if (windows) g_free(windows);@@ -183,3 +202,12 @@
stacking_set_list(); } +void stacking_raise_internal(Window win) +{ + Window wins[2]; /* only ever restack 2 windows. */ + + wins[0] = top_window; + wins[1] = win; + + XRestackWindows(ob_display, wins, 2); +}
M
openbox/stacking.h
→
openbox/stacking.h
@@ -2,6 +2,7 @@ #ifndef __stacking_h
#define __stacking_h #include <glib.h> +#include <X11/Xlib.h> struct Client;@@ -19,6 +20,9 @@ } StackLayer;
/* list of Client*s in stacking order from highest to lowest */ extern GList *stacking_list; + +void stacking_startup(); +void stacking_shutdown(); /*! Sets the client stacking list on the root window from the stacking_clientlist */@@ -35,5 +39,8 @@ void stacking_raise(struct Client *client);
/*! Lowers a client window below all others in its stacking layer */ void stacking_lower(struct Client *client); + +/*! Raises an internal window (e.g. menus) */ +void stacking_raise_internal(Window win); #endif