FlatLaf icon indicating copy to clipboard operation
FlatLaf copied to clipboard

Window maximizes with single click (should be double click)

Open rkeen-siemens opened this issue 2 years ago • 6 comments

On Linux (at least CentOS with Gnome 3) single clicking the header of the main frame will maximize/restore the frame. This should only happen on a double click.

The problem seems to be that sometimes the click event is sent to the FlatTitlePane.Handler and sometimes it isn't. This only seems to be an issue when using a trackpad with tap to click on a single tap. Clicking the trackpad or using a mouse seem to work as expected. Here are the events passed to the handler's mousePressed and mouseClicked methods for the various input methods. In case it makes a difference, I'm testing this via HP ZCentral Remote Boost to a remote linux instance using a Mac OS 13.1 client with a Magic Trackpad (original, not the 2nd).

Trackpad Single Tap

pressed at 1673293639029 with e.getClickCount 1 and clickCount 1 clicked at 1673293639040 with e.getClickCount 1 // <-- This click event triggers the maximize/restore erroneously

Trackpad Single Click

pressed at 1673293654677 with e.getClickCount 1 and clickCount 1 // No click event sent to the handler

Mouse Single Click

pressed at 1673293672853 with e.getClickCount 1 and clickCount 1 // No click event sent to the handler

Trackpad Double Tap

pressed at 1673293689761 with e.getClickCount 1 and clickCount 1 clicked at 1673293689762 with e.getClickCount 1 // <-- This click event triggers the maximize/restore early // Only if the title bar stays at the top will you get the second press/click events pressed at 1673293689907 with e.getClickCount 2 and clickCount 2 clicked at 1673293689908 with e.getClickCount 2

Trackpad Double Click

pressed at 1673293708430 with e.getClickCount 1 and clickCount 1 pressed at 1673293708625 with e.getClickCount 2 and clickCount 2 clicked at 1673293708740 with e.getClickCount 2

Mouse Double Click

pressed at 1673293731535 with e.getClickCount 1 and clickCount 1 pressed at 1673293731707 with e.getClickCount 2 and clickCount 2 clicked at 1673293731807 with e.getClickCount 2

rkeen-siemens avatar Jan 09 '23 20:01 rkeen-siemens

Does this only happen when using FlatLaf?

I have also had issues (see #621) where a Mac trackpad is causing invalid mouse events, but this is unrelated to FlatLaf.

remcopoelstra avatar Jan 27 '23 12:01 remcopoelstra

I've only seen it with FlatLaf.

rkeen-siemens avatar Jan 30 '23 16:01 rkeen-siemens

Some more data points:

  • I do not see the issue at all with the application running on Windows 10
  • I also see it when connecting via VNC (haven't tried with a local Linux machine)
  • I also see it when single clicking the title bar with a mouse (not a trackpad) when another application is active. Clicking with a mouse while the application is active works as expected (i.e. it is only maximized on a double click).
  • I see the same behavior with the mouse when using a Windows client to VNC to a Linux machine running the application, but it doesn't seem to be as reliably reproducible. A Windows trackpad (at least the built in one on my Dell laptop) behaves the same way as the mouse click (i.e. it only maximizes when clicked when the application is inactive).

rkeen-siemens avatar Jan 31 '23 18:01 rkeen-siemens

Thanks for the detailed information :+1:

Tried to reproduce, but works for me. I'm running CentOS in VirtualBox on Win11 using Magic Trackpad Model 2011 connected to Win11 via https://magicutilities.net/.

Maybe it is related to VNC/remote access...

Could you please check, for trackpad single tap, the return value of FlatNativeLinuxLibrary.moveOrResizeWindow() in this line: https://github.com/JFormDesigner/FlatLaf/blob/425f3acced1b17854dd94f2deda8f7d8a0756982/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java#L1294

I'm also interested in the value of field linuxNativeMove in mouseClicked().

Maybe changing this line: https://github.com/JFormDesigner/FlatLaf/blob/425f3acced1b17854dd94f2deda8f7d8a0756982/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java#L1236

to if( linuxNativeMove && SystemInfo.isLinux && ... fixes the issue?

DevCharly avatar Feb 23 '23 15:02 DevCharly

I've added suggested change from previous post to main branch.

Could you please try latest 3.1-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

DevCharly avatar Mar 03 '23 10:03 DevCharly

Looks like it is still an issue. I may have some time at the end of next week to look further into this (since I can easily reproduce).

rkeen-siemens avatar Mar 03 '23 19:03 rkeen-siemens