Path: blob/master/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
41153 views
/*1* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.lwawt;2627import java.awt.Graphics;28import java.awt.Insets;29import java.awt.Point;30import java.awt.Rectangle;31import java.awt.Window;32import java.awt.dnd.DropTarget;33import java.awt.event.FocusEvent;3435import sun.awt.LightweightFrame;36import sun.awt.OverrideNativeWindowHandle;37import sun.swing.JLightweightFrame;38import sun.swing.SwingAccessor;3940public class LWLightweightFramePeer extends LWWindowPeer implements OverrideNativeWindowHandle {4142public LWLightweightFramePeer(LightweightFrame target,43PlatformComponent platformComponent,44PlatformWindow platformWindow)45{46super(target, platformComponent, platformWindow, LWWindowPeer.PeerType.LW_FRAME);47}4849private LightweightFrame getLwTarget() {50return (LightweightFrame)getTarget();51}5253@Override54public Graphics getGraphics() {55return getLwTarget().getGraphics();56}5758@Override59protected void setVisibleImpl(final boolean visible) {60}6162@Override63public boolean requestWindowFocus(FocusEvent.Cause cause) {64if (!focusAllowedFor()) {65return false;66}67if (getPlatformWindow().rejectFocusRequest(cause)) {68return false;69}7071Window opposite = LWKeyboardFocusManagerPeer.getInstance().72getCurrentFocusedWindow();7374changeFocusedWindow(true, opposite);7576return true;77}7879@Override80public Point getLocationOnScreen() {81Rectangle bounds = getBounds();82return new Point(bounds.x, bounds.y); // todo83}8485@Override86public Insets getInsets() {87return new Insets(0, 0, 0, 0);88}8990@Override91public void setBounds(int x, int y, int w, int h, int op) {92setBounds(x, y, w, h, op, true, true);93}9495@Override96public void addDropTarget(DropTarget dt) {97getLwTarget().addDropTarget(dt);98}99100@Override101public void removeDropTarget(DropTarget dt) {102getLwTarget().removeDropTarget(dt);103}104105@Override106public void grab() {107getLwTarget().grabFocus();108}109110@Override111public void ungrab() {112getLwTarget().ungrabFocus();113}114115@Override116public void updateCursorImmediately() {117SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget());118}119120// SwingNode121private volatile long overriddenWindowHandle = 0L;122123@Override124public void overrideWindowHandle(final long handle) {125this.overriddenWindowHandle = handle;126}127128public long getOverriddenWindowHandle() {129return overriddenWindowHandle;130}131}132133134