Bug 458983 - Activating an app does not switch to other VD if app was manually moved there
Summary: Activating an app does not switch to other VD if app was manually moved there
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-11 00:06 UTC by Nicolas Fella
Modified: 2022-09-13 16:08 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 Nicolas Fella 2022-09-11 00:06:44 UTC
STEPS TO REPRODUCE
1. Have two virtual desktops 
2. Take some app that opens URLs and has support for xdg-activation (e.g. Neochat) and a browser that supports xdg-activation (e.g. Angelfish)
3. Open both apps on Desktop 1
4. Move Angelfish to Desktop 2 via the task manager
5. Click on a link in Neochat

OBSERVED RESULT
A bouncing cursor with the Angelfish icon. The URL is opened in Angelfish, but the desktop doesn't switch to desktop 2

EXPECTED RESULT
Virtual desktop 2 is now the current desktop

SOFTWARE/OS VERSIONS
KDE Plasma Version: master
KDE Frameworks Version: master
Qt Version: 5.15.5-kde

ADDITIONAL INFORMATION
Wayland

When Angelfish was launched on desktop 2 it switches correctly

When switching to desktop 2 after Angelfish was moved and switching back to desktop 1 it works correctly
Comment 1 Vlad Zahorodnii 2022-09-12 13:44:39 UTC
xdg-activation integration code uses Workspace::activateWindow(), so it should change the current desktop.
Comment 2 Vlad Zahorodnii 2022-09-12 13:45:19 UTC
It actually would be nice to add some tests.
Comment 3 Vlad Zahorodnii 2022-09-12 13:57:03 UTC
Works as expected with https://invent.kde.org/plasma/kwin/-/blob/master/tests/xdgactivationtest-qt5.cpp. Can you attach wayland debug log of angelfish?
Comment 4 Natalie Clarius 2022-09-12 14:07:52 UTC
What focus stealing prevention level do you have set?
Comment 5 Vlad Zahorodnii 2022-09-12 14:10:00 UTC
FSP plays no role on Wayland
Comment 6 Nicolas Fella 2022-09-12 15:06:46 UTC
I found that the isExposed() check in https://invent.kde.org/frameworks/kwindowsystem/-/blob/master/src/kwindowsystem.cpp#L455 is false and thus no activate call is made
Comment 7 Nicolas Fella 2022-09-12 15:09:39 UTC
xdgactivationtest-qt5 does work as expected indeed
Comment 8 Nicolas Fella 2022-09-12 15:20:11 UTC
(In reply to Nicolas Fella from comment #6)
> I found that the isExposed() check in
> https://invent.kde.org/frameworks/kwindowsystem/-/blob/master/src/
> kwindowsystem.cpp#L455 is false and thus no activate call is made

Removing that check makes it work as expected
Comment 9 Vlad Zahorodnii 2022-09-12 17:34:41 UTC
Weird. I believe isExposed() check is needed to ensure that there's wl_surface. But maybe it is safe to remove that and let kwayland-integration handle that. In fact it already does that https://invent.kde.org/plasma/kwayland-integration/-/blob/bc7509672153434a8ae6f8f5eec8bc1806644303/src/windowsystem/windowsystem.cpp#L43

Regardless, it makes sense to remove that check
Comment 10 Bug Janitor Service 2022-09-13 06:30:58 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kwindowsystem/-/merge_requests/61
Comment 11 Vlad Zahorodnii 2022-09-13 16:08:06 UTC
Git commit acf85e40ff6fa14d90cffe6107f188c85b03d244 by Vlad Zahorodnii.
Committed on 13/09/2022 at 06:26.
Pushed by vladz into branch 'master'.

Remove QWindow::isExposed() check in activateWindow()

A window can be considered as unexposed if it's not visible, e.g. it's
minimized or not on current virtual desktop. The isExposed() check
neuters the desired side-effects of the activateWindow() request.

As far as I understand, QWindow::isExposed() check was added to ensure
that there's wl_surface, but kwayland-integration noops if the
wl_surface is missing.
Co-authored: Nicolas Fella <nicolas.fella@gmx.de>

M  +0    -4    src/kwindowsystem.cpp

https://invent.kde.org/frameworks/kwindowsystem/commit/acf85e40ff6fa14d90cffe6107f188c85b03d244