author | serb |
Wed, 08 May 2019 14:34:21 -0700 | |
changeset 54873 | 442e683e65fa |
parent 53187 | 64e7a73195c1 |
child 57400 | 978ffc56771f |
child 58320 | 3020baa4efa4 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
54873
442e683e65fa
7141393: [macosx] CARemoteLayer code refactoring and unit test
serb
parents:
53187
diff
changeset
|
2 |
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
12047 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
32872 | 26 |
#import "jni_util.h" |
12047 | 27 |
#import "CGLGraphicsConfig.h" |
28 |
#import "AWTView.h" |
|
29 |
#import "AWTWindow.h" |
|
30 |
#import "JavaComponentAccessibility.h" |
|
31 |
#import "JavaTextAccessibility.h" |
|
37787 | 32 |
#import "JavaAccessibilityUtilities.h" |
12047 | 33 |
#import "GeomUtilities.h" |
34 |
#import "OSVersion.h" |
|
32872 | 35 |
#import "ThreadUtilities.h" |
36 |
||
52745
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
37 |
#import <Carbon/Carbon.h> |
32872 | 38 |
#import <JavaNativeFoundation/JavaNativeFoundation.h> |
12047 | 39 |
|
40 |
@interface AWTView() |
|
41 |
@property (retain) CDropTarget *_dropTarget; |
|
42 |
@property (retain) CDragSource *_dragSource; |
|
23255
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
21278
diff
changeset
|
43 |
|
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
21278
diff
changeset
|
44 |
-(void) deliverResize: (NSRect) rect; |
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
21278
diff
changeset
|
45 |
-(void) resetTrackingArea; |
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
21278
diff
changeset
|
46 |
-(void) deliverJavaKeyEventHelper: (NSEvent*) event; |
33858
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
47 |
-(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint; |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
48 |
-(NSMutableString *) parseString : (id) complexString; |
12047 | 49 |
@end |
50 |
||
51 |
// Uncomment this line to see fprintfs of each InputMethod API being called on this View |
|
52 |
//#define IM_DEBUG TRUE |
|
53 |
//#define EXTRA_DEBUG |
|
54 |
||
55 |
static BOOL shouldUsePressAndHold() { |
|
56 |
static int shouldUsePressAndHold = -1; |
|
57 |
if (shouldUsePressAndHold != -1) return shouldUsePressAndHold; |
|
58 |
shouldUsePressAndHold = !isSnowLeopardOrLower(); |
|
59 |
return shouldUsePressAndHold; |
|
60 |
} |
|
61 |
||
62 |
@implementation AWTView |
|
63 |
||
64 |
@synthesize _dropTarget; |
|
65 |
@synthesize _dragSource; |
|
66 |
@synthesize cglLayer; |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
67 |
@synthesize mouseIsOver; |
12047 | 68 |
|
69 |
// Note: Must be called on main (AppKit) thread only |
|
70 |
- (id) initWithRect: (NSRect) rect |
|
71 |
platformView: (jobject) cPlatformView |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
72 |
windowLayer: (CALayer*) windowLayer |
12047 | 73 |
{ |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
74 |
AWT_ASSERT_APPKIT_THREAD; |
12047 | 75 |
// Initialize ourselves |
76 |
self = [super initWithFrame: rect]; |
|
77 |
if (self == nil) return self; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
78 |
|
12047 | 79 |
m_cPlatformView = cPlatformView; |
80 |
fInputMethodLOCKABLE = NULL; |
|
81 |
fKeyEventsNeeded = NO; |
|
82 |
fProcessingKeystroke = NO; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
83 |
|
12047 | 84 |
fEnablePressAndHold = shouldUsePressAndHold(); |
85 |
fInPressAndHold = NO; |
|
86 |
fPAHNeedsToSelect = NO; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
87 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
88 |
mouseIsOver = NO; |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
89 |
[self resetTrackingArea]; |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
90 |
[self setAutoresizesSubviews:NO]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
91 |
|
12047 | 92 |
if (windowLayer != nil) { |
93 |
self.cglLayer = windowLayer; |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13990
diff
changeset
|
94 |
//Layer hosting view |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13990
diff
changeset
|
95 |
[self setLayer: cglLayer]; |
12047 | 96 |
[self setWantsLayer: YES]; |
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13990
diff
changeset
|
97 |
//Layer backed view |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13990
diff
changeset
|
98 |
//[self.layer addSublayer: (CALayer *)cglLayer]; |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13990
diff
changeset
|
99 |
//[self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize]; |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13990
diff
changeset
|
100 |
//[self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft]; |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13990
diff
changeset
|
101 |
//[self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable]; |
12047 | 102 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
103 |
|
12047 | 104 |
return self; |
105 |
} |
|
106 |
||
107 |
- (void) dealloc { |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
108 |
AWT_ASSERT_APPKIT_THREAD; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
109 |
|
12047 | 110 |
self.cglLayer = nil; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
111 |
|
20139 | 112 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
37787 | 113 |
(*env)->DeleteWeakGlobalRef(env, m_cPlatformView); |
12047 | 114 |
m_cPlatformView = NULL; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
115 |
|
12047 | 116 |
if (fInputMethodLOCKABLE != NULL) |
117 |
{ |
|
118 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
119 |
|
12047 | 120 |
JNFDeleteGlobalRef(env, fInputMethodLOCKABLE); |
121 |
fInputMethodLOCKABLE = NULL; |
|
122 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
123 |
|
53187 | 124 |
if (rolloverTrackingArea != nil) { |
125 |
[self removeTrackingArea:rolloverTrackingArea]; |
|
126 |
[rolloverTrackingArea release]; |
|
127 |
rolloverTrackingArea = nil; |
|
128 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
129 |
|
12047 | 130 |
[super dealloc]; |
131 |
} |
|
132 |
||
133 |
- (void) viewDidMoveToWindow { |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
134 |
AWT_ASSERT_APPKIT_THREAD; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
135 |
|
12047 | 136 |
[AWTToolkit eventCountPlusPlus]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
137 |
|
12047 | 138 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { |
139 |
[[self window] makeFirstResponder: self]; |
|
140 |
}]; |
|
141 |
if ([self window] != NULL) { |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
142 |
[self resetTrackingArea]; |
12047 | 143 |
} |
144 |
} |
|
145 |
||
146 |
- (BOOL) acceptsFirstMouse: (NSEvent *)event { |
|
147 |
return YES; |
|
148 |
} |
|
149 |
||
150 |
- (BOOL) acceptsFirstResponder { |
|
151 |
return YES; |
|
152 |
} |
|
153 |
||
154 |
- (BOOL) becomeFirstResponder { |
|
155 |
return YES; |
|
156 |
} |
|
157 |
||
158 |
- (BOOL) preservesContentDuringLiveResize { |
|
159 |
return YES; |
|
160 |
} |
|
161 |
||
162 |
/* |
|
163 |
* Automatically triggered functions. |
|
164 |
*/ |
|
165 |
||
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
166 |
- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
167 |
[super resizeWithOldSuperviewSize: oldBoundsSize]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
168 |
[self deliverResize: [self frame]]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
169 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
170 |
|
12047 | 171 |
/* |
172 |
* MouseEvents support |
|
173 |
*/ |
|
174 |
||
175 |
- (void) mouseDown: (NSEvent *)event { |
|
176 |
NSInputManager *inputManager = [NSInputManager currentInputManager]; |
|
177 |
if ([inputManager wantsToHandleMouseEvents]) { |
|
178 |
#if IM_DEBUG |
|
179 |
NSLog(@"-> IM wants to handle event"); |
|
180 |
#endif |
|
181 |
if (![inputManager handleMouseEvent:event]) { |
|
182 |
[self deliverJavaMouseEvent: event]; |
|
183 |
} else { |
|
184 |
#if IM_DEBUG |
|
185 |
NSLog(@"-> Event was handled."); |
|
186 |
#endif |
|
187 |
} |
|
188 |
} else { |
|
13007
f6bf3300b455
7172430: [macosx] debug message in non debug jdk build
kizune
parents:
12660
diff
changeset
|
189 |
#if IM_DEBUG |
12047 | 190 |
NSLog(@"-> IM does not want to handle event"); |
13007
f6bf3300b455
7172430: [macosx] debug message in non debug jdk build
kizune
parents:
12660
diff
changeset
|
191 |
#endif |
12047 | 192 |
[self deliverJavaMouseEvent: event]; |
193 |
} |
|
194 |
} |
|
195 |
||
196 |
- (void) mouseUp: (NSEvent *)event { |
|
197 |
[self deliverJavaMouseEvent: event]; |
|
198 |
} |
|
199 |
||
200 |
- (void) rightMouseDown: (NSEvent *)event { |
|
201 |
[self deliverJavaMouseEvent: event]; |
|
202 |
} |
|
203 |
||
204 |
- (void) rightMouseUp: (NSEvent *)event { |
|
205 |
[self deliverJavaMouseEvent: event]; |
|
206 |
} |
|
207 |
||
208 |
- (void) otherMouseDown: (NSEvent *)event { |
|
209 |
[self deliverJavaMouseEvent: event]; |
|
210 |
} |
|
211 |
||
212 |
- (void) otherMouseUp: (NSEvent *)event { |
|
213 |
[self deliverJavaMouseEvent: event]; |
|
214 |
} |
|
215 |
||
216 |
- (void) mouseMoved: (NSEvent *)event { |
|
217 |
// TODO: better way to redirect move events to the "under" view |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
218 |
|
12047 | 219 |
NSPoint eventLocation = [event locationInWindow]; |
220 |
NSPoint localPoint = [self convertPoint: eventLocation fromView: nil]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
221 |
|
12047 | 222 |
if ([self mouse: localPoint inRect: [self bounds]]) { |
223 |
[self deliverJavaMouseEvent: event]; |
|
224 |
} else { |
|
225 |
[[self nextResponder] mouseDown:event]; |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
- (void) mouseDragged: (NSEvent *)event { |
|
230 |
[self deliverJavaMouseEvent: event]; |
|
231 |
} |
|
232 |
||
233 |
- (void) rightMouseDragged: (NSEvent *)event { |
|
234 |
[self deliverJavaMouseEvent: event]; |
|
235 |
} |
|
236 |
||
237 |
- (void) otherMouseDragged: (NSEvent *)event { |
|
238 |
[self deliverJavaMouseEvent: event]; |
|
239 |
} |
|
240 |
||
241 |
- (void) mouseEntered: (NSEvent *)event { |
|
242 |
[[self window] setAcceptsMouseMovedEvents:YES]; |
|
243 |
//[[self window] makeFirstResponder:self]; |
|
244 |
[self deliverJavaMouseEvent: event]; |
|
245 |
} |
|
246 |
||
247 |
- (void) mouseExited: (NSEvent *)event { |
|
248 |
[[self window] setAcceptsMouseMovedEvents:NO]; |
|
249 |
[self deliverJavaMouseEvent: event]; |
|
250 |
//Restore the cursor back. |
|
251 |
//[CCursorManager _setCursor: [NSCursor arrowCursor]]; |
|
252 |
} |
|
253 |
||
254 |
- (void) scrollWheel: (NSEvent*) event { |
|
255 |
[self deliverJavaMouseEvent: event]; |
|
256 |
} |
|
257 |
||
258 |
/* |
|
259 |
* KeyEvents support |
|
260 |
*/ |
|
261 |
||
262 |
- (void) keyDown: (NSEvent *)event { |
|
263 |
fProcessingKeystroke = YES; |
|
264 |
fKeyEventsNeeded = YES; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
265 |
|
12047 | 266 |
// Allow TSM to look at the event and potentially send back NSTextInputClient messages. |
267 |
[self interpretKeyEvents:[NSArray arrayWithObject:event]]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
268 |
|
53187 | 269 |
if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod] && |
52745
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
270 |
fInputMethodLOCKABLE) |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
271 |
{ |
12047 | 272 |
fProcessingKeystroke = NO; |
273 |
if (!fInPressAndHold) { |
|
274 |
fInPressAndHold = YES; |
|
275 |
fPAHNeedsToSelect = YES; |
|
52745
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
276 |
} else { |
53187 | 277 |
// Abandon input to reset IM and unblock input after canceling |
52745
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
278 |
// input accented symbols |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
279 |
|
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
280 |
switch([event keyCode]) { |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
281 |
case kVK_Escape: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
282 |
case kVK_Delete: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
283 |
case kVK_Return: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
284 |
case kVK_ForwardDelete: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
285 |
case kVK_PageUp: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
286 |
case kVK_PageDown: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
287 |
case kVK_DownArrow: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
288 |
case kVK_UpArrow: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
289 |
case kVK_Home: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
290 |
case kVK_End: |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
291 |
[self abandonInput]; |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
292 |
break; |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
293 |
} |
12047 | 294 |
} |
295 |
return; |
|
296 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
297 |
|
13990
3e72145fd93a
7199180: [macosx] Dead keys handling for input methods
alexsch
parents:
13647
diff
changeset
|
298 |
NSString *eventCharacters = [event characters]; |
3e72145fd93a
7199180: [macosx] Dead keys handling for input methods
alexsch
parents:
13647
diff
changeset
|
299 |
BOOL isDeadKey = (eventCharacters != nil && [eventCharacters length] == 0); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
300 |
|
13990
3e72145fd93a
7199180: [macosx] Dead keys handling for input methods
alexsch
parents:
13647
diff
changeset
|
301 |
if ((![self hasMarkedText] && fKeyEventsNeeded) || isDeadKey) { |
12047 | 302 |
[self deliverJavaKeyEventHelper: event]; |
303 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
304 |
|
12047 | 305 |
fProcessingKeystroke = NO; |
306 |
} |
|
307 |
||
308 |
- (void) keyUp: (NSEvent *)event { |
|
309 |
[self deliverJavaKeyEventHelper: event]; |
|
310 |
} |
|
311 |
||
312 |
- (void) flagsChanged: (NSEvent *)event { |
|
313 |
[self deliverJavaKeyEventHelper: event]; |
|
314 |
} |
|
315 |
||
316 |
- (BOOL) performKeyEquivalent: (NSEvent *) event { |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
317 |
// if IM is active key events should be ignored |
29727
34e49b091c62
8073008: press-and-hold input method for accented characters works incorrectly on OS X
anashaty
parents:
28990
diff
changeset
|
318 |
if (![self hasMarkedText] && !fInPressAndHold) { |
34e49b091c62
8073008: press-and-hold input method for accented characters works incorrectly on OS X
anashaty
parents:
28990
diff
changeset
|
319 |
[self deliverJavaKeyEventHelper: event]; |
34e49b091c62
8073008: press-and-hold input method for accented characters works incorrectly on OS X
anashaty
parents:
28990
diff
changeset
|
320 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
321 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
322 |
// Workaround for 8020209: special case for "Cmd =" and "Cmd ." |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
323 |
// because Cocoa calls performKeyEquivalent twice for these keystrokes |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
324 |
NSUInteger modFlags = [event modifierFlags] & |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
325 |
(NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask); |
21268
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
326 |
if (modFlags == NSCommandKeyMask) { |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
327 |
NSString *eventChars = [event charactersIgnoringModifiers]; |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
328 |
if ([eventChars length] == 1) { |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
329 |
unichar ch = [eventChars characterAtIndex:0]; |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
330 |
if (ch == '=' || ch == '.') { |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
331 |
[[NSApp mainMenu] performKeyEquivalent: event]; |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
332 |
return YES; |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
333 |
} |
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
334 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
335 |
|
21268
b3298f607368
8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents:
20139
diff
changeset
|
336 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
337 |
|
12047 | 338 |
return NO; |
339 |
} |
|
340 |
||
341 |
/** |
|
342 |
* Utility methods and accessors |
|
343 |
*/ |
|
344 |
||
345 |
-(void) deliverJavaMouseEvent: (NSEvent *) event { |
|
12640 | 346 |
BOOL isEnabled = YES; |
347 |
NSWindow* window = [self window]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
348 |
if ([window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]]) { |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
349 |
isEnabled = [(AWTWindow*)[window delegate] isEnabled]; |
12640 | 350 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
351 |
|
12640 | 352 |
if (!isEnabled) { |
353 |
return; |
|
354 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
355 |
|
12640 | 356 |
NSEventType type = [event type]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
357 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
358 |
// check synthesized mouse entered/exited events |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
359 |
if ((type == NSMouseEntered && mouseIsOver) || (type == NSMouseExited && !mouseIsOver)) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
360 |
return; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
361 |
}else if ((type == NSMouseEntered && !mouseIsOver) || (type == NSMouseExited && mouseIsOver)) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
362 |
mouseIsOver = !mouseIsOver; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12178
diff
changeset
|
363 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
364 |
|
12047 | 365 |
[AWTToolkit eventCountPlusPlus]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
366 |
|
12047 | 367 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
368 |
|
12047 | 369 |
NSPoint eventLocation = [event locationInWindow]; |
370 |
NSPoint localPoint = [self convertPoint: eventLocation fromView: nil]; |
|
371 |
NSPoint absP = [NSEvent mouseLocation]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
372 |
|
12047 | 373 |
// Convert global numbers between Cocoa's coordinate system and Java. |
374 |
// TODO: need consitent way for doing that both with global as well as with local coordinates. |
|
375 |
// The reason to do it here is one more native method for getting screen dimension otherwise. |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
376 |
|
23316
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
23268
diff
changeset
|
377 |
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame]; |
12047 | 378 |
absP.y = screenRect.size.height - absP.y; |
379 |
jint clickCount; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
380 |
|
12047 | 381 |
if (type == NSMouseEntered || |
382 |
type == NSMouseExited || |
|
383 |
type == NSScrollWheel || |
|
384 |
type == NSMouseMoved) { |
|
385 |
clickCount = 0; |
|
386 |
} else { |
|
387 |
clickCount = [event clickCount]; |
|
388 |
} |
|
43823
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
389 |
|
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
390 |
jdouble deltaX = [event deltaX]; |
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
391 |
jdouble deltaY = [event deltaY]; |
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
392 |
if ([AWTToolkit hasPreciseScrollingDeltas: event]) { |
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
393 |
deltaX = [event scrollingDeltaX] * 0.1; |
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
394 |
deltaY = [event scrollingDeltaY] * 0.1; |
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
395 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
396 |
|
23268 | 397 |
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); |
41773
58254fa6487a
8166591: [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra is very fast (Trackpad, Retina only)
alexsch
parents:
39551
diff
changeset
|
398 |
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V"); |
12047 | 399 |
jobject jEvent = JNFNewObject(env, jctor_NSEvent, |
400 |
[event type], |
|
401 |
[event modifierFlags], |
|
402 |
clickCount, |
|
403 |
[event buttonNumber], |
|
404 |
(jint)localPoint.x, (jint)localPoint.y, |
|
405 |
(jint)absP.x, (jint)absP.y, |
|
43823
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
406 |
deltaY, |
bf04b9310757
8173876: Fast precise scrolling and DeltaAccumulator fix for macOS Sierra 10.12.2
malenkov
parents:
41773
diff
changeset
|
407 |
deltaX, |
41773
58254fa6487a
8166591: [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra is very fast (Trackpad, Retina only)
alexsch
parents:
39551
diff
changeset
|
408 |
[AWTToolkit scrollStateWithEvent: event]); |
24555
42926c558bc8
8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents:
23651
diff
changeset
|
409 |
CHECK_NULL(jEvent); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
410 |
|
12047 | 411 |
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); |
23268 | 412 |
static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); |
37787 | 413 |
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView); |
414 |
if (!(*env)->IsSameObject(env, jlocal, NULL)) { |
|
415 |
JNFCallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent); |
|
416 |
(*env)->DeleteLocalRef(env, jlocal); |
|
417 |
} |
|
24555
42926c558bc8
8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents:
23651
diff
changeset
|
418 |
(*env)->DeleteLocalRef(env, jEvent); |
12047 | 419 |
} |
420 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
421 |
- (void) resetTrackingArea { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
422 |
if (rolloverTrackingArea != nil) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
423 |
[self removeTrackingArea:rolloverTrackingArea]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
424 |
[rolloverTrackingArea release]; |
12047 | 425 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
426 |
|
20134
8711b271f96c
8012026: [macosx] Component.getMousePosition() does not work in an applet on MacOS
pchelko
parents:
15985
diff
changeset
|
427 |
int options = (NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited | |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
428 |
NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
429 |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
430 |
rolloverTrackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect] |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
431 |
options: options |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
432 |
owner:self |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
433 |
userInfo:nil |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
434 |
]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
435 |
[self addTrackingArea:rolloverTrackingArea]; |
12047 | 436 |
} |
437 |
||
438 |
- (void)updateTrackingAreas { |
|
439 |
[super updateTrackingAreas]; |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
440 |
[self resetTrackingArea]; |
12047 | 441 |
} |
442 |
||
443 |
- (void) resetCursorRects { |
|
444 |
[super resetCursorRects]; |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13007
diff
changeset
|
445 |
[self resetTrackingArea]; |
12047 | 446 |
} |
447 |
||
448 |
-(void) deliverJavaKeyEventHelper: (NSEvent *) event { |
|
12660 | 449 |
static NSEvent* sLastKeyEvent = nil; |
450 |
if (event == sLastKeyEvent) { |
|
12659
fa378682b3cb
7142565: [macosx] Many special keys processed twice in text fields
ant
parents:
12648
diff
changeset
|
451 |
// The event is repeatedly delivered by keyDown: after performKeyEquivalent: |
fa378682b3cb
7142565: [macosx] Many special keys processed twice in text fields
ant
parents:
12648
diff
changeset
|
452 |
return; |
fa378682b3cb
7142565: [macosx] Many special keys processed twice in text fields
ant
parents:
12648
diff
changeset
|
453 |
} |
12660 | 454 |
[sLastKeyEvent release]; |
455 |
sLastKeyEvent = [event retain]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
456 |
|
12047 | 457 |
[AWTToolkit eventCountPlusPlus]; |
458 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
459 |
|
12047 | 460 |
jstring characters = NULL; |
25114
cafd0de74734
8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents:
24555
diff
changeset
|
461 |
jstring charactersIgnoringModifiers = NULL; |
12047 | 462 |
if ([event type] != NSFlagsChanged) { |
463 |
characters = JNFNSToJavaString(env, [event characters]); |
|
25114
cafd0de74734
8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents:
24555
diff
changeset
|
464 |
charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]); |
12047 | 465 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
466 |
|
23268 | 467 |
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); |
25114
cafd0de74734
8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents:
24555
diff
changeset
|
468 |
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;Ljava/lang/String;)V"); |
24555
42926c558bc8
8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents:
23651
diff
changeset
|
469 |
jobject jEvent = JNFNewObject(env, jctor_NSEvent, |
12047 | 470 |
[event type], |
471 |
[event modifierFlags], |
|
472 |
[event keyCode], |
|
25114
cafd0de74734
8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents:
24555
diff
changeset
|
473 |
characters, |
cafd0de74734
8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents:
24555
diff
changeset
|
474 |
charactersIgnoringModifiers); |
24555
42926c558bc8
8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents:
23651
diff
changeset
|
475 |
CHECK_NULL(jEvent); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
476 |
|
12047 | 477 |
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); |
478 |
static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView, |
|
23268 | 479 |
"deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); |
37787 | 480 |
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView); |
481 |
if (!(*env)->IsSameObject(env, jlocal, NULL)) { |
|
482 |
JNFCallVoidMethod(env, jlocal, jm_deliverKeyEvent, jEvent); |
|
483 |
(*env)->DeleteLocalRef(env, jlocal); |
|
484 |
} |
|
12047 | 485 |
if (characters != NULL) { |
486 |
(*env)->DeleteLocalRef(env, characters); |
|
487 |
} |
|
24555
42926c558bc8
8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents:
23651
diff
changeset
|
488 |
(*env)->DeleteLocalRef(env, jEvent); |
12047 | 489 |
} |
490 |
||
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
491 |
-(void) deliverResize: (NSRect) rect { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
492 |
jint x = (jint) rect.origin.x; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
493 |
jint y = (jint) rect.origin.y; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
494 |
jint w = (jint) rect.size.width; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
495 |
jint h = (jint) rect.size.height; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
496 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
497 |
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
498 |
static JNF_MEMBER_CACHE(jm_deliverResize, jc_PlatformView, "deliverResize", "(IIII)V"); |
37787 | 499 |
|
500 |
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView); |
|
501 |
if (!(*env)->IsSameObject(env, jlocal, NULL)) { |
|
502 |
JNFCallVoidMethod(env, jlocal, jm_deliverResize, x,y,w,h); |
|
503 |
(*env)->DeleteLocalRef(env, jlocal); |
|
504 |
} |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
505 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
506 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
507 |
|
12047 | 508 |
- (void) drawRect:(NSRect)dirtyRect { |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
509 |
AWT_ASSERT_APPKIT_THREAD; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
510 |
|
12047 | 511 |
[super drawRect:dirtyRect]; |
512 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
513 |
if (env != NULL) { |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
514 |
/* |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
515 |
if ([self inLiveResize]) { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
516 |
NSRect rs[4]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
517 |
NSInteger count; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
518 |
[self getRectsExposedDuringLiveResize:rs count:&count]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
519 |
for (int i = 0; i < count; i++) { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
520 |
JNU_CallMethodByName(env, NULL, [m_awtWindow cPlatformView], |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
521 |
"deliverWindowDidExposeEvent", "(FFFF)V", |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
522 |
(jfloat)rs[i].origin.x, (jfloat)rs[i].origin.y, |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
523 |
(jfloat)rs[i].size.width, (jfloat)rs[i].size.height); |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
524 |
if ((*env)->ExceptionOccurred(env)) { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
525 |
(*env)->ExceptionDescribe(env); |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
526 |
(*env)->ExceptionClear(env); |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
527 |
} |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
528 |
} |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
529 |
} else { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
530 |
*/ |
12047 | 531 |
static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView"); |
532 |
static JNF_MEMBER_CACHE(jm_deliverWindowDidExposeEvent, jc_CPlatformView, "deliverWindowDidExposeEvent", "()V"); |
|
37787 | 533 |
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView); |
534 |
if (!(*env)->IsSameObject(env, jlocal, NULL)) { |
|
535 |
JNFCallVoidMethod(env, jlocal, jm_deliverWindowDidExposeEvent); |
|
536 |
(*env)->DeleteLocalRef(env, jlocal); |
|
537 |
} |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
538 |
/* |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
539 |
} |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
540 |
*/ |
12047 | 541 |
} |
542 |
} |
|
543 |
||
33858
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
544 |
-(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint { |
51927
c88fd713b51c
8191178: [macos] Problem with input of yen symbol
psadhukhan
parents:
47500
diff
changeset
|
545 |
if ((codePoint == 0x0024) || (codePoint == 0x00A3) || |
c88fd713b51c
8191178: [macos] Problem with input of yen symbol
psadhukhan
parents:
47500
diff
changeset
|
546 |
(codePoint == 0x00A5) || |
c88fd713b51c
8191178: [macos] Problem with input of yen symbol
psadhukhan
parents:
47500
diff
changeset
|
547 |
((codePoint >= 0x20A3) && (codePoint <= 0x20BF)) || |
c88fd713b51c
8191178: [macos] Problem with input of yen symbol
psadhukhan
parents:
47500
diff
changeset
|
548 |
((codePoint >= 0x3000) && (codePoint <= 0x303F)) || |
39551
7eaf6bb9bc67
8148984: [macosx] Chinese Comma cannot be entered using Pinyin Input Method on OS X
dmarkov
parents:
37787
diff
changeset
|
549 |
((codePoint >= 0xFF00) && (codePoint <= 0xFFEF))) { |
7eaf6bb9bc67
8148984: [macosx] Chinese Comma cannot be entered using Pinyin Input Method on OS X
dmarkov
parents:
37787
diff
changeset
|
550 |
// Code point is in 'CJK Symbols and Punctuation' or |
51927
c88fd713b51c
8191178: [macos] Problem with input of yen symbol
psadhukhan
parents:
47500
diff
changeset
|
551 |
// 'Halfwidth and Fullwidth Forms' Unicode block or |
c88fd713b51c
8191178: [macos] Problem with input of yen symbol
psadhukhan
parents:
47500
diff
changeset
|
552 |
// currency symbols unicode |
33858
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
553 |
return YES; |
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
554 |
} |
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
555 |
return NO; |
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
556 |
} |
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
557 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
558 |
-(NSMutableString *) parseString : (id) complexString { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
559 |
if ([complexString isKindOfClass:[NSString class]]) { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
560 |
return [complexString mutableCopy]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
561 |
} |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
562 |
else { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
563 |
return [complexString mutableString]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
564 |
} |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
565 |
} |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
566 |
|
12047 | 567 |
// NSAccessibility support |
568 |
- (jobject)awtComponent:(JNIEnv*)env |
|
569 |
{ |
|
570 |
static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView"); |
|
571 |
static JNF_MEMBER_CACHE(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;"); |
|
572 |
if ((env == NULL) || (m_cPlatformView == NULL)) { |
|
573 |
NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters."); |
|
574 |
if (env != NULL) |
|
575 |
{ |
|
576 |
JNFDumpJavaStack(env); |
|
577 |
} |
|
578 |
return NULL; |
|
579 |
} |
|
37787 | 580 |
|
581 |
jobject peer = NULL; |
|
582 |
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView); |
|
583 |
if (!(*env)->IsSameObject(env, jlocal, NULL)) { |
|
584 |
peer = JNFGetObjectField(env, jlocal, jf_Peer); |
|
585 |
(*env)->DeleteLocalRef(env, jlocal); |
|
586 |
} |
|
12047 | 587 |
static JNF_CLASS_CACHE(jc_LWWindowPeer, "sun/lwawt/LWWindowPeer"); |
588 |
static JNF_MEMBER_CACHE(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;"); |
|
589 |
if (peer == NULL) { |
|
590 |
NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView"); |
|
591 |
JNFDumpJavaStack(env); |
|
592 |
return NULL; |
|
593 |
} |
|
37787 | 594 |
jobject comp = JNFGetObjectField(env, peer, jf_Target); |
595 |
(*env)->DeleteLocalRef(env, peer); |
|
596 |
return comp; |
|
597 |
} |
|
598 |
||
599 |
+ (AWTView *) awtView:(JNIEnv*)env ofAccessible:(jobject)jaccessible |
|
600 |
{ |
|
601 |
static JNF_STATIC_MEMBER_CACHE(jm_getAWTView, sjc_CAccessibility, "getAWTView", "(Ljavax/accessibility/Accessible;)J"); |
|
602 |
||
603 |
jlong jptr = JNFCallStaticLongMethod(env, jm_getAWTView, jaccessible); |
|
604 |
if (jptr == 0) return nil; |
|
605 |
||
606 |
return (AWTView *)jlong_to_ptr(jptr); |
|
12047 | 607 |
} |
608 |
||
609 |
- (id)getAxData:(JNIEnv*)env |
|
610 |
{ |
|
37787 | 611 |
jobject jcomponent = [self awtComponent:env]; |
612 |
id ax = [[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:jcomponent withIndex:-1 withView:self withJavaRole:nil] autorelease]; |
|
613 |
(*env)->DeleteLocalRef(env, jcomponent); |
|
614 |
return ax; |
|
12047 | 615 |
} |
616 |
||
617 |
- (NSArray *)accessibilityAttributeNames |
|
618 |
{ |
|
619 |
return [[super accessibilityAttributeNames] arrayByAddingObject:NSAccessibilityChildrenAttribute]; |
|
620 |
} |
|
621 |
||
622 |
// NSAccessibility messages |
|
623 |
// attribute methods |
|
624 |
- (id)accessibilityAttributeValue:(NSString *)attribute |
|
625 |
{ |
|
626 |
AWT_ASSERT_APPKIT_THREAD; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
627 |
|
12047 | 628 |
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) |
629 |
{ |
|
630 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
631 |
|
12047 | 632 |
(*env)->PushLocalFrame(env, 4); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
633 |
|
12047 | 634 |
id result = NSAccessibilityUnignoredChildrenForOnlyChild([self getAxData:env]); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
635 |
|
12047 | 636 |
(*env)->PopLocalFrame(env, NULL); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
637 |
|
12047 | 638 |
return result; |
639 |
} |
|
640 |
else |
|
641 |
{ |
|
642 |
return [super accessibilityAttributeValue:attribute]; |
|
643 |
} |
|
644 |
} |
|
645 |
- (BOOL)accessibilityIsIgnored |
|
646 |
{ |
|
647 |
return YES; |
|
648 |
} |
|
649 |
||
650 |
- (id)accessibilityHitTest:(NSPoint)point |
|
651 |
{ |
|
652 |
AWT_ASSERT_APPKIT_THREAD; |
|
653 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
654 |
|
12047 | 655 |
(*env)->PushLocalFrame(env, 4); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
656 |
|
12047 | 657 |
id result = [[self getAxData:env] accessibilityHitTest:point withEnv:env]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
658 |
|
12047 | 659 |
(*env)->PopLocalFrame(env, NULL); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
660 |
|
12047 | 661 |
return result; |
662 |
} |
|
663 |
||
664 |
- (id)accessibilityFocusedUIElement |
|
665 |
{ |
|
666 |
AWT_ASSERT_APPKIT_THREAD; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
667 |
|
12047 | 668 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
669 |
|
12047 | 670 |
(*env)->PushLocalFrame(env, 4); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
671 |
|
12047 | 672 |
id result = [[self getAxData:env] accessibilityFocusedUIElement]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
673 |
|
12047 | 674 |
(*env)->PopLocalFrame(env, NULL); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
675 |
|
12047 | 676 |
return result; |
677 |
} |
|
678 |
||
679 |
// --- Services menu support for lightweights --- |
|
680 |
||
21278 | 681 |
// finds the focused accessible element, and if it is a text element, obtains the text from it |
12047 | 682 |
- (NSString *)accessibleSelectedText |
683 |
{ |
|
684 |
id focused = [self accessibilityFocusedUIElement]; |
|
685 |
if (![focused isKindOfClass:[JavaTextAccessibility class]]) return nil; |
|
686 |
return [(JavaTextAccessibility *)focused accessibilitySelectedTextAttribute]; |
|
687 |
} |
|
688 |
||
689 |
// same as above, but converts to RTFD |
|
690 |
- (NSData *)accessibleSelectedTextAsRTFD |
|
691 |
{ |
|
692 |
NSString *selectedText = [self accessibleSelectedText]; |
|
693 |
NSAttributedString *styledText = [[NSAttributedString alloc] initWithString:selectedText]; |
|
36462
dee5ee6606e2
8141553: [macosx] JDK fails to build with Xcode 7 on 10.11
serb
parents:
33858
diff
changeset
|
694 |
NSData *rtfdData = [styledText RTFDFromRange:NSMakeRange(0, [styledText length]) |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
695 |
documentAttributes: |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
696 |
@{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType}]; |
12047 | 697 |
[styledText release]; |
698 |
return rtfdData; |
|
699 |
} |
|
700 |
||
21278 | 701 |
// finds the focused accessible element, and if it is a text element, sets the text in it |
12047 | 702 |
- (BOOL)replaceAccessibleTextSelection:(NSString *)text |
703 |
{ |
|
704 |
id focused = [self accessibilityFocusedUIElement]; |
|
705 |
if (![focused isKindOfClass:[JavaTextAccessibility class]]) return NO; |
|
706 |
[(JavaTextAccessibility *)focused accessibilitySetSelectedTextAttribute:text]; |
|
707 |
return YES; |
|
708 |
} |
|
709 |
||
710 |
// called for each service in the Services menu - only handle text for now |
|
711 |
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType |
|
712 |
{ |
|
713 |
if ([[self window] firstResponder] != self) return nil; // let AWT components handle themselves |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
714 |
|
12047 | 715 |
if ([sendType isEqual:NSStringPboardType] || [returnType isEqual:NSStringPboardType]) { |
716 |
NSString *selectedText = [self accessibleSelectedText]; |
|
717 |
if (selectedText) return self; |
|
718 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
719 |
|
12047 | 720 |
return nil; |
721 |
} |
|
722 |
||
723 |
// fetch text from Java and hand off to the service |
|
724 |
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types |
|
725 |
{ |
|
726 |
if ([types containsObject:NSStringPboardType]) |
|
727 |
{ |
|
728 |
[pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; |
|
729 |
return [pboard setString:[self accessibleSelectedText] forType:NSStringPboardType]; |
|
730 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
731 |
|
12047 | 732 |
if ([types containsObject:NSRTFDPboardType]) |
733 |
{ |
|
734 |
[pboard declareTypes:[NSArray arrayWithObject:NSRTFDPboardType] owner:nil]; |
|
735 |
return [pboard setData:[self accessibleSelectedTextAsRTFD] forType:NSRTFDPboardType]; |
|
736 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
737 |
|
12047 | 738 |
return NO; |
739 |
} |
|
740 |
||
741 |
// write text back to Java from the service |
|
742 |
- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard |
|
743 |
{ |
|
744 |
if ([[pboard types] containsObject:NSStringPboardType]) |
|
745 |
{ |
|
746 |
NSString *text = [pboard stringForType:NSStringPboardType]; |
|
747 |
return [self replaceAccessibleTextSelection:text]; |
|
748 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
749 |
|
12047 | 750 |
if ([[pboard types] containsObject:NSRTFDPboardType]) |
751 |
{ |
|
752 |
NSData *rtfdData = [pboard dataForType:NSRTFDPboardType]; |
|
36462
dee5ee6606e2
8141553: [macosx] JDK fails to build with Xcode 7 on 10.11
serb
parents:
33858
diff
changeset
|
753 |
NSAttributedString *styledText = [[NSAttributedString alloc] initWithRTFD:rtfdData documentAttributes:NULL]; |
12047 | 754 |
NSString *text = [styledText string]; |
755 |
[styledText release]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
756 |
|
12047 | 757 |
return [self replaceAccessibleTextSelection:text]; |
758 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
759 |
|
12047 | 760 |
return NO; |
761 |
} |
|
762 |
||
763 |
||
764 |
-(void) setDragSource:(CDragSource *)source { |
|
765 |
self._dragSource = source; |
|
766 |
} |
|
767 |
||
768 |
||
769 |
- (void) setDropTarget:(CDropTarget *)target { |
|
770 |
self._dropTarget = target; |
|
15985
b9e25a486549
8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents:
15322
diff
changeset
|
771 |
[ThreadUtilities performOnMainThread:@selector(controlModelControlValid) on:self._dropTarget withObject:nil waitUntilDone:YES]; |
12047 | 772 |
} |
773 |
||
774 |
/******************************** BEGIN NSDraggingSource Interface ********************************/ |
|
775 |
||
776 |
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag |
|
777 |
{ |
|
778 |
// If draggingSource is nil route the message to the superclass (if responding to the selector): |
|
779 |
CDragSource *dragSource = self._dragSource; |
|
780 |
NSDragOperation dragOp = NSDragOperationNone; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
781 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
782 |
if (dragSource != nil) { |
12047 | 783 |
dragOp = [dragSource draggingSourceOperationMaskForLocal:flag]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
784 |
} |
12047 | 785 |
return dragOp; |
786 |
} |
|
787 |
||
788 |
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination |
|
789 |
{ |
|
790 |
// If draggingSource is nil route the message to the superclass (if responding to the selector): |
|
791 |
CDragSource *dragSource = self._dragSource; |
|
792 |
NSArray* array = nil; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
793 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
794 |
if (dragSource != nil) { |
12047 | 795 |
array = [dragSource namesOfPromisedFilesDroppedAtDestination:dropDestination]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
796 |
} |
12047 | 797 |
return array; |
798 |
} |
|
799 |
||
800 |
- (void)draggedImage:(NSImage *)image beganAt:(NSPoint)screenPoint |
|
801 |
{ |
|
802 |
// If draggingSource is nil route the message to the superclass (if responding to the selector): |
|
803 |
CDragSource *dragSource = self._dragSource; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
804 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
805 |
if (dragSource != nil) { |
12047 | 806 |
[dragSource draggedImage:image beganAt:screenPoint]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
807 |
} |
12047 | 808 |
} |
809 |
||
810 |
- (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation |
|
811 |
{ |
|
812 |
// If draggingSource is nil route the message to the superclass (if responding to the selector): |
|
813 |
CDragSource *dragSource = self._dragSource; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
814 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
815 |
if (dragSource != nil) { |
12047 | 816 |
[dragSource draggedImage:image endedAt:screenPoint operation:operation]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
817 |
} |
12047 | 818 |
} |
819 |
||
820 |
- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint |
|
821 |
{ |
|
822 |
// If draggingSource is nil route the message to the superclass (if responding to the selector): |
|
823 |
CDragSource *dragSource = self._dragSource; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
824 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
825 |
if (dragSource != nil) { |
12047 | 826 |
[dragSource draggedImage:image movedTo:screenPoint]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
827 |
} |
12047 | 828 |
} |
829 |
||
830 |
- (BOOL)ignoreModifierKeysWhileDragging |
|
831 |
{ |
|
832 |
// If draggingSource is nil route the message to the superclass (if responding to the selector): |
|
833 |
CDragSource *dragSource = self._dragSource; |
|
834 |
BOOL result = FALSE; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
835 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
836 |
if (dragSource != nil) { |
12047 | 837 |
result = [dragSource ignoreModifierKeysWhileDragging]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
838 |
} |
12047 | 839 |
return result; |
840 |
} |
|
841 |
||
842 |
/******************************** END NSDraggingSource Interface ********************************/ |
|
843 |
||
844 |
/******************************** BEGIN NSDraggingDestination Interface ********************************/ |
|
845 |
||
846 |
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender |
|
847 |
{ |
|
848 |
// If draggingDestination is nil route the message to the superclass: |
|
849 |
CDropTarget *dropTarget = self._dropTarget; |
|
850 |
NSDragOperation dragOp = NSDragOperationNone; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
851 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
852 |
if (dropTarget != nil) { |
12047 | 853 |
dragOp = [dropTarget draggingEntered:sender]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
854 |
} |
12047 | 855 |
return dragOp; |
856 |
} |
|
857 |
||
858 |
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender |
|
859 |
{ |
|
860 |
// If draggingDestination is nil route the message to the superclass: |
|
861 |
CDropTarget *dropTarget = self._dropTarget; |
|
862 |
NSDragOperation dragOp = NSDragOperationNone; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
863 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
864 |
if (dropTarget != nil) { |
12047 | 865 |
dragOp = [dropTarget draggingUpdated:sender]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
866 |
} |
12047 | 867 |
return dragOp; |
868 |
} |
|
869 |
||
870 |
- (void)draggingExited:(id <NSDraggingInfo>)sender |
|
871 |
{ |
|
872 |
// If draggingDestination is nil route the message to the superclass: |
|
873 |
CDropTarget *dropTarget = self._dropTarget; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
874 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
875 |
if (dropTarget != nil) { |
12047 | 876 |
[dropTarget draggingExited:sender]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
877 |
} |
12047 | 878 |
} |
879 |
||
880 |
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender |
|
881 |
{ |
|
882 |
// If draggingDestination is nil route the message to the superclass: |
|
883 |
CDropTarget *dropTarget = self._dropTarget; |
|
884 |
BOOL result = FALSE; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
885 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
886 |
if (dropTarget != nil) { |
12047 | 887 |
result = [dropTarget prepareForDragOperation:sender]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
888 |
} |
12047 | 889 |
return result; |
890 |
} |
|
891 |
||
892 |
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender |
|
893 |
{ |
|
894 |
// If draggingDestination is nil route the message to the superclass: |
|
895 |
CDropTarget *dropTarget = self._dropTarget; |
|
896 |
BOOL result = FALSE; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
897 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
898 |
if (dropTarget != nil) { |
12047 | 899 |
result = [dropTarget performDragOperation:sender]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
900 |
} |
12047 | 901 |
return result; |
902 |
} |
|
903 |
||
904 |
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender |
|
905 |
{ |
|
906 |
// If draggingDestination is nil route the message to the superclass: |
|
907 |
CDropTarget *dropTarget = self._dropTarget; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
908 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
909 |
if (dropTarget != nil) { |
12047 | 910 |
[dropTarget concludeDragOperation:sender]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
911 |
} |
12047 | 912 |
} |
913 |
||
914 |
- (void)draggingEnded:(id <NSDraggingInfo>)sender |
|
915 |
{ |
|
916 |
// If draggingDestination is nil route the message to the superclass: |
|
917 |
CDropTarget *dropTarget = self._dropTarget; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
918 |
|
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
919 |
if (dropTarget != nil) { |
12047 | 920 |
[dropTarget draggingEnded:sender]; |
47166
dd1972cc4cd4
8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop
serb
parents:
47134
diff
changeset
|
921 |
} |
12047 | 922 |
} |
923 |
||
924 |
/******************************** END NSDraggingDestination Interface ********************************/ |
|
925 |
||
926 |
/******************************** BEGIN NSTextInputClient Protocol ********************************/ |
|
927 |
||
928 |
||
929 |
JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod"); |
|
930 |
||
931 |
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange |
|
932 |
{ |
|
933 |
#ifdef IM_DEBUG |
|
934 |
fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]); |
|
935 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
936 |
|
12047 | 937 |
if (fInputMethodLOCKABLE == NULL) { |
938 |
return; |
|
939 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
940 |
|
12047 | 941 |
// Insert happens at the end of PAH |
942 |
fInPressAndHold = NO; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
943 |
|
12047 | 944 |
// insertText gets called when the user commits text generated from an input method. It also gets |
945 |
// called during ordinary input as well. We only need to send an input method event when we have marked |
|
946 |
// text, or 'text in progress'. We also need to send the event if we get an insert text out of the blue! |
|
947 |
// (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex |
|
948 |
// Unicode value. |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
949 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
950 |
NSMutableString * useString = [self parseString:aString]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
951 |
NSUInteger utf16Length = [useString lengthOfBytesUsingEncoding:NSUTF16StringEncoding]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
952 |
NSUInteger utf8Length = [useString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; |
33858
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
953 |
BOOL aStringIsComplex = NO; |
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
954 |
if ((utf16Length > 2) || |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
955 |
((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:[useString characterAtIndex:0]])) { |
33858
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
956 |
aStringIsComplex = YES; |
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
957 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
958 |
|
33858
7554d0e25d7f
8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents:
32872
diff
changeset
|
959 |
if ([self hasMarkedText] || !fProcessingKeystroke || aStringIsComplex) { |
12047 | 960 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
961 |
|
12047 | 962 |
static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V"); |
963 |
// We need to select the previous glyph so that it is overwritten. |
|
964 |
if (fPAHNeedsToSelect) { |
|
965 |
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph); |
|
966 |
fPAHNeedsToSelect = NO; |
|
967 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
968 |
|
12047 | 969 |
static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V"); |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
970 |
jstring insertedText = JNFNSToJavaString(env, useString); |
12047 | 971 |
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode) |
972 |
(*env)->DeleteLocalRef(env, insertedText); |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
973 |
|
12047 | 974 |
// The input method event will create psuedo-key events for each character in the committed string. |
975 |
// We also don't want to send the character that triggered the insertText, usually a return. [3337563] |
|
976 |
fKeyEventsNeeded = NO; |
|
977 |
} |
|
47134
bb00cc237908
8180370: Characters are skipped on input of Korean text on OS X
aghaisas
parents:
43823
diff
changeset
|
978 |
else { |
bb00cc237908
8180370: Characters are skipped on input of Korean text on OS X
aghaisas
parents:
43823
diff
changeset
|
979 |
// Need to set back the fKeyEventsNeeded flag so that the string following the |
bb00cc237908
8180370: Characters are skipped on input of Korean text on OS X
aghaisas
parents:
43823
diff
changeset
|
980 |
// marked text is not ignored by keyDown |
bb00cc237908
8180370: Characters are skipped on input of Korean text on OS X
aghaisas
parents:
43823
diff
changeset
|
981 |
if ([useString length] > 0) { |
bb00cc237908
8180370: Characters are skipped on input of Korean text on OS X
aghaisas
parents:
43823
diff
changeset
|
982 |
fKeyEventsNeeded = YES; |
bb00cc237908
8180370: Characters are skipped on input of Korean text on OS X
aghaisas
parents:
43823
diff
changeset
|
983 |
} |
bb00cc237908
8180370: Characters are skipped on input of Korean text on OS X
aghaisas
parents:
43823
diff
changeset
|
984 |
} |
12047 | 985 |
fPAHNeedsToSelect = NO; |
52745
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
986 |
|
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
987 |
// Abandon input to reset IM and unblock input after entering accented |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
988 |
// symbols |
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
989 |
|
83de6a8b6c33
8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
avu
parents:
51927
diff
changeset
|
990 |
[self abandonInput]; |
12047 | 991 |
} |
992 |
||
993 |
- (void) doCommandBySelector:(SEL)aSelector |
|
994 |
{ |
|
995 |
#ifdef IM_DEBUG |
|
996 |
fprintf(stderr, "AWTView InputMethod Selector Called : [doCommandBySelector]\n"); |
|
997 |
NSLog(@"%@", NSStringFromSelector(aSelector)); |
|
998 |
#endif // IM_DEBUG |
|
999 |
if (@selector(insertNewline:) == aSelector || @selector(insertTab:) == aSelector || @selector(deleteBackward:) == aSelector) |
|
1000 |
{ |
|
1001 |
fKeyEventsNeeded = YES; |
|
1002 |
} |
|
1003 |
} |
|
1004 |
||
1005 |
// setMarkedText: cannot take a nil first argument. aString can be NSString or NSAttributedString |
|
1006 |
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replacementRange:(NSRange)replacementRange |
|
1007 |
{ |
|
1008 |
if (!fInputMethodLOCKABLE) |
|
1009 |
return; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1010 |
|
12047 | 1011 |
BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]]; |
1012 |
NSAttributedString *attrString = (isAttributedString ? (NSAttributedString *)aString : nil); |
|
1013 |
NSString *incomingString = (isAttributedString ? [aString string] : aString); |
|
1014 |
#ifdef IM_DEBUG |
|
1015 |
fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", loc=%lu, length=%lu\n", [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length); |
|
1016 |
#endif // IM_DEBUG |
|
1017 |
static JNF_MEMBER_CACHE(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V"); |
|
1018 |
static JNF_MEMBER_CACHE(jm_addAttribute, jc_CInputMethod, "addAttribute", "(ZZII)V"); |
|
1019 |
static JNF_MEMBER_CACHE(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIZ)V"); |
|
1020 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1021 |
|
12047 | 1022 |
// NSInputContext already did the analysis of the TSM event and created attributes indicating |
1023 |
// the underlining and color that should be done to the string. We need to look at the underline |
|
1024 |
// style and color to determine what kind of Java hilighting needs to be done. |
|
1025 |
jstring inProcessText = JNFNSToJavaString(env, incomingString); |
|
1026 |
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); // AWT_THREADING Safe (AWTRunLoopMode) |
|
1027 |
(*env)->DeleteLocalRef(env, inProcessText); |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1028 |
|
12047 | 1029 |
if (isAttributedString) { |
1030 |
NSUInteger length; |
|
1031 |
NSRange effectiveRange; |
|
1032 |
NSDictionary *attributes; |
|
1033 |
length = [attrString length]; |
|
1034 |
effectiveRange = NSMakeRange(0, 0); |
|
1035 |
while (NSMaxRange(effectiveRange) < length) { |
|
1036 |
attributes = [attrString attributesAtIndex:NSMaxRange(effectiveRange) |
|
1037 |
effectiveRange:&effectiveRange]; |
|
1038 |
if (attributes) { |
|
1039 |
BOOL isThickUnderline, isGray; |
|
1040 |
NSNumber *underlineSizeObj = |
|
1041 |
(NSNumber *)[attributes objectForKey:NSUnderlineStyleAttributeName]; |
|
1042 |
NSInteger underlineSize = [underlineSizeObj integerValue]; |
|
1043 |
isThickUnderline = (underlineSize > 1); |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1044 |
|
12047 | 1045 |
NSColor *underlineColorObj = |
1046 |
(NSColor *)[attributes objectForKey:NSUnderlineColorAttributeName]; |
|
1047 |
isGray = !([underlineColorObj isEqual:[NSColor blackColor]]); |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1048 |
|
12047 | 1049 |
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode) |
1050 |
} |
|
1051 |
} |
|
1052 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1053 |
|
12047 | 1054 |
static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V"); |
1055 |
// We need to select the previous glyph so that it is overwritten. |
|
1056 |
if (fPAHNeedsToSelect) { |
|
1057 |
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph); |
|
1058 |
fPAHNeedsToSelect = NO; |
|
1059 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1060 |
|
12047 | 1061 |
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode) |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1062 |
|
12047 | 1063 |
// If the marked text is being cleared (zero-length string) don't handle the key event. |
1064 |
if ([incomingString length] == 0) { |
|
1065 |
fKeyEventsNeeded = NO; |
|
1066 |
} |
|
1067 |
} |
|
1068 |
||
1069 |
- (void) unmarkText |
|
1070 |
{ |
|
1071 |
#ifdef IM_DEBUG |
|
1072 |
fprintf(stderr, "AWTView InputMethod Selector Called : [unmarkText]\n"); |
|
1073 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1074 |
|
12047 | 1075 |
if (!fInputMethodLOCKABLE) { |
1076 |
return; |
|
1077 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1078 |
|
12047 | 1079 |
// unmarkText cancels any input in progress and commits it to the text field. |
1080 |
static JNF_MEMBER_CACHE(jm_unmarkText, jc_CInputMethod, "unmarkText", "()V"); |
|
1081 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
1082 |
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText); // AWT_THREADING Safe (AWTRunLoopMode) |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1083 |
|
12047 | 1084 |
} |
1085 |
||
1086 |
- (BOOL) hasMarkedText |
|
1087 |
{ |
|
1088 |
#ifdef IM_DEBUG |
|
1089 |
fprintf(stderr, "AWTView InputMethod Selector Called : [hasMarkedText]\n"); |
|
1090 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1091 |
|
12047 | 1092 |
if (!fInputMethodLOCKABLE) { |
1093 |
return NO; |
|
1094 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1095 |
|
12047 | 1096 |
static JNF_MEMBER_CACHE(jf_fCurrentText, jc_CInputMethod, "fCurrentText", "Ljava/text/AttributedString;"); |
1097 |
static JNF_MEMBER_CACHE(jf_fCurrentTextLength, jc_CInputMethod, "fCurrentTextLength", "I"); |
|
1098 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
1099 |
jobject currentText = JNFGetObjectField(env, fInputMethodLOCKABLE, jf_fCurrentText); |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1100 |
|
12047 | 1101 |
jint currentTextLength = JNFGetIntField(env, fInputMethodLOCKABLE, jf_fCurrentTextLength); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1102 |
|
12047 | 1103 |
BOOL hasMarkedText = (currentText != NULL && currentTextLength > 0); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1104 |
|
12047 | 1105 |
if (currentText != NULL) { |
1106 |
(*env)->DeleteLocalRef(env, currentText); |
|
1107 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1108 |
|
12047 | 1109 |
return hasMarkedText; |
1110 |
} |
|
1111 |
||
1112 |
- (NSInteger) conversationIdentifier |
|
1113 |
{ |
|
1114 |
#ifdef IM_DEBUG |
|
1115 |
fprintf(stderr, "AWTView InputMethod Selector Called : [conversationIdentifier]\n"); |
|
1116 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1117 |
|
12047 | 1118 |
return (NSInteger) self; |
1119 |
} |
|
1120 |
||
1121 |
/* Returns attributed string at the range. This allows input mangers to |
|
1122 |
query any range in backing-store (Andy's request) |
|
1123 |
*/ |
|
1124 |
- (NSAttributedString *) attributedSubstringForProposedRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange |
|
1125 |
{ |
|
1126 |
#ifdef IM_DEBUG |
|
1127 |
fprintf(stderr, "AWTView InputMethod Selector Called : [attributedSubstringFromRange] location=%lu, length=%lu\n", (unsigned long)theRange.location, (unsigned long)theRange.length); |
|
1128 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1129 |
|
12047 | 1130 |
static JNF_MEMBER_CACHE(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;"); |
1131 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
1132 |
jobject theString = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); // AWT_THREADING Safe (AWTRunLoopMode) |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1133 |
|
12047 | 1134 |
id result = [[[NSAttributedString alloc] initWithString:JNFJavaToNSString(env, theString)] autorelease]; |
1135 |
#ifdef IM_DEBUG |
|
1136 |
NSLog(@"attributedSubstringFromRange returning \"%@\"", result); |
|
1137 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1138 |
|
12047 | 1139 |
(*env)->DeleteLocalRef(env, theString); |
1140 |
return result; |
|
1141 |
} |
|
1142 |
||
1143 |
/* This method returns the range for marked region. If hasMarkedText == false, |
|
1144 |
it'll return NSNotFound location & 0 length range. |
|
1145 |
*/ |
|
1146 |
- (NSRange) markedRange |
|
1147 |
{ |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1148 |
|
12047 | 1149 |
#ifdef IM_DEBUG |
1150 |
fprintf(stderr, "AWTView InputMethod Selector Called : [markedRange]\n"); |
|
1151 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1152 |
|
12047 | 1153 |
if (!fInputMethodLOCKABLE) { |
1154 |
return NSMakeRange(NSNotFound, 0); |
|
1155 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1156 |
|
12047 | 1157 |
static JNF_MEMBER_CACHE(jm_markedRange, jc_CInputMethod, "markedRange", "()[I"); |
1158 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
1159 |
jarray array; |
|
1160 |
jboolean isCopy; |
|
1161 |
jint *_array; |
|
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1162 |
NSRange range = NSMakeRange(NSNotFound, 0); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1163 |
|
12047 | 1164 |
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode) |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1165 |
|
12047 | 1166 |
if (array) { |
1167 |
_array = (*env)->GetIntArrayElements(env, array, &isCopy); |
|
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1168 |
if (_array != NULL) { |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1169 |
range.location = _array[0]; |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1170 |
range.length = _array[1]; |
12047 | 1171 |
#ifdef IM_DEBUG |
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1172 |
fprintf(stderr, "markedRange returning (%lu, %lu)\n", |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1173 |
(unsigned long)range.location, (unsigned long)range.length); |
12047 | 1174 |
#endif // IM_DEBUG |
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1175 |
(*env)->ReleaseIntArrayElements(env, array, _array, 0); |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1176 |
} |
12047 | 1177 |
(*env)->DeleteLocalRef(env, array); |
1178 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1179 |
|
12047 | 1180 |
return range; |
1181 |
} |
|
1182 |
||
1183 |
/* This method returns the range for selected region. Just like markedRange method, |
|
1184 |
its location field contains char index from the text beginning. |
|
1185 |
*/ |
|
1186 |
- (NSRange) selectedRange |
|
1187 |
{ |
|
1188 |
if (!fInputMethodLOCKABLE) { |
|
1189 |
return NSMakeRange(NSNotFound, 0); |
|
1190 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1191 |
|
12047 | 1192 |
static JNF_MEMBER_CACHE(jm_selectedRange, jc_CInputMethod, "selectedRange", "()[I"); |
1193 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
1194 |
jarray array; |
|
1195 |
jboolean isCopy; |
|
1196 |
jint *_array; |
|
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1197 |
NSRange range = NSMakeRange(NSNotFound, 0); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1198 |
|
12047 | 1199 |
#ifdef IM_DEBUG |
1200 |
fprintf(stderr, "AWTView InputMethod Selector Called : [selectedRange]\n"); |
|
1201 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1202 |
|
12047 | 1203 |
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode) |
1204 |
if (array) { |
|
1205 |
_array = (*env)->GetIntArrayElements(env, array, &isCopy); |
|
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1206 |
if (_array != NULL) { |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1207 |
range.location = _array[0]; |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1208 |
range.length = _array[1]; |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1209 |
(*env)->ReleaseIntArrayElements(env, array, _array, 0); |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1210 |
} |
12047 | 1211 |
(*env)->DeleteLocalRef(env, array); |
1212 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1213 |
|
12047 | 1214 |
return range; |
1215 |
} |
|
1216 |
||
1217 |
/* This method returns the first frame of rects for theRange in screen coordindate system. |
|
1218 |
*/ |
|
1219 |
- (NSRect) firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange |
|
1220 |
{ |
|
1221 |
if (!fInputMethodLOCKABLE) { |
|
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1222 |
return NSZeroRect; |
12047 | 1223 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1224 |
|
12047 | 1225 |
static JNF_MEMBER_CACHE(jm_firstRectForCharacterRange, jc_CInputMethod, |
1226 |
"firstRectForCharacterRange", "(I)[I"); |
|
1227 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
1228 |
jarray array; |
|
1229 |
jboolean isCopy; |
|
1230 |
jint *_array; |
|
1231 |
NSRect rect; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1232 |
|
12047 | 1233 |
#ifdef IM_DEBUG |
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1234 |
fprintf(stderr, |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1235 |
"AWTView InputMethod Selector Called : [firstRectForCharacterRange:] location=%lu, length=%lu\n", |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1236 |
(unsigned long)theRange.location, (unsigned long)theRange.length); |
12047 | 1237 |
#endif // IM_DEBUG |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1238 |
|
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1239 |
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange, |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1240 |
theRange.location); // AWT_THREADING Safe (AWTRunLoopMode) |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1241 |
|
12047 | 1242 |
_array = (*env)->GetIntArrayElements(env, array, &isCopy); |
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1243 |
if (_array) { |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1244 |
rect = ConvertNSScreenRect(env, NSMakeRect(_array[0], _array[1], _array[2], _array[3])); |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1245 |
(*env)->ReleaseIntArrayElements(env, array, _array, 0); |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1246 |
} else { |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1247 |
rect = NSZeroRect; |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1248 |
} |
12047 | 1249 |
(*env)->DeleteLocalRef(env, array); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1250 |
|
12047 | 1251 |
#ifdef IM_DEBUG |
23625
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1252 |
fprintf(stderr, |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1253 |
"firstRectForCharacterRange returning x=%f, y=%f, width=%f, height=%f\n", |
bb223c2c6fc0
8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents:
23328
diff
changeset
|
1254 |
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); |
12047 | 1255 |
#endif // IM_DEBUG |
1256 |
return rect; |
|
1257 |
} |
|
1258 |
||
1259 |
/* This method returns the index for character that is nearest to thePoint. thPoint is in |
|
1260 |
screen coordinate system. |
|
1261 |
*/ |
|
1262 |
- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint |
|
1263 |
{ |
|
1264 |
if (!fInputMethodLOCKABLE) { |
|
1265 |
return NSNotFound; |
|
1266 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1267 |
|
12047 | 1268 |
static JNF_MEMBER_CACHE(jm_characterIndexForPoint, jc_CInputMethod, |
1269 |
"characterIndexForPoint", "(II)I"); |
|
1270 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1271 |
|
12047 | 1272 |
NSPoint flippedLocation = ConvertNSScreenPoint(env, thePoint); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1273 |
|
12047 | 1274 |
#ifdef IM_DEBUG |
1275 |
fprintf(stderr, "AWTView InputMethod Selector Called : [characterIndexForPoint:(NSPoint)thePoint] x=%f, y=%f\n", flippedLocation.x, flippedLocation.y); |
|
1276 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1277 |
|
12047 | 1278 |
jint index = JNFCallIntMethod(env, fInputMethodLOCKABLE, jm_characterIndexForPoint, (jint)flippedLocation.x, (jint)flippedLocation.y); // AWT_THREADING Safe (AWTRunLoopMode) |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1279 |
|
12047 | 1280 |
#ifdef IM_DEBUG |
1281 |
fprintf(stderr, "characterIndexForPoint returning %ld\n", index); |
|
1282 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1283 |
|
12047 | 1284 |
if (index == -1) { |
1285 |
return NSNotFound; |
|
1286 |
} else { |
|
1287 |
return (NSUInteger)index; |
|
1288 |
} |
|
1289 |
} |
|
1290 |
||
1291 |
- (NSArray*) validAttributesForMarkedText |
|
1292 |
{ |
|
1293 |
#ifdef IM_DEBUG |
|
1294 |
fprintf(stderr, "AWTView InputMethod Selector Called : [validAttributesForMarkedText]\n"); |
|
1295 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1296 |
|
12047 | 1297 |
return [NSArray array]; |
1298 |
} |
|
1299 |
||
1300 |
- (void)setInputMethod:(jobject)inputMethod |
|
1301 |
{ |
|
1302 |
#ifdef IM_DEBUG |
|
1303 |
fprintf(stderr, "AWTView InputMethod Selector Called : [setInputMethod]\n"); |
|
1304 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1305 |
|
12047 | 1306 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1307 |
|
12047 | 1308 |
// Get rid of the old one |
1309 |
if (fInputMethodLOCKABLE) { |
|
1310 |
JNFDeleteGlobalRef(env, fInputMethodLOCKABLE); |
|
1311 |
} |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1312 |
|
12047 | 1313 |
// Save a global ref to the new input method. |
1314 |
if (inputMethod != NULL) |
|
1315 |
fInputMethodLOCKABLE = JNFNewGlobalRef(env, inputMethod); |
|
1316 |
else |
|
1317 |
fInputMethodLOCKABLE = NULL; |
|
1318 |
} |
|
1319 |
||
1320 |
- (void)abandonInput |
|
1321 |
{ |
|
1322 |
#ifdef IM_DEBUG |
|
1323 |
fprintf(stderr, "AWTView InputMethod Selector Called : [abandonInput]\n"); |
|
1324 |
#endif // IM_DEBUG |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1325 |
|
15985
b9e25a486549
8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents:
15322
diff
changeset
|
1326 |
[ThreadUtilities performOnMainThread:@selector(markedTextAbandoned:) on:[NSInputManager currentInputManager] withObject:self waitUntilDone:YES]; |
12047 | 1327 |
[self unmarkText]; |
1328 |
} |
|
1329 |
||
1330 |
/******************************** END NSTextInputClient Protocol ********************************/ |
|
1331 |
||
1332 |
||
1333 |
||
1334 |
||
1335 |
@end // AWTView |
|
1336 |
||
1337 |
/* |
|
1338 |
* Class: sun_lwawt_macosx_CPlatformView |
|
1339 |
* Method: nativeCreateView |
|
1340 |
* Signature: (IIII)J |
|
1341 |
*/ |
|
1342 |
JNIEXPORT jlong JNICALL |
|
1343 |
Java_sun_lwawt_macosx_CPlatformView_nativeCreateView |
|
1344 |
(JNIEnv *env, jobject obj, jint originX, jint originY, jint width, jint height, jlong windowLayerPtr) |
|
1345 |
{ |
|
1346 |
__block AWTView *newView = nil; |
|
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1347 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1348 |
JNF_COCOA_ENTER(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1349 |
|
12047 | 1350 |
NSRect rect = NSMakeRect(originX, originY, width, height); |
37787 | 1351 |
jobject cPlatformView = (*env)->NewWeakGlobalRef(env, obj); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1352 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1353 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1354 |
|
12047 | 1355 |
CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); |
23651
e41298d0da2f
8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents:
23625
diff
changeset
|
1356 |
newView = [[AWTView alloc] initWithRect:rect |
e41298d0da2f
8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents:
23625
diff
changeset
|
1357 |
platformView:cPlatformView |
e41298d0da2f
8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents:
23625
diff
changeset
|
1358 |
windowLayer:windowLayer]; |
12047 | 1359 |
}]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1360 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1361 |
JNF_COCOA_EXIT(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1362 |
|
12047 | 1363 |
return ptr_to_jlong(newView); |
1364 |
} |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1365 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1366 |
/* |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1367 |
* Class: sun_lwawt_macosx_CPlatformView |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1368 |
* Method: nativeSetAutoResizable |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1369 |
* Signature: (JZ)V; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1370 |
*/ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1371 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1372 |
JNIEXPORT void JNICALL |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1373 |
Java_sun_lwawt_macosx_CPlatformView_nativeSetAutoResizable |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1374 |
(JNIEnv *env, jclass cls, jlong viewPtr, jboolean toResize) |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1375 |
{ |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1376 |
JNF_COCOA_ENTER(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1377 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1378 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1379 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1380 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1381 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1382 |
if (toResize) { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1383 |
[view setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1384 |
} else { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1385 |
[view setAutoresizingMask: NSViewMinYMargin | NSViewMaxXMargin]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1386 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1387 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1388 |
if ([view superview] != nil) { |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1389 |
[[view superview] setAutoresizesSubviews:(BOOL)toResize]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1390 |
} |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1391 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1392 |
}]; |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1393 |
JNF_COCOA_EXIT(env); |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1394 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1395 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1396 |
/* |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1397 |
* Class: sun_lwawt_macosx_CPlatformView |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1398 |
* Method: nativeGetNSViewDisplayID |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1399 |
* Signature: (J)I; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1400 |
*/ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1401 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1402 |
JNIEXPORT jint JNICALL |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1403 |
Java_sun_lwawt_macosx_CPlatformView_nativeGetNSViewDisplayID |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1404 |
(JNIEnv *env, jclass cls, jlong viewPtr) |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1405 |
{ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1406 |
__block jint ret; //CGDirectDisplayID |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1407 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1408 |
JNF_COCOA_ENTER(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1409 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1410 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1411 |
NSWindow *window = [view window]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1412 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1413 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1414 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1415 |
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue]; |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1416 |
}]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1417 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1418 |
JNF_COCOA_EXIT(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1419 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1420 |
return ret; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1421 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1422 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1423 |
/* |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1424 |
* Class: sun_lwawt_macosx_CPlatformView |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1425 |
* Method: nativeGetLocationOnScreen |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1426 |
* Signature: (J)Ljava/awt/Rectangle; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1427 |
*/ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1428 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1429 |
JNIEXPORT jobject JNICALL |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1430 |
Java_sun_lwawt_macosx_CPlatformView_nativeGetLocationOnScreen |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1431 |
(JNIEnv *env, jclass cls, jlong viewPtr) |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1432 |
{ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1433 |
jobject jRect = NULL; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1434 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1435 |
JNF_COCOA_ENTER(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1436 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1437 |
__block NSRect rect = NSZeroRect; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1438 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1439 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1440 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1441 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1442 |
NSRect viewBounds = [view bounds]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1443 |
NSRect frameInWindow = [view convertRect:viewBounds toView:nil]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1444 |
rect = [[view window] convertRectToScreen:frameInWindow]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1445 |
//Convert coordinates to top-left corner origin |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1446 |
rect = ConvertNSScreenRect(NULL, rect); |
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1447 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1448 |
}]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1449 |
jRect = NSToJavaRect(env, rect); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1450 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1451 |
JNF_COCOA_EXIT(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1452 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1453 |
return jRect; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1454 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1455 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1456 |
/* |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1457 |
* Class: sun_lwawt_macosx_CPlatformView |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1458 |
* Method: nativeIsViewUnderMouse |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1459 |
* Signature: (J)Z; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1460 |
*/ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1461 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1462 |
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CPlatformView_nativeIsViewUnderMouse |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1463 |
(JNIEnv *env, jclass clazz, jlong viewPtr) |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1464 |
{ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1465 |
__block jboolean underMouse = JNI_FALSE; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1466 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1467 |
JNF_COCOA_ENTER(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1468 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1469 |
NSView *nsView = OBJC(viewPtr); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1470 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1471 |
NSPoint ptWindowCoords = [[nsView window] mouseLocationOutsideOfEventStream]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1472 |
NSPoint ptViewCoords = [nsView convertPoint:ptWindowCoords fromView:nil]; |
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1473 |
underMouse = [nsView hitTest:ptViewCoords] != nil; |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1474 |
}]; |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1475 |
|
36897
086e09a30b77
8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents:
36462
diff
changeset
|
1476 |
JNF_COCOA_EXIT(env); |
47500
9b702b6608f9
8186559: [macos] the screen location is wrong when using AWT/SWT bridge with dual monitors
serb
parents:
47216
diff
changeset
|
1477 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1478 |
return underMouse; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14306
diff
changeset
|
1479 |
} |