Bug 489135 - Some native Wayland fullscreen applications start at wrong screen
Summary: Some native Wayland fullscreen applications start at wrong screen
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: multi-screen (other bugs)
Version First Reported In: 6.1.0
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-24 19:29 UTC by Oleg
Modified: 2024-06-24 19:39 UTC (History)
1 user (show)

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


Attachments
Fullscreen apps go on the wrong screen (3.88 MB, video/webm)
2024-06-24 19:30 UTC, Oleg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg 2024-06-24 19:29:23 UTC
SUMMARY
In multi-monitor setup, some native Wayland clients are starting fullscreen on a screen other than primary (see the attachment). Notable examples are:
1. SDL2 apps with SDL_VIDEODRIVER=wayland (not SDL3 apps though)
2. GLFW apps
3. Telegram Desktop


STEPS TO REPRODUCE
1. Assemble a multi-monitor setup
2. Configure desired primary display
3. Try to launch some SDL2/GLFW game in fullscreen with Wayland backend

OBSERVED RESULT
Game most likely will go fullscreen on a screen other than primary (it can go to the primary screen, but that's not guaranteed).

EXPECTED RESULT
Game should start fullscreen on the screen I've configured as primary in Display Settings.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.0
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.1
Kernel Version: 6.9.6-2-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700K CPU @ 4.20GHz
Memory: 15.6 ГиБ of RAM
Graphics Processor: AMD Radeon RX 6700 XT

ADDITIONAL INFORMATION
The root of the problem is that Wayland has no concept of a primary screen. Without that concept, applications try to guess which screen would be primary, and so they pick the first reported wl_output. Since reported order of wl_outputs doesn't mean anything in reality (as was explained here https://bugs.kde.org/show_bug.cgi?id=488963) applications end up on a wrong screen. I see three possible solutions for this problem:
1. Every possible Wayland client should implement "kde_output_order_v1" protocol (like SDL3 did).
2. https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/242 should be merged and implemented in both KWin and clients.
3. KWin should reorder reported wl_outputs and always put primary screen as a first reported wl_output.
I see the third option as the most realistic one.
Comment 1 Oleg 2024-06-24 19:30:50 UTC
Created attachment 170922 [details]
Fullscreen apps go on the wrong screen
Comment 2 Zamundaaa 2024-06-24 19:39:52 UTC
Apps wrongly choosing the screen to put their window is not something we can fix, it needs to be fixed in the apps / toolkits themselves. They should pass a NULL wl_output to the fullscreen request to make KWin put the window on the correct screen.
For a potential workaround for toolkits with old APIs that make the proper way impossible, see https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/179.

> Game should start fullscreen on the screen I've configured as primary in Display Settings
No, that setting has nothing to do with window placement.
> Every possible Wayland client should implement "kde_output_order_v1" protocol
No, that too is completely unrelated to window placement.
> KWin should reorder reported wl_outputs and always put primary screen as a first reported wl_output
You can't reorder Wayland globals.