From: Michael Stapelberg Date: Tue, 7 Apr 2009 14:48:42 +0000 (+0200) Subject: Bugfix: Set focus to the client which was previously focused instead of the next... X-Git-Tag: 3.a-bf1~56 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cb7b7a73d2900a0c846997e888e36ec9ffbd0782;p=i3%2Fi3 Bugfix: Set focus to the client which was previously focused instead of the next client when moving windows This fixes ticket #21 --- diff --git a/src/commands.c b/src/commands.c index 258d5a09..bc3f277c 100644 --- a/src/commands.c +++ b/src/commands.c @@ -171,12 +171,22 @@ static void move_current_window(xcb_connection_t *conn, direction_t direction) { container->currently_focused->dock) return; - /* As soon as the client is moved away, the next client in the old + /* As soon as the client is moved away, the last focused client in the old * container needs to get focus, if any. Therefore, we save it here. */ Client *current_client = container->currently_focused; - Client *to_focus = CIRCLEQ_NEXT_OR_NULL(&(container->clients), current_client, clients); - if (to_focus == NULL) - to_focus = CIRCLEQ_PREV_OR_NULL(&(container->clients), current_client, clients); + Client *to_focus = NULL, *client_loop; + + SLIST_FOREACH(client_loop, &(container->workspace->focus_stack), focus_clients) + if ((client_loop->container == container) && (client_loop != current_client)) { + to_focus = client_loop; + break; + } + + if (to_focus == NULL) { + to_focus = CIRCLEQ_NEXT_OR_NULL(&(container->clients), current_client, clients); + if (to_focus == NULL) + to_focus = CIRCLEQ_PREV_OR_NULL(&(container->clients), current_client, clients); + } switch (direction) { case D_LEFT: