author | alexsch |
Thu, 18 Oct 2012 18:28:42 +0400 | |
changeset 14165 | dcb1f9388f85 |
parent 13777 | c94cf7e1bac2 |
child 14311 | b2492ea8d08e |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|
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 |
||
26 |
#import <Cocoa/Cocoa.h> |
|
27 |
#import <JavaNativeFoundation/JavaNativeFoundation.h> |
|
28 |
#import <JavaRuntimeSupport/JavaRuntimeSupport.h> |
|
29 |
||
30 |
#import "sun_lwawt_macosx_CPlatformWindow.h" |
|
31 |
#import "com_apple_eawt_event_GestureHandler.h" |
|
32 |
#import "com_apple_eawt_FullScreenHandler.h" |
|
33 |
||
34 |
#import "AWTWindow.h" |
|
35 |
#import "AWTView.h" |
|
36 |
#import "CMenu.h" |
|
37 |
#import "CMenuBar.h" |
|
38 |
#import "LWCToolkit.h" |
|
39 |
#import "GeomUtilities.h" |
|
40 |
#import "ThreadUtilities.h" |
|
41 |
#import "OSVersion.h" |
|
42 |
||
43 |
#define MASK(KEY) \ |
|
44 |
(sun_lwawt_macosx_CPlatformWindow_ ## KEY) |
|
45 |
||
46 |
#define IS(BITS, KEY) \ |
|
47 |
((BITS & MASK(KEY)) != 0) |
|
48 |
||
49 |
#define SET(BITS, KEY, VALUE) \ |
|
50 |
BITS = VALUE ? BITS | MASK(KEY) : BITS & ~MASK(KEY) |
|
51 |
||
52 |
static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow"); |
|
53 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
54 |
// -------------------------------------------------------------- |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
55 |
// NSWindow/NSPanel descendants implementation |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
56 |
#define AWT_NS_WINDOW_IMPLEMENTATION \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
57 |
- (id) initWithDelegate:(AWTWindow *)delegate \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
58 |
frameRect:(NSRect)contectRect \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
59 |
styleMask:(NSUInteger)styleMask \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
60 |
contentView:(NSView *)view \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
61 |
{ \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
62 |
self = [super initWithContentRect:contectRect \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
63 |
styleMask:styleMask \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
64 |
backing:NSBackingStoreBuffered \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
65 |
defer:NO]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
66 |
\ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
67 |
if (self == nil) return nil; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
68 |
\ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
69 |
[self setDelegate:delegate]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
70 |
[self setContentView:view]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
71 |
[self setInitialFirstResponder:view]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
72 |
[self setReleasedWhenClosed:NO]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
73 |
[self setPreservesContentDuringLiveResize:YES]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
74 |
\ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
75 |
return self; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
76 |
} \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
77 |
\ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
78 |
/* NSWindow overrides */ \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
79 |
- (BOOL) canBecomeKeyWindow { \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
80 |
return [(AWTWindow*)[self delegate] canBecomeKeyWindow]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
81 |
} \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
82 |
\ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
83 |
- (BOOL) canBecomeMainWindow { \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
84 |
return [(AWTWindow*)[self delegate] canBecomeMainWindow]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
85 |
} \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
86 |
\ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
87 |
- (BOOL) worksWhenModal { \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
88 |
return [(AWTWindow*)[self delegate] worksWhenModal]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
89 |
} \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
90 |
\ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
91 |
- (void)sendEvent:(NSEvent *)event { \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
92 |
[(AWTWindow*)[self delegate] sendEvent:event]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
93 |
[super sendEvent:event]; \ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
94 |
} |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
95 |
|
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
96 |
@implementation AWTWindow_Normal |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
97 |
AWT_NS_WINDOW_IMPLEMENTATION |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
98 |
@end |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
99 |
@implementation AWTWindow_Panel |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
100 |
AWT_NS_WINDOW_IMPLEMENTATION |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
101 |
@end |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
102 |
// END of NSWindow/NSPanel descendants implementation |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
103 |
// -------------------------------------------------------------- |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
104 |
|
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
105 |
|
12047 | 106 |
@implementation AWTWindow |
107 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
108 |
@synthesize nsWindow; |
12047 | 109 |
@synthesize javaPlatformWindow; |
110 |
@synthesize javaMenuBar; |
|
111 |
@synthesize javaMinSize; |
|
112 |
@synthesize javaMaxSize; |
|
113 |
@synthesize styleBits; |
|
12640 | 114 |
@synthesize isEnabled; |
12047 | 115 |
|
116 |
- (void) updateMinMaxSize:(BOOL)resizable { |
|
117 |
if (resizable) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
118 |
[self.nsWindow setMinSize:self.javaMinSize]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
119 |
[self.nsWindow setMaxSize:self.javaMaxSize]; |
12047 | 120 |
} else { |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
121 |
NSRect currentFrame = [self.nsWindow frame]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
122 |
[self.nsWindow setMinSize:currentFrame.size]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
123 |
[self.nsWindow setMaxSize:currentFrame.size]; |
12047 | 124 |
} |
125 |
} |
|
126 |
||
127 |
// creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits |
|
128 |
+ (NSUInteger) styleMaskForStyleBits:(jint)styleBits { |
|
129 |
NSUInteger type = 0; |
|
130 |
if (IS(styleBits, DECORATED)) { |
|
131 |
type |= NSTitledWindowMask; |
|
132 |
if (IS(styleBits, CLOSEABLE)) type |= NSClosableWindowMask; |
|
133 |
if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask; |
|
134 |
if (IS(styleBits, RESIZABLE)) type |= NSResizableWindowMask; |
|
135 |
} else { |
|
136 |
type |= NSBorderlessWindowMask; |
|
137 |
} |
|
138 |
||
12177
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
139 |
if (IS(styleBits, TEXTURED)) type |= NSTexturedBackgroundWindowMask; |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
140 |
if (IS(styleBits, UNIFIED)) type |= NSUnifiedTitleAndToolbarWindowMask; |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
141 |
if (IS(styleBits, UTILITY)) type |= NSUtilityWindowMask; |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
142 |
if (IS(styleBits, HUD)) type |= NSHUDWindowMask; |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
143 |
if (IS(styleBits, SHEET)) type |= NSDocModalWindowMask; |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
144 |
if (IS(styleBits, NONACTIVATING)) type |= NSNonactivatingPanelMask; |
12047 | 145 |
|
146 |
return type; |
|
147 |
} |
|
148 |
||
149 |
// updates _METHOD_PROP_BITMASK based properties on the window |
|
150 |
- (void) setPropertiesForStyleBits:(jint)bits mask:(jint)mask { |
|
151 |
if (IS(mask, RESIZABLE)) { |
|
152 |
BOOL resizable = IS(bits, RESIZABLE); |
|
153 |
[self updateMinMaxSize:resizable]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
154 |
[self.nsWindow setShowsResizeIndicator:resizable]; |
12047 | 155 |
} |
156 |
||
157 |
if (IS(mask, HAS_SHADOW)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
158 |
[self.nsWindow setHasShadow:IS(bits, HAS_SHADOW)]; |
12047 | 159 |
} |
160 |
||
161 |
if (IS(mask, ZOOMABLE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
162 |
[[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled:IS(bits, ZOOMABLE)]; |
12047 | 163 |
} |
164 |
||
165 |
if (IS(mask, ALWAYS_ON_TOP)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
166 |
[self.nsWindow setLevel:IS(bits, ALWAYS_ON_TOP) ? NSFloatingWindowLevel : NSNormalWindowLevel]; |
12047 | 167 |
} |
168 |
||
169 |
if (IS(mask, HIDES_ON_DEACTIVATE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
170 |
[self.nsWindow setHidesOnDeactivate:IS(bits, HIDES_ON_DEACTIVATE)]; |
12047 | 171 |
} |
172 |
||
173 |
if (IS(mask, DRAGGABLE_BACKGROUND)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
174 |
[self.nsWindow setMovableByWindowBackground:IS(bits, DRAGGABLE_BACKGROUND)]; |
12047 | 175 |
} |
176 |
||
177 |
if (IS(mask, DOCUMENT_MODIFIED)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
178 |
[self.nsWindow setDocumentEdited:IS(bits, DOCUMENT_MODIFIED)]; |
12047 | 179 |
} |
180 |
||
13777
c94cf7e1bac2
7197320: [macosx] Full Screen option missing when Window.documentModified
alexsch
parents:
13647
diff
changeset
|
181 |
if (IS(mask, FULLSCREENABLE) && [self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) { |
c94cf7e1bac2
7197320: [macosx] Full Screen option missing when Window.documentModified
alexsch
parents:
13647
diff
changeset
|
182 |
if (IS(bits, FULLSCREENABLE)) { |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
183 |
[self.nsWindow setCollectionBehavior:(1 << 7) /*NSWindowCollectionBehaviorFullScreenPrimary*/]; |
12047 | 184 |
} else { |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
185 |
[self.nsWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault]; |
12047 | 186 |
} |
187 |
} |
|
188 |
||
189 |
} |
|
190 |
||
191 |
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow |
|
192 |
styleBits:(jint)bits |
|
193 |
frameRect:(NSRect)rect |
|
194 |
contentView:(NSView *)view |
|
195 |
{ |
|
196 |
AWT_ASSERT_APPKIT_THREAD; |
|
197 |
||
198 |
NSUInteger styleMask = [AWTWindow styleMaskForStyleBits:bits]; |
|
199 |
NSRect contentRect = rect; //[NSWindow contentRectForFrameRect:rect styleMask:styleMask]; |
|
200 |
if (contentRect.size.width <= 0.0) { |
|
201 |
contentRect.size.width = 1.0; |
|
202 |
} |
|
203 |
if (contentRect.size.height <= 0.0) { |
|
204 |
contentRect.size.height = 1.0; |
|
205 |
} |
|
206 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
207 |
self = [super init]; |
12047 | 208 |
|
209 |
if (self == nil) return nil; // no hope |
|
210 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
211 |
if (IS(bits, UTILITY) || |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
212 |
IS(bits, NONACTIVATING) || |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
213 |
IS(bits, HUD) || |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
214 |
IS(bits, HIDES_ON_DEACTIVATE)) |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
215 |
{ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
216 |
self.nsWindow = [[AWTWindow_Panel alloc] initWithDelegate:self |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
217 |
frameRect:contentRect |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
218 |
styleMask:styleMask |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
219 |
contentView:view]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
220 |
} |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
221 |
else |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
222 |
{ |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
223 |
// These windows will appear in the window list in the dock icon menu |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
224 |
self.nsWindow = [[AWTWindow_Normal alloc] initWithDelegate:self |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
225 |
frameRect:contentRect |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
226 |
styleMask:styleMask |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
227 |
contentView:view]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
228 |
} |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
229 |
|
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
230 |
if (self.nsWindow == nil) return nil; // no hope either |
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
231 |
[self.nsWindow release]; // the property retains the object already |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
232 |
|
12640 | 233 |
self.isEnabled = YES; |
12047 | 234 |
self.javaPlatformWindow = platformWindow; |
235 |
self.styleBits = bits; |
|
236 |
[self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)]; |
|
237 |
||
238 |
return self; |
|
239 |
} |
|
240 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
241 |
+ (BOOL) isAWTWindow:(NSWindow *)window { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
242 |
return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
243 |
} |
12640 | 244 |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
245 |
// returns id for the topmost window under mouse |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
246 |
+ (NSInteger) getTopmostWindowUnderMouseID { |
12640 | 247 |
|
248 |
NSRect screenRect = [[NSScreen mainScreen] frame]; |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
249 |
NSPoint nsMouseLocation = [NSEvent mouseLocation]; |
12640 | 250 |
CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y); |
251 |
||
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
252 |
NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID); |
12640 | 253 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
254 |
for (NSDictionary *window in windows) { |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
255 |
NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue]; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
256 |
if (layer == 0) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
257 |
CGRect rect; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
258 |
CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
259 |
if (CGRectContainsPoint(rect, cgMouseLocation)) { |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
260 |
return [[window objectForKey:(id)kCGWindowNumber] integerValue]; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
261 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
262 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
263 |
} |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
264 |
return -1; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
265 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
266 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
267 |
// checks that this window is under the mouse cursor and this point is not overlapped by others windows |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
268 |
- (BOOL) isTopmostWindowUnderMouse { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
269 |
return [self.nsWindow windowNumber] == [AWTWindow getTopmostWindowUnderMouseID]; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
270 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
271 |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
272 |
+ (AWTWindow *) getTopmostWindowUnderMouse { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
273 |
NSEnumerator *windowEnumerator = [[NSApp windows] objectEnumerator]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
274 |
NSWindow *window; |
12640 | 275 |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
276 |
NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID]; |
12640 | 277 |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
278 |
while ((window = [windowEnumerator nextObject]) != nil) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
279 |
if ([window windowNumber] == topmostWindowUnderMouseID) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
280 |
BOOL isAWTWindow = [AWTWindow isAWTWindow: window]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
281 |
return isAWTWindow ? (AWTWindow *) [window delegate] : nil; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
282 |
} |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
283 |
} |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
284 |
return nil; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
285 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
286 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
287 |
+ (void) synthesizeMouseEnteredExitedEvents:(NSWindow*)window withType:(NSEventType)eventType { |
12640 | 288 |
|
289 |
NSPoint screenLocation = [NSEvent mouseLocation]; |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
290 |
NSPoint windowLocation = [window convertScreenToBase: screenLocation]; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
291 |
int modifierFlags = (eventType == NSMouseEntered) ? NSMouseEnteredMask : NSMouseExitedMask; |
12640 | 292 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
293 |
NSEvent *mouseEvent = [NSEvent enterExitEventWithType: eventType |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
294 |
location: windowLocation |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
295 |
modifierFlags: modifierFlags |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
296 |
timestamp: 0 |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
297 |
windowNumber: [window windowNumber] |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
298 |
context: nil |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
299 |
eventNumber: 0 |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
300 |
trackingNumber: 0 |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
301 |
userData: nil |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
302 |
]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
303 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
304 |
[[window contentView] deliverJavaMouseEvent: mouseEvent]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
305 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
306 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
307 |
+ (void) synthesizeMouseEnteredExitedEventsForAllWindows { |
12640 | 308 |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
309 |
NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
310 |
NSArray *windows = [NSApp windows]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
311 |
NSWindow *window; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
312 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
313 |
NSEnumerator *windowEnumerator = [windows objectEnumerator]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
314 |
while ((window = [windowEnumerator nextObject]) != nil) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
315 |
if ([AWTWindow isAWTWindow: window]) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
316 |
BOOL isUnderMouse = ([window windowNumber] == topmostWindowUnderMouseID); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
317 |
BOOL mouseIsOver = [[window contentView] mouseIsOver]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
318 |
if (isUnderMouse && !mouseIsOver) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
319 |
[AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseEntered]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
320 |
} else if (!isUnderMouse && mouseIsOver) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
321 |
[AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseExited]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
322 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
323 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
324 |
} |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
325 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
326 |
|
14165
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
327 |
+ (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window { |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
328 |
AWT_ASSERT_APPKIT_THREAD; |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
329 |
NSScreen *screen = [window screen]; |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
330 |
NSDictionary *deviceDescription = [screen deviceDescription]; |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
331 |
return [deviceDescription objectForKey:@"NSScreenNumber"]; |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
332 |
} |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
333 |
|
12047 | 334 |
- (void) dealloc { |
335 |
AWT_ASSERT_APPKIT_THREAD; |
|
336 |
||
337 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
338 |
[self.javaPlatformWindow setJObject:nil withEnv:env]; |
|
339 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
340 |
self.nsWindow = nil; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
341 |
|
12047 | 342 |
[super dealloc]; |
343 |
} |
|
344 |
||
345 |
// NSWindow overrides |
|
346 |
- (BOOL) canBecomeKeyWindow { |
|
347 |
AWT_ASSERT_APPKIT_THREAD; |
|
12640 | 348 |
return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY); |
12047 | 349 |
} |
350 |
||
351 |
- (BOOL) canBecomeMainWindow { |
|
352 |
AWT_ASSERT_APPKIT_THREAD; |
|
12640 | 353 |
return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN); |
12047 | 354 |
} |
355 |
||
356 |
- (BOOL) worksWhenModal { |
|
357 |
AWT_ASSERT_APPKIT_THREAD; |
|
358 |
return IS(self.styleBits, MODAL_EXCLUDED); |
|
359 |
} |
|
360 |
||
361 |
||
362 |
// Gesture support |
|
363 |
- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { |
|
364 |
AWT_ASSERT_APPKIT_THREAD; |
|
365 |
||
366 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
367 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
368 |
if (platformWindow != NULL) { |
|
369 |
// extract the target AWT Window object out of the CPlatformWindow |
|
370 |
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); |
|
371 |
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); |
|
372 |
if (awtWindow != NULL) { |
|
373 |
// translate the point into Java coordinates |
|
374 |
NSPoint loc = [event locationInWindow]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
375 |
loc.y = [self.nsWindow frame].size.height - loc.y; |
12047 | 376 |
|
377 |
// send up to the GestureHandler to recursively dispatch on the AWT event thread |
|
378 |
static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler"); |
|
379 |
static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V"); |
|
380 |
JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b); |
|
381 |
(*env)->DeleteLocalRef(env, awtWindow); |
|
382 |
} |
|
383 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
- (void)beginGestureWithEvent:(NSEvent *)event { |
|
388 |
[self postGesture:event |
|
389 |
as:com_apple_eawt_event_GestureHandler_PHASE |
|
390 |
a:-1.0 |
|
391 |
b:0.0]; |
|
392 |
} |
|
393 |
||
394 |
- (void)endGestureWithEvent:(NSEvent *)event { |
|
395 |
[self postGesture:event |
|
396 |
as:com_apple_eawt_event_GestureHandler_PHASE |
|
397 |
a:1.0 |
|
398 |
b:0.0]; |
|
399 |
} |
|
400 |
||
401 |
- (void)magnifyWithEvent:(NSEvent *)event { |
|
402 |
[self postGesture:event |
|
403 |
as:com_apple_eawt_event_GestureHandler_MAGNIFY |
|
404 |
a:[event magnification] |
|
405 |
b:0.0]; |
|
406 |
} |
|
407 |
||
408 |
- (void)rotateWithEvent:(NSEvent *)event { |
|
409 |
[self postGesture:event |
|
410 |
as:com_apple_eawt_event_GestureHandler_ROTATE |
|
411 |
a:[event rotation] |
|
412 |
b:0.0]; |
|
413 |
} |
|
414 |
||
415 |
- (void)swipeWithEvent:(NSEvent *)event { |
|
416 |
[self postGesture:event |
|
417 |
as:com_apple_eawt_event_GestureHandler_SWIPE |
|
418 |
a:[event deltaX] |
|
419 |
b:[event deltaY]]; |
|
420 |
} |
|
421 |
||
422 |
||
423 |
// NSWindowDelegate methods |
|
424 |
||
425 |
- (void) _deliverMoveResizeEvent { |
|
426 |
AWT_ASSERT_APPKIT_THREAD; |
|
427 |
||
428 |
// deliver the event if this is a user-initiated live resize or as a side-effect |
|
429 |
// of a Java initiated resize, because AppKit can override the bounds and force |
|
430 |
// the bounds of the window to avoid the Dock or remain on screen. |
|
431 |
[AWTToolkit eventCountPlusPlus]; |
|
432 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
433 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
434 |
if (platformWindow == NULL) { |
|
435 |
// TODO: create generic AWT assert |
|
436 |
} |
|
437 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
438 |
NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); |
12047 | 439 |
|
440 |
static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V"); |
|
441 |
JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent, |
|
442 |
(jint)frame.origin.x, |
|
443 |
(jint)frame.origin.y, |
|
444 |
(jint)frame.size.width, |
|
445 |
(jint)frame.size.height); |
|
446 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
447 |
} |
|
448 |
||
449 |
- (void)windowDidMove:(NSNotification *)notification { |
|
450 |
AWT_ASSERT_APPKIT_THREAD; |
|
451 |
||
452 |
[self _deliverMoveResizeEvent]; |
|
453 |
} |
|
454 |
||
455 |
- (void)windowDidResize:(NSNotification *)notification { |
|
456 |
AWT_ASSERT_APPKIT_THREAD; |
|
457 |
||
458 |
[self _deliverMoveResizeEvent]; |
|
459 |
} |
|
460 |
||
461 |
- (void)windowDidExpose:(NSNotification *)notification { |
|
462 |
AWT_ASSERT_APPKIT_THREAD; |
|
463 |
||
464 |
[AWTToolkit eventCountPlusPlus]; |
|
465 |
// TODO: don't see this callback invoked anytime so we track |
|
466 |
// window exposing in _setVisible:(BOOL) |
|
467 |
} |
|
468 |
||
469 |
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)proposedFrame { |
|
470 |
AWT_ASSERT_APPKIT_THREAD; |
|
471 |
||
472 |
[AWTToolkit eventCountPlusPlus]; |
|
473 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
474 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
475 |
if (platformWindow != NULL) { |
|
476 |
static JNF_MEMBER_CACHE(jm_deliverZoom, jc_CPlatformWindow, "deliverZoom", "(Z)V"); |
|
477 |
JNFCallVoidMethod(env, platformWindow, jm_deliverZoom, ![window isZoomed]); |
|
478 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
479 |
} |
|
480 |
return YES; |
|
481 |
} |
|
482 |
||
483 |
- (void) _deliverIconify:(BOOL)iconify { |
|
484 |
AWT_ASSERT_APPKIT_THREAD; |
|
485 |
||
486 |
[AWTToolkit eventCountPlusPlus]; |
|
487 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
488 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
489 |
if (platformWindow != NULL) { |
|
490 |
static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V"); |
|
491 |
JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify); |
|
492 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
493 |
} |
|
494 |
} |
|
495 |
||
496 |
- (void)windowDidMiniaturize:(NSNotification *)notification { |
|
497 |
AWT_ASSERT_APPKIT_THREAD; |
|
498 |
||
499 |
[self _deliverIconify:JNI_TRUE]; |
|
500 |
} |
|
501 |
||
502 |
- (void)windowDidDeminiaturize:(NSNotification *)notification { |
|
503 |
AWT_ASSERT_APPKIT_THREAD; |
|
504 |
||
505 |
[self _deliverIconify:JNI_FALSE]; |
|
506 |
} |
|
507 |
||
508 |
- (void) _deliverWindowFocusEvent:(BOOL)focused { |
|
509 |
//AWT_ASSERT_APPKIT_THREAD; |
|
510 |
||
511 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
|
512 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
513 |
if (platformWindow != NULL) { |
|
514 |
static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(Z)V"); |
|
515 |
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused); |
|
516 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
517 |
} |
|
518 |
} |
|
519 |
||
520 |
||
521 |
- (void) windowDidBecomeKey: (NSNotification *) notification { |
|
522 |
AWT_ASSERT_APPKIT_THREAD; |
|
523 |
[AWTToolkit eventCountPlusPlus]; |
|
524 |
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO]; |
|
525 |
[self _deliverWindowFocusEvent:YES]; |
|
526 |
} |
|
527 |
||
528 |
- (void) windowDidResignKey: (NSNotification *) notification { |
|
529 |
// TODO: check why sometimes at start is invoked *not* on AppKit main thread. |
|
530 |
AWT_ASSERT_APPKIT_THREAD; |
|
531 |
[AWTToolkit eventCountPlusPlus]; |
|
532 |
[self.javaMenuBar deactivate]; |
|
533 |
[self _deliverWindowFocusEvent:NO]; |
|
534 |
} |
|
535 |
||
536 |
- (void) windowDidBecomeMain: (NSNotification *) notification { |
|
537 |
AWT_ASSERT_APPKIT_THREAD; |
|
538 |
[AWTToolkit eventCountPlusPlus]; |
|
539 |
||
540 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
541 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
542 |
if (platformWindow != NULL) { |
|
543 |
static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V"); |
|
544 |
JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain); |
|
545 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
546 |
} |
|
547 |
} |
|
548 |
||
549 |
- (BOOL)windowShouldClose:(id)sender { |
|
550 |
AWT_ASSERT_APPKIT_THREAD; |
|
551 |
[AWTToolkit eventCountPlusPlus]; |
|
552 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
553 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
554 |
if (platformWindow != NULL) { |
|
555 |
static JNF_MEMBER_CACHE(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V"); |
|
556 |
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowClosingEvent); |
|
557 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
558 |
} |
|
559 |
// The window will be closed (if allowed) as result of sending Java event |
|
560 |
return NO; |
|
561 |
} |
|
562 |
||
563 |
||
564 |
- (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env { |
|
565 |
static JNF_CLASS_CACHE(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler"); |
|
566 |
static JNF_STATIC_MEMBER_CACHE(jm_notifyFullScreenOperation, jc_FullScreenHandler, "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V"); |
|
567 |
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); |
|
568 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
569 |
if (platformWindow != NULL) { |
|
570 |
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); |
|
571 |
if (awtWindow != NULL) { |
|
572 |
JNFCallStaticVoidMethod(env, jm_notifyFullScreenOperation, awtWindow, op); |
|
573 |
(*env)->DeleteLocalRef(env, awtWindow); |
|
574 |
} |
|
575 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
576 |
} |
|
577 |
} |
|
578 |
||
579 |
||
580 |
- (void)windowWillEnterFullScreen:(NSNotification *)notification { |
|
581 |
static JNF_MEMBER_CACHE(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V"); |
|
582 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
583 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
584 |
if (platformWindow != NULL) { |
|
585 |
JNFCallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen); |
|
586 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env]; |
|
587 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
588 |
} |
|
589 |
} |
|
590 |
||
591 |
- (void)windowDidEnterFullScreen:(NSNotification *)notification { |
|
592 |
static JNF_MEMBER_CACHE(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V"); |
|
593 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
594 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
595 |
if (platformWindow != NULL) { |
|
596 |
JNFCallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen); |
|
597 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env]; |
|
598 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
599 |
} |
|
600 |
} |
|
601 |
||
602 |
- (void)windowWillExitFullScreen:(NSNotification *)notification { |
|
603 |
static JNF_MEMBER_CACHE(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V"); |
|
604 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
605 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
606 |
if (platformWindow != NULL) { |
|
607 |
JNFCallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen); |
|
608 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env]; |
|
609 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
610 |
} |
|
611 |
} |
|
612 |
||
613 |
- (void)windowDidExitFullScreen:(NSNotification *)notification { |
|
614 |
static JNF_MEMBER_CACHE(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V"); |
|
615 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
616 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
617 |
if (platformWindow != NULL) { |
|
618 |
JNFCallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen); |
|
619 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env]; |
|
620 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
621 |
} |
|
622 |
} |
|
623 |
||
624 |
- (void)sendEvent:(NSEvent *)event { |
|
625 |
if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) { |
|
626 |
||
627 |
NSPoint p = [NSEvent mouseLocation]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
628 |
NSRect frame = [self.nsWindow frame]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
629 |
NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame]; |
12047 | 630 |
|
631 |
// Check if the click happened in the non-client area (title bar) |
|
632 |
if (p.y >= (frame.origin.y + contentRect.size.height)) { |
|
633 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
|
634 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
635 |
// Currently, no need to deliver the whole NSEvent. |
|
636 |
static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); |
|
637 |
JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); |
|
638 |
} |
|
639 |
} |
|
640 |
} |
|
12402
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
641 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
642 |
- (void)constrainSize:(NSSize*)size { |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
643 |
float minWidth = 0.f, minHeight = 0.f; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
644 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
645 |
if (IS(self.styleBits, DECORATED)) { |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
646 |
NSRect frame = [self.nsWindow frame]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
647 |
NSRect contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[self.nsWindow styleMask]]; |
12402
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
648 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
649 |
float top = frame.size.height - contentRect.size.height; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
650 |
float left = contentRect.origin.x - frame.origin.x; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
651 |
float bottom = contentRect.origin.y - frame.origin.y; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
652 |
float right = frame.size.width - (contentRect.size.width + left); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
653 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
654 |
// Speculative estimation: 80 - enough for window decorations controls |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
655 |
minWidth += left + right + 80; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
656 |
minHeight += top + bottom; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
657 |
} |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
658 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
659 |
minWidth = MAX(1.f, minWidth); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
660 |
minHeight = MAX(1.f, minHeight); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
661 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
662 |
size->width = MAX(size->width, minWidth); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
663 |
size->height = MAX(size->height, minHeight); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
664 |
} |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
665 |
|
12640 | 666 |
- (void) setEnabled: (BOOL)flag { |
667 |
self.isEnabled = flag; |
|
668 |
||
669 |
if (IS(self.styleBits, CLOSEABLE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
670 |
[[self.nsWindow standardWindowButton:NSWindowCloseButton] setEnabled: flag]; |
12640 | 671 |
} |
672 |
||
673 |
if (IS(self.styleBits, MINIMIZABLE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
674 |
[[self.nsWindow standardWindowButton:NSWindowMiniaturizeButton] setEnabled: flag]; |
12640 | 675 |
} |
676 |
||
677 |
if (IS(self.styleBits, ZOOMABLE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
678 |
[[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled: flag]; |
12640 | 679 |
} |
680 |
||
681 |
if (IS(self.styleBits, RESIZABLE)) { |
|
682 |
[self updateMinMaxSize:flag]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
683 |
[self.nsWindow setShowsResizeIndicator:flag]; |
12640 | 684 |
} |
685 |
} |
|
686 |
||
12047 | 687 |
@end // AWTWindow |
688 |
||
689 |
||
690 |
/* |
|
691 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
692 |
* Method: nativeCreateNSWindow |
|
693 |
* Signature: (JJIIII)J |
|
694 |
*/ |
|
695 |
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow |
|
696 |
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h) |
|
697 |
{ |
|
698 |
__block AWTWindow *window = nil; |
|
699 |
||
700 |
JNF_COCOA_ENTER(env); |
|
701 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
702 |
||
703 |
JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env]; |
|
704 |
NSView *contentView = OBJC(contentViewPtr); |
|
705 |
NSRect frameRect = NSMakeRect(x, y, w, h); |
|
706 |
||
707 |
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ |
|
708 |
AWT_ASSERT_APPKIT_THREAD; |
|
709 |
||
710 |
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow |
|
711 |
styleBits:styleBits |
|
712 |
frameRect:frameRect |
|
713 |
contentView:contentView]; |
|
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
714 |
// the window is released is CPlatformWindow.nativeDispose() |
12047 | 715 |
|
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
716 |
if (window) CFRetain(window.nsWindow); |
12047 | 717 |
}]; |
718 |
||
719 |
JNF_COCOA_EXIT(env); |
|
720 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
721 |
return ptr_to_jlong(window ? window.nsWindow : nil); |
12047 | 722 |
} |
723 |
||
724 |
/* |
|
725 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
726 |
* Method: nativeSetNSWindowStyleBits |
|
727 |
* Signature: (JII)V |
|
728 |
*/ |
|
729 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStyleBits |
|
730 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits) |
|
731 |
{ |
|
732 |
JNF_COCOA_ENTER(env); |
|
733 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
734 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
735 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 736 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
737 |
AWT_ASSERT_APPKIT_THREAD; |
|
738 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
739 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
740 |
|
12047 | 741 |
// scans the bit field, and only updates the values requested by the mask |
742 |
// (this implicity handles the _CALLBACK_PROP_BITMASK case, since those are passive reads) |
|
743 |
jint newBits = window.styleBits & ~mask | bits & mask; |
|
744 |
||
745 |
// resets the NSWindow's style mask if the mask intersects any of those bits |
|
746 |
if (mask & MASK(_STYLE_PROP_BITMASK)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
747 |
[nsWindow setStyleMask:[AWTWindow styleMaskForStyleBits:newBits]]; |
12047 | 748 |
} |
749 |
||
750 |
// calls methods on NSWindow to change other properties, based on the mask |
|
751 |
if (mask & MASK(_METHOD_PROP_BITMASK)) { |
|
752 |
[window setPropertiesForStyleBits:bits mask:mask]; |
|
753 |
} |
|
754 |
||
755 |
window.styleBits = newBits; |
|
756 |
}]; |
|
757 |
||
758 |
JNF_COCOA_EXIT(env); |
|
759 |
} |
|
760 |
||
761 |
/* |
|
762 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
763 |
* Method: nativeSetNSWindowMenuBar |
|
764 |
* Signature: (JJ)V |
|
765 |
*/ |
|
766 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMenuBar |
|
767 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jlong menuBarPtr) |
|
768 |
{ |
|
769 |
JNF_COCOA_ENTER(env); |
|
770 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
771 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
772 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 773 |
CMenuBar *menuBar = OBJC(menuBarPtr); |
774 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
775 |
AWT_ASSERT_APPKIT_THREAD; |
|
776 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
777 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
778 |
|
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
779 |
if ([nsWindow isKeyWindow]) [window.javaMenuBar deactivate]; |
12047 | 780 |
window.javaMenuBar = menuBar; |
781 |
||
782 |
// if ([self isKeyWindow]) { |
|
783 |
[CMenuBar activate:window.javaMenuBar modallyDisabled:NO]; |
|
784 |
// } |
|
785 |
}]; |
|
786 |
||
787 |
JNF_COCOA_EXIT(env); |
|
788 |
} |
|
789 |
||
790 |
/* |
|
791 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
792 |
* Method: nativeGetNSWindowInsets |
|
793 |
* Signature: (J)Ljava/awt/Insets; |
|
794 |
*/ |
|
795 |
JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets |
|
796 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
797 |
{ |
|
798 |
jobject ret = NULL; |
|
799 |
||
800 |
JNF_COCOA_ENTER(env); |
|
801 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
802 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
803 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 804 |
__block NSRect contentRect = NSZeroRect; |
805 |
__block NSRect frame = NSZeroRect; |
|
806 |
||
807 |
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ |
|
808 |
AWT_ASSERT_APPKIT_THREAD; |
|
809 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
810 |
frame = [nsWindow frame]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
811 |
contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]]; |
12047 | 812 |
}]; |
813 |
||
814 |
jint top = (jint)(frame.size.height - contentRect.size.height); |
|
815 |
jint left = (jint)(contentRect.origin.x - frame.origin.x); |
|
816 |
jint bottom = (jint)(contentRect.origin.y - frame.origin.y); |
|
817 |
jint right = (jint)(frame.size.width - (contentRect.size.width + left)); |
|
818 |
||
819 |
static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets"); |
|
820 |
static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V"); |
|
821 |
ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right); |
|
822 |
||
823 |
JNF_COCOA_EXIT(env); |
|
824 |
return ret; |
|
825 |
} |
|
826 |
||
827 |
/* |
|
828 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
829 |
* Method: nativeSetNSWindowBounds |
|
830 |
* Signature: (JDDDD)V |
|
831 |
*/ |
|
832 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds |
|
833 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height) |
|
834 |
{ |
|
835 |
JNF_COCOA_ENTER(env); |
|
836 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
837 |
||
838 |
NSRect jrect = NSMakeRect(originX, originY, width, height); |
|
839 |
||
840 |
// TODO: not sure we need displayIfNeeded message in our view |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
841 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 842 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
843 |
AWT_ASSERT_APPKIT_THREAD; |
|
844 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
845 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
846 |
|
12047 | 847 |
NSRect rect = ConvertNSScreenRect(NULL, jrect); |
12402
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
848 |
[window constrainSize:&rect.size]; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
849 |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
850 |
[nsWindow setFrame:rect display:YES]; |
12047 | 851 |
|
852 |
// only start tracking events if pointer is above the toplevel |
|
853 |
// TODO: should post an Entered event if YES. |
|
854 |
NSPoint mLocation = [NSEvent mouseLocation]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
855 |
[nsWindow setAcceptsMouseMovedEvents:NSPointInRect(mLocation, rect)]; |
12047 | 856 |
|
857 |
// ensure we repaint the whole window after the resize operation |
|
858 |
// (this will also re-enable screen updates, which were disabled above) |
|
859 |
// TODO: send PaintEvent |
|
12640 | 860 |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
861 |
[AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; |
12047 | 862 |
}]; |
863 |
||
864 |
JNF_COCOA_EXIT(env); |
|
865 |
} |
|
866 |
||
867 |
/* |
|
868 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
869 |
* Method: nativeSetNSWindowMinMax |
|
870 |
* Signature: (JDDDD)V |
|
871 |
*/ |
|
872 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax |
|
873 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH) |
|
874 |
{ |
|
875 |
JNF_COCOA_ENTER(env); |
|
876 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
877 |
||
878 |
if (minW < 1) minW = 1; |
|
879 |
if (minH < 1) minH = 1; |
|
880 |
if (maxW < 1) maxW = 1; |
|
881 |
if (maxH < 1) maxH = 1; |
|
882 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
883 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 884 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
885 |
AWT_ASSERT_APPKIT_THREAD; |
|
886 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
887 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
888 |
|
12402
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
889 |
NSSize min = { minW, minH }; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
890 |
NSSize max = { maxW, maxH }; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
891 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
892 |
[window constrainSize:&min]; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
893 |
[window constrainSize:&max]; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
894 |
|
12047 | 895 |
window.javaMinSize = min; |
896 |
window.javaMaxSize = max; |
|
897 |
[window updateMinMaxSize:IS(window.styleBits, RESIZABLE)]; |
|
898 |
}]; |
|
899 |
||
900 |
JNF_COCOA_EXIT(env); |
|
901 |
} |
|
902 |
||
903 |
/* |
|
904 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
905 |
* Method: nativePushNSWindowToBack |
|
906 |
* Signature: (J)V |
|
907 |
*/ |
|
908 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToBack |
|
909 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
910 |
{ |
|
911 |
JNF_COCOA_ENTER(env); |
|
912 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
913 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
914 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 915 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
916 |
AWT_ASSERT_APPKIT_THREAD; |
|
917 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
918 |
[nsWindow orderBack:nil]; |
12047 | 919 |
}]; |
920 |
||
921 |
JNF_COCOA_EXIT(env); |
|
922 |
} |
|
923 |
||
924 |
/* |
|
925 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
926 |
* Method: nativePushNSWindowToFront |
|
927 |
* Signature: (J)V |
|
928 |
*/ |
|
929 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToFront |
|
930 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
931 |
{ |
|
932 |
JNF_COCOA_ENTER(env); |
|
933 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
934 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
935 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 936 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
937 |
AWT_ASSERT_APPKIT_THREAD; |
|
938 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
939 |
if (![nsWindow isKeyWindow]) { |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
940 |
[nsWindow makeKeyAndOrderFront:nsWindow]; |
12047 | 941 |
} else { |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
942 |
[nsWindow orderFront:nsWindow]; |
12047 | 943 |
} |
944 |
}]; |
|
945 |
||
946 |
JNF_COCOA_EXIT(env); |
|
947 |
} |
|
948 |
||
949 |
/* |
|
950 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
951 |
* Method: nativeSetNSWindowTitle |
|
952 |
* Signature: (JLjava/lang/String;)V |
|
953 |
*/ |
|
954 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowTitle |
|
955 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jstring jtitle) |
|
956 |
{ |
|
957 |
JNF_COCOA_ENTER(env); |
|
958 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
959 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
960 |
NSWindow *nsWindow = OBJC(windowPtr); |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
961 |
[nsWindow performSelectorOnMainThread:@selector(setTitle:) |
12047 | 962 |
withObject:JNFJavaToNSString(env, jtitle) |
963 |
waitUntilDone:NO]; |
|
964 |
||
965 |
JNF_COCOA_EXIT(env); |
|
966 |
} |
|
967 |
||
968 |
/* |
|
969 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
970 |
* Method: nativeRevalidateNSWindowShadow |
|
971 |
* Signature: (J)V |
|
972 |
*/ |
|
973 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeRevalidateNSWindowShadow |
|
974 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
975 |
{ |
|
976 |
JNF_COCOA_ENTER(env); |
|
977 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
978 |
NSWindow *nsWindow = OBJC(windowPtr); |
13233 | 979 |
if ([NSThread isMainThread]) { |
980 |
[nsWindow invalidateShadow]; |
|
981 |
} else { |
|
982 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
983 |
AWT_ASSERT_APPKIT_THREAD; |
|
12047 | 984 |
|
13233 | 985 |
[nsWindow invalidateShadow]; |
986 |
}]; |
|
987 |
} |
|
12047 | 988 |
|
989 |
JNF_COCOA_EXIT(env); |
|
990 |
} |
|
991 |
||
992 |
/* |
|
993 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
994 |
* Method: nativeScreenOn_AppKitThread |
|
995 |
* Signature: (J)I |
|
996 |
*/ |
|
997 |
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeScreenOn_1AppKitThread |
|
998 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
999 |
{ |
|
1000 |
jint ret = 0; |
|
1001 |
||
1002 |
JNF_COCOA_ENTER(env); |
|
1003 |
AWT_ASSERT_APPKIT_THREAD; |
|
1004 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1005 |
NSWindow *nsWindow = OBJC(windowPtr); |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1006 |
NSDictionary *props = [[nsWindow screen] deviceDescription]; |
12047 | 1007 |
ret = [[props objectForKey:@"NSScreenNumber"] intValue]; |
1008 |
||
1009 |
JNF_COCOA_EXIT(env); |
|
1010 |
||
1011 |
return ret; |
|
1012 |
} |
|
1013 |
||
1014 |
/* |
|
1015 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
1016 |
* Method: nativeSetNSWindowMinimizedIcon |
|
1017 |
* Signature: (JJ)V |
|
1018 |
*/ |
|
1019 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinimizedIcon |
|
1020 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jlong nsImagePtr) |
|
1021 |
{ |
|
1022 |
JNF_COCOA_ENTER(env); |
|
1023 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
1024 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1025 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 1026 |
NSImage *image = OBJC(nsImagePtr); |
1027 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
1028 |
AWT_ASSERT_APPKIT_THREAD; |
|
1029 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1030 |
[nsWindow setMiniwindowImage:image]; |
12047 | 1031 |
}]; |
1032 |
||
1033 |
JNF_COCOA_EXIT(env); |
|
1034 |
} |
|
1035 |
||
1036 |
/* |
|
1037 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
1038 |
* Method: nativeSetNSWindowRepresentedFilename |
|
1039 |
* Signature: (JLjava/lang/String;)V |
|
1040 |
*/ |
|
1041 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowRepresentedFilename |
|
1042 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jstring filename) |
|
1043 |
{ |
|
1044 |
JNF_COCOA_ENTER(env); |
|
1045 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
1046 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1047 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 1048 |
NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)]; |
1049 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
1050 |
AWT_ASSERT_APPKIT_THREAD; |
|
1051 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1052 |
[nsWindow setRepresentedURL:url]; |
12047 | 1053 |
}]; |
1054 |
||
1055 |
JNF_COCOA_EXIT(env); |
|
1056 |
} |
|
1057 |
||
1058 |
/* |
|
1059 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
1060 |
* Method: nativeSetNSWindowSecurityWarningPositioning |
|
1061 |
* Signature: (JDDFF)V |
|
1062 |
*/ |
|
1063 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowSecurityWarningPositioning |
|
1064 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble x, jdouble y, jfloat biasX, jfloat biasY) |
|
1065 |
{ |
|
1066 |
JNF_COCOA_ENTER(env); |
|
1067 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
1068 |
||
1069 |
[JNFException raise:env as:kRuntimeException reason:"unimplemented"]; |
|
1070 |
||
1071 |
JNF_COCOA_EXIT(env); |
|
1072 |
} |
|
1073 |
||
1074 |
/* |
|
1075 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1076 |
* Method: nativeGetTopmostPlatformWindowUnderMouse |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1077 |
* Signature: (J)V |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1078 |
*/ |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1079 |
JNIEXPORT jobject |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1080 |
JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1081 |
(JNIEnv *env, jclass clazz) |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1082 |
{ |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1083 |
jobject topmostWindowUnderMouse = nil; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1084 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1085 |
JNF_COCOA_ENTER(env); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1086 |
AWT_ASSERT_APPKIT_THREAD; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1087 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1088 |
AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1089 |
if (awtWindow != nil) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1090 |
topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject]; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1091 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1092 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1093 |
JNF_COCOA_EXIT(env); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1094 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1095 |
return topmostWindowUnderMouse; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1096 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1097 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1098 |
/* |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1099 |
* Class: sun_lwawt_macosx_CPlatformWindow |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1100 |
* Method: nativeSynthesizeMouseEnteredExitedEvents |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1101 |
* Signature: (J)V |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1102 |
*/ |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1103 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1104 |
(JNIEnv *env, jclass clazz) |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1105 |
{ |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1106 |
JNF_COCOA_ENTER(env); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1107 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
12640 | 1108 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1109 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1110 |
AWT_ASSERT_APPKIT_THREAD; |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13233
diff
changeset
|
1111 |
[AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1112 |
}]; |
12640 | 1113 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1114 |
JNF_COCOA_EXIT(env); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1115 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1116 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1117 |
/* |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1118 |
* Class: sun_lwawt_macosx_CPlatformWindow |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1119 |
* Method: nativeGetDisplayID_AppKitThread |
12047 | 1120 |
* Signature: (J)I |
1121 |
*/ |
|
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1122 |
JNIEXPORT jint JNICALL |
14165
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1123 |
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID |
12047 | 1124 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
1125 |
{ |
|
14165
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1126 |
__block jint ret; // CGDirectDisplayID |
12047 | 1127 |
|
1128 |
JNF_COCOA_ENTER(env); |
|
1129 |
||
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1130 |
NSWindow *window = OBJC(windowPtr); |
14165
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1131 |
|
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1132 |
if ([NSThread isMainThread]) { |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1133 |
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue]; |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1134 |
} else { |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1135 |
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1136 |
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue]; |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1137 |
}]; |
dcb1f9388f85
7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents:
13777
diff
changeset
|
1138 |
} |
12047 | 1139 |
|
1140 |
JNF_COCOA_EXIT(env); |
|
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1141 |
|
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1142 |
return ret; |
12047 | 1143 |
} |
1144 |
||
1145 |
/* |
|
1146 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
1147 |
* Method: _toggleFullScreenMode |
|
1148 |
* Signature: (J)V |
|
1149 |
*/ |
|
1150 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow__1toggleFullScreenMode |
|
1151 |
(JNIEnv *env, jobject peer, jlong windowPtr) |
|
1152 |
{ |
|
1153 |
JNF_COCOA_ENTER(env); |
|
1154 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1155 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 1156 |
SEL toggleFullScreenSelector = @selector(toggleFullScreen:); |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1157 |
if (![nsWindow respondsToSelector:toggleFullScreenSelector]) return; |
12047 | 1158 |
|
1159 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1160 |
[nsWindow performSelector:toggleFullScreenSelector withObject:nil]; |
12047 | 1161 |
}]; |
1162 |
||
1163 |
JNF_COCOA_EXIT(env); |
|
1164 |
} |
|
1165 |
||
1166 |
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CMouseInfoPeer_nativeIsWindowUnderMouse |
|
1167 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
1168 |
{ |
|
1169 |
__block jboolean underMouse = JNI_FALSE; |
|
1170 |
||
1171 |
JNF_COCOA_ENTER(env); |
|
1172 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
1173 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1174 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 1175 |
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^() { |
1176 |
AWT_ASSERT_APPKIT_THREAD; |
|
1177 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1178 |
NSPoint pt = [nsWindow mouseLocationOutsideOfEventStream]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1179 |
underMouse = [[nsWindow contentView] hitTest:pt] != nil; |
12047 | 1180 |
}]; |
1181 |
||
1182 |
JNF_COCOA_EXIT(env); |
|
1183 |
||
1184 |
return underMouse; |
|
1185 |
} |
|
12640 | 1186 |
|
1187 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetEnabled |
|
1188 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jboolean isEnabled) |
|
1189 |
{ |
|
1190 |
JNF_COCOA_ENTER(env); |
|
1191 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1192 |
NSWindow *nsWindow = OBJC(windowPtr); |
12640 | 1193 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1194 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1195 |
|
12640 | 1196 |
[window setEnabled: isEnabled]; |
1197 |
}]; |
|
1198 |
||
1199 |
JNF_COCOA_EXIT(env); |
|
1200 |
} |
|
1201 |
||
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1202 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeDispose |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1203 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1204 |
{ |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1205 |
JNF_COCOA_ENTER(env); |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1206 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1207 |
NSWindow *nsWindow = OBJC(windowPtr); |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1208 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1209 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1210 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1211 |
// AWTWindow holds a reference to the NSWindow in its nsWindow |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1212 |
// property. Unsetting the delegate allows it to be deallocated |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1213 |
// which releases the reference. This, in turn, allows the window |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1214 |
// itself be deallocated. |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1215 |
[nsWindow setDelegate: nil]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1216 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1217 |
[window release]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1218 |
}]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1219 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1220 |
JNF_COCOA_EXIT(env); |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1221 |
} |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1222 |