Bug 462996 - Windows do not stay on the virtual desktop they are on
Summary: Windows do not stay on the virtual desktop they are on
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.26.4
Platform: Neon Linux
: NOR normal with 4 votes (vote)
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 463410 464280 464924 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-12-13 10:58 UTC by Riccardo Robecchi
Modified: 2023-01-30 22:03 UTC (History)
17 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Riccardo Robecchi 2022-12-13 10:58:35 UTC
SUMMARY
Windows of applications which are activated by other applications do not stay on the virtual desktop they are on. To give a practical example, if I have Firefox on desktop 1 and I open a link from desktop 2, the Firefox window is moved to desktop 3. This didn't happen before the latest round of updates on Neon.


STEPS TO REPRODUCE
1. Open Firefox on desktop 1
2. click on a link from another app (e.g. Thunderbird) on desktop 2

OBSERVED RESULT
The Firefox window is moved to desktop 2.

EXPECTED RESULT
The Firefox window stays on desktop 2.

SOFTWARE/OS VERSIONS
Linux: KDE neon
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.100.0
Qt Version: 5.15.7

ADDITIONAL INFORMATION
Comment 1 Natalie Clarius 2022-12-15 13:09:46 UTC
Please make sure you have System Settings > Window Management > Window Behavior > Advanced  > When activating a window on a different dektop: set to Switch to that Virtual Desktop.
Comment 2 Natalie Clarius 2022-12-15 16:59:08 UTC
Can reproduce even with said setting enabled, but only on X11.

Are there any other applications this happens with?
Comment 3 sparhawk 2022-12-16 02:07:43 UTC
I'm also seeing this, with the same setting. Having said that, there are two options for that setting, i.e. "Switch to that Virtual Desktop" and "Bring window to current Virtual Desktop". Neither sounds like the old (and IMO preferred) behaviour, which is "neither", i.e. leave the window there and don't switch me.

I presume you mean other applications that move Virtual Desktops. I only see it with Firefox. OTOH Signal and Pidgin still have the old behaviour (of "neither").

However, I can also trigger this bug from links in other applications, e.g. from the Terminator terminal emulation.
Comment 4 g111 2022-12-20 13:43:26 UTC
I am wondering about this issue, too. Again with firefox here. It is a little bit annoying, because I do not want my windows being moved around automatically. This makes them hard to find later.

Operating System: Kubuntu 22.04
KDE Plasma Version: 5.24.7
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.3
Kernel Version: 5.15.0-56-generic (64-bit)
Graphics Platform: X11
Graphics Processor: Mesa Intel® Xe Graphics


The mentioned setting
System Settings > Window Management > Window Behavior > Advanced  > When activating a window on a different dektop: set to Switch to that Virtual Desktop.
is not available in my System Settings.
Comment 5 Tom Englund 2022-12-20 16:46:14 UTC
i personally always have firefox on the 4th virtual desktop, for now i worked around this by making a special application setting/rule that always forces it to be on the 4th virtual desktop. now it doesnt move around when i open urls in other virtual desktops.
Comment 6 80p3fy75dc 2022-12-21 10:58:34 UTC
Same issue here (Arch Linux / Gentoo / Plasma 5.26.4) with Firefox when opening any external link from any other program. Firefox keeps being moved to the workspace where the other program I'm opening the link from is located.

Settings > Window Management > Window Behavior > Advanced  > When activating a window on a different Virtual Desktop: "Switch to that Virtual Desktop" was already the default.

The old behavior was the best in my opinion. When opening an external link from another program, I just had the Firefox task manager icon background color changing so that I know something was happening and that's it. No window moved, no workspace switching/focusing whatsoever.

Hope it'll be fixed.
Comment 7 Riccardo Robecchi 2022-12-23 11:03:29 UTC
One thing I've noticed is that Firefox stays on the same virtual desktop it is on if I click on a link on Thunderbird. I have also tried setting Vivaldi as the default browser, and it works as expected (the window is kept on the virtual desktop it is on).

Given this, is it possible that somehow it is actually Firefox at fault here, rather than KWin?
Comment 8 g111 2022-12-23 12:55:15 UTC
It seems having to do with the command that is used to open a firefox window:

https://www.reddit.com/r/kde/comments/zm6gag/prevent_a_browser_window_from_changing_virtual/

in short: With "xdg-open" the window is moved. With "firefox" it is not moved. With "XDG_CURRENT_DESKTOP=X-Generic xdg-open" the window is not moved.
Comment 9 sparhawk 2022-12-24 00:48:04 UTC
Nice find @g111. I can confirm that all of those commands behave the same for me
Comment 10 Nicolas Fella 2022-12-31 00:30:24 UTC
See https://bugs.kde.org/show_bug.cgi?id=463410#c5 for the explanation
Comment 11 Nicolas Fella 2022-12-31 00:30:42 UTC
*** Bug 463410 has been marked as a duplicate of this bug. ***
Comment 13 Vlad Zahorodnii 2023-01-04 12:07:09 UTC
Git commit cf81be19a8334b26a3cd8069294386d94750bee8 by Vlad Zahorodnii, on behalf of Nicolas Fella.
Committed on 04/01/2023 at 11:30.
Pushed by vladz into branch 'master'.

[kprocessrunner] Don't specify which desktop the app should be launched on

It should be up to the window manager to decide which desktop newly launched applications should go to

Usually that will be the current desktop, but for example when activating an already running app KWin allows to switch the current desktop to the one the app is running

Specifying the current desktop here breaks that

M  +0    -5    src/gui/kprocessrunner.cpp

https://invent.kde.org/frameworks/kio/commit/cf81be19a8334b26a3cd8069294386d94750bee8
Comment 14 Vlad Zahorodnii 2023-01-04 16:07:22 UTC
Git commit a40dd9a1586c768ee956f193d2d70ec5e66c2cbe by Vlad Zahorodnii, on behalf of Nicolas Fella.
Committed on 04/01/2023 at 12:12.
Pushed by vladz into branch 'master'.

Only make startup notification change the virtual desktop if requested

Startup notifications optionally contain the target desktop the app should be launched to.

If present the window is sent to that desktop, if not it is sent to the current desktop.

Later in Workspace::activateWindow we check if the window is on the current desktop, and if not
we either move it to the current desktop or switch to the window's desktop depending on user preference.

However, this is broken because the window was already moved to the current desktop. To avoid this
only move the window if specifically requested by the startup id.

M  +4    -9    src/activation.cpp

https://invent.kde.org/plasma/kwin/commit/a40dd9a1586c768ee956f193d2d70ec5e66c2cbe
Comment 15 Nicolas Fella 2023-01-14 15:12:31 UTC
*** Bug 464280 has been marked as a duplicate of this bug. ***
Comment 16 Nicolas Fella 2023-01-28 11:16:42 UTC
*** Bug 464924 has been marked as a duplicate of this bug. ***
Comment 17 Luigi Toscano 2023-01-30 22:03:25 UTC
So does the fix require both kio 5.103 and Plasma 5.27?