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.
master
Nicolas Fella 2 years ago
parent c8c021a780
commit 653681ac40

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

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

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

Loading…
Cancel
Save