From cbf4fcb9b5b05146dae464d6414c9a8b8144ddba Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 21 Jan 2011 21:49:56 +0100 Subject: [PATCH] Bugfix: Fix focus problems when switching workspaces by pushing the window stack before mapping --- src/x.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/x.c b/src/x.c index b929fdcd..f99dbcfc 100644 --- a/src/x.c +++ b/src/x.c @@ -559,13 +559,16 @@ static void x_push_node_unmaps(Con *con) { * Pushes all changes (state of each node, see x_push_node() and the window * stack) to X11. * + * NOTE: We need to push the stack first so that the windows have the correct + * stacking order. This is relevant for workspace switching where we map the + * windows because mapping may generate EnterNotify events. When they are + * generated in the wrong order, this will cause focus problems when switching + * workspaces. + * */ void x_push_changes(Con *con) { con_state *state; - DLOG("\n\n PUSHING CHANGES\n\n"); - x_push_node(con); - DLOG("-- PUSHING WINDOW STACK --\n"); bool order_changed = false; /* X11 correctly represents the stack if we push it from bottom to top */ @@ -587,6 +590,9 @@ void x_push_changes(Con *con) { state->initial = false; } + DLOG("\n\n PUSHING CHANGES\n\n"); + x_push_node(con); + xcb_window_t to_focus = focused->frame; if (focused->window != NULL) to_focus = focused->window->id;