Skip to content

Commit d7dc474

Browse files
author
Harshitha Onkar
committed
8305712: [MacOS] Deprecated Cocoa-NSEvent names
Reviewed-by: dmarkov, prr
1 parent e0620b8 commit d7dc474

File tree

13 files changed

+116
-106
lines changed

13 files changed

+116
-106
lines changed

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -139,7 +139,7 @@ void handleKeyEvent(int eventType, int modifierFlags, String chars, String chars
139139
short keyCode, boolean needsKeyTyped, boolean needsKeyReleased) {
140140
boolean isFlagsChangedEvent =
141141
isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) :
142-
(eventType == CocoaConstants.NSFlagsChanged);
142+
(eventType == CocoaConstants.NSEventTypeFlagsChanged);
143143

144144
int jeventType = KeyEvent.KEY_PRESSED;
145145
int jkeyCode = KeyEvent.VK_UNDEFINED;

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -187,7 +187,7 @@ private void deliverMouseEvent(final NSEvent event) {
187187
int absX = event.getAbsX();
188188
int absY = event.getAbsY();
189189

190-
if (event.getType() == CocoaConstants.NSScrollWheel) {
190+
if (event.getType() == CocoaConstants.NSEventTypeScrollWheel) {
191191
responder.handleScrollEvent(x, y, absX, absY, event.getModifierFlags(),
192192
event.getScrollDeltaX(), event.getScrollDeltaY(),
193193
event.getScrollPhase());

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1022,7 +1022,7 @@ public void setModalBlocked(boolean blocked) {
10221022
// We are going to show a modal window. Previously displayed window will be
10231023
// blocked/disabled. So we have to send mouse exited event to it now, since
10241024
// all mouse events are discarded for blocked/disabled windows.
1025-
execute(ptr -> nativeSynthesizeMouseEnteredExitedEvents(ptr, CocoaConstants.NSMouseExited));
1025+
execute(ptr -> nativeSynthesizeMouseEnteredExitedEvents(ptr, CocoaConstants.NSEventTypeMouseExited));
10261026
}
10271027

10281028
execute(ptr -> nativeSetEnabled(ptr, !blocked));

src/java.desktop/macosx/classes/sun/lwawt/macosx/CocoaConstants.java

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,54 +30,54 @@ public final class CocoaConstants {
3030
private CocoaConstants(){}
3131

3232
//from the NSEvent class reference:
33-
public static final int NSLeftMouseDown = 1;
34-
public static final int NSLeftMouseUp = 2;
35-
public static final int NSRightMouseDown = 3;
36-
public static final int NSRightMouseUp = 4;
37-
public static final int NSMouseMoved = 5;
38-
public static final int NSLeftMouseDragged = 6;
39-
public static final int NSRightMouseDragged = 7;
40-
public static final int NSMouseEntered = 8;
41-
public static final int NSMouseExited = 9;
42-
public static final int NSKeyDown = 10;
43-
public static final int NSKeyUp = 11;
44-
public static final int NSFlagsChanged = 12;
33+
public static final int NSEventTypeLeftMouseDown = 1;
34+
public static final int NSEventTypeLeftMouseUp = 2;
35+
public static final int NSEventTypeRightMouseDown = 3;
36+
public static final int NSEventTypeRightMouseUp = 4;
37+
public static final int NSEventTypeMouseMoved = 5;
38+
public static final int NSEventTypeLeftMouseDragged = 6;
39+
public static final int NSEventTypeRightMouseDragged = 7;
40+
public static final int NSEventTypeMouseEntered = 8;
41+
public static final int NSEventTypeMouseExited = 9;
42+
public static final int NSEventTypeKeyDown = 10;
43+
public static final int NSEventTypeKeyUp = 11;
44+
public static final int NSEventTypeFlagsChanged = 12;
4545

46-
public static final int NSScrollWheel = 22;
47-
public static final int NSOtherMouseDown = 25;
48-
public static final int NSOtherMouseUp = 26;
49-
public static final int NSOtherMouseDragged = 27;
46+
public static final int NSEventTypeScrollWheel = 22;
47+
public static final int NSEventTypeOtherMouseDown = 25;
48+
public static final int NSEventTypeOtherMouseUp = 26;
49+
public static final int NSEventTypeOtherMouseDragged = 27;
5050

5151
public static final int AllLeftMouseEventsMask =
52-
1 << NSLeftMouseDown |
53-
1 << NSLeftMouseUp |
54-
1 << NSLeftMouseDragged;
52+
1 << NSEventTypeLeftMouseDown |
53+
1 << NSEventTypeLeftMouseUp |
54+
1 << NSEventTypeLeftMouseDragged;
5555

5656
public static final int AllRightMouseEventsMask =
57-
1 << NSRightMouseDown |
58-
1 << NSRightMouseUp |
59-
1 << NSRightMouseDragged;
57+
1 << NSEventTypeRightMouseDown |
58+
1 << NSEventTypeRightMouseUp |
59+
1 << NSEventTypeRightMouseDragged;
6060

6161
public static final int AllOtherMouseEventsMask =
62-
1 << NSOtherMouseDown |
63-
1 << NSOtherMouseUp |
64-
1 << NSOtherMouseDragged;
62+
1 << NSEventTypeOtherMouseDown |
63+
1 << NSEventTypeOtherMouseUp |
64+
1 << NSEventTypeOtherMouseDragged;
6565

6666
/*
67-
NSAppKitDefined = 13,
68-
NSSystemDefined = 14,
69-
NSApplicationDefined = 15,
70-
NSPeriodic = 16,
71-
NSCursorUpdate = 17,
72-
NSScrollWheel = 22,
73-
NSTabletPoint = 23,
74-
NSTabletProximity = 24,
75-
NSEventTypeGesture = 29,
76-
NSEventTypeMagnify = 30,
77-
NSEventTypeSwipe = 31,
78-
NSEventTypeRotate = 18,
79-
NSEventTypeBeginGesture = 19,
80-
NSEventTypeEndGesture = 20
67+
NSEventTypeAppKitDefined = 13,
68+
NSEventTypeSystemDefined = 14,
69+
NSEventTypeApplicationDefined = 15,
70+
NSEventTypePeriodic = 16,
71+
NSEventTypeCursorUpdate = 17,
72+
NSEventTypeScrollWheel = 22,
73+
NSEventTypeTabletPoint = 23,
74+
NSEventTypeTabletProximity = 24,
75+
NSEventTypeGesture = 29,
76+
NSEventTypeMagnify = 30,
77+
NSEventTypeSwipe = 31,
78+
NSEventTypeRotate = 18,
79+
NSEventTypeBeginGesture = 19,
80+
NSEventTypeEndGesture = 20
8181
*/
8282

8383
// See http://developer.apple.com/library/mac/#documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html

src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -207,37 +207,37 @@ static int npToJavaEventType(int npEventType) {
207207
static int nsToJavaEventType(int nsEventType) {
208208
int jeventType = 0;
209209
switch (nsEventType) {
210-
case CocoaConstants.NSLeftMouseDown:
211-
case CocoaConstants.NSRightMouseDown:
212-
case CocoaConstants.NSOtherMouseDown:
210+
case CocoaConstants.NSEventTypeLeftMouseDown:
211+
case CocoaConstants.NSEventTypeRightMouseDown:
212+
case CocoaConstants.NSEventTypeOtherMouseDown:
213213
jeventType = MouseEvent.MOUSE_PRESSED;
214214
break;
215-
case CocoaConstants.NSLeftMouseUp:
216-
case CocoaConstants.NSRightMouseUp:
217-
case CocoaConstants.NSOtherMouseUp:
215+
case CocoaConstants.NSEventTypeLeftMouseUp:
216+
case CocoaConstants.NSEventTypeRightMouseUp:
217+
case CocoaConstants.NSEventTypeOtherMouseUp:
218218
jeventType = MouseEvent.MOUSE_RELEASED;
219219
break;
220-
case CocoaConstants.NSMouseMoved:
220+
case CocoaConstants.NSEventTypeMouseMoved:
221221
jeventType = MouseEvent.MOUSE_MOVED;
222222
break;
223-
case CocoaConstants.NSLeftMouseDragged:
224-
case CocoaConstants.NSRightMouseDragged:
225-
case CocoaConstants.NSOtherMouseDragged:
223+
case CocoaConstants.NSEventTypeLeftMouseDragged:
224+
case CocoaConstants.NSEventTypeRightMouseDragged:
225+
case CocoaConstants.NSEventTypeOtherMouseDragged:
226226
jeventType = MouseEvent.MOUSE_DRAGGED;
227227
break;
228-
case CocoaConstants.NSMouseEntered:
228+
case CocoaConstants.NSEventTypeMouseEntered:
229229
jeventType = MouseEvent.MOUSE_ENTERED;
230230
break;
231-
case CocoaConstants.NSMouseExited:
231+
case CocoaConstants.NSEventTypeMouseExited:
232232
jeventType = MouseEvent.MOUSE_EXITED;
233233
break;
234-
case CocoaConstants.NSScrollWheel:
234+
case CocoaConstants.NSEventTypeScrollWheel:
235235
jeventType = MouseEvent.MOUSE_WHEEL;
236236
break;
237-
case CocoaConstants.NSKeyDown:
237+
case CocoaConstants.NSEventTypeKeyDown:
238238
jeventType = KeyEvent.KEY_PRESSED;
239239
break;
240-
case CocoaConstants.NSKeyUp:
240+
case CocoaConstants.NSEventTypeKeyUp:
241241
jeventType = KeyEvent.KEY_RELEASED;
242242
break;
243243
}

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -354,9 +354,9 @@ -(void) deliverJavaMouseEvent: (NSEvent *) event {
354354
NSEventType type = [event type];
355355

356356
// check synthesized mouse entered/exited events
357-
if ((type == NSMouseEntered && mouseIsOver) || (type == NSMouseExited && !mouseIsOver)) {
357+
if ((type == NSEventTypeMouseEntered && mouseIsOver) || (type == NSEventTypeMouseExited && !mouseIsOver)) {
358358
return;
359-
}else if ((type == NSMouseEntered && !mouseIsOver) || (type == NSMouseExited && mouseIsOver)) {
359+
}else if ((type == NSEventTypeMouseEntered && !mouseIsOver) || (type == NSEventTypeMouseExited && mouseIsOver)) {
360360
mouseIsOver = !mouseIsOver;
361361
}
362362

@@ -376,10 +376,10 @@ -(void) deliverJavaMouseEvent: (NSEvent *) event {
376376
absP.y = screenRect.size.height - absP.y;
377377
jint clickCount;
378378

379-
if (type == NSMouseEntered ||
380-
type == NSMouseExited ||
381-
type == NSScrollWheel ||
382-
type == NSMouseMoved) {
379+
if (type == NSEventTypeMouseEntered ||
380+
type == NSEventTypeMouseExited ||
381+
type == NSEventTypeScrollWheel ||
382+
type == NSEventTypeMouseMoved) {
383383
clickCount = 0;
384384
} else {
385385
clickCount = [event clickCount];
@@ -458,7 +458,7 @@ -(void) deliverJavaKeyEventHelper: (NSEvent *) event {
458458

459459
jstring characters = NULL;
460460
jstring charactersIgnoringModifiers = NULL;
461-
if ([event type] != NSFlagsChanged) {
461+
if ([event type] != NSEventTypeFlagsChanged) {
462462
characters = NSStringToJavaString(env, [event characters]);
463463
charactersIgnoringModifiers = NSStringToJavaString(env, [event charactersIgnoringModifiers]);
464464
}

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -439,7 +439,7 @@ + (void) synthesizeMouseEnteredExitedEvents:(NSWindow*)window withType:(NSEventT
439439

440440
NSPoint screenLocation = [NSEvent mouseLocation];
441441
NSPoint windowLocation = [window convertScreenToBase: screenLocation];
442-
int modifierFlags = (eventType == NSMouseEntered) ? NSMouseEnteredMask : NSMouseExitedMask;
442+
int modifierFlags = (eventType == NSEventTypeMouseEntered) ? NSMouseEnteredMask : NSMouseExitedMask;
443443

444444
NSEvent *mouseEvent = [NSEvent enterExitEventWithType: eventType
445445
location: windowLocation
@@ -467,9 +467,9 @@ + (void) synthesizeMouseEnteredExitedEventsForAllWindows {
467467
BOOL isUnderMouse = ([window windowNumber] == topmostWindowUnderMouseID);
468468
BOOL mouseIsOver = [[window contentView] mouseIsOver];
469469
if (isUnderMouse && !mouseIsOver) {
470-
[AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseEntered];
470+
[AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSEventTypeMouseEntered];
471471
} else if (!isUnderMouse && mouseIsOver) {
472-
[AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseExited];
472+
[AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSEventTypeMouseExited];
473473
}
474474
}
475475
}
@@ -999,7 +999,9 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification {
999999
}
10001000

10011001
- (void)sendEvent:(NSEvent *)event {
1002-
if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
1002+
if ([event type] == NSEventTypeLeftMouseDown ||
1003+
[event type] == NSEventTypeRightMouseDown ||
1004+
[event type] == NSEventTypeOtherMouseDown) {
10031005
if ([self isBlocked]) {
10041006
// Move parent windows to front and make sure that a child window is displayed
10051007
// in front of its nearest parent.
@@ -1602,7 +1604,7 @@ + (AWTWindow *) lastKeyWindow {
16021604
{
16031605
JNI_COCOA_ENTER(env);
16041606

1605-
if (eventType == NSMouseEntered || eventType == NSMouseExited) {
1607+
if (eventType == NSEventTypeMouseEntered || eventType == NSEventTypeMouseExited) {
16061608
NSWindow *nsWindow = OBJC(windowPtr);
16071609

16081610
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){

src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,7 @@ - (void)handleAction:(NSMenuItem *)sender {
8282
// means we have to handle it here.
8383
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
8484

85-
if ([currEvent type] == NSKeyDown) {
85+
if ([currEvent type] == NSEventTypeKeyDown) {
8686
// The action event can be ignored only if the key window is an AWT window.
8787
// Otherwise, the action event is the only notification and must be processed.
8888
NSWindow *keyWindow = [NSApp keyWindow];

src/java.desktop/macosx/native/libawt_lwawt/awt/DnDUtilities.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -163,32 +163,32 @@ + (NSDragOperation)mapJavaDragOperationToNS:(jint)dragOperation
163163
// Mouse and key modifiers mapping:
164164
+ (NSUInteger)mapJavaExtModifiersToNSMouseDownButtons:(jint)modifiers
165165
{
166-
NSUInteger result = NSLeftMouseDown;
166+
NSUInteger result = NSEventTypeLeftMouseDown;
167167

168168
if ((modifiers & java_awt_event_InputEvent_BUTTON1_DOWN_MASK) != 0)
169-
result = NSLeftMouseDown;
169+
result = NSEventTypeLeftMouseDown;
170170

171171
if ((modifiers & java_awt_event_InputEvent_BUTTON2_DOWN_MASK) != 0)
172-
result = NSOtherMouseDown;
172+
result = NSEventTypeOtherMouseDown;
173173

174174
if ((modifiers & java_awt_event_InputEvent_BUTTON3_DOWN_MASK) != 0)
175-
result = NSRightMouseDown;
175+
result = NSEventTypeRightMouseDown;
176176

177177
return result;
178178
}
179179

180180
+ (NSUInteger)mapJavaExtModifiersToNSMouseUpButtons:(jint)modifiers
181181
{
182-
NSUInteger result = NSLeftMouseUp;
182+
NSUInteger result = NSEventTypeLeftMouseUp;
183183

184184
if ((modifiers & java_awt_event_InputEvent_BUTTON1_DOWN_MASK) != 0)
185-
result = NSLeftMouseUp;
185+
result = NSEventTypeLeftMouseUp;
186186

187187
if ((modifiers & java_awt_event_InputEvent_BUTTON2_DOWN_MASK) != 0)
188-
result = NSOtherMouseUp;
188+
result = NSEventTypeOtherMouseUp;
189189

190190
if ((modifiers & java_awt_event_InputEvent_BUTTON3_DOWN_MASK) != 0)
191-
result = NSRightMouseUp;
191+
result = NSEventTypeRightMouseUp;
192192

193193
return result;
194194
}

src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -98,7 +98,7 @@ + (void) eventCountPlusPlus{
9898

9999
+ (jint) scrollStateWithEvent: (NSEvent*) event {
100100

101-
if ([event type] != NSScrollWheel) {
101+
if ([event type] != NSEventTypeScrollWheel) {
102102
return 0;
103103
}
104104

@@ -126,7 +126,7 @@ + (jint) scrollStateWithEvent: (NSEvent*) event {
126126
}
127127

128128
+ (BOOL) hasPreciseScrollingDeltas: (NSEvent*) event {
129-
return [event type] == NSScrollWheel
129+
return [event type] == NSEventTypeScrollWheel
130130
&& [event respondsToSelector:@selector(hasPreciseScrollingDeltas)]
131131
&& [event hasPreciseScrollingDeltas];
132132
}

0 commit comments

Comments
 (0)