diff --git a/CHANGELOG.md b/CHANGELOG.md index 49500fdb..eab0cae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ FlatLaf Change Log - Extras: `FlatSVGIcon` color filters now can access painting component to implement component state based color mappings. (issue #906) - Linux: Added `libflatlaf-linux-arm64.so` for Linux on ARM64. (issue #899) +- Linux: Use X11 window manager events to resize window, if FlatLaf window + decorations are enabled. This gives FlatLaf windows a more "native" feeling. + (issue #866) - IntelliJ Themes: - Updated to latest versions and fixed various issues. - Support customizing through properties files. (issue #824) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLinuxLibrary.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLinuxLibrary.java index 952d0ece..6dc170e1 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLinuxLibrary.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLinuxLibrary.java @@ -49,8 +49,17 @@ class FlatNativeLinuxLibrary } // direction for _NET_WM_MOVERESIZE message - // see https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html - static final int MOVE = 8; + // see https://specifications.freedesktop.org/wm-spec/latest/ar01s04.html + static final int + SIZE_TOPLEFT = 0, + SIZE_TOP = 1, + SIZE_TOPRIGHT = 2, + SIZE_RIGHT = 3, + SIZE_BOTTOMRIGHT = 4, + SIZE_BOTTOM = 5, + SIZE_BOTTOMLEFT = 6, + SIZE_LEFT = 7, + MOVE = 8; private static Boolean isXWindowSystem; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowResizer.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowResizer.java index 06f75a2e..c63ac409 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowResizer.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowResizer.java @@ -188,7 +188,7 @@ public abstract class FlatWindowResizer protected abstract Dimension getWindowMinimumSize(); protected abstract Dimension getWindowMaximumSize(); - protected void beginResizing( int resizeDir ) {} + protected void beginResizing( int resizeDir, MouseEvent e ) {} protected void endResizing() {} //---- interface PropertyChangeListener ---- @@ -370,7 +370,25 @@ public abstract class FlatWindowResizer } @Override - protected void beginResizing( int resizeDir ) { + protected void beginResizing( int resizeDir, MouseEvent e ) { + // on Linux, resize window using window manager + if( SystemInfo.isLinux && window != null && FlatNativeLinuxLibrary.isWMUtilsSupported( window ) ) { + int direction = -1; + switch( resizeDir ) { + case N_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_TOP; break; + case S_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_BOTTOM; break; + case W_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_LEFT; break; + case E_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_RIGHT; break; + case NW_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_TOPLEFT; break; + case NE_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_TOPRIGHT; break; + case SW_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_BOTTOMLEFT; break; + case SE_RESIZE_CURSOR: direction = FlatNativeLinuxLibrary.SIZE_BOTTOMRIGHT; break; + } + + if( direction >= 0 && FlatNativeLinuxLibrary.moveOrResizeWindow( window, e, direction ) ) + return; + } + centerComp.setBounds( 0, 0, resizeComp.getWidth(), resizeComp.getHeight() ); centerComp.setCursor( getPredefinedCursor( resizeDir ) ); centerComp.setVisible( true ); @@ -462,7 +480,7 @@ public abstract class FlatWindowResizer } @Override - protected void beginResizing( int resizeDir ) { + protected void beginResizing( int resizeDir, MouseEvent e ) { int direction = 0; switch( resizeDir ) { case N_RESIZE_CURSOR: direction = NORTH; break; @@ -581,7 +599,7 @@ debug*/ dragRightOffset = windowBounds.x + windowBounds.width - xOnScreen; dragBottomOffset = windowBounds.y + windowBounds.height - yOnScreen; - beginResizing( resizeDir ); + beginResizing( resizeDir, e ); } @Override diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index c39995ff..db0f7d8b 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -564,8 +564,8 @@ RadioButtonMenuItem.background = @menuBackground #---- RootPane ---- RootPane.border = com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder -RootPane.borderDragThickness = 5 -RootPane.cornerDragWidth = 16 +RootPane.borderDragThickness = 6 +RootPane.cornerDragWidth = 32 RootPane.honorFrameMinimumSizeOnResize = false RootPane.honorDialogMinimumSizeOnResize = true diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt index a1c64d4f..6dfdc9a5 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt @@ -852,8 +852,8 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F RootPane.activeBorderColor #4d5154 HSL 206 4 32 com.formdev.flatlaf.util.DerivedColor [UI] lighten(7% autoInverse) RootPane.background #3c3f41 HSL 204 4 25 javax.swing.plaf.ColorUIResource [UI] RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI] -RootPane.borderDragThickness 5 -RootPane.cornerDragWidth 16 +RootPane.borderDragThickness 6 +RootPane.cornerDragWidth 32 RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object; [0] ENTER [1] press diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt index b3e564d4..7c962f5c 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt @@ -857,8 +857,8 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F RootPane.activeBorderColor #737373 HSL 0 0 45 com.formdev.flatlaf.util.DerivedColor [UI] darken(50% autoInverse) RootPane.background #f2f2f2 HSL 0 0 95 javax.swing.plaf.ColorUIResource [UI] RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI] -RootPane.borderDragThickness 5 -RootPane.cornerDragWidth 16 +RootPane.borderDragThickness 6 +RootPane.cornerDragWidth 32 RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object; [0] ENTER [1] press diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt index 0392e80f..e3b2d2e2 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt @@ -861,8 +861,8 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F RootPane.activeBorderColor #303030 HSL 0 0 19 com.formdev.flatlaf.util.DerivedColor [UI] lighten(7% autoInverse) RootPane.background #1e1e1e HSL 0 0 12 javax.swing.plaf.ColorUIResource [UI] RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI] -RootPane.borderDragThickness 5 -RootPane.cornerDragWidth 16 +RootPane.borderDragThickness 6 +RootPane.cornerDragWidth 32 RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object; [0] ENTER [1] press diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt index 4dc02870..64ecd8e1 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt @@ -865,8 +865,8 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F RootPane.activeBorderColor #777777 HSL 0 0 47 com.formdev.flatlaf.util.DerivedColor [UI] darken(50% autoInverse) RootPane.background #f6f6f6 HSL 0 0 96 javax.swing.plaf.ColorUIResource [UI] RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI] -RootPane.borderDragThickness 5 -RootPane.cornerDragWidth 16 +RootPane.borderDragThickness 6 +RootPane.cornerDragWidth 32 RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object; [0] ENTER [1] press diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index 8ffb24da..a597cd12 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -889,8 +889,8 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F RootPane.background #ccffcc HSL 120 100 90 javax.swing.plaf.ColorUIResource [UI] RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI] -RootPane.borderDragThickness 5 -RootPane.cornerDragWidth 16 +RootPane.borderDragThickness 6 +RootPane.cornerDragWidth 32 RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object; [0] ENTER [1] press