Bug 491582

Summary: Custom right-click menu for WINE system tray icon is mis-positioned when using a fractional scale factor
Product: [Plasma] plasmashell Reporter: Alexey <alexinq6>
Component: XembedSNIProxyAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: alexinq6, fanzhuyifan, kde, kde, materka, nate, pavel23dob
Priority: NOR Keywords: regression
Version First Reported In: 6.1.4   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Demo 1
Demo 2
Label misalignment
The menu appears outside the screen (displaced down).
The menu is moved down (vertical panel, 1.25 display scaling).
The menu is located correctly (vertical panel, 1.0 display scaling)
The menu is located correctly (vertical panel, 2.0 display scaling)

Description Alexey 2024-08-11 15:45:44 UTC
Created attachment 172512 [details]
Demo 1

SUMMARY
Since some release (probably the 6th), my Wine applications that use tray menus (mainly game launchers) stopped displaying the menu. The tray icon still displayed animation, but the menu did not open. Today I decided to move the bottom panel to the left and found that with this arrangement, the launcher menus are visible on the screen.

STEPS TO REPRODUCE
1. Open some Wine app with tray menus;
2. Try to right click it (or do something else to open menu).

OBSERVED RESULT
Popup tray menu opens correctly with correct position.

EXPECTED RESULT
Popup tray menu shows something out of screen with bottom panel and nearly at bottom left corner with left-aligned panel.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
Wayland session, fractional scaling (1.25).
Comment 1 Alexey 2024-08-11 15:46:10 UTC
Created attachment 172513 [details]
Demo 2
Comment 2 Konrad Materka 2024-08-18 16:08:17 UTC
Is it OK if you disable fraction scaling? Are you using multiple screens?
Comment 3 Alexey 2024-08-23 17:15:55 UTC
(In reply to Konrad Materka from comment #2)
> Is it OK if you disable fraction scaling? Are you using multiple screens?

no and no.
Comment 4 Nate Graham 2024-08-29 22:43:17 UTC
The 6th corresponds to when Plasma 6.1.4 was released FWIW, so I guess it was a regression in that release.
Comment 5 Alexey 2024-10-14 14:41:58 UTC
(In reply to Nate Graham from comment #4)
> The 6th corresponds to when Plasma 6.1.4 was released FWIW, so I guess it
> was a regression in that release.

After playing a little with the system settings, I noticed that the downward deviation on the Y axis depends on the degree of system scaling: the closer it is to 1, the smaller the deviation. The most ironic part of my “investigation” was the discovery of the same bug when working in the Sublime Merge, with which I compared v6.1.3 and v6.1.4: the closer the scaling is to one, the smaller the deviation of the hint from its true position (see attachment), so, with taking into account my unsuccessful attempts not to see this bug when building and running older versions of xembedproxy in the current session, I came to the conclusion that the problem is systemic. I can also note that the problem does not affect integer scaling. By the way, Sublime Merge is not XWayland, so I’m not sure that the problem is related to Xorg applications, just as I’m not sure that the bugs I’m seeing are related.
Comment 6 Alexey 2024-10-14 14:42:47 UTC
Created attachment 174809 [details]
Label misalignment
Comment 7 Nate Graham 2024-10-16 18:25:34 UTC
Now I'm confused because I thought we were talking about system tray icons, but your latest screenshot shows an app, not a system tray icon. If the tooltip is mis-positioned in an app, then it's either a bug in the app or KWin, but not the System Tray.

Can you clarify what the original problem was, and how it relates to the latest screenshot?
Comment 8 Alexey 2024-10-16 20:10:21 UTC
Created attachment 174908 [details]
The menu appears outside the screen (displaced down).
Comment 9 Alexey 2024-10-16 20:11:01 UTC
Created attachment 174909 [details]
The menu is moved down (vertical panel, 1.25 display scaling).
Comment 10 Nate Graham 2024-10-16 20:11:45 UTC
Ok, so the previous screenshot you posted was unrelated, then?
Comment 11 Alexey 2024-10-16 20:11:55 UTC
Created attachment 174910 [details]
The menu is located correctly (vertical panel, 1.0 display scaling)
Comment 12 Alexey 2024-10-16 20:12:07 UTC
Created attachment 174911 [details]
The menu is located correctly (vertical panel, 2.0 display scaling)
Comment 13 Alexey 2024-10-16 20:15:32 UTC
Note: As I said before, the degree to which the menu is "deviated down" depends on the fractional scaling' factor, but the relation is not clear to me.
Comment 14 Alexey 2024-10-16 20:20:24 UTC
(In reply to Nate Graham from comment #10)
> Ok, so the previous screenshot you posted was unrelated, then?

Idk, really. It looks like it's unrelated, but both issues look similar. Sorry for the mess...
Comment 15 Konrad Materka 2024-10-17 20:22:46 UTC
Which version of XWayland are you using? I was able to reproduce with XWayland 23.2.6 (Neon/Ubuntu 24.04). Previously I had XWayland 24.2 (compiled from sources) and it was working better, but I can't verify now.
Comment 16 Alexey 2024-10-19 18:45:09 UTC
(In reply to Konrad Materka from comment #15)
> Which version of XWayland are you using? I was able to reproduce with
> XWayland 23.2.6 (Neon/Ubuntu 24.04). Previously I had XWayland 24.2
> (compiled from sources) and it was working better, but I can't verify now.

24.1.3
Comment 17 Alexey 2025-06-28 13:09:43 UTC
Some new info here:

Cell format: loDPI/phDPI/xy/physicalGeometry/virtualGeometry

              Apply scaling themselves                                             Scaled by the system
75%      72/137.612/(2121,1423)/1920x1080/1920x1080      96/183.483/(2121,1422)/2560x1440/2560x1440
100%    96/137.612/(1480,1063)/1920x1080/1920x1080      96/137.612/(1480,1063)/1920x1080/1920x1080
125%    120/137.612/(2196,1690)/1920x1080/1920x1080    96/110.09/(1099,847)/1536x864/1536x864

There are several strange things, for example, unchanged positions in the case of 75% scaling, but, honestly, I really don't understand how it turns out.

So, as mentioned earlier, the problem is to map a position from the "XWayland world" into the "Wayland world". Yesterday I had a little free time, and I conducted some research on the plasma-workspace code base and found some lines in the of the system tray applet folder, which performs (maybe) the opposite of what is needed in the case of XEmbedsniproxy: https://invent.kde.org/plasma/plasma-workspace/-/blob/master/applets/systemtray/systemtray.cpp#l336.