0N/A/*
2362N/A * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage sun.awt.X11;
0N/A
0N/Aimport java.util.*;
0N/Aimport java.awt.*;
0N/Aimport java.awt.peer.*;
0N/Aimport java.awt.event.*;
1976N/Aimport sun.awt.AWTAccessor;
0N/A
0N/Aimport sun.awt.*;
0N/A
0N/Aclass XDialogPeer extends XDecoratedPeer implements DialogPeer {
0N/A
0N/A private Boolean undecorated;
0N/A
0N/A XDialogPeer(Dialog target) {
0N/A super(target);
0N/A }
0N/A
0N/A public void preInit(XCreateWindowParams params) {
0N/A super.preInit(params);
0N/A
0N/A Dialog target = (Dialog)(this.target);
0N/A undecorated = Boolean.valueOf(target.isUndecorated());
0N/A winAttr.nativeDecor = !target.isUndecorated();
0N/A if (winAttr.nativeDecor) {
0N/A winAttr.decorations = winAttr.AWT_DECOR_ALL;
0N/A } else {
0N/A winAttr.decorations = winAttr.AWT_DECOR_NONE;
0N/A }
216N/A winAttr.functions = MWMConstants.MWM_FUNC_ALL;
0N/A winAttr.isResizable = true; //target.isResizable();
0N/A winAttr.initialResizability = target.isResizable();
0N/A winAttr.title = target.getTitle();
0N/A winAttr.initialState = XWindowAttributesData.NORMAL;
0N/A }
0N/A
0N/A public void setVisible(boolean vis) {
0N/A XToolkit.awtLock();
0N/A try {
0N/A Dialog target = (Dialog)this.target;
0N/A if (vis) {
0N/A if (target.getModalityType() != Dialog.ModalityType.MODELESS) {
0N/A if (!isModalBlocked()) {
0N/A XBaseWindow.ungrabInput();
0N/A }
0N/A }
0N/A } else {
0N/A restoreTransientFor(this);
0N/A prevTransientFor = null;
0N/A nextTransientFor = null;
0N/A }
0N/A } finally {
0N/A XToolkit.awtUnlock();
0N/A }
0N/A
0N/A super.setVisible(vis);
0N/A }
0N/A
106N/A @Override
106N/A boolean isTargetUndecorated() {
0N/A if (undecorated != null) {
0N/A return undecorated.booleanValue();
0N/A } else {
0N/A return ((Dialog)target).isUndecorated();
0N/A }
0N/A }
0N/A
0N/A int getDecorations() {
0N/A int d = super.getDecorations();
0N/A // remove minimize and maximize buttons for dialogs
216N/A if ((d & MWMConstants.MWM_DECOR_ALL) != 0) {
216N/A d |= (MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE);
0N/A } else {
216N/A d &= ~(MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE);
0N/A }
0N/A return d;
0N/A }
0N/A
0N/A int getFunctions() {
0N/A int f = super.getFunctions();
0N/A // remove minimize and maximize functions for dialogs
216N/A if ((f & MWMConstants.MWM_FUNC_ALL) != 0) {
216N/A f |= (MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
0N/A } else {
216N/A f &= ~(MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
0N/A }
0N/A return f;
0N/A }
0N/A
0N/A public void blockWindows(java.util.List<Window> toBlock) {
0N/A Vector<XWindowPeer> javaToplevels = null;
0N/A XToolkit.awtLock();
0N/A try {
0N/A javaToplevels = XWindowPeer.collectJavaToplevels();
0N/A for (Window w : toBlock) {
1976N/A XWindowPeer wp = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
0N/A if (wp != null) {
0N/A wp.setModalBlocked((Dialog)target, true, javaToplevels);
0N/A }
0N/A }
0N/A } finally {
0N/A XToolkit.awtUnlock();
0N/A }
0N/A }
0N/A
0N/A /*
0N/A * WARNING: don't call client code in this method!
0N/A *
0N/A * The check is performed before the dialog is shown.
0N/A * The focused window can't be blocked at the time it's focused.
0N/A * Thus we don't have to perform any transitive (a blocker of a blocker) checks.
0N/A */
0N/A boolean isFocusedWindowModalBlocker() {
5336N/A Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
0N/A XWindowPeer focusedWindowPeer = null;
0N/A
0N/A if (focusedWindow != null) {
1976N/A focusedWindowPeer = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(focusedWindow);
0N/A } else {
0N/A /*
0N/A * For the case when a potential blocked window is not yet focused
0N/A * on the Java level (e.g. it's just been mapped) we're asking for the
0N/A * focused window on the native level.
0N/A */
0N/A focusedWindowPeer = getNativeFocusedWindowPeer();
0N/A }
0N/A synchronized (getStateLock()) {
0N/A if (focusedWindowPeer != null && focusedWindowPeer.modalBlocker == target) {
0N/A return true;
0N/A }
0N/A }
0N/A return super.isFocusedWindowModalBlocker();
0N/A }
0N/A}