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