mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 06:20:53 +03:00
Linux: fixed continuous cursor toggling between resize and standard cursor when resizing window with FlatLaf window decorations (issue #907)
This commit is contained in:
@@ -7,6 +7,9 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
- HTML: Fixed wrong rendering if HTML text contains `<style>` tag with
|
- HTML: Fixed wrong rendering if HTML text contains `<style>` tag with
|
||||||
attributes (e.g. `<style type='text/css'>`). (issue #905; regression in 3.5.1)
|
attributes (e.g. `<style type='text/css'>`). (issue #905; regression in 3.5.1)
|
||||||
|
- FlatLaf window decorations:
|
||||||
|
- Linux: Fixed continuous cursor toggling between resize and standard cursor
|
||||||
|
when resizing window. (issue #907)
|
||||||
|
|
||||||
|
|
||||||
## 3.5.2
|
## 3.5.2
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import javax.swing.DesktopManager;
|
|||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JInternalFrame;
|
import javax.swing.JInternalFrame;
|
||||||
import javax.swing.JLayeredPane;
|
import javax.swing.JLayeredPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JRootPane;
|
import javax.swing.JRootPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -191,7 +192,7 @@ public abstract class FlatWindowResizer
|
|||||||
protected abstract Dimension getWindowMinimumSize();
|
protected abstract Dimension getWindowMinimumSize();
|
||||||
protected abstract Dimension getWindowMaximumSize();
|
protected abstract Dimension getWindowMaximumSize();
|
||||||
|
|
||||||
protected void beginResizing( int direction ) {}
|
protected void beginResizing( int resizeDir ) {}
|
||||||
protected void endResizing() {}
|
protected void endResizing() {}
|
||||||
|
|
||||||
//---- interface PropertyChangeListener ----
|
//---- interface PropertyChangeListener ----
|
||||||
@@ -234,17 +235,46 @@ public abstract class FlatWindowResizer
|
|||||||
{
|
{
|
||||||
protected Window window;
|
protected Window window;
|
||||||
|
|
||||||
|
private final JComponent centerComp;
|
||||||
private final boolean limitResizeToScreenBounds;
|
private final boolean limitResizeToScreenBounds;
|
||||||
|
|
||||||
public WindowResizer( JRootPane rootPane ) {
|
public WindowResizer( JRootPane rootPane ) {
|
||||||
super( rootPane );
|
super( rootPane );
|
||||||
|
|
||||||
|
// Transparent "center" component that is made visible only while resizing window.
|
||||||
|
// It uses same cursor as the area where resize dragging started.
|
||||||
|
// This ensures that the cursor shape stays stable while dragging mouse
|
||||||
|
// into the window to make window smaller. Otherwise it would toggling between
|
||||||
|
// resize and standard cursor because the component layout is not updated
|
||||||
|
// fast enough and the mouse cursor is always updated from the component
|
||||||
|
// at the mouse location.
|
||||||
|
centerComp = new JPanel();
|
||||||
|
centerComp.setOpaque( false );
|
||||||
|
centerComp.setVisible( false );
|
||||||
|
Container cont = rootPane.getLayeredPane();
|
||||||
|
cont.add( centerComp, WINDOW_RESIZER_LAYER, 4 );
|
||||||
|
|
||||||
// On Linux, limit window resizing to screen bounds because otherwise
|
// On Linux, limit window resizing to screen bounds because otherwise
|
||||||
// there would be a strange effect when the mouse is moved over a sidebar
|
// there would be a strange effect when the mouse is moved over a sidebar
|
||||||
// while resizing and the opposite window side is also resized.
|
// while resizing and the opposite window side is also resized.
|
||||||
limitResizeToScreenBounds = SystemInfo.isLinux;
|
limitResizeToScreenBounds = SystemInfo.isLinux;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uninstall() {
|
||||||
|
Container cont = topDragComp.getParent();
|
||||||
|
cont.remove( centerComp );
|
||||||
|
|
||||||
|
super.uninstall();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doLayout() {
|
||||||
|
super.doLayout();
|
||||||
|
|
||||||
|
centerComp.setBounds( 0, 0, resizeComp.getWidth(), resizeComp.getHeight() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addNotify() {
|
protected void addNotify() {
|
||||||
Container parent = resizeComp.getParent();
|
Container parent = resizeComp.getParent();
|
||||||
@@ -346,6 +376,18 @@ public abstract class FlatWindowResizer
|
|||||||
public void windowStateChanged( WindowEvent e ) {
|
public void windowStateChanged( WindowEvent e ) {
|
||||||
updateVisibility();
|
updateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void beginResizing( int resizeDir ) {
|
||||||
|
centerComp.setCursor( getPredefinedCursor( resizeDir ) );
|
||||||
|
centerComp.setVisible( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void endResizing() {
|
||||||
|
centerComp.setVisible( false );
|
||||||
|
centerComp.setCursor( null );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- class InternalFrameResizer -----------------------------------------
|
//---- class InternalFrameResizer -----------------------------------------
|
||||||
@@ -427,7 +469,18 @@ public abstract class FlatWindowResizer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void beginResizing( int direction ) {
|
protected void beginResizing( int resizeDir ) {
|
||||||
|
int direction = 0;
|
||||||
|
switch( resizeDir ) {
|
||||||
|
case N_RESIZE_CURSOR: direction = NORTH; break;
|
||||||
|
case S_RESIZE_CURSOR: direction = SOUTH; break;
|
||||||
|
case W_RESIZE_CURSOR: direction = WEST; break;
|
||||||
|
case E_RESIZE_CURSOR: direction = EAST; break;
|
||||||
|
case NW_RESIZE_CURSOR: direction = NORTH_WEST; break;
|
||||||
|
case NE_RESIZE_CURSOR: direction = NORTH_EAST; break;
|
||||||
|
case SW_RESIZE_CURSOR: direction = SOUTH_WEST; break;
|
||||||
|
case SE_RESIZE_CURSOR: direction = SOUTH_EAST; break;
|
||||||
|
}
|
||||||
desktopManager.get().beginResizingFrame( getFrame(), direction );
|
desktopManager.get().beginResizingFrame( getFrame(), direction );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,18 +588,7 @@ debug*/
|
|||||||
dragRightOffset = windowBounds.x + windowBounds.width - xOnScreen;
|
dragRightOffset = windowBounds.x + windowBounds.width - xOnScreen;
|
||||||
dragBottomOffset = windowBounds.y + windowBounds.height - yOnScreen;
|
dragBottomOffset = windowBounds.y + windowBounds.height - yOnScreen;
|
||||||
|
|
||||||
int direction = 0;
|
beginResizing( resizeDir );
|
||||||
switch( resizeDir ) {
|
|
||||||
case N_RESIZE_CURSOR: direction = NORTH; break;
|
|
||||||
case S_RESIZE_CURSOR: direction = SOUTH; break;
|
|
||||||
case W_RESIZE_CURSOR: direction = WEST; break;
|
|
||||||
case E_RESIZE_CURSOR: direction = EAST; break;
|
|
||||||
case NW_RESIZE_CURSOR: direction = NORTH_WEST; break;
|
|
||||||
case NE_RESIZE_CURSOR: direction = NORTH_EAST; break;
|
|
||||||
case SW_RESIZE_CURSOR: direction = SOUTH_WEST; break;
|
|
||||||
case SE_RESIZE_CURSOR: direction = SOUTH_EAST; break;
|
|
||||||
}
|
|
||||||
beginResizing( direction );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user