Bug 501505

Summary: Support for xrandr emulation
Product: [Plasma] kwin Reporter: Ellie <el>
Component: xwaylandAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: coucouf, madness742, nate, postix, xaver.hugl
Priority: NOR    
Version First Reported In: 6.2.4   
Target Milestone: ---   
Platform: Other   
OS: Linux   
URL: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1803
See Also: https://bugs.kde.org/show_bug.cgi?id=502390
Latest Commit: Version Fixed/Implemented In: 6.5.4
Sentry Crash Report:

Description Ellie 2025-03-14 19:32:46 UTC
SUMMARY

KWin Wayland doesn't seem to allow apps to fullscreen at letterboxed old resolutions 640x480, 800x600, and 1024x768 on a Full HD widescreen panel. In the era of everything being some GPU surface there doesn't seem really to be a good reason, and under KWin X11 this seems to have worked fine: https://discuss.kde.org/t/old-games-with-fixed-resolutions-in-wine-no-longer-run-in-full-screen-since-plasma-6/17770/5

The lack of the resolutions working affects a huge list of old games, probably multiple hundreds, that would otherwise run fine, both older 32bit Windows games from the 98 to XP era, and even some native Linux ports of those that I've seen.

STEPS TO REPRODUCE

1. Try to launch any application that insists on launching at any of 640x480, 800x600, 1024,x768. It can be a Windows app running through wine, or a basic SDL1 or SDL2 Linux app.

OBSERVED RESULT

The app will either use a wildly wrong mode, which involves some broken combinations of: 1. renders in frameless window in top-left with rest of the screen showing random other stuff, 2. renders stretched rather than letter boxed (this is rare), 3. renders completely off-center but with even some parts cut off, and so on. And this is usually combined with the mouse coordinates being so off, that it's impossible to use the program.

Or the app will give you an error and not even start up.

EXPECTED RESULT

The resolutions work, and are scaled up and letterboxed by KWin as necessary if the physical screen doesn't have a built-in scaler to do that. Aspect-ratio should be preserved by default.

SOFTWARE/OS VERSIONS

Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: postmarketOS v24.12 based on Alpine 3.21.3
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2025-03-14 19:33:40 UTC
Thank you for the bug report!

However Plasma 6.2.4 is no longer eligible for support or maintenance from KDE; supported versions are 5.27. (LTS), and 6.3 (non-LTS) or newer. Please upgrade to a supported version as soon as your distribution makes it available to you. Plasma is a fast-moving project, and bugs in one version are often fixed in the next one.

If you need support for Plasma 6.2.4, please contact your distribution, who bears the responsibility of providing support for older releases that are no longer supported by KDE.

If you can reproduce the issue after upgrading to a supported version, feel free to re-open this bug report.
Comment 2 Zamundaaa 2025-03-14 19:48:41 UTC
Heh, looks like I opened this just at the right time, to still notice it before the bot closed it.

KWin doesn't have any restrictions for resolutions apps are allowed to use - and it couldn't even if we wanted to, the Wayland protocol has no way to enforce such a thing. What you're describing sounds like xrandr emulation not working properly. You can report that at https://gitlab.freedesktop.org/xorg/xserver/-/issues
Comment 3 Ellie 2025-03-14 19:57:00 UTC
My apologies for the uninformed question, but how would I test if xrandr emulation works? And isn't wine currently switching over to Wayland? Some apps report display mode setting failures, so something along the chain seems to enforce a restriction.
Comment 4 Zamundaaa 2025-03-14 22:04:17 UTC
I don't know if there's a minimal test app to be honest, might be a good thing to bring up for Xwayland developers.
I just tried with some games on Steam, but Proton has a "hack" for fullscreen things... thinking of that though, you could try using Proton to work around this too.
Comment 5 Zamundaaa 2025-03-14 22:06:12 UTC
About
> And isn't wine currently switching over to Wayland?
It has gained some support for Wayland, but it's not used by default, and probably won't be for a very long time. If you go and enable it, or use a pre-built Proton bundle with Wayland enabled by default like https://github.com/Melechtna/Proton-with-Wayland (which I use for HDR gaming) it *might* also fix the problem though.
Comment 6 Ellie 2025-03-15 00:01:47 UTC
Thank you so much for all the responses. I did some investigations:

1. I confirmed with "Pizza Connection 2" that Proton handles this correctly and normal wine doesn't.

2. I confirmed via SDL2 that when using SDL2's x11 backend I get the same problem, suggesting this isn't a wine issue but as you suggested, perhaps an XWayland problem since with SDL2's wayland backend it's (more) correct.

3. However, this seems to be in so far also a minor potential Wayland and KWin issue, in that if I open a window at 640x480 with SDL2 via the Wayland backend, it seems to give me a window of the expected logical size. But it's stretched to the wrong aspect ratio. I don't think this is what is expected by 99% of applications out there, and it should be letterboxed instead. So it's less broken than through XWayland, but doesn't seem to do quite what's expected either.
Comment 7 Ellie 2025-03-26 12:22:26 UTC
It seems like Xwayland devs think this is a KDE issue: 

https://gitlab.freedesktop.org/xorg/xserver/-/issues/1803

My apologies if reopening is the wrong action. Also, under native Wayland the wrong aspect ratio seems to remain an issue.
Comment 8 Zamundaaa 2025-10-16 21:59:40 UTC
It turns out that there was a bug on the Xwayland side, but we're also missing handling for _XWAYLAND_RANDR_EMU_MONITOR_RECTS - we need to read the property and adjust the configure requests for the application window too.
Comment 9 Bug Janitor Service 2025-10-16 22:34:12 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/8263
Comment 10 Zamundaaa 2025-11-27 16:20:30 UTC
Git commit bc5a2002e9afb78b336e9ea2b7699015c578b2bc by Xaver Hugl.
Committed on 27/11/2025 at 15:59.
Pushed by zamundaaa into branch 'master'.

x11window: support xrandr emulation

If a fullscreen x11 client requests mode changes,
- Xwayland will set _XWAYLAND_RANDR_EMU_MONITOR_RECTS on all windows of the
  client
- we need to configure the window to match the emulated size
- Xwayland will set up the viewport to present the window properly on the
  Wayland side

M  +1    -1    autotests/integration/CMakeLists.txt
M  +328  -3    autotests/integration/x11_window_test.cpp
M  +1    -0    src/atoms.cpp
M  +1    -0    src/atoms.h
M  +2    -0    src/events.cpp
M  +28   -4    src/x11window.cpp

https://invent.kde.org/plasma/kwin/-/commit/bc5a2002e9afb78b336e9ea2b7699015c578b2bc
Comment 11 Zamundaaa 2025-11-27 20:18:33 UTC
Git commit 3a1745a2332f2f0e40fe61ccaa9d68973f57659b by Xaver Hugl.
Committed on 27/11/2025 at 17:59.
Pushed by zamundaaa into branch 'Plasma/6.5'.

x11window: support xrandr emulation

If a fullscreen x11 client requests mode changes,
- Xwayland will set _XWAYLAND_RANDR_EMU_MONITOR_RECTS on all windows of the
  client
- we need to configure the window to match the emulated size
- Xwayland will set up the viewport to present the window properly on the
  Wayland side

(cherry picked from commit bc5a2002e9afb78b336e9ea2b7699015c578b2bc)

Co-authored-by: Xaver Hugl <xaver.hugl@kde.org>

M  +1    -1    autotests/integration/CMakeLists.txt
M  +328  -3    autotests/integration/x11_window_test.cpp
M  +1    -0    src/atoms.cpp
M  +1    -0    src/atoms.h
M  +2    -0    src/events.cpp
M  +28   -4    src/x11window.cpp

https://invent.kde.org/plasma/kwin/-/commit/3a1745a2332f2f0e40fe61ccaa9d68973f57659b