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