From: Orestis Floros Date: Tue, 11 Sep 2018 17:09:16 +0000 (+0300) Subject: randr_disable_output: Always restore focus X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=db3b9e41874400958cf85b461a5d1ff04a398fa3;p=i3%2Fi3 randr_disable_output: Always restore focus con_detach and con_attach modify the focus stack. This will make sure that the currently focused workspace will remain focused after disabling an output. --- diff --git a/src/randr.c b/src/randr.c index 0c1f9704..4123cfcf 100644 --- a/src/randr.c +++ b/src/randr.c @@ -942,13 +942,8 @@ void randr_disable_output(Output *output) { if (output->con != NULL) { /* We need to move the workspaces from the disappearing output to the first output */ - /* 1: Get the con to focus next, if the disappearing ws is focused */ - Con *next = NULL; - if (TAILQ_FIRST(&(croot->focus_head)) == output->con) { - DLOG("This output (%p) was focused! Getting next\n", output->con); - next = focused; - DLOG("next = %p\n", next); - } + /* 1: Get the con to focus next */ + Con *next = focused; /* 2: iterate through workspaces and re-assign them, fixing the coordinates * of floating containers as we go */ @@ -971,15 +966,12 @@ void randr_disable_output(Output *output) { TAILQ_FOREACH(floating_con, &(current->floating_head), floating_windows) { floating_fix_coordinates(floating_con, &(output->con->rect), &(first->con->rect)); } - DLOG("Done, next\n"); } - DLOG("re-attached all workspaces\n"); - if (next) { - DLOG("now focusing next = %p\n", next); - con_activate(next); - workspace_show(con_get_workspace(next)); - } + /* Restore focus after con_detach / con_attach */ + DLOG("now focusing next = %p\n", next); + con_focus(next); + workspace_show(con_get_workspace(next)); /* 3: move the dock clients to the first output */ Con *child;