mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
Linux: fixed double-click on title bar to maximize/restore (issue #482)
This commit is contained in:
@@ -32,6 +32,7 @@ import java.awt.Image;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentEvent;
|
||||
@@ -1167,6 +1168,7 @@ debug*/
|
||||
|
||||
private Point dragOffset;
|
||||
private boolean nativeMove;
|
||||
private long lastSingleClickWhen;
|
||||
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e ) {
|
||||
@@ -1209,22 +1211,33 @@ debug*/
|
||||
|
||||
// on Linux, move or maximize/restore window
|
||||
if( SystemInfo.isLinux && FlatNativeLinuxLibrary.isWMUtilsSupported( window ) ) {
|
||||
switch( e.getClickCount() ) {
|
||||
// double-click is not always recognized in Java when using _NET_WM_MOVERESIZE message
|
||||
int clickCount = e.getClickCount();
|
||||
if( clickCount == 1 && (e.getWhen() - lastSingleClickWhen) <= getMultiClickInterval() )
|
||||
clickCount = 2;
|
||||
|
||||
switch( clickCount ) {
|
||||
case 1:
|
||||
// move window via _NET_WM_MOVERESIZE event
|
||||
// move window via _NET_WM_MOVERESIZE message
|
||||
e.consume();
|
||||
nativeMove = FlatNativeLinuxLibrary.moveOrResizeWindow( window, e, FlatNativeLinuxLibrary.MOVE );
|
||||
lastSingleClickWhen = e.getWhen();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// maximize/restore on double-click
|
||||
// also done here because no mouse clicked event is sent when using _NET_WM_MOVERESIZE event
|
||||
// also done here because no mouse clicked event is sent when using _NET_WM_MOVERESIZE message
|
||||
maximizeOrRestore();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getMultiClickInterval() {
|
||||
Object value = Toolkit.getDefaultToolkit().getDesktopProperty( "awt.multiClickInterval" );
|
||||
return (value instanceof Integer) ? (Integer) value : 200;
|
||||
}
|
||||
|
||||
@Override public void mouseReleased( MouseEvent e ) {}
|
||||
@Override public void mouseEntered( MouseEvent e ) {}
|
||||
@Override public void mouseExited( MouseEvent e ) {}
|
||||
|
||||
Reference in New Issue
Block a user