From 653681ac40dc87bbe117eb538dc502b3bc50de38 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 15 Jan 2023 22:56:08 +0100 Subject: [PATCH] Allow activating windows on other desktops regardless of focus stealing protection Currently, on X11, when activating a window that is not on the current desktop we allow this only if focus stealing protection is set to none. If any focus stealing protection is set then activation is denied. That behavior is unintiutive to the user. When I e.g. click on a notification from a chat app I expect something to happen, regardless of focus stealing protection. Remove the special handling of windows on different desktops and only apply the usual focus stealing prevention checks (based on timestamps etc). This also matches the behavior on Wayland. --- src/activation.cpp | 13 +------------ src/netinfo.cpp | 4 ++-- src/x11window.h | 3 +-- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/activation.cpp b/src/activation.cpp index 53bfe42fc6..20e0e5decd 100644 --- a/src/activation.cpp +++ b/src/activation.cpp @@ -814,9 +814,7 @@ enum Level { } // focus_in -> the window got FocusIn event -// ignore_desktop - call comes from _NET_ACTIVE_WINDOW message, don't refuse just because of window -// is on a different desktop -bool X11Window::allowWindowActivation(xcb_timestamp_t time, bool focus_in, bool ignore_desktop) +bool X11Window::allowWindowActivation(xcb_timestamp_t time, bool focus_in) { auto window = this; // options->focusStealingPreventionLevel : @@ -860,11 +858,6 @@ bool X11Window::allowWindowActivation(xcb_timestamp_t time, bool focus_in, bool return false; } - // Desktop switching is only allowed in the "no protection" case - if (!ignore_desktop && !window->isOnCurrentDesktop()) { - return false; // allow only with level == 0 - } - // No active window, it's ok to pass focus // NOTICE that extreme protection needs to be handled before to allow protection on unmanged windows if (ac == nullptr || ac->isDesktop()) { @@ -881,10 +874,6 @@ bool X11Window::allowWindowActivation(xcb_timestamp_t time, bool focus_in, bool return true; } - if (!window->isOnCurrentDesktop()) { // we allowed explicit self-activation across virtual desktops - return false; // inside a window or if no window was active, but not otherwise - } - // High FPS, not intr-window change. Only allow if the active window has only minor interest if (level > FSP::Medium && protection > FSP::Low) { return false; diff --git a/src/netinfo.cpp b/src/netinfo.cpp index e93c84d44a..c37c9203ba 100644 --- a/src/netinfo.cpp +++ b/src/netinfo.cpp @@ -163,12 +163,12 @@ void RootInfo::changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_ti return; // WORKAROUND? With > 1 plasma activities, we cause this ourselves. bug #240673 } else { // NET::FromApplication X11Window *c2; - if (c->allowWindowActivation(timestamp, false, true)) { + if (c->allowWindowActivation(timestamp, false)) { workspace->activateWindow(c); // if activation of the requestor's window would be allowed, allow activation too } else if (active_window != XCB_WINDOW_NONE && (c2 = workspace->findClient(Predicate::WindowMatch, active_window)) != nullptr - && c2->allowWindowActivation(timestampCompare(timestamp, c2->userTime() > 0 ? timestamp : c2->userTime()), false, true)) { + && c2->allowWindowActivation(timestampCompare(timestamp, c2->userTime() > 0 ? timestamp : c2->userTime()), false)) { workspace->activateWindow(c); } else { c->demandAttention(); diff --git a/src/x11window.h b/src/x11window.h index d67342d340..516d40a842 100644 --- a/src/x11window.h +++ b/src/x11window.h @@ -301,8 +301,7 @@ public: void handleSync(); void handleSyncTimeout(); - bool allowWindowActivation(xcb_timestamp_t time = -1U, bool focus_in = false, - bool ignore_desktop = false); + bool allowWindowActivation(xcb_timestamp_t time = -1U, bool focus_in = false); static void cleanupX11();