1 /*
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
235 contentView:view];
236 }
237 else
238 {
239 // These windows will appear in the window list in the dock icon menu
240 self.nsWindow = [[AWTWindow_Normal alloc] initWithDelegate:self
241 frameRect:contentRect
242 styleMask:styleMask
243 contentView:view];
244 }
245
246 if (self.nsWindow == nil) return nil; // no hope either
247 [self.nsWindow release]; // the property retains the object already
248
249 self.isEnabled = YES;
250 self.javaPlatformWindow = platformWindow;
251 self.styleBits = bits;
252 self.ownerWindow = owner;
253 [self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
254
255 return self;
256 }
257
258 + (BOOL) isAWTWindow:(NSWindow *)window {
259 return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
260 }
261
262 // returns id for the topmost window under mouse
263 + (NSInteger) getTopmostWindowUnderMouseID {
264 NSInteger result = -1;
265
266 NSRect screenRect = [[NSScreen mainScreen] frame];
267 NSPoint nsMouseLocation = [NSEvent mouseLocation];
268 CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
269
270 NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
271
272 for (NSDictionary *window in windows) {
273 NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
274 if (layer == 0) {
|
1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
235 contentView:view];
236 }
237 else
238 {
239 // These windows will appear in the window list in the dock icon menu
240 self.nsWindow = [[AWTWindow_Normal alloc] initWithDelegate:self
241 frameRect:contentRect
242 styleMask:styleMask
243 contentView:view];
244 }
245
246 if (self.nsWindow == nil) return nil; // no hope either
247 [self.nsWindow release]; // the property retains the object already
248
249 self.isEnabled = YES;
250 self.javaPlatformWindow = platformWindow;
251 self.styleBits = bits;
252 self.ownerWindow = owner;
253 [self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
254
255 if (IS(self.styleBits, IS_POPUP)) {
256 [self.nsWindow setCollectionBehavior:(1 << 8) /*NSWindowCollectionBehaviorFullScreenAuxiliary*/];
257 }
258
259 return self;
260 }
261
262 + (BOOL) isAWTWindow:(NSWindow *)window {
263 return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
264 }
265
266 // returns id for the topmost window under mouse
267 + (NSInteger) getTopmostWindowUnderMouseID {
268 NSInteger result = -1;
269
270 NSRect screenRect = [[NSScreen mainScreen] frame];
271 NSPoint nsMouseLocation = [NSEvent mouseLocation];
272 CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
273
274 NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
275
276 for (NSDictionary *window in windows) {
277 NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
278 if (layer == 0) {
|