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