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