]> git.sur5r.net Git - i3/i3/commitdiff
Focus windows upon ConfigureWindow with stack-mode=Above (#2865)
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Sun, 20 Aug 2017 12:56:44 +0000 (14:56 +0200)
committerGitHub <noreply@github.com>
Sun, 20 Aug 2017 12:56:44 +0000 (14:56 +0200)
fixes #2708
fixes #2745

src/handlers.c
testcases/t/269-focus-stack-above.t [new file with mode: 0644]

index 9fb9040e3067f6170805f51a4060a6f087b1d76c..7d83f54131a7c5b61deb7435e30aa4f2d855d024 100644 (file)
@@ -400,11 +400,28 @@ static void handle_configure_request(xcb_configure_request_event_t *event) {
                 DLOG("Dock client will not be moved, we only support moving it to another output.\n");
             }
         }
+        fake_absolute_configure_notify(con);
+        return;
     }
 
-    fake_absolute_configure_notify(con);
+    if (event->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
+        DLOG("window 0x%08x wants to be stacked %d\n", event->window, event->stack_mode);
+        if (event->stack_mode == XCB_STACK_MODE_ABOVE) {
+            /* Emacs and IntelliJ Idea “request focus” by stacking their window
+             * above all others. */
+            if (!fullscreen && con_is_leaf(con)) {
+                if (strcmp(con_get_workspace(con)->name, "__i3_scratch") == 0) {
+                    DLOG("This is a scratchpad container, ignoring ConfigureRequest\n");
+                    return;
+                }
 
-    return;
+                con_focus(con);
+                tree_render();
+            }
+        }
+    }
+
+    fake_absolute_configure_notify(con);
 }
 
 /*
diff --git a/testcases/t/269-focus-stack-above.t b/testcases/t/269-focus-stack-above.t
new file mode 100644 (file)
index 0000000..e178526
--- /dev/null
@@ -0,0 +1,39 @@
+#!perl
+# vim:ts=4:sw=4:expandtab
+#
+# Please read the following documents before working on tests:
+# • http://build.i3wm.org/docs/testsuite.html
+#   (or docs/testsuite)
+#
+# • http://build.i3wm.org/docs/lib-i3test.html
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
+#
+# • http://build.i3wm.org/docs/ipc.html
+#   (or docs/ipc)
+#
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
+#   (unless you are already familiar with Perl)
+#
+# Verifies a ConfigureWindow request with stack-mode=Above is translated into
+# focusing the target window by i3.
+# Ticket: #2708
+# Bug still in: 4.13-207-gafdf6792
+use i3test;
+use X11::XCB qw(CONFIG_WINDOW_STACK_MODE STACK_MODE_ABOVE);
+
+my $ws = fresh_workspace;
+my $left_window = open_window;
+my $right_window = open_window;
+
+is($x->input_focus, $right_window->id, 'right window has focus');
+my $old_focus = get_focused($ws);
+
+$x->configure_window($left_window->id, CONFIG_WINDOW_STACK_MODE, (STACK_MODE_ABOVE));
+$x->flush;
+
+sync_with_i3;
+
+is($x->input_focus, $left_window->id, 'left window has focus');
+isnt(get_focused($ws), $old_focus, 'right window is no longer focused');
+
+done_testing;