Bug 462389

Summary: Legacy Applications: Apply scaling themselves: Scaling changes depending on 2nd screen enabled or not
Product: [Plasma] kwin Reporter: postix <postix>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: REPORTED ---    
Severity: normal CC: nate
Priority: NOR    
Version First Reported In: 5.26.4   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: kWin Support Info: Primary Screen only
kWin Support Info: 2nd screen enabled
Screenshot: 5.26.3, PyCharm after waking up from suspend
kWin Support Info: After waking up from suspend
kWin Support Info: After waking up from suspend

Description postix 2022-11-29 11:16:54 UTC
SUMMARY

I have enabled Legacy Applications: Apply scaling themselves and adjusted the individual scaling of applications via environmental variables (GDK_SCALE=2.0, etc.) in a way, that it looks fine on the primary screen.
The primary screen scales with 200%. 

If, however, the 2nd screen is enabled, which scales with 125%, it may happen, that the legacy X11 applications spontaneously changes its scaling from 2.0 to 1.0. 
In this case I need to change the env variable and restart the application. Doing this every now and then is rather annoying.

(Or vice versa, adjusted for multi-screen usage and scales with 1.0 when 2nd screen is detached.)

Would it be possible and make sense to introduce an option to always consider the scaling of the primary screen only, so that scaling doesn't change and need to be corrected when screens are attached/detached?

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20221126
KDE Plasma Version: 5.26.3
KDE Frameworks Version: 5.100.0
Qt Version: 5.15.7
Kernel Version: 6.0.8-1-default (64-bit)
Graphics Platform: Wayland
Graphics Processor: AMD Radeon RX 580 Series
Comment 1 postix 2022-11-29 11:17:46 UTC
Created attachment 154132 [details]
kWin Support Info: Primary Screen only

An application (PyCharm) with GDK_SCALING=1 scaled with 1.0.
Comment 2 postix 2022-11-29 11:19:46 UTC
Created attachment 154133 [details]
kWin Support Info: 2nd screen enabled

The application (PyCharm) spontaneously changed 200% scaling while running. The expectation was, that the scaling does not change, when enabling the 2nd screen in kscreen.

```
diff kWin_wayland_5-26-3_SingleScreen.txt kWin_wayland_5-26-3_2ndScreenEnabled.txt 
153c153
< Geometry: 0,0,1920x1080
---
> Geometry: 1536,0,1920x1080
160c160,164
< Enabled: 0
---
> Enabled: 1
> Geometry: 0,0,1536x864
> Scale: 1.25
> Refresh Rate: 60000
> Adaptive Sync: incapable
```
Comment 3 Nate Graham 2022-11-29 18:43:42 UTC
> and adjusted the individual scaling of applications via environmental variables
This isn't supported, and it's highly likely that your workaround is causing more problems than it's solving, or at least obscuring the true problem and making it impossible for us to fix.

Please remove the manual workaround, try again, and if you still have a problem, describe what the problem is so we can fix it. But we can't fix problems caused by workarounds breaking.
Comment 4 postix 2022-11-29 19:53:47 UTC
Nate, you mean it's not supposed to set the scaling now with the "Legacy Applications: Apply scaling themselves" option enabled in the sense of https://wiki.archlinux.org/title/HiDPI#Applications ?
Comment 5 Nate Graham 2022-11-29 21:34:14 UTC
The system should be setting all necessary environment variables. If it's not, that's another bug. :) 

The problem with filing bug reports saying, "I applied this workaround and now I have a bug" is that we don't know where the real issue for us to fix is.
Comment 6 postix 2022-12-01 14:25:02 UTC
Created attachment 154198 [details]
Screenshot: 5.26.3, PyCharm after waking up from suspend

I ran PyCharm w/o setting any env variables and it scaled fine with a factor of 2 on my 200% scaled screen.

When I just woke up the system from suspend, the window looked like in the screenshot:
In the background the still 2x scaled window was still displayed, but in the upper left corner, it showed the same window with a 1.0 scaling and a blinking line cursor.
After resizing the window by dragging the titlebar, it changed and only a single 1.0 scaled window was displayed.

When I opened GIMP to edit the screenshot, for which I still had set `Exec=env GDK_SCALE=2.0` in its desktop file, it also opened now with a 1.0 scaling.


The currently only (semi-)related global scaling variables are:
```
QT_WAYLAND_FORCE_DPI=96
QT_AUTO_SCREEN_SCALE_FACTOR=0
PLASMA_USE_QT_SCALING=1
```
Comment 7 postix 2022-12-01 14:25:30 UTC
Created attachment 154199 [details]
kWin Support Info: After waking up from suspend
Comment 8 postix 2022-12-01 14:26:00 UTC
Created attachment 154200 [details]
kWin Support Info: After waking up from suspend
Comment 9 postix 2022-12-01 14:28:21 UTC
To comment 6: It helped to set a different scaling factor in kscreen, hit apply, hit revert and restarting PyCharm: Now it scales with 200% again.
Comment 10 postix 2022-12-01 14:29:20 UTC
(In reply to postix from comment #9)
> To comment 6: It helped to set a different scaling factor in kscreen, hit
> apply, hit revert and restarting PyCharm: Now it scales with 200% again.

Same for GIMP. So for some reasons, it picks up the wrong scaling (namely 1.0 instead of 2.0) when coming from suspend.
Comment 11 postix 2022-12-01 15:54:05 UTC
Well, what's described from comment 6 onward doesn't happen always. Maybe there's a racing condition?
Comment 12 postix 2022-12-01 18:07:08 UTC
Now it happened within a session, when I closed PyCharm and reopened it. Could fix it like in comment 9 again.
Comment 13 Bug Janitor Service 2022-12-16 05:15:41 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 14 postix 2022-12-16 12:47:24 UTC
Some information was provided.