From e438e3aec9d43a451912c3158ddfe126ce30ce24 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 31 Jul 2010 10:40:01 +0200 Subject: [PATCH] Stack clients without causing X11 errors Previously, the bottom-most window in the stacking order would cause an error because we tried to stack it above it's sibling XCB_NONE. This was invalid. That X11 error didn't hurt, but it does look weird. Fix this by not issuing that invalid ConfigureWindow request. Signed-off-by: Uli Schlachter --- stack.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/stack.c b/stack.c index 9896add59..ed33b5ac0 100644 --- a/stack.c +++ b/stack.c @@ -70,6 +70,24 @@ stack_windows(void) need_stack_refresh = true; } +/** Stack a window above another window, without causing errors. + * \param w The window. + * \param previous The window which should be below this window. + */ +static void +stack_window_above(xcb_window_t w, xcb_window_t previous) +{ + if (previous == XCB_NONE) + /* This would cause an error from the X server. Also, if we really + * changed the stacking order of all windows, they'd all have to redraw + * themselves. Doing it like this is better. */ + return; + + xcb_configure_window(globalconf.connection, w, + XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, + (uint32_t[]) { previous, XCB_STACK_MODE_ABOVE }); +} + /** Stack a client above. * \param client The client. * \param previous The previous client on the stack. @@ -78,9 +96,7 @@ stack_windows(void) static xcb_window_t stack_client_above(client_t *c, xcb_window_t previous) { - xcb_configure_window(globalconf.connection, c->window, - XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, - (uint32_t[]) { previous, XCB_STACK_MODE_ABOVE }); + stack_window_above(c->window, previous); previous = c->window; @@ -150,9 +166,6 @@ stack_refresh() if(!need_stack_refresh) return; - /* XCB_NONE is an invalid value for XCB_CONFIG_WINDOW_SIBLING and will cause - * an error instead of changing the stacking order. This is a *good* thing. - * Else we would be forcing windows to redraw themselves. */ xcb_window_t next = XCB_NONE; /* stack desktop windows */ @@ -165,10 +178,7 @@ stack_refresh() foreach(wibox, globalconf.wiboxes) if(!(*wibox)->ontop) { - xcb_configure_window(globalconf.connection, - (*wibox)->window, - XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, - (uint32_t[]) { next, XCB_STACK_MODE_ABOVE }); + stack_window_above((*wibox)->window, next); next = (*wibox)->window; } @@ -182,10 +192,7 @@ stack_refresh() foreach(wibox, globalconf.wiboxes) if((*wibox)->ontop) { - xcb_configure_window(globalconf.connection, - (*wibox)->window, - XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, - (uint32_t[]) { next, XCB_STACK_MODE_ABOVE }); + stack_window_above((*wibox)->window, next); next = (*wibox)->window; }