fix workspace not being focused on title bar scroll (#5518)

This commit is contained in:
Orestis Floros 2023-05-29 14:08:46 +02:00 committed by GitHub
parent fde43a078b
commit a95870120c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1 @@
fix workspace not being focused on title bar scroll

View File

@ -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));

View File

@ -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;