]> git.sur5r.net Git - i3/i3/blobdiff - src/commands.c
Make 'focus' disable blocking fullscreen windows
[i3/i3] / src / commands.c
index 264cd04f63cbd590e0e92fff81ab5829feafde62..162f0892f4105941afe19aa33d2726c997b3c4f4 100644 (file)
@@ -1250,6 +1250,20 @@ void cmd_focus_direction(I3_CMD, const char *direction) {
     ysuccess(true);
 }
 
+/*
+ * Focus a container and disable any other fullscreen container not permitting the focus.
+ *
+ */
+static void cmd_focus_force_focus(Con *con) {
+    /* Disable fullscreen container in workspace with container to be focused. */
+    Con *ws = con_get_workspace(con);
+    Con *fullscreen_on_ws = (focused && focused->fullscreen_mode == CF_GLOBAL) ? focused : con_get_fullscreen_con(ws, CF_OUTPUT);
+    if (fullscreen_on_ws && fullscreen_on_ws != con && !con_has_parent(con, fullscreen_on_ws)) {
+        con_disable_fullscreen(fullscreen_on_ws);
+    }
+    con_focus(con);
+}
+
 /*
  * Implementation of 'focus tiling|floating|mode_toggle'.
  *
@@ -1274,7 +1288,7 @@ void cmd_focus_window_mode(I3_CMD, const char *window_mode) {
             (!to_floating && current->type == CT_FLOATING_CON))
             continue;
 
-        con_focus(con_descend_focused(current));
+        cmd_focus_force_focus(con_descend_focused(current));
         success = true;
         break;
     }
@@ -1341,13 +1355,6 @@ void cmd_focus(I3_CMD) {
         if (!ws)
             continue;
 
-        /* Check the fullscreen focus constraints. */
-        if (!con_fullscreen_permits_focusing(current->con)) {
-            LOG("Cannot change focus while in fullscreen mode (fullscreen rules).\n");
-            ysuccess(false);
-            return;
-        }
-
         /* In case this is a scratchpad window, call scratchpad_show(). */
         if (ws == __i3_scratch) {
             scratchpad_show(current->con);
@@ -1371,7 +1378,7 @@ void cmd_focus(I3_CMD) {
          * So we focus 'current' to make it the currently focused window of
          * the target workspace, then revert focus. */
         Con *currently_focused = focused;
-        con_focus(current->con);
+        cmd_focus_force_focus(current->con);
         con_focus(currently_focused);
 
         /* Now switch to the workspace, then focus */