From a0268a38d30ca8a55ca36f570848b581f8ca92e8 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 25 Apr 2015 22:43:46 -0400 Subject: [PATCH] Ignore InputHint when not in WM_HINTS When InputHint is not in WM_HINTS (i.e., the flag is not set), treat the window as if the InputHint was set (the default behavior). This means that i3 will focus the window when it becomes managed. fixes #1676 --- src/window.c | 6 ++++-- testcases/t/158-wm_take_focus.t | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/window.c b/src/window.c index 5485bcc3..36737943 100644 --- a/src/window.c +++ b/src/window.c @@ -254,8 +254,10 @@ void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *ur return; } - win->doesnt_accept_focus = !hints.input; - LOG("WM_HINTS.input changed to \"%d\"\n", hints.input); + if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) { + win->doesnt_accept_focus = !hints.input; + LOG("WM_HINTS.input changed to \"%d\"\n", hints.input); + } if (urgency_hint != NULL) *urgency_hint = (xcb_icccm_wm_hints_get_urgency(&hints) != 0); diff --git a/testcases/t/158-wm_take_focus.t b/testcases/t/158-wm_take_focus.t index 050e1162..b8dae3b1 100644 --- a/testcases/t/158-wm_take_focus.t +++ b/testcases/t/158-wm_take_focus.t @@ -50,12 +50,15 @@ sub recv_take_focus { } subtest 'Window without WM_TAKE_FOCUS', sub { - fresh_workspace; + my $ws = fresh_workspace; my $window = open_window; ok(!recv_take_focus($window), 'did not receive ClientMessage'); + my $con = shift get_ws_content($ws); + ok($con->{focused}, 'con is focused'); + done_testing; }; @@ -72,7 +75,7 @@ subtest 'Window without WM_TAKE_FOCUS', sub { # list), the window cannot accept input focus, so we should not try to focus # the window at all. subtest 'Window with WM_TAKE_FOCUS and without InputHint', sub { - fresh_workspace; + my $ws = fresh_workspace; my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS'); @@ -88,6 +91,9 @@ subtest 'Window with WM_TAKE_FOCUS and without InputHint', sub { ok(!recv_take_focus($window), 'did not receive ClientMessage'); + my $con = shift get_ws_content($ws); + ok($con->{focused}, 'con is focused'); + done_testing; }; @@ -97,7 +103,7 @@ subtest 'Window with WM_TAKE_FOCUS and without InputHint', sub { # nearly identical presently, so this is currently used also as a proxy test # for the latter case. subtest 'Window with WM_TAKE_FOCUS and unspecified InputHint', sub { - fresh_workspace; + my $ws = fresh_workspace; my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS'); @@ -105,6 +111,9 @@ subtest 'Window with WM_TAKE_FOCUS and unspecified InputHint', sub { ok(!recv_take_focus($window), 'did not receive ClientMessage'); + my $con = shift get_ws_content($ws); + ok($con->{focused}, 'con is focused'); + done_testing; }; -- 2.39.2