Skip to content

Commit

Permalink
Window decorations on Linux: limit window resizing/moving to left mou…
Browse files Browse the repository at this point in the history
…se button (issue #482)
  • Loading branch information
DevCharly committed Mar 17, 2022
1 parent 47508dc commit c63f4e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Expand Up @@ -1016,6 +1016,9 @@ public void mousePressed( MouseEvent e ) {
if( window == null )
return; // should newer occur

if( !SwingUtilities.isLeftMouseButton( e ) )
return;

dragOffset = SwingUtilities.convertPoint( FlatTitlePane.this, e.getPoint(), window );
}

Expand All @@ -1030,6 +1033,9 @@ public void mouseDragged( MouseEvent e ) {
if( window == null )
return; // should newer occur

if( !SwingUtilities.isLeftMouseButton( e ) )
return;

if( hasNativeCustomDecoration() )
return; // do nothing if having native window border

Expand Down
Expand Up @@ -43,6 +43,7 @@
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.JRootPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import com.formdev.flatlaf.util.SystemInfo;
import com.formdev.flatlaf.util.UIScale;
Expand Down Expand Up @@ -521,7 +522,7 @@ public void mouseClicked( MouseEvent e ) {

@Override
public void mousePressed( MouseEvent e ) {
if( !isWindowResizable() )
if( !SwingUtilities.isLeftMouseButton( e ) || !isWindowResizable() )
return;

int xOnScreen = e.getXOnScreen();
Expand Down Expand Up @@ -550,7 +551,7 @@ public void mousePressed( MouseEvent e ) {

@Override
public void mouseReleased( MouseEvent e ) {
if( !isWindowResizable() )
if( !SwingUtilities.isLeftMouseButton( e ) || !isWindowResizable() )
return;

dragLeftOffset = dragRightOffset = dragTopOffset = dragBottomOffset = 0;
Expand All @@ -576,7 +577,7 @@ public void mouseMoved( MouseEvent e ) {

@Override
public void mouseDragged( MouseEvent e ) {
if( !isWindowResizable() )
if( !SwingUtilities.isLeftMouseButton( e ) || !isWindowResizable() )
return;

int xOnScreen = e.getXOnScreen();
Expand Down

0 comments on commit c63f4e9

Please sign in to comment.