]> git.sur5r.net Git - i3/i3/commitdiff
randr_disable_output: Always restore focus
authorOrestis Floros <orestisf1993@gmail.com>
Tue, 11 Sep 2018 17:09:16 +0000 (20:09 +0300)
committerOrestis Floros <orestisf1993@gmail.com>
Wed, 12 Sep 2018 13:46:47 +0000 (16:46 +0300)
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

index 0c1f9704c9e87b9e6340fc6ab8666c6b119125cd..4123cfcfc16f4f84f54f1a080850ce9783c13d6b 100644 (file)
@@ -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;