Window decorations on Linux: limit window resizing/moving to left mouse button (issue #482)

This commit is contained in:
Karl Tauber
2022-03-18 00:05:15 +01:00
parent 47508dc6ac
commit c63f4e9662
2 changed files with 10 additions and 3 deletions

View File

@@ -1016,6 +1016,9 @@ debug*/
if( window == null ) if( window == null )
return; // should newer occur return; // should newer occur
if( !SwingUtilities.isLeftMouseButton( e ) )
return;
dragOffset = SwingUtilities.convertPoint( FlatTitlePane.this, e.getPoint(), window ); dragOffset = SwingUtilities.convertPoint( FlatTitlePane.this, e.getPoint(), window );
} }
@@ -1030,6 +1033,9 @@ debug*/
if( window == null ) if( window == null )
return; // should newer occur return; // should newer occur
if( !SwingUtilities.isLeftMouseButton( e ) )
return;
if( hasNativeCustomDecoration() ) if( hasNativeCustomDecoration() )
return; // do nothing if having native window border return; // do nothing if having native window border

View File

@@ -43,6 +43,7 @@ import javax.swing.JComponent;
import javax.swing.JInternalFrame; import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane; import javax.swing.JLayeredPane;
import javax.swing.JRootPane; import javax.swing.JRootPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.SystemInfo;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
@@ -521,7 +522,7 @@ debug*/
@Override @Override
public void mousePressed( MouseEvent e ) { public void mousePressed( MouseEvent e ) {
if( !isWindowResizable() ) if( !SwingUtilities.isLeftMouseButton( e ) || !isWindowResizable() )
return; return;
int xOnScreen = e.getXOnScreen(); int xOnScreen = e.getXOnScreen();
@@ -550,7 +551,7 @@ debug*/
@Override @Override
public void mouseReleased( MouseEvent e ) { public void mouseReleased( MouseEvent e ) {
if( !isWindowResizable() ) if( !SwingUtilities.isLeftMouseButton( e ) || !isWindowResizable() )
return; return;
dragLeftOffset = dragRightOffset = dragTopOffset = dragBottomOffset = 0; dragLeftOffset = dragRightOffset = dragTopOffset = dragBottomOffset = 0;
@@ -576,7 +577,7 @@ debug*/
@Override @Override
public void mouseDragged( MouseEvent e ) { public void mouseDragged( MouseEvent e ) {
if( !isWindowResizable() ) if( !SwingUtilities.isLeftMouseButton( e ) || !isWindowResizable() )
return; return;
int xOnScreen = e.getXOnScreen(); int xOnScreen = e.getXOnScreen();