Bug 480642 - Xwayland apps scaling issues
Summary: Xwayland apps scaling issues
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 5.93.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2024-01-31 23:11 UTC by dominik.klementowski
Modified: 2024-02-03 04:15 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dominik.klementowski 2024-01-31 23:11:08 UTC
SUMMARY
Handling Xwayland apps while using scaling and multi monitor setups has been improved a lot recently, but one issue kind of stayed. Bellow is link to demo on video.

In my test I have laptop with its internal 1080p screen set to 125% and external 1440p monitor with native 100%. What I do is closing and opening laptops' lid causing the internal screen to go away and back on. Xwayland windows content is not properly updated until the window is at least moved, either leaving empty transparent space, or the content is too big to fit in the window. Previously when I tested it with 5.x series, iirc it would only update on window resize, so now it's a bit better.

Some have also inappropriate scale and window content gets too small, but this report is not about that, I'm aware of the current Xorg/Xwayland limitations.


STEPS TO REPRODUCE
1. Use multi screen setup with mixed dpi
2. Open some Xwayland app
3. Remove or add output with a scaling

OBSERVED RESULT
Xwayland window content is not properly updated until its window is moved

EXPECTED RESULT
Xwayland windows are updated automatically without a need to move/resize etc


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Arch Linux, kde-unstable
(available in About System)
KDE Plasma Version: 5.93.0
KDE Frameworks Version: 5.249.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION
Video demo https://www.dropbox.com/scl/fi/lq7voksaxdgpr6kwzdbfs/xwayland-apps-multi-dpi.mkv?rlkey=xqsmq26eju51w312u2abcq6h1&dl=0
Comment 1 fanzhuyifan 2024-02-01 02:41:45 UTC
Thank you for your bug report!

Unfortunately setting per-monitor scaling using tools like xrandr in the X11 session is not supported. KDE only supports per-monitor scaling in the plasma session.
Comment 2 fanzhuyifan 2024-02-01 02:42:43 UTC
Oh sorry that was a mistake -- I thought you were on X11
Comment 3 dominik.klementowski 2024-02-01 02:44:45 UTC
(In reply to fanzhuyifan from comment #2)
> Oh sorry that was a mistake -- I thought you were on X11

Yes, that is Wayland session and I’m using everything as is without messing with xrandr or anything manually.
Comment 4 Doug 2024-02-01 05:04:36 UTC
I cannot reproduce this, when turning off a screen an Xwayland app on the screen that stayed on doesn't appear to be effected in any way.  An Xwayland app on the screen turned off reappears on the screen not turned off at the proper scale.

Neon Testing, Plasma 5.92.90, Frameworks 5.249.0, Qt 6.6.1
Comment 5 dominik.klementowski 2024-02-01 12:08:03 UTC
(In reply to Doug from comment #4)
> I cannot reproduce this, when turning off a screen an Xwayland app on the
> screen that stayed on doesn't appear to be effected in any way.  An Xwayland
> app on the screen turned off reappears on the screen not turned off at the
> proper scale.
> 
> Neon Testing, Plasma 5.92.90, Frameworks 5.249.0, Qt 6.6.1

That is also true for me if the app window sits on a scaled screen. In the case I'm describing (and as you can also see on the video), Xwayland windows are placed on unscaled 100% screen, and the screen I add or remove is at 125% scale.
Comment 6 Zamundaaa 2024-02-01 17:02:03 UTC
A much simpler way to test this is to just have one display connected and change the scale while having X11 windows open. Can confirm
Comment 7 Bug Janitor Service 2024-02-01 17:40:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5085
Comment 8 Zamundaaa 2024-02-02 01:00:42 UTC
Git commit c2749e3acf974d47127f899549919ae19c9e9719 by Xaver Hugl.
Committed on 02/02/2024 at 01:00.
Pushed by zamundaaa into branch 'master'.

x11window: explicitly resize when the Xwayland scale changes

With how Xwayland scaling works, KWin assumes the window already uses the
new coordinate system - but that doesn't happen until Xwayland and the client
know about the new size as well.

M  +8    -0    src/x11window.cpp
M  +1    -0    src/x11window.h

https://invent.kde.org/plasma/kwin/-/commit/c2749e3acf974d47127f899549919ae19c9e9719
Comment 9 Zamundaaa 2024-02-02 01:19:30 UTC
Git commit 63868e4dd491da2e9cd28a0115566408d202ad8a by Xaver Hugl.
Committed on 02/02/2024 at 01:06.
Pushed by zamundaaa into branch 'Plasma/6.0'.

x11window: explicitly resize when the Xwayland scale changes

With how Xwayland scaling works, KWin assumes the window already uses the
new coordinate system - but that doesn't happen until Xwayland and the client
know about the new size as well.
(cherry picked from commit c2749e3acf974d47127f899549919ae19c9e9719)

M  +8    -0    src/x11window.cpp
M  +1    -0    src/x11window.h

https://invent.kde.org/plasma/kwin/-/commit/63868e4dd491da2e9cd28a0115566408d202ad8a