Bug 492018

Summary: Wrong mouse position in popup menus in Java apps using AWT/Swing
Product: [Plasma] kwin Reporter: Jin Liu <ad.liu.jin>
Component: X11 IntegrationAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal    
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: screenshot

Description Jin Liu 2024-08-22 03:18:21 UTC
SUMMARY
kwin has a change in when `ConfigureNotify` is sent:
https://invent.kde.org/plasma/kwin/-/commit/7b486e215d44bbd9fdeb8f1180c76fb16ec6a311

The above change conforms to ICCCM, but it breaks Java apps using Swing: after maximizing the app window, in popup menus, the app considers the mouse cursor to be at a different position than it visually is, as if the app window is in the position before maximizing.

We suspect this is caused by AWT special-casing `ConfigureNotify` behavior on a WM whitelist:
https://github.com/openjdk/jdk/blob/88ccbb60919e4523064b0da17184eedcd9efa087/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java#L772
And `kwin` is not in the list. Making `kwin` disguise as `mutter` fixes the problem, which confirms the theory.

Upstream bug report:
https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8338752

STEPS TO REPRODUCE
1. Start KDE Plasma 6.2-dev.
2. Start the Java app `jdownloader2`, unmaximized.
3. Move the app window to the screen center.
4. Maximize the app window.
5. Right click to show the popup menu.

OBSERVED RESULT
Mouse is considered to be to the top-left of its actual position.

EXPECTED RESULT
Mouse works alright in the menu.
Comment 1 Jin Liu 2024-08-22 03:20:02 UTC
Created attachment 172838 [details]
screenshot