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