From a95870120ce30843d95bdc5d87d26973789ed947 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Mon, 29 May 2023 14:08:46 +0200 Subject: fix workspace not being focused on title bar scroll (#5518) --- release-notes/bugfixes/2-title-scroll | 1 + src/click.c | 3 +++ testcases/t/297-scroll-tabbed.t | 39 ++++++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 release-notes/bugfixes/2-title-scroll 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(< 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; -- cgit v1.2.3-54-g00ecf