author | yan |
Mon, 06 Oct 2008 16:45:00 +0400 | |
changeset 1966 | 12a51fb0db0d |
parent 449 | 7820f232278d |
child 4371 | dc9dcb8b0ae7 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
2 |
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 | 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. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
package sun.awt.X11; |
|
26 |
||
27 |
import java.util.*; |
|
28 |
import java.awt.*; |
|
29 |
import java.awt.peer.*; |
|
30 |
import java.awt.event.*; |
|
31 |
import sun.awt.ComponentAccessor; |
|
32 |
||
33 |
import sun.awt.*; |
|
34 |
||
35 |
class XDialogPeer extends XDecoratedPeer implements DialogPeer { |
|
36 |
||
37 |
private Boolean undecorated; |
|
38 |
||
39 |
XDialogPeer(Dialog target) { |
|
40 |
super(target); |
|
41 |
} |
|
42 |
||
43 |
public void preInit(XCreateWindowParams params) { |
|
44 |
super.preInit(params); |
|
45 |
||
46 |
Dialog target = (Dialog)(this.target); |
|
47 |
undecorated = Boolean.valueOf(target.isUndecorated()); |
|
48 |
winAttr.nativeDecor = !target.isUndecorated(); |
|
49 |
if (winAttr.nativeDecor) { |
|
50 |
winAttr.decorations = winAttr.AWT_DECOR_ALL; |
|
51 |
} else { |
|
52 |
winAttr.decorations = winAttr.AWT_DECOR_NONE; |
|
53 |
} |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
54 |
winAttr.functions = MWMConstants.MWM_FUNC_ALL; |
2 | 55 |
winAttr.isResizable = true; //target.isResizable(); |
56 |
winAttr.initialResizability = target.isResizable(); |
|
57 |
winAttr.title = target.getTitle(); |
|
58 |
winAttr.initialState = XWindowAttributesData.NORMAL; |
|
59 |
} |
|
60 |
||
61 |
public void setVisible(boolean vis) { |
|
62 |
XToolkit.awtLock(); |
|
63 |
try { |
|
64 |
Dialog target = (Dialog)this.target; |
|
65 |
if (vis) { |
|
66 |
if (target.getModalityType() != Dialog.ModalityType.MODELESS) { |
|
67 |
if (!isModalBlocked()) { |
|
68 |
XBaseWindow.ungrabInput(); |
|
69 |
} |
|
70 |
} |
|
71 |
} else { |
|
72 |
restoreTransientFor(this); |
|
73 |
prevTransientFor = null; |
|
74 |
nextTransientFor = null; |
|
75 |
} |
|
76 |
} finally { |
|
77 |
XToolkit.awtUnlock(); |
|
78 |
} |
|
79 |
||
80 |
super.setVisible(vis); |
|
81 |
} |
|
82 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
83 |
@Override |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
84 |
boolean isTargetUndecorated() { |
2 | 85 |
if (undecorated != null) { |
86 |
return undecorated.booleanValue(); |
|
87 |
} else { |
|
88 |
return ((Dialog)target).isUndecorated(); |
|
89 |
} |
|
90 |
} |
|
91 |
||
92 |
int getDecorations() { |
|
93 |
int d = super.getDecorations(); |
|
94 |
// remove minimize and maximize buttons for dialogs |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
95 |
if ((d & MWMConstants.MWM_DECOR_ALL) != 0) { |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
96 |
d |= (MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE); |
2 | 97 |
} else { |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
98 |
d &= ~(MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE); |
2 | 99 |
} |
100 |
return d; |
|
101 |
} |
|
102 |
||
103 |
int getFunctions() { |
|
104 |
int f = super.getFunctions(); |
|
105 |
// remove minimize and maximize functions for dialogs |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
106 |
if ((f & MWMConstants.MWM_FUNC_ALL) != 0) { |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
107 |
f |= (MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE); |
2 | 108 |
} else { |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
129
diff
changeset
|
109 |
f &= ~(MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE); |
2 | 110 |
} |
111 |
return f; |
|
112 |
} |
|
113 |
||
114 |
public void blockWindows(java.util.List<Window> toBlock) { |
|
115 |
Vector<XWindowPeer> javaToplevels = null; |
|
116 |
XToolkit.awtLock(); |
|
117 |
try { |
|
118 |
javaToplevels = XWindowPeer.collectJavaToplevels(); |
|
119 |
for (Window w : toBlock) { |
|
120 |
XWindowPeer wp = (XWindowPeer)ComponentAccessor.getPeer(w); |
|
121 |
if (wp != null) { |
|
122 |
wp.setModalBlocked((Dialog)target, true, javaToplevels); |
|
123 |
} |
|
124 |
} |
|
125 |
} finally { |
|
126 |
XToolkit.awtUnlock(); |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
/* |
|
131 |
* WARNING: don't call client code in this method! |
|
132 |
* |
|
133 |
* The check is performed before the dialog is shown. |
|
134 |
* The focused window can't be blocked at the time it's focused. |
|
135 |
* Thus we don't have to perform any transitive (a blocker of a blocker) checks. |
|
136 |
*/ |
|
137 |
boolean isFocusedWindowModalBlocker() { |
|
138 |
Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow(); |
|
139 |
XWindowPeer focusedWindowPeer = null; |
|
140 |
||
141 |
if (focusedWindow != null) { |
|
142 |
focusedWindowPeer = (XWindowPeer)ComponentAccessor.getPeer(focusedWindow); |
|
143 |
} else { |
|
144 |
/* |
|
145 |
* For the case when a potential blocked window is not yet focused |
|
146 |
* on the Java level (e.g. it's just been mapped) we're asking for the |
|
147 |
* focused window on the native level. |
|
148 |
*/ |
|
149 |
focusedWindowPeer = getNativeFocusedWindowPeer(); |
|
150 |
} |
|
151 |
synchronized (getStateLock()) { |
|
152 |
if (focusedWindowPeer != null && focusedWindowPeer.modalBlocker == target) { |
|
153 |
return true; |
|
154 |
} |
|
155 |
} |
|
156 |
return super.isFocusedWindowModalBlocker(); |
|
157 |
} |
|
158 |
} |