Bug 463410 - Virtual Desktop behavior selection under Window Behavior/Advanced does not have an effect.
Summary: Virtual Desktop behavior selection under Window Behavior/Advanced does not ha...
Status: RESOLVED DUPLICATE of bug 462996
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.26.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-23 21:21 UTC by kde
Modified: 2022-12-31 00:35 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kde 2022-12-23 21:21:01 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1.  Go to System Settings -> Window Management -> Window Behavior -> Advanced -> Virtual Desktop behavior
2. Choose either "Switch to that Virtual Desktop" or "Bring window to current Virtual Desktop"
3. Both options result in "Bring window to current Virtual Desktop"

OBSERVED RESULT
Selection "Switch to that Virtual Desktop" does not work. The activated windows is moved to current Virtual Desktop

EXPECTED RESULT
The current  Virtual Desktop should switch to the Desktop with the activated window

SOFTWARE/OS VERSIONS

Linux/KDE Plasma:  openSUSE Tumbleweed 20221221 / 5.26.4
(available in About System)
KDE Plasma Version: 5.26.4
KDE Frameworks Version:  5.101.0
Qt Version:  5.15.7

ADDITIONAL INFORMATION
Comment 1 Nicolas Fella 2022-12-30 00:39:37 UTC
Works fine for me. What application are you testing? Please give exact steps for what you are doing
Comment 2 kde 2022-12-30 04:07:49 UTC
Thanks for checking!
Let's say I have Firefox running in "Virtual Desktop 1" and Thunderbird in "Virtual Desktop 2". Now I click a link in Thunderbird which will be opened by Firefox.
When I opt with "Bring window to current Virtual Desktop" I'd expect that my view stays in "Virtual Desktop 2" and Firefox will be moved from "Virtual Desktop 1" to"Virtual Desktop 2"
With option "Switch to that Virtual Desktop" I'd expect that my view switches to "Virtual Desktop 1".
But on my system with both options Firefox will be moved from "Virtual Desktop 1" to"Virtual Desktop 2"
Comment 3 Natalie Clarius 2022-12-30 12:16:31 UTC
If it only affects Firefox, it's probably a duplicate of https://bugs.kde.org/show_bug.cgi?id=462996  

Or can you confirm it with any other applications?
Comment 4 Nicolas Fella 2022-12-30 12:58:36 UTC
Correction: It works fine for me on Wayland. On X11 it seems to be as you described. Tested with Firefox and Neochat
Comment 5 Nicolas Fella 2022-12-30 14:29:39 UTC
I think I see the problem.

On X11 when an application is activated it sends a startup id. This startup ID optionally contains a desktop number that hints to the window manager where the app should be started on. For apps started from Plasma this will be the current desktop: https://invent.kde.org/frameworks/kio/-/blob/master/src/gui/kprocessrunner.cpp#L277

When KWin receives this id it checks the desktop number and falls back to the current desktop. Then it sends the window to that desktop: https://invent.kde.org/plasma/kwin/-/blob/master/src/activation.cpp#L775

Only later in the code we get to the point where we check the desktop switch behavior setting: https://invent.kde.org/plasma/kwin/-/blob/master/src/activation.cpp#L290. At this point the window is already on the current desktop, so the whole thing doesn't trigger at all.

The first half of this only happens on X11, which explains why it works on Wayland
Comment 6 Bug Janitor Service 2022-12-31 00:07:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3380
Comment 7 Bug Janitor Service 2022-12-31 00:14:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1097
Comment 8 Nicolas Fella 2022-12-31 00:30:42 UTC

*** This bug has been marked as a duplicate of bug 462996 ***
Comment 9 kde 2022-12-31 00:35:49 UTC
(In reply to Nicolas Fella from comment #5)
> I think I see the problem.
> 
> On X11 when an application is activated it sends a startup id. This startup
> ID optionally contains a desktop number that hints to the window manager
> where the app should be started on. For apps started from Plasma this will
> be the current desktop:
> https://invent.kde.org/frameworks/kio/-/blob/master/src/gui/kprocessrunner.
> cpp#L277
> 
> When KWin receives this id it checks the desktop number and falls back to
> the current desktop. Then it sends the window to that desktop:
> https://invent.kde.org/plasma/kwin/-/blob/master/src/activation.cpp#L775
> 
> Only later in the code we get to the point where we check the desktop switch
> behavior setting:
> https://invent.kde.org/plasma/kwin/-/blob/master/src/activation.cpp#L290. At
> this point the window is already on the current desktop, so the whole thing
> doesn't trigger at all.
> 
> The first half of this only happens on X11, which explains why it works on
> Wayland

Thank you for this quick find!