Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java
32288 views
/*1* Copyright (c) 2002, 2012, 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*/24package sun.awt.X11;2526import java.util.*;27import java.awt.*;28import java.awt.peer.*;29import java.awt.event.*;30import sun.awt.AWTAccessor;3132import sun.awt.*;3334class XDialogPeer extends XDecoratedPeer implements DialogPeer {3536private Boolean undecorated;3738XDialogPeer(Dialog target) {39super(target);40}4142public void preInit(XCreateWindowParams params) {43super.preInit(params);4445Dialog target = (Dialog)(this.target);46undecorated = Boolean.valueOf(target.isUndecorated());47winAttr.nativeDecor = !target.isUndecorated();48if (winAttr.nativeDecor) {49winAttr.decorations = winAttr.AWT_DECOR_ALL;50} else {51winAttr.decorations = winAttr.AWT_DECOR_NONE;52}53winAttr.functions = MWMConstants.MWM_FUNC_ALL;54winAttr.isResizable = true; //target.isResizable();55winAttr.initialResizability = target.isResizable();56winAttr.title = target.getTitle();57winAttr.initialState = XWindowAttributesData.NORMAL;58}5960public void setVisible(boolean vis) {61XToolkit.awtLock();62try {63Dialog target = (Dialog)this.target;64if (vis) {65if (target.getModalityType() != Dialog.ModalityType.MODELESS) {66if (!isModalBlocked()) {67XBaseWindow.ungrabInput();68}69}70} else {71restoreTransientFor(this);72prevTransientFor = null;73nextTransientFor = null;74}75} finally {76XToolkit.awtUnlock();77}7879super.setVisible(vis);80}8182@Override83boolean isTargetUndecorated() {84if (undecorated != null) {85return undecorated.booleanValue();86} else {87return ((Dialog)target).isUndecorated();88}89}9091int getDecorations() {92int d = super.getDecorations();93// remove minimize and maximize buttons for dialogs94if ((d & MWMConstants.MWM_DECOR_ALL) != 0) {95d |= (MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE);96} else {97d &= ~(MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE);98}99return d;100}101102int getFunctions() {103int f = super.getFunctions();104// remove minimize and maximize functions for dialogs105if ((f & MWMConstants.MWM_FUNC_ALL) != 0) {106f |= (MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE);107} else {108f &= ~(MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE);109}110return f;111}112113public void blockWindows(java.util.List<Window> toBlock) {114Vector<XWindowPeer> javaToplevels = null;115XToolkit.awtLock();116try {117javaToplevels = XWindowPeer.collectJavaToplevels();118for (Window w : toBlock) {119XWindowPeer wp = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);120if (wp != null) {121wp.setModalBlocked((Dialog)target, true, javaToplevels);122}123}124} finally {125XToolkit.awtUnlock();126}127}128129/*130* WARNING: don't call client code in this method!131*132* The check is performed before the dialog is shown.133* The focused window can't be blocked at the time it's focused.134* Thus we don't have to perform any transitive (a blocker of a blocker) checks.135*/136boolean isFocusedWindowModalBlocker() {137Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();138XWindowPeer focusedWindowPeer = null;139140if (focusedWindow != null) {141focusedWindowPeer = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(focusedWindow);142} else {143/*144* For the case when a potential blocked window is not yet focused145* on the Java level (e.g. it's just been mapped) we're asking for the146* focused window on the native level.147*/148focusedWindowPeer = getNativeFocusedWindowPeer();149}150synchronized (getStateLock()) {151if (focusedWindowPeer != null && focusedWindowPeer.modalBlocker == target) {152return true;153}154}155return super.isFocusedWindowModalBlocker();156}157}158159160