aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrestis Floros <orestisflo@gmail.com>2023-05-29 14:08:46 +0200
committerGitHub <noreply@github.com>2023-05-29 14:08:46 +0200
commita95870120ce30843d95bdc5d87d26973789ed947 (patch)
tree1391535515343f5072f32a0ba8d5baceef71669d
parentfde43a078b1fac5fc5842eb1cfb7e2a1a9f7bca8 (diff)
downloadi3-a95870120ce30843d95bdc5d87d26973789ed947.tar.gz
i3-a95870120ce30843d95bdc5d87d26973789ed947.zip
fix workspace not being focused on title bar scroll (#5518)
-rw-r--r--release-notes/bugfixes/2-title-scroll1
-rw-r--r--src/click.c3
-rw-r--r--testcases/t/297-scroll-tabbed.t39
3 files changed, 42 insertions, 1 deletions
diff --git a/release-notes/bugfixes/2-title-scroll b/release-notes/bugfixes/2-title-scroll
new file mode 100644
index 00000000..af43ccd7
--- /dev/null
+++ b/release-notes/bugfixes/2-title-scroll
@@ -0,0 +1 @@
+fix workspace not being focused on title bar scroll
diff --git a/src/click.c b/src/click.c
index 19c1dfaa..27dd7109 100644
--- a/src/click.c
+++ b/src/click.c
@@ -221,6 +221,9 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
/* 1: see if the user scrolled on the decoration of a stacked/tabbed con */
if (in_stacked && dest == CLICK_DECORATION && is_scroll) {
DLOG("Scrolling on a window decoration\n");
+ /* Correctly move workspace focus first, see: #5472 */
+ workspace_show(ws);
+
/* Use the focused child of the tabbed / stacked container, not the
* container the user scrolled on. */
Con *current = TAILQ_FIRST(&(con->parent->focus_head));
diff --git a/testcases/t/297-scroll-tabbed.t b/testcases/t/297-scroll-tabbed.t
index b535d0cd..c47b5315 100644
--- a/testcases/t/297-scroll-tabbed.t
+++ b/testcases/t/297-scroll-tabbed.t
@@ -18,9 +18,11 @@
# only one window is focused as a result.
# Ticket: #3215 (PR)
# Bug still in: 4.15-92-g666aa9e0
-use i3test;
+use i3test i3_autostart => 0;
use i3test::XTEST;
+my $pid = launch_with_config('-default');
+
sub scroll_down {
# button5 = scroll down
xtest_button_press(5, 3, 3);
@@ -81,4 +83,39 @@ cmd '[id=' . $outside->id . '] focus';
scroll_up;
is($x->input_focus, $first->id, 'Scrolling from outside the tabbed container works');
+exit_gracefully($pid);
+
+###############################################################################
+# Test that focus changes workspace correctly with 'focus_follows_mouse no'
+# See issue #5472.
+###############################################################################
+$pid = launch_with_config(<<EOT
+# i3 config file (v4)
+font font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+focus_follows_mouse no
+fake-outputs 1024x768+0+0,1024x768+1024+0
+EOT
+);
+
+my $ws1 = fresh_workspace(output => 0);
+$first = open_window;
+cmd 'layout tabbed';
+is($x->input_focus, $first->id, 'sanity check: window focused');
+open_window;
+
+my $ws2 = fresh_workspace(output => 1);
+ok(get_ws($ws2)->{focused}, 'sanity check: second workspace focused');
+
+# Decoration of top left window.
+$x->root->warp_pointer(3, 3);
+
+my @events = events_for( sub { scroll_up }, 'workspace');
+is($x->input_focus, $first->id, 'window focused');
+is(scalar @events, 1, 'Received 1 workspace event');
+is($events[0]->{change}, 'focus', 'Event has change = focus');
+is($events[0]->{current}->{name}, $ws1, 'new == ws1');
+is($events[0]->{old}->{name}, $ws2, 'old == ws2');
+
+exit_gracefully($pid);
+
done_testing;