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 23 * questions. 24 */ 25 26 27 package sun.lwawt.macosx; 28 29 import java.awt.AWTKeyStroke; 30 import java.awt.Point; 31 import java.awt.Toolkit; 32 33 import sun.awt.EmbeddedFrame; 34 import sun.lwawt.LWWindowPeer; 35 36 @SuppressWarnings("serial") // JDK implementation class 37 public class CEmbeddedFrame extends EmbeddedFrame { 38 39 private CPlatformResponder responder; 40 private static final Object classLock = new Object(); 41 private static volatile CEmbeddedFrame globalFocusedWindow; 42 private CEmbeddedFrame browserWindowFocusedApplet; 43 private boolean parentWindowActive = true; 44 45 public CEmbeddedFrame() { 46 show(); 47 } 48 49 @SuppressWarnings("deprecation") 50 public void addNotify() { 51 if (getPeer() == null) { 52 LWCToolkit toolkit = (LWCToolkit)Toolkit.getDefaultToolkit(); 53 LWWindowPeer peer = toolkit.createEmbeddedFrame(this); 54 setPeer(peer); 55 responder = new CPlatformResponder(peer, true); 56 } 57 super.addNotify(); 58 } 59 60 public void registerAccelerator(AWTKeyStroke stroke) {} 61 62 public void unregisterAccelerator(AWTKeyStroke stroke) {} 63 64 @SuppressWarnings("deprecation") 65 protected long getLayerPtr() { 66 LWWindowPeer peer = (LWWindowPeer)getPeer(); 67 return peer.getLayerPtr(); 68 } 69 70 // ----------------------------------------------------------------------- 71 // SYNTHETIC EVENT DELIVERY 72 // ----------------------------------------------------------------------- 73 74 public void handleMouseEvent(int eventType, int modifierFlags, double pluginX, 75 double pluginY, int buttonNumber, int clickCount) { 76 int x = (int)pluginX; 77 int y = (int)pluginY; 78 Point locationOnScreen = getLocationOnScreen(); 79 int screenX = locationOnScreen.x + x; 80 int screenY = locationOnScreen.y + y; 81 82 if (eventType == CocoaConstants.NPCocoaEventMouseEntered) { 83 CCursorManager.nativeSetAllowsCursorSetInBackground(true); 84 } else if (eventType == CocoaConstants.NPCocoaEventMouseExited) { 85 CCursorManager.nativeSetAllowsCursorSetInBackground(false); 86 } 87 | 1 /* 2 * Copyright (c) 2011, 2015, 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 23 * questions. 24 */ 25 26 27 package sun.lwawt.macosx; 28 29 import java.awt.AWTKeyStroke; 30 import java.awt.Point; 31 import java.awt.Toolkit; 32 33 import sun.awt.AWTAccessor; 34 import sun.awt.EmbeddedFrame; 35 import sun.lwawt.LWWindowPeer; 36 37 @SuppressWarnings("serial") // JDK implementation class 38 public class CEmbeddedFrame extends EmbeddedFrame { 39 40 private CPlatformResponder responder; 41 private static final Object classLock = new Object(); 42 private static volatile CEmbeddedFrame globalFocusedWindow; 43 private CEmbeddedFrame browserWindowFocusedApplet; 44 private boolean parentWindowActive = true; 45 46 public CEmbeddedFrame() { 47 show(); 48 } 49 50 public void addNotify() { 51 if (!isDisplayable()) { 52 LWCToolkit toolkit = (LWCToolkit)Toolkit.getDefaultToolkit(); 53 LWWindowPeer peer = toolkit.createEmbeddedFrame(this); 54 setPeer(peer); 55 responder = new CPlatformResponder(peer, true); 56 } 57 super.addNotify(); 58 } 59 60 public void registerAccelerator(AWTKeyStroke stroke) {} 61 62 public void unregisterAccelerator(AWTKeyStroke stroke) {} 63 64 protected long getLayerPtr() { 65 return AWTAccessor.getComponentAccessor().<LWWindowPeer>getPeer(this) 66 .getLayerPtr(); 67 } 68 69 // ----------------------------------------------------------------------- 70 // SYNTHETIC EVENT DELIVERY 71 // ----------------------------------------------------------------------- 72 73 public void handleMouseEvent(int eventType, int modifierFlags, double pluginX, 74 double pluginY, int buttonNumber, int clickCount) { 75 int x = (int)pluginX; 76 int y = (int)pluginY; 77 Point locationOnScreen = getLocationOnScreen(); 78 int screenX = locationOnScreen.x + x; 79 int screenY = locationOnScreen.y + y; 80 81 if (eventType == CocoaConstants.NPCocoaEventMouseEntered) { 82 CCursorManager.nativeSetAllowsCursorSetInBackground(true); 83 } else if (eventType == CocoaConstants.NPCocoaEventMouseExited) { 84 CCursorManager.nativeSetAllowsCursorSetInBackground(false); 85 } 86 |