From db3b9e41874400958cf85b461a5d1ff04a398fa3 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Tue, 11 Sep 2018 20:09:16 +0300 Subject: [PATCH] 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. --- src/randr.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) 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;