author | serb |
Tue, 26 Jun 2012 13:46:09 +0400 | |
changeset 13143 | 31c70a66a053 |
parent 13009 | f409e6ef0185 |
child 13233 | 4d45f7ebc0d7 |
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 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
181 |
if ([self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) { |
12047 | 182 |
if (IS(mask, 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 |
||
12640 | 241 |
// checks that this window is under the mouse cursor and this point is not overlapped by others windows |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
242 |
- (BOOL) isTopmostWindowUnderMouse { |
12640 | 243 |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
244 |
int currentWinID = [self.nsWindow windowNumber]; |
12640 | 245 |
|
246 |
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
|
247 |
NSPoint nsMouseLocation = [NSEvent mouseLocation]; |
12640 | 248 |
CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y); |
249 |
||
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
250 |
NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID); |
12640 | 251 |
|
252 |
||
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
253 |
for (NSDictionary *window in windows) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
254 |
int layer = [[window objectForKey:(id)kCGWindowLayer] intValue]; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
255 |
if (layer == 0) { |
12640 | 256 |
int winID = [[window objectForKey:(id)kCGWindowNumber] intValue]; |
12535
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)) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
260 |
return currentWinID == winID; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
261 |
} else if (currentWinID == winID) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
262 |
return NO; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
263 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
264 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
265 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
266 |
return NO; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
267 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
268 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
269 |
- (void) synthesizeMouseEnteredExitedEvents { |
12640 | 270 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
271 |
int eventType = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
272 |
BOOL isUnderMouse = [self isTopmostWindowUnderMouse]; |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
273 |
BOOL mouseIsOver = [[self.nsWindow contentView] mouseIsOver]; |
12640 | 274 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
275 |
if (isUnderMouse && !mouseIsOver) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
276 |
eventType = NSMouseEntered; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
277 |
} else if (!isUnderMouse && mouseIsOver) { |
12640 | 278 |
eventType = NSMouseExited; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
279 |
} else { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
280 |
return; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
281 |
} |
12640 | 282 |
|
283 |
NSPoint screenLocation = [NSEvent mouseLocation]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
284 |
NSPoint windowLocation = [self.nsWindow convertScreenToBase: screenLocation]; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
285 |
int modifierFlags = (eventType == NSMouseEntered) ? NSMouseEnteredMask : NSMouseExitedMask; |
12640 | 286 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
287 |
NSEvent *mouseEvent = [NSEvent enterExitEventWithType: eventType |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
288 |
location: windowLocation |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
289 |
modifierFlags: modifierFlags |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
290 |
timestamp: 0 |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
291 |
windowNumber: [self.nsWindow windowNumber] |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
292 |
context: nil |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
293 |
eventNumber: 0 |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
294 |
trackingNumber: 0 |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
295 |
userData: nil |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
296 |
]; |
12640 | 297 |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
298 |
[[self.nsWindow contentView] deliverJavaMouseEvent: mouseEvent]; |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
299 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
300 |
|
12047 | 301 |
- (void) dealloc { |
302 |
AWT_ASSERT_APPKIT_THREAD; |
|
303 |
||
304 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
305 |
[self.javaPlatformWindow setJObject:nil withEnv:env]; |
|
306 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
307 |
self.nsWindow = nil; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
308 |
|
12047 | 309 |
[super dealloc]; |
310 |
} |
|
311 |
||
312 |
// NSWindow overrides |
|
313 |
- (BOOL) canBecomeKeyWindow { |
|
314 |
AWT_ASSERT_APPKIT_THREAD; |
|
12640 | 315 |
return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY); |
12047 | 316 |
} |
317 |
||
318 |
- (BOOL) canBecomeMainWindow { |
|
319 |
AWT_ASSERT_APPKIT_THREAD; |
|
12640 | 320 |
return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN); |
12047 | 321 |
} |
322 |
||
323 |
- (BOOL) worksWhenModal { |
|
324 |
AWT_ASSERT_APPKIT_THREAD; |
|
325 |
return IS(self.styleBits, MODAL_EXCLUDED); |
|
326 |
} |
|
327 |
||
328 |
||
329 |
// Gesture support |
|
330 |
- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { |
|
331 |
AWT_ASSERT_APPKIT_THREAD; |
|
332 |
||
333 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
334 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
335 |
if (platformWindow != NULL) { |
|
336 |
// extract the target AWT Window object out of the CPlatformWindow |
|
337 |
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); |
|
338 |
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); |
|
339 |
if (awtWindow != NULL) { |
|
340 |
// translate the point into Java coordinates |
|
341 |
NSPoint loc = [event locationInWindow]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
342 |
loc.y = [self.nsWindow frame].size.height - loc.y; |
12047 | 343 |
|
344 |
// send up to the GestureHandler to recursively dispatch on the AWT event thread |
|
345 |
static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler"); |
|
346 |
static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V"); |
|
347 |
JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b); |
|
348 |
(*env)->DeleteLocalRef(env, awtWindow); |
|
349 |
} |
|
350 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
351 |
} |
|
352 |
} |
|
353 |
||
354 |
- (void)beginGestureWithEvent:(NSEvent *)event { |
|
355 |
[self postGesture:event |
|
356 |
as:com_apple_eawt_event_GestureHandler_PHASE |
|
357 |
a:-1.0 |
|
358 |
b:0.0]; |
|
359 |
} |
|
360 |
||
361 |
- (void)endGestureWithEvent:(NSEvent *)event { |
|
362 |
[self postGesture:event |
|
363 |
as:com_apple_eawt_event_GestureHandler_PHASE |
|
364 |
a:1.0 |
|
365 |
b:0.0]; |
|
366 |
} |
|
367 |
||
368 |
- (void)magnifyWithEvent:(NSEvent *)event { |
|
369 |
[self postGesture:event |
|
370 |
as:com_apple_eawt_event_GestureHandler_MAGNIFY |
|
371 |
a:[event magnification] |
|
372 |
b:0.0]; |
|
373 |
} |
|
374 |
||
375 |
- (void)rotateWithEvent:(NSEvent *)event { |
|
376 |
[self postGesture:event |
|
377 |
as:com_apple_eawt_event_GestureHandler_ROTATE |
|
378 |
a:[event rotation] |
|
379 |
b:0.0]; |
|
380 |
} |
|
381 |
||
382 |
- (void)swipeWithEvent:(NSEvent *)event { |
|
383 |
[self postGesture:event |
|
384 |
as:com_apple_eawt_event_GestureHandler_SWIPE |
|
385 |
a:[event deltaX] |
|
386 |
b:[event deltaY]]; |
|
387 |
} |
|
388 |
||
389 |
||
390 |
// NSWindowDelegate methods |
|
391 |
||
392 |
- (void) _deliverMoveResizeEvent { |
|
393 |
AWT_ASSERT_APPKIT_THREAD; |
|
394 |
||
395 |
// deliver the event if this is a user-initiated live resize or as a side-effect |
|
396 |
// of a Java initiated resize, because AppKit can override the bounds and force |
|
397 |
// the bounds of the window to avoid the Dock or remain on screen. |
|
398 |
[AWTToolkit eventCountPlusPlus]; |
|
399 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
400 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
401 |
if (platformWindow == NULL) { |
|
402 |
// TODO: create generic AWT assert |
|
403 |
} |
|
404 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
405 |
NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); |
12047 | 406 |
|
407 |
static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V"); |
|
408 |
JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent, |
|
409 |
(jint)frame.origin.x, |
|
410 |
(jint)frame.origin.y, |
|
411 |
(jint)frame.size.width, |
|
412 |
(jint)frame.size.height); |
|
413 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
414 |
} |
|
415 |
||
416 |
- (void)windowDidMove:(NSNotification *)notification { |
|
417 |
AWT_ASSERT_APPKIT_THREAD; |
|
418 |
||
419 |
[self _deliverMoveResizeEvent]; |
|
420 |
} |
|
421 |
||
422 |
- (void)windowDidResize:(NSNotification *)notification { |
|
423 |
AWT_ASSERT_APPKIT_THREAD; |
|
424 |
||
425 |
[self _deliverMoveResizeEvent]; |
|
426 |
} |
|
427 |
||
428 |
- (void)windowDidExpose:(NSNotification *)notification { |
|
429 |
AWT_ASSERT_APPKIT_THREAD; |
|
430 |
||
431 |
[AWTToolkit eventCountPlusPlus]; |
|
432 |
// TODO: don't see this callback invoked anytime so we track |
|
433 |
// window exposing in _setVisible:(BOOL) |
|
434 |
} |
|
435 |
||
436 |
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)proposedFrame { |
|
437 |
AWT_ASSERT_APPKIT_THREAD; |
|
438 |
||
439 |
[AWTToolkit eventCountPlusPlus]; |
|
440 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
441 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
442 |
if (platformWindow != NULL) { |
|
443 |
static JNF_MEMBER_CACHE(jm_deliverZoom, jc_CPlatformWindow, "deliverZoom", "(Z)V"); |
|
444 |
JNFCallVoidMethod(env, platformWindow, jm_deliverZoom, ![window isZoomed]); |
|
445 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
446 |
} |
|
447 |
return YES; |
|
448 |
} |
|
449 |
||
450 |
- (void) _deliverIconify:(BOOL)iconify { |
|
451 |
AWT_ASSERT_APPKIT_THREAD; |
|
452 |
||
453 |
[AWTToolkit eventCountPlusPlus]; |
|
454 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
455 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
456 |
if (platformWindow != NULL) { |
|
457 |
static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V"); |
|
458 |
JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify); |
|
459 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
460 |
} |
|
461 |
} |
|
462 |
||
463 |
- (void)windowDidMiniaturize:(NSNotification *)notification { |
|
464 |
AWT_ASSERT_APPKIT_THREAD; |
|
465 |
||
466 |
[self _deliverIconify:JNI_TRUE]; |
|
467 |
} |
|
468 |
||
469 |
- (void)windowDidDeminiaturize:(NSNotification *)notification { |
|
470 |
AWT_ASSERT_APPKIT_THREAD; |
|
471 |
||
472 |
[self _deliverIconify:JNI_FALSE]; |
|
473 |
} |
|
474 |
||
475 |
- (void) _deliverWindowFocusEvent:(BOOL)focused { |
|
476 |
//AWT_ASSERT_APPKIT_THREAD; |
|
477 |
||
478 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
|
479 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
480 |
if (platformWindow != NULL) { |
|
481 |
static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(Z)V"); |
|
482 |
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused); |
|
483 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
484 |
} |
|
485 |
} |
|
486 |
||
487 |
||
488 |
- (void) windowDidBecomeKey: (NSNotification *) notification { |
|
489 |
AWT_ASSERT_APPKIT_THREAD; |
|
490 |
[AWTToolkit eventCountPlusPlus]; |
|
491 |
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO]; |
|
492 |
[self _deliverWindowFocusEvent:YES]; |
|
493 |
} |
|
494 |
||
495 |
- (void) windowDidResignKey: (NSNotification *) notification { |
|
496 |
// TODO: check why sometimes at start is invoked *not* on AppKit main thread. |
|
497 |
AWT_ASSERT_APPKIT_THREAD; |
|
498 |
[AWTToolkit eventCountPlusPlus]; |
|
499 |
[self.javaMenuBar deactivate]; |
|
500 |
[self _deliverWindowFocusEvent:NO]; |
|
501 |
} |
|
502 |
||
503 |
- (void) windowDidBecomeMain: (NSNotification *) notification { |
|
504 |
AWT_ASSERT_APPKIT_THREAD; |
|
505 |
[AWTToolkit eventCountPlusPlus]; |
|
506 |
||
507 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
508 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
509 |
if (platformWindow != NULL) { |
|
510 |
static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V"); |
|
511 |
JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain); |
|
512 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
513 |
} |
|
514 |
} |
|
515 |
||
516 |
- (BOOL)windowShouldClose:(id)sender { |
|
517 |
AWT_ASSERT_APPKIT_THREAD; |
|
518 |
[AWTToolkit eventCountPlusPlus]; |
|
519 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
520 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
521 |
if (platformWindow != NULL) { |
|
522 |
static JNF_MEMBER_CACHE(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V"); |
|
523 |
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowClosingEvent); |
|
524 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
525 |
} |
|
526 |
// The window will be closed (if allowed) as result of sending Java event |
|
527 |
return NO; |
|
528 |
} |
|
529 |
||
530 |
||
531 |
- (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env { |
|
532 |
static JNF_CLASS_CACHE(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler"); |
|
533 |
static JNF_STATIC_MEMBER_CACHE(jm_notifyFullScreenOperation, jc_FullScreenHandler, "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V"); |
|
534 |
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); |
|
535 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
536 |
if (platformWindow != NULL) { |
|
537 |
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); |
|
538 |
if (awtWindow != NULL) { |
|
539 |
JNFCallStaticVoidMethod(env, jm_notifyFullScreenOperation, awtWindow, op); |
|
540 |
(*env)->DeleteLocalRef(env, awtWindow); |
|
541 |
} |
|
542 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
543 |
} |
|
544 |
} |
|
545 |
||
546 |
||
547 |
- (void)windowWillEnterFullScreen:(NSNotification *)notification { |
|
548 |
static JNF_MEMBER_CACHE(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V"); |
|
549 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
550 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
551 |
if (platformWindow != NULL) { |
|
552 |
JNFCallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen); |
|
553 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env]; |
|
554 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
555 |
} |
|
556 |
} |
|
557 |
||
558 |
- (void)windowDidEnterFullScreen:(NSNotification *)notification { |
|
559 |
static JNF_MEMBER_CACHE(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V"); |
|
560 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
561 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
562 |
if (platformWindow != NULL) { |
|
563 |
JNFCallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen); |
|
564 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env]; |
|
565 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
566 |
} |
|
567 |
} |
|
568 |
||
569 |
- (void)windowWillExitFullScreen:(NSNotification *)notification { |
|
570 |
static JNF_MEMBER_CACHE(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V"); |
|
571 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
572 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
573 |
if (platformWindow != NULL) { |
|
574 |
JNFCallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen); |
|
575 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env]; |
|
576 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
- (void)windowDidExitFullScreen:(NSNotification *)notification { |
|
581 |
static JNF_MEMBER_CACHE(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V"); |
|
582 |
JNIEnv *env = [ThreadUtilities getJNIEnv]; |
|
583 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
584 |
if (platformWindow != NULL) { |
|
585 |
JNFCallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen); |
|
586 |
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env]; |
|
587 |
(*env)->DeleteLocalRef(env, platformWindow); |
|
588 |
} |
|
589 |
} |
|
590 |
||
591 |
- (void)sendEvent:(NSEvent *)event { |
|
592 |
if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) { |
|
593 |
||
594 |
NSPoint p = [NSEvent mouseLocation]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
595 |
NSRect frame = [self.nsWindow frame]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
596 |
NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame]; |
12047 | 597 |
|
598 |
// Check if the click happened in the non-client area (title bar) |
|
599 |
if (p.y >= (frame.origin.y + contentRect.size.height)) { |
|
600 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
|
601 |
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; |
|
602 |
// Currently, no need to deliver the whole NSEvent. |
|
603 |
static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); |
|
604 |
JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); |
|
605 |
} |
|
606 |
} |
|
607 |
} |
|
12402
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
608 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
609 |
- (void)constrainSize:(NSSize*)size { |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
610 |
float minWidth = 0.f, minHeight = 0.f; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
611 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
612 |
if (IS(self.styleBits, DECORATED)) { |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
613 |
NSRect frame = [self.nsWindow frame]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
614 |
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
|
615 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
616 |
float top = frame.size.height - contentRect.size.height; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
617 |
float left = contentRect.origin.x - frame.origin.x; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
618 |
float bottom = contentRect.origin.y - frame.origin.y; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
619 |
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
|
620 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
621 |
// Speculative estimation: 80 - enough for window decorations controls |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
622 |
minWidth += left + right + 80; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
623 |
minHeight += top + bottom; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
624 |
} |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
625 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
626 |
minWidth = MAX(1.f, minWidth); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
627 |
minHeight = MAX(1.f, minHeight); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
628 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
629 |
size->width = MAX(size->width, minWidth); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
630 |
size->height = MAX(size->height, minHeight); |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
631 |
} |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
632 |
|
12640 | 633 |
- (void) setEnabled: (BOOL)flag { |
634 |
self.isEnabled = flag; |
|
635 |
||
636 |
if (IS(self.styleBits, CLOSEABLE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
637 |
[[self.nsWindow standardWindowButton:NSWindowCloseButton] setEnabled: flag]; |
12640 | 638 |
} |
639 |
||
640 |
if (IS(self.styleBits, MINIMIZABLE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
641 |
[[self.nsWindow standardWindowButton:NSWindowMiniaturizeButton] setEnabled: flag]; |
12640 | 642 |
} |
643 |
||
644 |
if (IS(self.styleBits, ZOOMABLE)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
645 |
[[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled: flag]; |
12640 | 646 |
} |
647 |
||
648 |
if (IS(self.styleBits, RESIZABLE)) { |
|
649 |
[self updateMinMaxSize:flag]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
650 |
[self.nsWindow setShowsResizeIndicator:flag]; |
12640 | 651 |
} |
652 |
} |
|
653 |
||
12047 | 654 |
@end // AWTWindow |
655 |
||
656 |
||
657 |
/* |
|
658 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
659 |
* Method: nativeCreateNSWindow |
|
660 |
* Signature: (JJIIII)J |
|
661 |
*/ |
|
662 |
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow |
|
663 |
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h) |
|
664 |
{ |
|
665 |
__block AWTWindow *window = nil; |
|
666 |
||
667 |
JNF_COCOA_ENTER(env); |
|
668 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
669 |
||
670 |
JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env]; |
|
671 |
NSView *contentView = OBJC(contentViewPtr); |
|
672 |
NSRect frameRect = NSMakeRect(x, y, w, h); |
|
673 |
||
674 |
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ |
|
675 |
AWT_ASSERT_APPKIT_THREAD; |
|
676 |
||
677 |
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow |
|
678 |
styleBits:styleBits |
|
679 |
frameRect:frameRect |
|
680 |
contentView:contentView]; |
|
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
681 |
// the window is released is CPlatformWindow.nativeDispose() |
12047 | 682 |
|
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
683 |
if (window) CFRetain(window.nsWindow); |
12047 | 684 |
}]; |
685 |
||
686 |
JNF_COCOA_EXIT(env); |
|
687 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
688 |
return ptr_to_jlong(window ? window.nsWindow : nil); |
12047 | 689 |
} |
690 |
||
691 |
/* |
|
692 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
693 |
* Method: nativeSetNSWindowStyleBits |
|
694 |
* Signature: (JII)V |
|
695 |
*/ |
|
696 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStyleBits |
|
697 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits) |
|
698 |
{ |
|
699 |
JNF_COCOA_ENTER(env); |
|
700 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
701 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
702 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 703 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
704 |
AWT_ASSERT_APPKIT_THREAD; |
|
705 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
706 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
707 |
|
12047 | 708 |
// scans the bit field, and only updates the values requested by the mask |
709 |
// (this implicity handles the _CALLBACK_PROP_BITMASK case, since those are passive reads) |
|
710 |
jint newBits = window.styleBits & ~mask | bits & mask; |
|
711 |
||
712 |
// resets the NSWindow's style mask if the mask intersects any of those bits |
|
713 |
if (mask & MASK(_STYLE_PROP_BITMASK)) { |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
714 |
[nsWindow setStyleMask:[AWTWindow styleMaskForStyleBits:newBits]]; |
12047 | 715 |
} |
716 |
||
717 |
// calls methods on NSWindow to change other properties, based on the mask |
|
718 |
if (mask & MASK(_METHOD_PROP_BITMASK)) { |
|
719 |
[window setPropertiesForStyleBits:bits mask:mask]; |
|
720 |
} |
|
721 |
||
722 |
window.styleBits = newBits; |
|
723 |
}]; |
|
724 |
||
725 |
JNF_COCOA_EXIT(env); |
|
726 |
} |
|
727 |
||
728 |
/* |
|
729 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
730 |
* Method: nativeSetNSWindowMenuBar |
|
731 |
* Signature: (JJ)V |
|
732 |
*/ |
|
733 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMenuBar |
|
734 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jlong menuBarPtr) |
|
735 |
{ |
|
736 |
JNF_COCOA_ENTER(env); |
|
737 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
738 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
739 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 740 |
CMenuBar *menuBar = OBJC(menuBarPtr); |
741 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
742 |
AWT_ASSERT_APPKIT_THREAD; |
|
743 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
744 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
745 |
|
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
746 |
if ([nsWindow isKeyWindow]) [window.javaMenuBar deactivate]; |
12047 | 747 |
window.javaMenuBar = menuBar; |
748 |
||
749 |
// if ([self isKeyWindow]) { |
|
750 |
[CMenuBar activate:window.javaMenuBar modallyDisabled:NO]; |
|
751 |
// } |
|
752 |
}]; |
|
753 |
||
754 |
JNF_COCOA_EXIT(env); |
|
755 |
} |
|
756 |
||
757 |
/* |
|
758 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
759 |
* Method: nativeGetNSWindowInsets |
|
760 |
* Signature: (J)Ljava/awt/Insets; |
|
761 |
*/ |
|
762 |
JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets |
|
763 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
764 |
{ |
|
765 |
jobject ret = NULL; |
|
766 |
||
767 |
JNF_COCOA_ENTER(env); |
|
768 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
769 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
770 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 771 |
__block NSRect contentRect = NSZeroRect; |
772 |
__block NSRect frame = NSZeroRect; |
|
773 |
||
774 |
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ |
|
775 |
AWT_ASSERT_APPKIT_THREAD; |
|
776 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
777 |
frame = [nsWindow frame]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
778 |
contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]]; |
12047 | 779 |
}]; |
780 |
||
781 |
jint top = (jint)(frame.size.height - contentRect.size.height); |
|
782 |
jint left = (jint)(contentRect.origin.x - frame.origin.x); |
|
783 |
jint bottom = (jint)(contentRect.origin.y - frame.origin.y); |
|
784 |
jint right = (jint)(frame.size.width - (contentRect.size.width + left)); |
|
785 |
||
786 |
static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets"); |
|
787 |
static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V"); |
|
788 |
ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right); |
|
789 |
||
790 |
JNF_COCOA_EXIT(env); |
|
791 |
return ret; |
|
792 |
} |
|
793 |
||
794 |
/* |
|
795 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
796 |
* Method: nativeSetNSWindowBounds |
|
797 |
* Signature: (JDDDD)V |
|
798 |
*/ |
|
799 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds |
|
800 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height) |
|
801 |
{ |
|
802 |
JNF_COCOA_ENTER(env); |
|
803 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
804 |
||
805 |
NSRect jrect = NSMakeRect(originX, originY, width, height); |
|
806 |
||
807 |
// 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
|
808 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 809 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
810 |
AWT_ASSERT_APPKIT_THREAD; |
|
811 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
812 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
813 |
|
12047 | 814 |
NSRect rect = ConvertNSScreenRect(NULL, jrect); |
12402
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
815 |
[window constrainSize:&rect.size]; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
816 |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
817 |
[nsWindow setFrame:rect display:YES]; |
12047 | 818 |
|
819 |
// only start tracking events if pointer is above the toplevel |
|
820 |
// TODO: should post an Entered event if YES. |
|
821 |
NSPoint mLocation = [NSEvent mouseLocation]; |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
822 |
[nsWindow setAcceptsMouseMovedEvents:NSPointInRect(mLocation, rect)]; |
12047 | 823 |
|
824 |
// ensure we repaint the whole window after the resize operation |
|
825 |
// (this will also re-enable screen updates, which were disabled above) |
|
826 |
// TODO: send PaintEvent |
|
12640 | 827 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
828 |
[window synthesizeMouseEnteredExitedEvents]; |
12047 | 829 |
}]; |
830 |
||
831 |
JNF_COCOA_EXIT(env); |
|
832 |
} |
|
833 |
||
834 |
/* |
|
835 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
836 |
* Method: nativeSetNSWindowMinMax |
|
837 |
* Signature: (JDDDD)V |
|
838 |
*/ |
|
839 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax |
|
840 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH) |
|
841 |
{ |
|
842 |
JNF_COCOA_ENTER(env); |
|
843 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
844 |
||
845 |
if (minW < 1) minW = 1; |
|
846 |
if (minH < 1) minH = 1; |
|
847 |
if (maxW < 1) maxW = 1; |
|
848 |
if (maxH < 1) maxH = 1; |
|
849 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
850 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 851 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
852 |
AWT_ASSERT_APPKIT_THREAD; |
|
853 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
854 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
855 |
|
12402
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
856 |
NSSize min = { minW, minH }; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
857 |
NSSize max = { maxW, maxH }; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
858 |
|
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
859 |
[window constrainSize:&min]; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
860 |
[window constrainSize:&max]; |
f3903de3fd9e
7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents:
12177
diff
changeset
|
861 |
|
12047 | 862 |
window.javaMinSize = min; |
863 |
window.javaMaxSize = max; |
|
864 |
[window updateMinMaxSize:IS(window.styleBits, RESIZABLE)]; |
|
865 |
}]; |
|
866 |
||
867 |
JNF_COCOA_EXIT(env); |
|
868 |
} |
|
869 |
||
870 |
/* |
|
871 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
872 |
* Method: nativePushNSWindowToBack |
|
873 |
* Signature: (J)V |
|
874 |
*/ |
|
875 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToBack |
|
876 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
877 |
{ |
|
878 |
JNF_COCOA_ENTER(env); |
|
879 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
880 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
881 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 882 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
883 |
AWT_ASSERT_APPKIT_THREAD; |
|
884 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
885 |
[nsWindow orderBack:nil]; |
12047 | 886 |
}]; |
887 |
||
888 |
JNF_COCOA_EXIT(env); |
|
889 |
} |
|
890 |
||
891 |
/* |
|
892 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
893 |
* Method: nativePushNSWindowToFront |
|
894 |
* Signature: (J)V |
|
895 |
*/ |
|
896 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToFront |
|
897 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
898 |
{ |
|
899 |
JNF_COCOA_ENTER(env); |
|
900 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
901 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
902 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 903 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
904 |
AWT_ASSERT_APPKIT_THREAD; |
|
905 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
906 |
if (![nsWindow isKeyWindow]) { |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
907 |
[nsWindow makeKeyAndOrderFront:nsWindow]; |
12047 | 908 |
} else { |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
909 |
[nsWindow orderFront:nsWindow]; |
12047 | 910 |
} |
911 |
}]; |
|
912 |
||
913 |
JNF_COCOA_EXIT(env); |
|
914 |
} |
|
915 |
||
916 |
/* |
|
917 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
918 |
* Method: nativeSetNSWindowTitle |
|
919 |
* Signature: (JLjava/lang/String;)V |
|
920 |
*/ |
|
921 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowTitle |
|
922 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jstring jtitle) |
|
923 |
{ |
|
924 |
JNF_COCOA_ENTER(env); |
|
925 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
926 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
927 |
NSWindow *nsWindow = OBJC(windowPtr); |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
928 |
[nsWindow performSelectorOnMainThread:@selector(setTitle:) |
12047 | 929 |
withObject:JNFJavaToNSString(env, jtitle) |
930 |
waitUntilDone:NO]; |
|
931 |
||
932 |
JNF_COCOA_EXIT(env); |
|
933 |
} |
|
934 |
||
935 |
/* |
|
936 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
937 |
* Method: nativeRevalidateNSWindowShadow |
|
938 |
* Signature: (J)V |
|
939 |
*/ |
|
940 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeRevalidateNSWindowShadow |
|
941 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
942 |
{ |
|
943 |
JNF_COCOA_ENTER(env); |
|
944 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
945 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
946 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 947 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
948 |
AWT_ASSERT_APPKIT_THREAD; |
|
949 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
950 |
[nsWindow invalidateShadow]; |
12047 | 951 |
}]; |
952 |
||
953 |
JNF_COCOA_EXIT(env); |
|
954 |
} |
|
955 |
||
956 |
/* |
|
957 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
958 |
* Method: nativeScreenOn_AppKitThread |
|
959 |
* Signature: (J)I |
|
960 |
*/ |
|
961 |
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeScreenOn_1AppKitThread |
|
962 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
963 |
{ |
|
964 |
jint ret = 0; |
|
965 |
||
966 |
JNF_COCOA_ENTER(env); |
|
967 |
AWT_ASSERT_APPKIT_THREAD; |
|
968 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
969 |
NSWindow *nsWindow = OBJC(windowPtr); |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
970 |
NSDictionary *props = [[nsWindow screen] deviceDescription]; |
12047 | 971 |
ret = [[props objectForKey:@"NSScreenNumber"] intValue]; |
972 |
||
973 |
JNF_COCOA_EXIT(env); |
|
974 |
||
975 |
return ret; |
|
976 |
} |
|
977 |
||
978 |
/* |
|
979 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
980 |
* Method: nativeSetNSWindowMinimizedIcon |
|
981 |
* Signature: (JJ)V |
|
982 |
*/ |
|
983 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinimizedIcon |
|
984 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jlong nsImagePtr) |
|
985 |
{ |
|
986 |
JNF_COCOA_ENTER(env); |
|
987 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
988 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
989 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 990 |
NSImage *image = OBJC(nsImagePtr); |
991 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
992 |
AWT_ASSERT_APPKIT_THREAD; |
|
993 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
994 |
[nsWindow setMiniwindowImage:image]; |
12047 | 995 |
}]; |
996 |
||
997 |
JNF_COCOA_EXIT(env); |
|
998 |
} |
|
999 |
||
1000 |
/* |
|
1001 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
1002 |
* Method: nativeSetNSWindowRepresentedFilename |
|
1003 |
* Signature: (JLjava/lang/String;)V |
|
1004 |
*/ |
|
1005 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowRepresentedFilename |
|
1006 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jstring filename) |
|
1007 |
{ |
|
1008 |
JNF_COCOA_ENTER(env); |
|
1009 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
1010 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1011 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 1012 |
NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)]; |
1013 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
1014 |
AWT_ASSERT_APPKIT_THREAD; |
|
1015 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1016 |
[nsWindow setRepresentedURL:url]; |
12047 | 1017 |
}]; |
1018 |
||
1019 |
JNF_COCOA_EXIT(env); |
|
1020 |
} |
|
1021 |
||
1022 |
/* |
|
1023 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
1024 |
* Method: nativeSetNSWindowSecurityWarningPositioning |
|
1025 |
* Signature: (JDDFF)V |
|
1026 |
*/ |
|
1027 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowSecurityWarningPositioning |
|
1028 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble x, jdouble y, jfloat biasX, jfloat biasY) |
|
1029 |
{ |
|
1030 |
JNF_COCOA_ENTER(env); |
|
1031 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
1032 |
||
1033 |
[JNFException raise:env as:kRuntimeException reason:"unimplemented"]; |
|
1034 |
||
1035 |
JNF_COCOA_EXIT(env); |
|
1036 |
} |
|
1037 |
||
1038 |
/* |
|
1039 |
* 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
|
1040 |
* Method: nativeSynthesizeMouseEnteredExitedEvents |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1041 |
* Signature: (J)V |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1042 |
*/ |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1043 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1044 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1045 |
{ |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1046 |
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
|
1047 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
12640 | 1048 |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1049 |
NSWindow *nsWindow = OBJC(windowPtr); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1050 |
[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
|
1051 |
AWT_ASSERT_APPKIT_THREAD; |
12640 | 1052 |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1053 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1054 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1055 |
[window synthesizeMouseEnteredExitedEvents]; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1056 |
}]; |
12640 | 1057 |
|
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1058 |
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
|
1059 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1060 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1061 |
/* |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12402
diff
changeset
|
1062 |
* Class: sun_lwawt_macosx_CPlatformWindow |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1063 |
* Method: nativeGetDisplayID_AppKitThread |
12047 | 1064 |
* Signature: (J)I |
1065 |
*/ |
|
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1066 |
JNIEXPORT jint JNICALL |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1067 |
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID_1AppKitThread |
12047 | 1068 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
1069 |
{ |
|
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1070 |
jint ret; // CGDirectDisplayID |
12047 | 1071 |
|
1072 |
JNF_COCOA_ENTER(env); |
|
1073 |
AWT_ASSERT_APPKIT_THREAD; |
|
1074 |
||
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1075 |
NSWindow *window = OBJC(windowPtr); |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1076 |
NSScreen *screen = [window screen]; |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1077 |
NSDictionary *deviceDescription = [screen deviceDescription]; |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1078 |
NSNumber *displayID = [deviceDescription objectForKey:@"NSScreenNumber"]; |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1079 |
ret = (jint)[displayID intValue]; |
12047 | 1080 |
|
1081 |
JNF_COCOA_EXIT(env); |
|
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1082 |
|
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12648
diff
changeset
|
1083 |
return ret; |
12047 | 1084 |
} |
1085 |
||
1086 |
/* |
|
1087 |
* Class: sun_lwawt_macosx_CPlatformWindow |
|
1088 |
* Method: _toggleFullScreenMode |
|
1089 |
* Signature: (J)V |
|
1090 |
*/ |
|
1091 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow__1toggleFullScreenMode |
|
1092 |
(JNIEnv *env, jobject peer, jlong windowPtr) |
|
1093 |
{ |
|
1094 |
JNF_COCOA_ENTER(env); |
|
1095 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1096 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 1097 |
SEL toggleFullScreenSelector = @selector(toggleFullScreen:); |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1098 |
if (![nsWindow respondsToSelector:toggleFullScreenSelector]) return; |
12047 | 1099 |
|
1100 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
|
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1101 |
[nsWindow performSelector:toggleFullScreenSelector withObject:nil]; |
12047 | 1102 |
}]; |
1103 |
||
1104 |
JNF_COCOA_EXIT(env); |
|
1105 |
} |
|
1106 |
||
1107 |
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CMouseInfoPeer_nativeIsWindowUnderMouse |
|
1108 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
|
1109 |
{ |
|
1110 |
__block jboolean underMouse = JNI_FALSE; |
|
1111 |
||
1112 |
JNF_COCOA_ENTER(env); |
|
1113 |
AWT_ASSERT_NOT_APPKIT_THREAD; |
|
1114 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1115 |
NSWindow *nsWindow = OBJC(windowPtr); |
12047 | 1116 |
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^() { |
1117 |
AWT_ASSERT_APPKIT_THREAD; |
|
1118 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1119 |
NSPoint pt = [nsWindow mouseLocationOutsideOfEventStream]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1120 |
underMouse = [[nsWindow contentView] hitTest:pt] != nil; |
12047 | 1121 |
}]; |
1122 |
||
1123 |
JNF_COCOA_EXIT(env); |
|
1124 |
||
1125 |
return underMouse; |
|
1126 |
} |
|
12640 | 1127 |
|
1128 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetEnabled |
|
1129 |
(JNIEnv *env, jclass clazz, jlong windowPtr, jboolean isEnabled) |
|
1130 |
{ |
|
1131 |
JNF_COCOA_ENTER(env); |
|
1132 |
||
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1133 |
NSWindow *nsWindow = OBJC(windowPtr); |
12640 | 1134 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
12648
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1135 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
00c38c393e11
7149062: [macosx] dock menu don't show available frames
anthony
parents:
12640
diff
changeset
|
1136 |
|
12640 | 1137 |
[window setEnabled: isEnabled]; |
1138 |
}]; |
|
1139 |
||
1140 |
JNF_COCOA_EXIT(env); |
|
1141 |
} |
|
1142 |
||
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1143 |
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeDispose |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1144 |
(JNIEnv *env, jclass clazz, jlong windowPtr) |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1145 |
{ |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1146 |
JNF_COCOA_ENTER(env); |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1147 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1148 |
NSWindow *nsWindow = OBJC(windowPtr); |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1149 |
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1150 |
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1151 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1152 |
// 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
|
1153 |
// property. Unsetting the delegate allows it to be deallocated |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1154 |
// 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
|
1155 |
// itself be deallocated. |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1156 |
[nsWindow setDelegate: nil]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1157 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1158 |
[window release]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1159 |
}]; |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1160 |
|
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1161 |
JNF_COCOA_EXIT(env); |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1162 |
} |
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
1163 |