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