From 4b844353ee21e78c698e71f30c25db4470066c98 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 2 Jan 2023 19:54:05 +0100 Subject: [PATCH] Window decorations: fixed broken window resizing on Linux multi-screen setups (issue #632) --- CHANGELOG.md | 2 ++ .../com/formdev/flatlaf/ui/FlatWindowResizer.java | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 510bcc6a3..61284ce16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FlatLaf Change Log #### Fixed bugs +- FlatLaf window decorations on Linux: Fixed broken window resizing on + multi-screen setups. (issue #632) - IntelliJ Themes: - Fixed default button hover background in "Solarized Light" theme. (issue #628) 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 849c0a359..9eb3f2f04 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 @@ -606,9 +606,10 @@ public void mouseDragged( MouseEvent e ) { if( resizeDir == S_RESIZE_CURSOR || resizeDir == SW_RESIZE_CURSOR || resizeDir == SE_RESIZE_CURSOR ) { newBounds.height = (yOnScreen + dragBottomOffset) - newBounds.y; if( limitToParentBounds() ) { - int parentHeight = getParentBounds().height; - if( newBounds.y + newBounds.height > parentHeight ) - newBounds.height = parentHeight - newBounds.y; + Rectangle parentBounds = getParentBounds(); + int parentBottomY = parentBounds.y + parentBounds.height; + if( newBounds.y + newBounds.height > parentBottomY ) + newBounds.height = parentBottomY - newBounds.y; } } @@ -624,9 +625,10 @@ public void mouseDragged( MouseEvent e ) { if( resizeDir == E_RESIZE_CURSOR || resizeDir == NE_RESIZE_CURSOR || resizeDir == SE_RESIZE_CURSOR ) { newBounds.width = (xOnScreen + dragRightOffset) - newBounds.x; if( limitToParentBounds() ) { - int parentWidth = getParentBounds().width; - if( newBounds.x + newBounds.width > parentWidth ) - newBounds.width = parentWidth - newBounds.x; + Rectangle parentBounds = getParentBounds(); + int parentRightX = parentBounds.x + parentBounds.width; + if( newBounds.x + newBounds.width > parentRightX ) + newBounds.width = parentRightX - newBounds.x; } }