From cc802436623d8c13182d998433b2e2feafed0980 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jun 2010 14:38:02 +0200 Subject: [PATCH] Track the sibling that unmanaged windows are above so we don't do the work of reordering them in the stacking lists for ConfigureNotify events where their stacking order didn't change --- openbox/event.c | 45 ++++++++++++++++++++++++++++++++------------- openbox/stacking.c | 16 ++++++++++++++++ openbox/stacking.h | 3 +++ openbox/window.h | 1 + 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/openbox/event.c b/openbox/event.c index 2dcdb6ca..bf404d37 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -521,6 +521,16 @@ static void event_process(const XEvent *ec, gpointer data) /* deal with it in the kernel */ + /* deal with it in the ObWindow superclass first */ + if (!obwin) { + Window p; /* parent window (it's never None in these events) */ + if (((e->type == CreateNotify && (p = e->xcreatewindow.parent)) || + (e->type == ReparentNotify && (p = e->xreparent.parent))) && + p == obt_root(ob_screen)) + { + obwin = UNMANAGED_AS_WINDOW(unmanaged_new(window)); + } + } if (obwin) event_handle_window(obwin, e); if (e->type == FocusIn) { @@ -648,16 +658,6 @@ static void event_process(const XEvent *ec, gpointer data) if (client && client != focus_client) frame_adjust_focus(client->frame, FALSE); } - else if (e->type == CreateNotify && - !obwin && e->xcreatewindow.parent == obt_root(ob_screen)) - { - obwin = UNMANAGED_AS_WINDOW(unmanaged_new(e->xcreatewindow.window)); - } - else if (e->type == ReparentNotify && - !obwin && e->xreparent.parent == obt_root(ob_screen)) - { - obwin = UNMANAGED_AS_WINDOW(unmanaged_new(e->xreparent.window)); - } else if (client) event_handle_client(client, e); else if (um) @@ -1817,7 +1817,22 @@ static void event_handle_window(ObWindow *wi, XEvent *e) } break; - + case CreateNotify: + if (e->xcreatewindow.parent == obt_root(ob_screen)) + /* we actually only care about tracking above for unmanaged + windows, and they are only created by create or reparent + events, at which time they become the top-most, so we don't + bother tracking above for all windows in this function */ + wi->above = window_top(stacking_topmost_window()); + break; + case ReparentNotify: + if (e->xreparent.parent == obt_root(ob_screen)) + /* we actually only care about tracking above for unmanaged + windows, and they are only created by create or reparent + events, at which time they become the top-most, so we don't + bother tracking above for all windows in this function */ + wi->above = window_top(stacking_topmost_window()); + break; case MapNotify: if (e->xmap.window == window_redir(wi)) { composite_dirty(); @@ -1900,8 +1915,12 @@ static void event_handle_unmanaged(ObUnmanaged *um, XEvent *e) obt_display_ignore_errors(FALSE); break; case ConfigureNotify: - /* XXX check if above changed */ - stacking_unmanaged_above_notify(um, e->xconfigure.above); + if (e->xconfigure.above != UNMANAGED_AS_WINDOW(um)->above) { + ob_debug("ConfigureNotify changed stacking order for " + "unmanaged 0x%lx", window_top(um)); + stacking_unmanaged_above_notify(um, e->xconfigure.above); + UNMANAGED_AS_WINDOW(um)->above = e->xconfigure.above; + } } } diff --git a/openbox/stacking.c b/openbox/stacking.c index a8dac998..6e9e8e81 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -964,3 +964,19 @@ void stacking_iter_free(ObStackingIter *it) { g_slice_free(ObStackingIter, it); } + +ObWindow* stacking_topmost_window(void) +{ + ObUNode *un = stacking_ulist ? stacking_ulist->data : NULL; + if (un && un->belowme == stacking_list) + /* the topmost unmanaged window is higher than the topmost + managed window, return it */ + return UNMANAGED_AS_WINDOW(un->um); + else if (stacking_list) + /* the topmost managed window exists so it must be the highest */ + return stacking_list->data; + else + /* there is no topmost managed window, and there must not be an + unmanaged window either, as it would be above NULL */ + return NULL; +} diff --git a/openbox/stacking.h b/openbox/stacking.h index 1577d944..6058786d 100644 --- a/openbox/stacking.h +++ b/openbox/stacking.h @@ -99,4 +99,7 @@ void stacking_iter_prev(ObStackingIter *it); struct _ObWindow* stacking_iter_win(ObStackingIter *it); void stacking_iter_free(ObStackingIter *it); +/*! Return the topmost window on the screen */ +struct _ObWindow* stacking_topmost_window(void); + #endif diff --git a/openbox/window.h b/openbox/window.h index 1e288333..9afcdcd2 100644 --- a/openbox/window.h +++ b/openbox/window.h @@ -77,6 +77,7 @@ struct _ObWindow { gint n_rects; /* number of objects in @rects */ gboolean mapped; gboolean is_redir; + Window above; /* the sibling window last reported that this is above */ #endif }; -- 2.34.1