@@ -765,10 +765,16 @@ public Dimension getMinimumSize() {
765
765
return target .getSize ();
766
766
}
767
767
768
- void showWindowMenu (int x , int y ) {
768
+ void showWindowMenu (long serial , int x , int y ) {
769
+ // "This request must be used in response to some sort of user action like
770
+ // a button press, key press, or touch down event."
771
+ // So 'serial' must appertain to such an event.
772
+
773
+ assert serial != 0 ;
774
+
769
775
int xNative = javaUnitsToSurfaceUnits (x );
770
776
int yNative = javaUnitsToSurfaceUnits (y );
771
- performLocked (() -> nativeShowWindowMenu (nativePtr , xNative , yNative ));
777
+ performLocked (() -> nativeShowWindowMenu (serial , nativePtr , xNative , yNative ));
772
778
}
773
779
774
780
@ Override
@@ -846,7 +852,7 @@ public void updateCursorImmediately() {
846
852
}
847
853
848
854
private void updateCursorImmediately (WLInputState inputState ) {
849
- WLComponentPeer peer = inputState .getPeer ();
855
+ WLComponentPeer peer = inputState .peerForPointerEvents ();
850
856
if (peer == null ) return ;
851
857
Cursor cursor = peer .getCursor (inputState .getPointerX (), inputState .getPointerY ());
852
858
setCursor (cursor , getGraphicsDevice () != null ? getGraphicsDevice ().getDisplayScale () : 1 );
@@ -864,6 +870,14 @@ Cursor getCursor(int x, int y) {
864
870
}
865
871
866
872
private static void setCursor (Cursor c , int scale ) {
873
+ long serial = WLToolkit .getInputState ().pointerEnterSerial ();
874
+ if (serial == 0 ) {
875
+ if (log .isLoggable (Level .WARNING )) {
876
+ log .warning ("setCursor aborted due to missing event serial" );
877
+ }
878
+ return ; // Wayland will ignore the request anyway
879
+ }
880
+
867
881
Cursor cursor ;
868
882
if (c .getType () == Cursor .CUSTOM_CURSOR && !(c instanceof WLCustomCursor )) {
869
883
cursor = Cursor .getDefaultCursor ();
@@ -888,7 +902,7 @@ private static void setCursor(Cursor c, int scale) {
888
902
}
889
903
AWTAccessor .getCursorAccessor ().setPData (cursor , scale , pData );
890
904
}
891
- nativeSetCursor (pData , scale );
905
+ nativeSetCursor (pData , scale , serial );
892
906
});
893
907
}
894
908
@@ -1013,7 +1027,16 @@ final void requestUnsetFullScreen() {
1013
1027
}
1014
1028
1015
1029
final void activate () {
1016
- performLocked (() -> nativeActivate (nativePtr ));
1030
+ // "The serial can come from an input or focus event."
1031
+ long serial = WLToolkit .getInputState ().keyboardEnterSerial ();
1032
+ long surface = WLToolkit .getInputState ().surfaceForKeyboardInput ();
1033
+ if (serial != 0 ) {
1034
+ performLocked (() -> nativeActivate (serial , nativePtr , surface ));
1035
+ } else {
1036
+ if (log .isLoggable (Level .WARNING )) {
1037
+ log .warning ("activate() aborted due to missing keyboard enter event serial" );
1038
+ }
1039
+ }
1017
1040
}
1018
1041
1019
1042
private static native void initIDs ();
@@ -1036,8 +1059,8 @@ protected native void nativeRepositionWLPopup(long ptr,
1036
1059
protected native void nativeDisposeFrame (long ptr );
1037
1060
1038
1061
private native long getWLSurface (long ptr );
1039
- private native void nativeStartDrag (long ptr );
1040
- private native void nativeStartResize (long ptr , int edges );
1062
+ private native void nativeStartDrag (long serial , long ptr );
1063
+ private native void nativeStartResize (long serial , long ptr , int edges );
1041
1064
1042
1065
private native void nativeSetTitle (long ptr , String title );
1043
1066
private native void nativeRequestMinimized (long ptr );
@@ -1051,11 +1074,11 @@ protected native void nativeRepositionWLPopup(long ptr,
1051
1074
private native void nativeSetWindowGeometry (long ptr , int x , int y , int width , int height );
1052
1075
private native void nativeSetMinimumSize (long ptr , int width , int height );
1053
1076
private native void nativeSetMaximumSize (long ptr , int width , int height );
1054
- private static native void nativeSetCursor (long pData , int scale );
1077
+ private static native void nativeSetCursor (long pData , int scale , long pointerEnterSerial );
1055
1078
private static native long nativeGetPredefinedCursor (String name , int scale );
1056
1079
private static native long nativeDestroyPredefinedCursor (long pData );
1057
- private native void nativeShowWindowMenu (long ptr , int x , int y );
1058
- private native void nativeActivate (long ptr );
1080
+ private native void nativeShowWindowMenu (long serial , long ptr , int x , int y );
1081
+ private native void nativeActivate (long serial , long ptr , long activatingSurfacePtr );
1059
1082
1060
1083
static long getNativePtrFor (Component component ) {
1061
1084
final ComponentAccessor acc = AWTAccessor .getComponentAccessor ();
@@ -1459,12 +1482,22 @@ private static void convertPointerEventToMWEParameters(
1459
1482
}
1460
1483
1461
1484
1462
- void startDrag () {
1463
- performLocked (() -> nativeStartDrag (nativePtr ));
1485
+ void startDrag (long serial ) {
1486
+ // "This request must be used in response to some sort of user action like a button press,
1487
+ // key press, or touch down event. The passed serial is used to determine the type
1488
+ // of interactive move (touch, pointer, etc)."
1489
+ assert serial != 0 ;
1490
+
1491
+ performLocked (() -> nativeStartDrag (serial , nativePtr ));
1464
1492
}
1465
1493
1466
- void startResize (int edges ) {
1467
- performLocked (() -> nativeStartResize (nativePtr , edges ));
1494
+ void startResize (long serial , int edges ) {
1495
+ // "This request must be used in response to some sort of user action like a button press,
1496
+ // key press, or touch down event. The passed serial is used to determine the type
1497
+ // of interactive resize (touch, pointer, etc)."
1498
+ assert serial != 0 ;
1499
+
1500
+ performLocked (() -> nativeStartResize (serial , nativePtr , edges ));
1468
1501
}
1469
1502
1470
1503
/**
0 commit comments