From 417a61ed616a272c9412ab4d8f2dcd04ead25fe1 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Sun, 23 Jan 2022 12:16:52 +0100 Subject: Have _NET_ACTIVE_WINDOW warp the pointer only on direct user input This functionally partly reverts commit db0f56a (Do not warp mouse to windows marked active by EWMH, 2022-01-17) which introduced a bug where the pointer would no longer be warped to windows activated by rofi. Since the window switcher internal to cwm calls client_ptr_warp directly this was not noticed immediately. Thankfully the EWMH spec defines a "source indication" [1] in the _NET_ACTIVE_WINDOW request [2]. This field specifies whether the request came from a normal application or a pager and "other clients that represent direct user actions". Window switchers like rofi should honor this field and therefore it is trivial to fix this bug by checking for the correct source indication value. This means that normal windows are now prohibited from warping the pointer under any circumstance, but the user (through specific applications) may still elect to have the window manager honor _NET_ACTIVE_WINDOW this way. [1] https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#sourceindication [2] https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm45682917892304 --- xevents.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xevents.c b/xevents.c index 12fb72b..8cfee2d 100644 --- a/xevents.c +++ b/xevents.c @@ -401,6 +401,17 @@ xev_handle_clientmessage(XEvent *ee) if ((old_cc = client_current(NULL)) != NULL) client_ptr_save(old_cc); client_show(cc); + + /* + * Only warp the pointer if the source indication field says that + * the request to activate another window comes from a pager or + * other direct user input. + * + * This will stop certain dialog windows from repeatedly activating + * themselves, effectively jailing the cursor. + */ + if(e->data.l[0] == 2) + client_ptr_warp(cc); } } else if (e->message_type == ewmh[_NET_WM_DESKTOP]) { if ((cc = client_find(e->window)) != NULL) { -- cgit v1.2.3-2-gb3c3