author | darcy |
Thu, 13 Mar 2014 12:40:27 -0700 | |
changeset 23647 | 41d22f2dbeb5 |
parent 23276 | add6f5c93bc6 |
child 24538 | 25bf8153fbfe |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
2 |
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.awt.X11; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import java.awt.event.*; |
|
30 |
import java.awt.peer.ComponentPeer; |
|
31 |
import java.awt.image.ColorModel; |
|
32 |
||
33 |
import java.lang.ref.WeakReference; |
|
34 |
||
35 |
import java.lang.reflect.Method; |
|
36 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2810
diff
changeset
|
37 |
import sun.util.logging.PlatformLogger; |
2 | 38 |
|
39 |
import sun.awt.*; |
|
40 |
||
41 |
import sun.awt.image.PixelConverter; |
|
42 |
||
43 |
import sun.java2d.SunGraphics2D; |
|
44 |
import sun.java2d.SurfaceData; |
|
45 |
||
46 |
public class XWindow extends XBaseWindow implements X11ComponentPeer { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2810
diff
changeset
|
47 |
private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2810
diff
changeset
|
48 |
private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2810
diff
changeset
|
49 |
private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2810
diff
changeset
|
50 |
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2810
diff
changeset
|
51 |
private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow"); |
2 | 52 |
/* If a motion comes in while a multi-click is pending, |
53 |
* allow a smudge factor so that moving the mouse by a small |
|
54 |
* amount does not wipe out the multi-click state variables. |
|
55 |
*/ |
|
56 |
private final static int AWT_MULTICLICK_SMUDGE = 4; |
|
57 |
// ButtonXXX events stuff |
|
58 |
static int rbutton = 0; |
|
59 |
static int lastX = 0, lastY = 0; |
|
60 |
static long lastTime = 0; |
|
61 |
static long lastButton = 0; |
|
62 |
static WeakReference lastWindowRef = null; |
|
63 |
static int clickCount = 0; |
|
64 |
||
65 |
// used to check if we need to re-create surfaceData. |
|
66 |
int oldWidth = -1; |
|
67 |
int oldHeight = -1; |
|
68 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
69 |
protected PropMwmHints mwm_hints; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
70 |
protected static XAtom wm_protocols; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
71 |
protected static XAtom wm_delete_window; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
72 |
protected static XAtom wm_take_focus; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
73 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
74 |
private boolean stateChanged; // Indicates whether the value on savedState is valid |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
75 |
private int savedState; // Holds last known state of the top-level window |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
76 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
77 |
XWindowAttributesData winAttr; |
2 | 78 |
|
79 |
protected X11GraphicsConfig graphicsConfig; |
|
80 |
protected AwtGraphicsConfigData graphicsConfigData; |
|
81 |
||
82 |
private boolean reparented; |
|
83 |
||
84 |
XWindow parent; |
|
85 |
||
86 |
Component target; |
|
87 |
||
88 |
private static int JAWT_LOCK_ERROR=0x00000001; |
|
89 |
private static int JAWT_LOCK_CLIP_CHANGED=0x00000002; |
|
90 |
private static int JAWT_LOCK_BOUNDS_CHANGED=0x00000004; |
|
91 |
private static int JAWT_LOCK_SURFACE_CHANGED=0x00000008; |
|
92 |
private int drawState = JAWT_LOCK_CLIP_CHANGED | |
|
93 |
JAWT_LOCK_BOUNDS_CHANGED | |
|
94 |
JAWT_LOCK_SURFACE_CHANGED; |
|
95 |
||
96 |
public static final String TARGET = "target", |
|
97 |
REPARENTED = "reparented"; // whether it is reparented by default |
|
98 |
||
99 |
SurfaceData surfaceData; |
|
100 |
||
101 |
XRepaintArea paintArea; |
|
116
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
102 |
|
2 | 103 |
// fallback default font object |
116
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
104 |
private static Font defaultFont; |
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
105 |
|
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
106 |
static synchronized Font getDefaultFont() { |
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
107 |
if (null == defaultFont) { |
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
108 |
defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); |
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
109 |
} |
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
110 |
return defaultFont; |
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
111 |
} |
2 | 112 |
|
447
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
113 |
/* A bitmask keeps the button's numbers as Button1Mask, Button2Mask, Button3Mask |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
114 |
* which are allowed to |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
115 |
* generate the CLICK event after the RELEASE has happened. |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
116 |
* There are conditions that must be true for that sending CLICK event: |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
117 |
* 1) button was initially PRESSED |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
118 |
* 2) no movement or drag has happened until RELEASE |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
119 |
*/ |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
120 |
private int mouseButtonClickAllowed = 0; |
2 | 121 |
|
122 |
native int getNativeColor(Color clr, GraphicsConfiguration gc); |
|
123 |
native void getWMInsets(long window, long left, long top, long right, long bottom, long border); |
|
124 |
native long getTopWindow(long window, long rootWin); |
|
125 |
native void getWindowBounds(long window, long x, long y, long width, long height); |
|
126 |
private native static void initIDs(); |
|
127 |
||
128 |
static { |
|
129 |
initIDs(); |
|
130 |
} |
|
131 |
||
132 |
XWindow(XCreateWindowParams params) { |
|
133 |
super(params); |
|
134 |
} |
|
135 |
||
136 |
XWindow() { |
|
137 |
} |
|
138 |
||
139 |
XWindow(long parentWindow, Rectangle bounds) { |
|
140 |
super(new XCreateWindowParams(new Object[] { |
|
141 |
BOUNDS, bounds, |
|
142 |
PARENT_WINDOW, Long.valueOf(parentWindow)})); |
|
143 |
} |
|
144 |
||
145 |
XWindow(Component target, long parentWindow, Rectangle bounds) { |
|
146 |
super(new XCreateWindowParams(new Object[] { |
|
147 |
BOUNDS, bounds, |
|
148 |
PARENT_WINDOW, Long.valueOf(parentWindow), |
|
149 |
TARGET, target})); |
|
150 |
} |
|
151 |
||
152 |
XWindow(Component target, long parentWindow) { |
|
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2473
diff
changeset
|
153 |
this(target, parentWindow, new Rectangle(target.getBounds())); |
2 | 154 |
} |
155 |
||
156 |
XWindow(Component target) { |
|
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2473
diff
changeset
|
157 |
this(target, (target.getParent() == null) ? 0 : getParentWindowID(target), new Rectangle(target.getBounds())); |
2 | 158 |
} |
159 |
||
160 |
XWindow(Object target) { |
|
161 |
this(null, 0, null); |
|
162 |
} |
|
163 |
||
164 |
/* This create is used by the XEmbeddedFramePeer since it has to create the window |
|
165 |
as a child of the netscape window. This netscape window is passed in as wid */ |
|
166 |
XWindow(long parentWindow) { |
|
167 |
super(new XCreateWindowParams(new Object[] { |
|
168 |
PARENT_WINDOW, Long.valueOf(parentWindow), |
|
169 |
REPARENTED, Boolean.TRUE, |
|
170 |
EMBEDDED, Boolean.TRUE})); |
|
171 |
} |
|
172 |
||
173 |
protected void initGraphicsConfiguration() { |
|
174 |
graphicsConfig = (X11GraphicsConfig) target.getGraphicsConfiguration(); |
|
175 |
graphicsConfigData = new AwtGraphicsConfigData(graphicsConfig.getAData()); |
|
176 |
} |
|
177 |
||
178 |
void preInit(XCreateWindowParams params) { |
|
179 |
super.preInit(params); |
|
180 |
reparented = Boolean.TRUE.equals(params.get(REPARENTED)); |
|
181 |
||
182 |
target = (Component)params.get(TARGET); |
|
183 |
||
184 |
initGraphicsConfiguration(); |
|
185 |
||
186 |
AwtGraphicsConfigData gData = getGraphicsConfigurationData(); |
|
187 |
X11GraphicsConfig config = (X11GraphicsConfig) getGraphicsConfiguration(); |
|
188 |
XVisualInfo visInfo = gData.get_awt_visInfo(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
189 |
params.putIfNull(EVENT_MASK, XConstants.KeyPressMask | XConstants.KeyReleaseMask |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
190 |
| XConstants.FocusChangeMask | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
191 |
| XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
192 |
| XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask); |
2 | 193 |
|
194 |
if (target != null) { |
|
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2473
diff
changeset
|
195 |
params.putIfNull(BOUNDS, new Rectangle(target.getBounds())); |
2 | 196 |
} else { |
197 |
params.putIfNull(BOUNDS, new Rectangle(0, 0, MIN_SIZE, MIN_SIZE)); |
|
198 |
} |
|
199 |
params.putIfNull(BORDER_PIXEL, Long.valueOf(0)); |
|
200 |
getColorModel(); // fix 4948833: this call forces the color map to be initialized |
|
201 |
params.putIfNull(COLORMAP, gData.get_awt_cmap()); |
|
202 |
params.putIfNull(DEPTH, gData.get_awt_depth()); |
|
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
203 |
params.putIfNull(VISUAL_CLASS, Integer.valueOf(XConstants.InputOutput)); |
2 | 204 |
params.putIfNull(VISUAL, visInfo.get_visual()); |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
205 |
params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap); |
2 | 206 |
Long parentWindow = (Long)params.get(PARENT_WINDOW); |
207 |
if (parentWindow == null || parentWindow.longValue() == 0) { |
|
208 |
XToolkit.awtLock(); |
|
209 |
try { |
|
210 |
int screen = visInfo.get_screen(); |
|
211 |
if (screen != -1) { |
|
212 |
params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), screen)); |
|
213 |
} else { |
|
214 |
params.add(PARENT_WINDOW, XToolkit.getDefaultRootWindow()); |
|
215 |
} |
|
216 |
} finally { |
|
217 |
XToolkit.awtUnlock(); |
|
218 |
} |
|
219 |
} |
|
220 |
||
221 |
paintArea = new XRepaintArea(); |
|
222 |
if (target != null) { |
|
223 |
this.parent = getParentXWindowObject(target.getParent()); |
|
224 |
} |
|
225 |
||
226 |
params.putIfNull(BACKING_STORE, XToolkit.getBackingStoreType()); |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
227 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
228 |
XToolkit.awtLock(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
229 |
try { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
230 |
if (wm_protocols == null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
231 |
wm_protocols = XAtom.get("WM_PROTOCOLS"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
232 |
wm_delete_window = XAtom.get("WM_DELETE_WINDOW"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
233 |
wm_take_focus = XAtom.get("WM_TAKE_FOCUS"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
234 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
235 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
236 |
finally { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
237 |
XToolkit.awtUnlock(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
238 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
239 |
winAttr = new XWindowAttributesData(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
240 |
savedState = XUtilConstants.WithdrawnState; |
2 | 241 |
} |
242 |
||
243 |
void postInit(XCreateWindowParams params) { |
|
244 |
super.postInit(params); |
|
245 |
||
246 |
setWMClass(getWMClass()); |
|
247 |
||
248 |
surfaceData = graphicsConfig.createSurfaceData(this); |
|
249 |
Color c; |
|
250 |
if (target != null && (c = target.getBackground()) != null) { |
|
251 |
// We need a version of setBackground that does not call repaint !! |
|
252 |
// and one that does not get overridden. The problem is that in postInit |
|
21278 | 253 |
// we call setBackground and we don't have all the stuff initialized to |
2 | 254 |
// do a full paint for most peers. So we cannot call setBackground in postInit. |
255 |
// instead we need to call xSetBackground. |
|
256 |
xSetBackground(c); |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
public GraphicsConfiguration getGraphicsConfiguration() { |
|
261 |
if (graphicsConfig == null) { |
|
262 |
initGraphicsConfiguration(); |
|
263 |
} |
|
264 |
return graphicsConfig; |
|
265 |
} |
|
266 |
||
267 |
public AwtGraphicsConfigData getGraphicsConfigurationData() { |
|
268 |
if (graphicsConfigData == null) { |
|
269 |
initGraphicsConfiguration(); |
|
270 |
} |
|
271 |
return graphicsConfigData; |
|
272 |
} |
|
273 |
||
274 |
protected String[] getWMClass() { |
|
275 |
return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()}; |
|
276 |
} |
|
277 |
||
278 |
void setReparented(boolean newValue) { |
|
279 |
reparented = newValue; |
|
280 |
} |
|
281 |
||
282 |
boolean isReparented() { |
|
283 |
return reparented; |
|
284 |
} |
|
285 |
||
286 |
static long getParentWindowID(Component target) { |
|
287 |
||
288 |
ComponentPeer peer = target.getParent().getPeer(); |
|
289 |
Component temp = target.getParent(); |
|
290 |
while (!(peer instanceof XWindow)) |
|
291 |
{ |
|
292 |
temp = temp.getParent(); |
|
293 |
peer = temp.getPeer(); |
|
294 |
} |
|
295 |
||
296 |
if (peer != null && peer instanceof XWindow) |
|
297 |
return ((XWindow)peer).getContentWindow(); |
|
298 |
else return 0; |
|
299 |
} |
|
300 |
||
301 |
||
302 |
static XWindow getParentXWindowObject(Component target) { |
|
303 |
if (target == null) return null; |
|
304 |
Component temp = target.getParent(); |
|
305 |
if (temp == null) return null; |
|
306 |
ComponentPeer peer = temp.getPeer(); |
|
307 |
if (peer == null) return null; |
|
308 |
while ((peer != null) && !(peer instanceof XWindow)) |
|
309 |
{ |
|
310 |
temp = temp.getParent(); |
|
311 |
peer = temp.getPeer(); |
|
312 |
} |
|
313 |
if (peer != null && peer instanceof XWindow) |
|
314 |
return (XWindow) peer; |
|
315 |
else return null; |
|
316 |
} |
|
317 |
||
318 |
||
319 |
boolean isParentOf(XWindow win) { |
|
320 |
if (!(target instanceof Container) || win == null || win.getTarget() == null) { |
|
321 |
return false; |
|
322 |
} |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
323 |
Container parent = AWTAccessor.getComponentAccessor().getParent(win.target); |
2 | 324 |
while (parent != null && parent != target) { |
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
325 |
parent = AWTAccessor.getComponentAccessor().getParent(parent); |
2 | 326 |
} |
327 |
return (parent == target); |
|
328 |
} |
|
329 |
||
330 |
public Object getTarget() { |
|
331 |
return target; |
|
332 |
} |
|
333 |
public Component getEventSource() { |
|
334 |
return target; |
|
335 |
} |
|
336 |
||
337 |
public ColorModel getColorModel(int transparency) { |
|
338 |
return graphicsConfig.getColorModel (transparency); |
|
339 |
} |
|
340 |
||
341 |
public ColorModel getColorModel() { |
|
342 |
if (graphicsConfig != null) { |
|
343 |
return graphicsConfig.getColorModel (); |
|
344 |
} |
|
345 |
else { |
|
346 |
return XToolkit.getStaticColorModel(); |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
Graphics getGraphics(SurfaceData surfData, Color afore, Color aback, Font afont) { |
|
351 |
if (surfData == null) return null; |
|
352 |
||
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
353 |
Component target = this.target; |
2 | 354 |
|
355 |
/* Fix for bug 4746122. Color and Font shouldn't be null */ |
|
356 |
Color bgColor = aback; |
|
357 |
if (bgColor == null) { |
|
358 |
bgColor = SystemColor.window; |
|
359 |
} |
|
360 |
Color fgColor = afore; |
|
361 |
if (fgColor == null) { |
|
362 |
fgColor = SystemColor.windowText; |
|
363 |
} |
|
364 |
Font font = afont; |
|
365 |
if (font == null) { |
|
116
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
366 |
font = XWindow.getDefaultFont(); |
2 | 367 |
} |
368 |
return new SunGraphics2D(surfData, fgColor, bgColor, font); |
|
369 |
} |
|
370 |
||
371 |
public Graphics getGraphics() { |
|
372 |
return getGraphics(surfaceData, |
|
373 |
target.getForeground(), |
|
374 |
target.getBackground(), |
|
375 |
target.getFont()); |
|
376 |
} |
|
377 |
||
378 |
public FontMetrics getFontMetrics(Font font) { |
|
379 |
return Toolkit.getDefaultToolkit().getFontMetrics(font); |
|
380 |
} |
|
381 |
||
382 |
public Rectangle getTargetBounds() { |
|
383 |
return target.getBounds(); |
|
384 |
} |
|
385 |
||
386 |
/** |
|
387 |
* Returns true if the event has been handled and should not be |
|
388 |
* posted to Java. |
|
389 |
*/ |
|
390 |
boolean prePostEvent(AWTEvent e) { |
|
391 |
return false; |
|
392 |
} |
|
393 |
||
394 |
static Method m_sendMessage; |
|
395 |
static void sendEvent(final AWTEvent e) { |
|
6826
1fc6a05552f2
6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents:
6824
diff
changeset
|
396 |
// The uses of this method imply that the incoming event is system-generated |
1fc6a05552f2
6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents:
6824
diff
changeset
|
397 |
SunToolkit.setSystemGenerated(e); |
2 | 398 |
PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() { |
399 |
public void run() { |
|
13604 | 400 |
AWTAccessor.getAWTEventAccessor().setPosted(e); |
2 | 401 |
((Component)e.getSource()).dispatchEvent(e); |
402 |
} |
|
403 |
}, PeerEvent.ULTIMATE_PRIORITY_EVENT); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
404 |
if (focusLog.isLoggable(PlatformLogger.Level.FINER) && (e instanceof FocusEvent)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
405 |
focusLog.finer("Sending " + e); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
406 |
} |
2 | 407 |
XToolkit.postEvent(XToolkit.targetToAppContext(e.getSource()), pe); |
408 |
} |
|
409 |
||
410 |
||
411 |
/* |
|
412 |
* Post an event to the event queue. |
|
413 |
*/ |
|
414 |
// NOTE: This method may be called by privileged threads. |
|
415 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
416 |
void postEvent(AWTEvent event) { |
|
417 |
XToolkit.postEvent(XToolkit.targetToAppContext(event.getSource()), event); |
|
418 |
} |
|
419 |
||
420 |
static void postEventStatic(AWTEvent event) { |
|
421 |
XToolkit.postEvent(XToolkit.targetToAppContext(event.getSource()), event); |
|
422 |
} |
|
423 |
||
424 |
public void postEventToEventQueue(final AWTEvent event) { |
|
425 |
//fix for 6239938 : Choice drop-down does not disappear when it loses focus, on XToolkit |
|
426 |
if (!prePostEvent(event)) { |
|
427 |
//event hasn't been handled and must be posted to EventQueue |
|
428 |
postEvent(event); |
|
429 |
} |
|
430 |
} |
|
431 |
||
432 |
// overriden in XCanvasPeer |
|
433 |
protected boolean doEraseBackground() { |
|
434 |
return true; |
|
435 |
} |
|
436 |
||
437 |
// We need a version of setBackground that does not call repaint !! |
|
438 |
// and one that does not get overridden. The problem is that in postInit |
|
21278 | 439 |
// we call setBackground and we don't have all the stuff initialized to |
2 | 440 |
// do a full paint for most peers. So we cannot call setBackground in postInit. |
441 |
final public void xSetBackground(Color c) { |
|
442 |
XToolkit.awtLock(); |
|
443 |
try { |
|
444 |
winBackground(c); |
|
445 |
// fix for 6558510: handle sun.awt.noerasebackground flag, |
|
446 |
// see doEraseBackground() and preInit() methods in XCanvasPeer |
|
447 |
if (!doEraseBackground()) { |
|
448 |
return; |
|
449 |
} |
|
450 |
// 6304250: XAWT: Items in choice show a blue border on OpenGL + Solaris10 when background color is set |
|
451 |
// Note: When OGL is enabled, surfaceData.pixelFor() will not |
|
452 |
// return a pixel value appropriate for passing to |
|
453 |
// XSetWindowBackground(). Therefore, we will use the ColorModel |
|
454 |
// for this component in order to calculate a pixel value from |
|
455 |
// the given RGB value. |
|
456 |
ColorModel cm = getColorModel(); |
|
457 |
int pixel = PixelConverter.instance.rgbToPixel(c.getRGB(), cm); |
|
458 |
XlibWrapper.XSetWindowBackground(XToolkit.getDisplay(), getContentWindow(), pixel); |
|
23248
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
21278
diff
changeset
|
459 |
XlibWrapper.XClearWindow(XToolkit.getDisplay(), getContentWindow()); |
2 | 460 |
} |
461 |
finally { |
|
462 |
XToolkit.awtUnlock(); |
|
463 |
} |
|
464 |
} |
|
465 |
||
466 |
public void setBackground(Color c) { |
|
467 |
xSetBackground(c); |
|
468 |
} |
|
469 |
||
470 |
Color backgroundColor; |
|
471 |
void winBackground(Color c) { |
|
472 |
backgroundColor = c; |
|
473 |
} |
|
474 |
||
475 |
public Color getWinBackground() { |
|
476 |
Color c = null; |
|
477 |
||
478 |
if (backgroundColor != null) { |
|
479 |
c = backgroundColor; |
|
480 |
} else if (parent != null) { |
|
481 |
c = parent.getWinBackground(); |
|
482 |
} |
|
483 |
||
484 |
if (c instanceof SystemColor) { |
|
485 |
c = new Color(c.getRGB()); |
|
486 |
} |
|
487 |
||
488 |
return c; |
|
489 |
} |
|
490 |
||
491 |
public boolean isEmbedded() { |
|
492 |
return embedded; |
|
493 |
} |
|
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
494 |
|
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
495 |
public final void repaint(int x, int y, int width, int height) { |
10096
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
7668
diff
changeset
|
496 |
if (!isVisible() || getWidth() == 0 || getHeight() == 0) { |
2 | 497 |
return; |
498 |
} |
|
499 |
Graphics g = getGraphics(); |
|
500 |
if (g != null) { |
|
501 |
try { |
|
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
502 |
g.setClip(x, y, width, height); |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
503 |
if (SunToolkit.isDispatchThreadForAppContext(getTarget())) { |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
504 |
paint(g); // The native and target will be painted in place. |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
505 |
} else { |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
506 |
paintPeer(g); |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
507 |
postPaintEvent(target, x, y, width, height); |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
508 |
} |
2 | 509 |
} finally { |
510 |
g.dispose(); |
|
511 |
} |
|
512 |
} |
|
513 |
} |
|
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
514 |
|
10096
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
7668
diff
changeset
|
515 |
void repaint() { |
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
516 |
repaint(0, 0, getWidth(), getHeight()); |
2 | 517 |
} |
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
518 |
|
10096
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
7668
diff
changeset
|
519 |
public void paint(final Graphics g) { |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
7668
diff
changeset
|
520 |
// paint peer |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
7668
diff
changeset
|
521 |
paintPeer(g); |
2 | 522 |
} |
523 |
||
10096
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
7668
diff
changeset
|
524 |
void paintPeer(final Graphics g) { |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
7668
diff
changeset
|
525 |
} |
2 | 526 |
//used by Peers to avoid flickering withing paint() |
527 |
protected void flush(){ |
|
528 |
XToolkit.awtLock(); |
|
529 |
try { |
|
530 |
XlibWrapper.XFlush(XToolkit.getDisplay()); |
|
531 |
} finally { |
|
532 |
XToolkit.awtUnlock(); |
|
533 |
} |
|
534 |
} |
|
535 |
||
536 |
public void popup(int x, int y, int width, int height) { |
|
537 |
// TBD: grab the pointer |
|
538 |
xSetBounds(x, y, width, height); |
|
539 |
} |
|
540 |
||
541 |
public void handleExposeEvent(XEvent xev) { |
|
542 |
super.handleExposeEvent(xev); |
|
543 |
XExposeEvent xe = xev.get_xexpose(); |
|
544 |
if (isEventDisabled(xev)) { |
|
545 |
return; |
|
546 |
} |
|
547 |
int x = xe.get_x(); |
|
548 |
int y = xe.get_y(); |
|
549 |
int w = xe.get_width(); |
|
550 |
int h = xe.get_height(); |
|
551 |
||
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
552 |
Component target = getEventSource(); |
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
553 |
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); |
2 | 554 |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
555 |
if (!compAccessor.getIgnoreRepaint(target) |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
556 |
&& compAccessor.getWidth(target) != 0 |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
557 |
&& compAccessor.getHeight(target) != 0) |
2 | 558 |
{ |
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
559 |
postPaintEvent(target, x, y, w, h); |
2 | 560 |
} |
561 |
} |
|
562 |
||
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
18178
diff
changeset
|
563 |
public void postPaintEvent(Component target, int x, int y, int w, int h) { |
2 | 564 |
PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher(). |
565 |
createPaintEvent(target, x, y, w, h); |
|
566 |
if (event != null) { |
|
567 |
postEventToEventQueue(event); |
|
568 |
} |
|
569 |
} |
|
570 |
||
571 |
static int getModifiers(int state, int button, int keyCode) { |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
572 |
return getModifiers(state, button, keyCode, 0, false); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
573 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
574 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
575 |
static int getModifiers(int state, int button, int keyCode, int type, boolean wheel_mouse) { |
2 | 576 |
int modifiers = 0; |
577 |
||
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
578 |
if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) { |
2 | 579 |
modifiers |= InputEvent.SHIFT_DOWN_MASK; |
580 |
} |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
581 |
if (((state & XConstants.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) { |
2 | 582 |
modifiers |= InputEvent.CTRL_DOWN_MASK; |
583 |
} |
|
584 |
if (((state & XToolkit.metaMask) != 0) ^ (keyCode == KeyEvent.VK_META)) { |
|
585 |
modifiers |= InputEvent.META_DOWN_MASK; |
|
586 |
} |
|
587 |
if (((state & XToolkit.altMask) != 0) ^ (keyCode == KeyEvent.VK_ALT)) { |
|
588 |
modifiers |= InputEvent.ALT_DOWN_MASK; |
|
589 |
} |
|
590 |
if (((state & XToolkit.modeSwitchMask) != 0) ^ (keyCode == KeyEvent.VK_ALT_GRAPH)) { |
|
591 |
modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; |
|
592 |
} |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
593 |
//InputEvent.BUTTON_DOWN_MASK array is starting from BUTTON1_DOWN_MASK on index == 0. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
594 |
// button currently reflects a real button number and starts from 1. (except NOBUTTON which is zero ) |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
595 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
596 |
/* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
597 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
598 |
//reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc. |
14888
7ad1550e7050
8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents:
14163
diff
changeset
|
599 |
for (int i = 0; i < XConstants.buttons.length; i ++){ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
600 |
//modifier should be added if : |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
601 |
// 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
602 |
// 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
603 |
// ONLY one of these conditions should be TRUE to add that modifier. |
14888
7ad1550e7050
8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents:
14163
diff
changeset
|
604 |
if (((state & XlibUtil.getButtonMask(i + 1)) != 0) != (button == XConstants.buttons[i])){ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
605 |
//exclude wheel buttons from adding their numbers as modifiers |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
606 |
if (!wheel_mouse) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
607 |
modifiers |= InputEvent.getMaskForButton(i+1); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
608 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
609 |
} |
2 | 610 |
} |
611 |
return modifiers; |
|
612 |
} |
|
613 |
||
614 |
static int getXModifiers(AWTKeyStroke stroke) { |
|
615 |
int mods = stroke.getModifiers(); |
|
616 |
int res = 0; |
|
617 |
if ((mods & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
618 |
res |= XConstants.ShiftMask; |
2 | 619 |
} |
620 |
if ((mods & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
621 |
res |= XConstants.ControlMask; |
2 | 622 |
} |
623 |
if ((mods & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) { |
|
624 |
res |= XToolkit.altMask; |
|
625 |
} |
|
626 |
if ((mods & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) { |
|
627 |
res |= XToolkit.metaMask; |
|
628 |
} |
|
629 |
if ((mods & (InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.ALT_GRAPH_MASK)) != 0) { |
|
630 |
res |= XToolkit.modeSwitchMask; |
|
631 |
} |
|
632 |
return res; |
|
633 |
} |
|
634 |
||
635 |
/** |
|
636 |
* Returns true if this event is disabled and shouldn't be passed to Java. |
|
637 |
* Default implementation returns false for all events. |
|
638 |
*/ |
|
639 |
static int getRightButtonNumber() { |
|
640 |
if (rbutton == 0) { // not initialized yet |
|
641 |
XToolkit.awtLock(); |
|
642 |
try { |
|
643 |
rbutton = XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), XlibWrapper.ibuffer, 3); |
|
644 |
} |
|
645 |
finally { |
|
646 |
XToolkit.awtUnlock(); |
|
647 |
} |
|
648 |
} |
|
649 |
return rbutton; |
|
650 |
} |
|
651 |
||
652 |
static int getMouseMovementSmudge() { |
|
653 |
//TODO: It's possible to read corresponding settings |
|
654 |
return AWT_MULTICLICK_SMUDGE; |
|
655 |
} |
|
656 |
||
657 |
public void handleButtonPressRelease(XEvent xev) { |
|
658 |
super.handleButtonPressRelease(xev); |
|
659 |
XButtonEvent xbe = xev.get_xbutton(); |
|
660 |
if (isEventDisabled(xev)) { |
|
661 |
return; |
|
662 |
} |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
663 |
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
664 |
eventLog.fine(xbe.toString()); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
665 |
} |
2 | 666 |
long when; |
667 |
int modifiers; |
|
668 |
boolean popupTrigger = false; |
|
669 |
int button=0; |
|
670 |
boolean wheel_mouse = false; |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
671 |
int lbutton = xbe.get_button(); |
2810
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
672 |
/* |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
673 |
* Ignore the buttons above 20 due to the bit limit for |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
674 |
* InputEvent.BUTTON_DOWN_MASK. |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
675 |
* One more bit is reserved for FIRST_HIGH_BIT. |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
676 |
*/ |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
677 |
if (lbutton > SunToolkit.MAX_BUTTONS_SUPPORTED) { |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
678 |
return; |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
679 |
} |
2 | 680 |
int type = xev.get_type(); |
681 |
when = xbe.get_time(); |
|
682 |
long jWhen = XToolkit.nowMillisUTC_offset(when); |
|
683 |
||
684 |
int x = xbe.get_x(); |
|
685 |
int y = xbe.get_y(); |
|
686 |
if (xev.get_xany().get_window() != window) { |
|
687 |
Point localXY = toLocal(xbe.get_x_root(), xbe.get_y_root()); |
|
688 |
x = localXY.x; |
|
689 |
y = localXY.y; |
|
690 |
} |
|
691 |
||
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
692 |
if (type == XConstants.ButtonPress) { |
447
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
693 |
//Allow this mouse button to generate CLICK event on next ButtonRelease |
14888
7ad1550e7050
8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents:
14163
diff
changeset
|
694 |
mouseButtonClickAllowed |= XlibUtil.getButtonMask(lbutton); |
2 | 695 |
XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null); |
696 |
/* |
|
697 |
multiclick checking |
|
698 |
*/ |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
699 |
if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
700 |
eventLog.finest("lastWindow = " + lastWindow + ", lastButton " |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
701 |
+ lastButton + ", lastTime " + lastTime + ", multiClickTime " |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
702 |
+ XToolkit.getMultiClickTime()); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
703 |
} |
2 | 704 |
if (lastWindow == this && lastButton == lbutton && (when - lastTime) < XToolkit.getMultiClickTime()) { |
705 |
clickCount++; |
|
706 |
} else { |
|
707 |
clickCount = 1; |
|
708 |
lastWindowRef = new WeakReference(this); |
|
709 |
lastButton = lbutton; |
|
710 |
lastX = x; |
|
711 |
lastY = y; |
|
712 |
} |
|
713 |
lastTime = when; |
|
714 |
||
715 |
||
716 |
/* |
|
717 |
Check for popup trigger !! |
|
718 |
*/ |
|
719 |
if (lbutton == getRightButtonNumber() || lbutton > 2) { |
|
720 |
popupTrigger = true; |
|
721 |
} else { |
|
722 |
popupTrigger = false; |
|
723 |
} |
|
724 |
} |
|
725 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
726 |
button = XConstants.buttons[lbutton - 1]; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
727 |
// 4 and 5 buttons are usually considered assigned to a first wheel |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
728 |
if (lbutton == XConstants.buttons[3] || |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
729 |
lbutton == XConstants.buttons[4]) { |
2 | 730 |
wheel_mouse = true; |
731 |
} |
|
732 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
733 |
// mapping extra buttons to numbers starting from 4. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
734 |
if ((button > XConstants.buttons[4]) && (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled())){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
735 |
return; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
736 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
737 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
738 |
if (button > XConstants.buttons[4]){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
739 |
button -= 2; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
740 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
741 |
modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse); |
2 | 742 |
|
743 |
if (!wheel_mouse) { |
|
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
744 |
MouseEvent me = new MouseEvent(getEventSource(), |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
745 |
type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED, |
2 | 746 |
jWhen,modifiers, x, y, |
747 |
xbe.get_x_root(), |
|
748 |
xbe.get_y_root(), |
|
749 |
clickCount,popupTrigger,button); |
|
750 |
||
751 |
postEventToEventQueue(me); |
|
752 |
||
447
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
753 |
if ((type == XConstants.ButtonRelease) && |
14888
7ad1550e7050
8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents:
14163
diff
changeset
|
754 |
((mouseButtonClickAllowed & XlibUtil.getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state |
2 | 755 |
{ |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
756 |
postEventToEventQueue(me = new MouseEvent(getEventSource(), |
2 | 757 |
MouseEvent.MOUSE_CLICKED, |
758 |
jWhen, |
|
759 |
modifiers, |
|
760 |
x, y, |
|
761 |
xbe.get_x_root(), |
|
762 |
xbe.get_y_root(), |
|
763 |
clickCount, |
|
764 |
false, button)); |
|
765 |
} |
|
766 |
||
767 |
} |
|
768 |
else { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
769 |
if (xev.get_type() == XConstants.ButtonPress) { |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
770 |
MouseWheelEvent mwe = new MouseWheelEvent(getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen, |
2 | 771 |
modifiers, |
772 |
x, y, |
|
773 |
xbe.get_x_root(), |
|
774 |
xbe.get_y_root(), |
|
5941
1a56de1b70b3
6957166: With XAWT, set arguments properly creating a MouseWheelEvent.
yan
parents:
5506
diff
changeset
|
775 |
1,false,MouseWheelEvent.WHEEL_UNIT_SCROLL, |
6824
053f05edc068
6973199: java/awt/Robot/RobotWheelTest/RobotWheelTest.html failed on JDK7 b102 bug passed on b101
dav
parents:
5941
diff
changeset
|
776 |
3,button==4 ? -1 : 1); |
2 | 777 |
postEventToEventQueue(mwe); |
778 |
} |
|
779 |
} |
|
780 |
||
447
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
781 |
/* Update the state variable AFTER the CLICKED event post. */ |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
782 |
if (type == XConstants.ButtonRelease) { |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
783 |
/* Exclude this mouse button from allowed list.*/ |
14888
7ad1550e7050
8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents:
14163
diff
changeset
|
784 |
mouseButtonClickAllowed &= ~ XlibUtil.getButtonMask(lbutton); |
447
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
785 |
} |
2 | 786 |
} |
787 |
||
788 |
public void handleMotionNotify(XEvent xev) { |
|
789 |
super.handleMotionNotify(xev); |
|
790 |
XMotionEvent xme = xev.get_xmotion(); |
|
791 |
if (isEventDisabled(xev)) { |
|
792 |
return; |
|
793 |
} |
|
794 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
795 |
int mouseKeyState = 0; //(xme.get_state() & (XConstants.buttonsMask[0] | XConstants.buttonsMask[1] | XConstants.buttonsMask[2])); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
796 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
797 |
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
798 |
// we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE) |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
799 |
// should be passed from XWindow. |
14888
7ad1550e7050
8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents:
14163
diff
changeset
|
800 |
final int buttonsNumber = XToolkit.getNumberOfButtonsForMask(); |
2810
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
801 |
|
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2805
diff
changeset
|
802 |
for (int i = 0; i < buttonsNumber; i++){ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
803 |
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
804 |
if ((i != 4) && (i != 5)) { |
14888
7ad1550e7050
8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents:
14163
diff
changeset
|
805 |
mouseKeyState = mouseKeyState | (xme.get_state() & XlibUtil.getButtonMask(i + 1)); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
806 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
807 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
447
diff
changeset
|
808 |
|
2 | 809 |
boolean isDragging = (mouseKeyState != 0); |
810 |
int mouseEventType = 0; |
|
811 |
||
812 |
if (isDragging) { |
|
813 |
mouseEventType = MouseEvent.MOUSE_DRAGGED; |
|
814 |
} else { |
|
815 |
mouseEventType = MouseEvent.MOUSE_MOVED; |
|
816 |
} |
|
817 |
||
818 |
/* |
|
819 |
Fix for 6176814 . Add multiclick checking. |
|
820 |
*/ |
|
821 |
int x = xme.get_x(); |
|
822 |
int y = xme.get_y(); |
|
823 |
XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null); |
|
824 |
||
825 |
if (!(lastWindow == this && |
|
826 |
(xme.get_time() - lastTime) < XToolkit.getMultiClickTime() && |
|
827 |
(Math.abs(lastX - x) < AWT_MULTICLICK_SMUDGE && |
|
828 |
Math.abs(lastY - y) < AWT_MULTICLICK_SMUDGE))) { |
|
829 |
clickCount = 0; |
|
830 |
lastWindowRef = null; |
|
447
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
439
diff
changeset
|
831 |
mouseButtonClickAllowed = 0; |
2 | 832 |
lastTime = 0; |
833 |
lastX = 0; |
|
834 |
lastY = 0; |
|
835 |
} |
|
836 |
||
837 |
long jWhen = XToolkit.nowMillisUTC_offset(xme.get_time()); |
|
838 |
int modifiers = getModifiers(xme.get_state(), 0, 0); |
|
839 |
boolean popupTrigger = false; |
|
840 |
||
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
841 |
Component source = getEventSource(); |
2 | 842 |
|
843 |
if (xme.get_window() != window) { |
|
844 |
Point localXY = toLocal(xme.get_x_root(), xme.get_y_root()); |
|
845 |
x = localXY.x; |
|
846 |
y = localXY.y; |
|
847 |
} |
|
848 |
/* Fix for 5039416. |
|
849 |
* According to canvas.c we shouldn't post any MouseEvent if mouse is dragging and clickCount!=0. |
|
850 |
*/ |
|
851 |
if ((isDragging && clickCount == 0) || !isDragging) { |
|
852 |
MouseEvent mme = new MouseEvent(source, mouseEventType, jWhen, |
|
853 |
modifiers, x, y, xme.get_x_root(), xme.get_y_root(), |
|
854 |
clickCount, popupTrigger, MouseEvent.NOBUTTON); |
|
855 |
postEventToEventQueue(mme); |
|
856 |
} |
|
857 |
} |
|
858 |
||
859 |
||
860 |
// REMIND: need to implement looking for disabled events |
|
861 |
public native boolean x11inputMethodLookupString(long event, long [] keysymArray); |
|
862 |
native boolean haveCurrentX11InputMethodInstance(); |
|
863 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
864 |
private boolean mouseAboveMe; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
865 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
866 |
public boolean isMouseAbove() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
867 |
synchronized (getStateLock()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
868 |
return mouseAboveMe; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
869 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
870 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
871 |
protected void setMouseAbove(boolean above) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
872 |
synchronized (getStateLock()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
873 |
mouseAboveMe = above; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
874 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
875 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
876 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
877 |
protected void enterNotify(long window) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
878 |
if (window == getWindow()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
879 |
setMouseAbove(true); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
880 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
881 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
882 |
protected void leaveNotify(long window) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
883 |
if (window == getWindow()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
884 |
setMouseAbove(false); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
885 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
886 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
887 |
|
2 | 888 |
public void handleXCrossingEvent(XEvent xev) { |
889 |
super.handleXCrossingEvent(xev); |
|
890 |
XCrossingEvent xce = xev.get_xcrossing(); |
|
891 |
||
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
892 |
if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
893 |
eventLog.finest(xce.toString()); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
894 |
} |
2 | 895 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
896 |
if (xce.get_type() == XConstants.EnterNotify) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
897 |
enterNotify(xce.get_window()); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
898 |
} else { // LeaveNotify: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
899 |
leaveNotify(xce.get_window()); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
900 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
901 |
|
2 | 902 |
// Skip event If it was caused by a grab |
903 |
// This is needed because on displays with focus-follows-mouse on MousePress X system generates |
|
904 |
// two XCrossing events with mode != NormalNotify. First of them notifies that the mouse has left |
|
905 |
// current component. Second one notifies that it has entered into the same component. |
|
906 |
// This looks like the window under the mouse has actually changed and Java handle these events |
|
907 |
// accordingly. This leads to impossibility to make a double click on Component (6404708) |
|
908 |
XWindowPeer toplevel = getToplevelXWindow(); |
|
909 |
if (toplevel != null && !toplevel.isModalBlocked()){ |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
910 |
if (xce.get_mode() != XConstants.NotifyNormal) { |
2 | 911 |
// 6404708 : need update cursor in accordance with skipping Leave/EnterNotify event |
912 |
// whereas it doesn't need to handled further. |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
913 |
if (xce.get_type() == XConstants.EnterNotify) { |
2 | 914 |
XAwtState.setComponentMouseEntered(getEventSource()); |
915 |
XGlobalCursorManager.nativeUpdateCursor(getEventSource()); |
|
916 |
} else { // LeaveNotify: |
|
917 |
XAwtState.setComponentMouseEntered(null); |
|
918 |
} |
|
919 |
return; |
|
920 |
} |
|
921 |
} |
|
922 |
// X sends XCrossing to all hierarchy so if the edge of child equals to |
|
923 |
// ancestor and mouse enters child, the ancestor will get an event too. |
|
924 |
// From java point the event is bogus as ancestor is obscured, so if |
|
925 |
// the child can get java event itself, we skip it on ancestor. |
|
926 |
long childWnd = xce.get_subwindow(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
927 |
if (childWnd != XConstants.None) { |
2 | 928 |
XBaseWindow child = XToolkit.windowToXWindow(childWnd); |
929 |
if (child != null && child instanceof XWindow && |
|
930 |
!child.isEventDisabled(xev)) |
|
931 |
{ |
|
932 |
return; |
|
933 |
} |
|
934 |
} |
|
935 |
||
936 |
// Remember old component with mouse to have the opportunity to send it MOUSE_EXITED. |
|
937 |
final Component compWithMouse = XAwtState.getComponentMouseEntered(); |
|
938 |
if (toplevel != null) { |
|
939 |
if(!toplevel.isModalBlocked()){ |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
940 |
if (xce.get_type() == XConstants.EnterNotify) { |
2 | 941 |
// Change XAwtState's component mouse entered to the up-to-date one before requesting |
942 |
// to update the cursor since XAwtState.getComponentMouseEntered() is used when the |
|
943 |
// cursor is updated (in XGlobalCursorManager.findHeavyweightUnderCursor()). |
|
944 |
XAwtState.setComponentMouseEntered(getEventSource()); |
|
945 |
XGlobalCursorManager.nativeUpdateCursor(getEventSource()); |
|
946 |
} else { // LeaveNotify: |
|
947 |
XAwtState.setComponentMouseEntered(null); |
|
948 |
} |
|
949 |
} else { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
950 |
((XComponentPeer) AWTAccessor.getComponentAccessor().getPeer(target)) |
2 | 951 |
.pSetCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
952 |
} |
|
953 |
} |
|
954 |
||
955 |
if (isEventDisabled(xev)) { |
|
956 |
return; |
|
957 |
} |
|
958 |
||
959 |
long jWhen = XToolkit.nowMillisUTC_offset(xce.get_time()); |
|
960 |
int modifiers = getModifiers(xce.get_state(),0,0); |
|
961 |
int clickCount = 0; |
|
962 |
boolean popupTrigger = false; |
|
963 |
int x = xce.get_x(); |
|
964 |
int y = xce.get_y(); |
|
965 |
if (xce.get_window() != window) { |
|
966 |
Point localXY = toLocal(xce.get_x_root(), xce.get_y_root()); |
|
967 |
x = localXY.x; |
|
968 |
y = localXY.y; |
|
969 |
} |
|
970 |
||
971 |
// This code tracks boundary crossing and ensures MOUSE_ENTER/EXIT |
|
972 |
// are posted in alternate pairs |
|
973 |
if (compWithMouse != null) { |
|
974 |
MouseEvent me = new MouseEvent(compWithMouse, |
|
975 |
MouseEvent.MOUSE_EXITED, jWhen, modifiers, xce.get_x(), |
|
976 |
xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, popupTrigger, |
|
977 |
MouseEvent.NOBUTTON); |
|
978 |
postEventToEventQueue(me); |
|
979 |
eventLog.finest("Clearing last window ref"); |
|
980 |
lastWindowRef = null; |
|
981 |
} |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
982 |
if (xce.get_type() == XConstants.EnterNotify) { |
2 | 983 |
MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED, |
984 |
jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, |
|
985 |
popupTrigger, MouseEvent.NOBUTTON); |
|
986 |
postEventToEventQueue(me); |
|
987 |
} |
|
988 |
} |
|
989 |
||
990 |
public void doLayout(int x, int y, int width, int height) {} |
|
991 |
||
992 |
public void handleConfigureNotifyEvent(XEvent xev) { |
|
993 |
Rectangle oldBounds = getBounds(); |
|
994 |
||
995 |
super.handleConfigureNotifyEvent(xev); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
996 |
if (insLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
997 |
insLog.finer("Configure, {0}, event disabled: {1}", |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2810
diff
changeset
|
998 |
xev.get_xconfigure(), isEventDisabled(xev)); |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
999 |
} |
2 | 1000 |
if (isEventDisabled(xev)) { |
1001 |
return; |
|
1002 |
} |
|
1003 |
||
1004 |
// if ( Check if it's a resize, a move, or a stacking order change ) |
|
1005 |
// { |
|
1006 |
Rectangle bounds = getBounds(); |
|
1007 |
if (!bounds.getSize().equals(oldBounds.getSize())) { |
|
1008 |
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED)); |
|
1009 |
} |
|
1010 |
if (!bounds.getLocation().equals(oldBounds.getLocation())) { |
|
1011 |
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED)); |
|
1012 |
} |
|
1013 |
// } |
|
1014 |
} |
|
1015 |
||
1016 |
public void handleMapNotifyEvent(XEvent xev) { |
|
1017 |
super.handleMapNotifyEvent(xev); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1018 |
if (log.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1019 |
log.fine("Mapped {0}", this); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1020 |
} |
2 | 1021 |
if (isEventDisabled(xev)) { |
1022 |
return; |
|
1023 |
} |
|
1024 |
ComponentEvent ce; |
|
1025 |
||
1026 |
ce = new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_SHOWN); |
|
1027 |
postEventToEventQueue(ce); |
|
1028 |
} |
|
1029 |
||
1030 |
public void handleUnmapNotifyEvent(XEvent xev) { |
|
1031 |
super.handleUnmapNotifyEvent(xev); |
|
1032 |
if (isEventDisabled(xev)) { |
|
1033 |
return; |
|
1034 |
} |
|
1035 |
ComponentEvent ce; |
|
1036 |
||
1037 |
ce = new ComponentEvent(target, ComponentEvent.COMPONENT_HIDDEN); |
|
1038 |
postEventToEventQueue(ce); |
|
1039 |
} |
|
1040 |
||
1041 |
private void dumpKeysymArray(XKeyEvent ev) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1042 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1043 |
keyEventLog.fine(" "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 0))+ |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1044 |
"\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 1))+ |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1045 |
"\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 2))+ |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1046 |
"\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 3))); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1047 |
} |
2 | 1048 |
} |
1049 |
/** |
|
1050 |
Return unicode character or 0 if no correspondent character found. |
|
1051 |
Parameter is a keysym basically from keysymdef.h |
|
1052 |
XXX: how about vendor keys? Is there some with Unicode value and not in the list? |
|
1053 |
*/ |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1054 |
int keysymToUnicode( long keysym, int state ) { |
2 | 1055 |
return XKeysym.convertKeysym( keysym, state ); |
1056 |
} |
|
1057 |
int keyEventType2Id( int xEventType ) { |
|
1058 |
return xEventType == XConstants.KeyPress ? java.awt.event.KeyEvent.KEY_PRESSED : |
|
1059 |
xEventType == XConstants.KeyRelease ? java.awt.event.KeyEvent.KEY_RELEASED : 0; |
|
1060 |
} |
|
1061 |
static private long xkeycodeToKeysym(XKeyEvent ev) { |
|
1062 |
return XKeysym.getKeysym( ev ); |
|
1063 |
} |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1064 |
private long xkeycodeToPrimaryKeysym(XKeyEvent ev) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1065 |
return XKeysym.xkeycode2primary_keysym( ev ); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1066 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1067 |
static private int primaryUnicode2JavaKeycode(int uni) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1068 |
return (uni > 0? sun.awt.ExtendedKeyCodes.getExtendedKeyCodeForChar(uni) : 0); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1069 |
//return (uni > 0? uni + 0x01000000 : 0); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1070 |
} |
2 | 1071 |
void logIncomingKeyEvent(XKeyEvent ev) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1072 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1073 |
keyEventLog.fine("--XWindow.java:handleKeyEvent:"+ev); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1074 |
} |
2 | 1075 |
dumpKeysymArray(ev); |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1076 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1077 |
keyEventLog.fine("XXXXXXXXXXXXXX javakeycode will be most probably:0x"+ Integer.toHexString(XKeysym.getJavaKeycodeOnly(ev))); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1078 |
} |
2 | 1079 |
} |
1080 |
public void handleKeyPress(XEvent xev) { |
|
1081 |
super.handleKeyPress(xev); |
|
1082 |
XKeyEvent ev = xev.get_xkey(); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1083 |
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1084 |
eventLog.fine(ev.toString()); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1085 |
} |
2 | 1086 |
if (isEventDisabled(xev)) { |
1087 |
return; |
|
1088 |
} |
|
1089 |
handleKeyPress(ev); |
|
1090 |
} |
|
1091 |
// called directly from this package, unlike handleKeyRelease. |
|
1092 |
// un-final it if you need to override it in a subclass. |
|
1093 |
final void handleKeyPress(XKeyEvent ev) { |
|
1094 |
long keysym[] = new long[2]; |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1095 |
int unicodeKey = 0; |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1096 |
keysym[0] = XConstants.NoSymbol; |
2 | 1097 |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1098 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1099 |
logIncomingKeyEvent( ev ); |
1100 |
} |
|
1101 |
if ( //TODO check if there's an active input method instance |
|
1102 |
// without calling a native method. Is it necessary though? |
|
1103 |
haveCurrentX11InputMethodInstance()) { |
|
1104 |
if (x11inputMethodLookupString(ev.pData, keysym)) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1105 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1106 |
keyEventLog.fine("--XWindow.java XIM did process event; return; dec keysym processed:"+(keysym[0])+ |
1107 |
"; hex keysym processed:"+Long.toHexString(keysym[0]) |
|
1108 |
); |
|
1109 |
} |
|
1110 |
return; |
|
1111 |
}else { |
|
1112 |
unicodeKey = keysymToUnicode( keysym[0], ev.get_state() ); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1113 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1114 |
keyEventLog.fine("--XWindow.java XIM did NOT process event, hex keysym:"+Long.toHexString(keysym[0])+"\n"+ |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
1115 |
" unicode key:"+Integer.toHexString(unicodeKey)); |
2 | 1116 |
} |
1117 |
} |
|
1118 |
}else { |
|
1119 |
// No input method instance found. For example, there's a Java Input Method. |
|
1120 |
// Produce do-it-yourself keysym and perhaps unicode character. |
|
1121 |
keysym[0] = xkeycodeToKeysym(ev); |
|
1122 |
unicodeKey = keysymToUnicode( keysym[0], ev.get_state() ); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1123 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1124 |
keyEventLog.fine("--XWindow.java XIM is absent; hex keysym:"+Long.toHexString(keysym[0])+"\n"+ |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
1125 |
" unicode key:"+Integer.toHexString(unicodeKey)); |
2 | 1126 |
} |
1127 |
} |
|
1128 |
// Keysym should be converted to Unicode, if possible and necessary, |
|
1129 |
// and Java KeyEvent keycode should be calculated. |
|
1130 |
// For press we should post pressed & typed Java events. |
|
1131 |
// |
|
1132 |
// Press event might be not processed to this time because |
|
1133 |
// (1) either XIM could not handle it or |
|
1134 |
// (2) it was Latin 1:1 mapping. |
|
1135 |
// |
|
14163
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1136 |
// Preserve modifiers to get Java key code for dead keys |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1137 |
boolean isDeadKey = isDeadKey(keysym[0]); |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1138 |
XKeysym.Keysym2JavaKeycode jkc = isDeadKey ? XKeysym.getJavaKeycode(keysym[0]) |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1139 |
: XKeysym.getJavaKeycode(ev); |
2 | 1140 |
if( jkc == null ) { |
1141 |
jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN); |
|
1142 |
} |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1143 |
|
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1144 |
// Take the first keysym from a keysym array associated with the XKeyevent |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1145 |
// and convert it to Unicode. Then, even if a Java keycode for the keystroke |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1146 |
// is undefined, we still have a guess of what has been engraved on a keytop. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1147 |
int unicodeFromPrimaryKeysym = keysymToUnicode( xkeycodeToPrimaryKeysym(ev) ,0); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1148 |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1149 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1150 |
keyEventLog.fine(">>>Fire Event:"+ |
1151 |
(ev.get_type() == XConstants.KeyPress ? "KEY_PRESSED; " : "KEY_RELEASED; ")+ |
|
1152 |
"jkeycode:decimal="+jkc.getJavaKeycode()+ |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1153 |
", hex=0x"+Integer.toHexString(jkc.getJavaKeycode())+"; "+ |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1154 |
" legacy jkeycode: decimal="+XKeysym.getLegacyJavaKeycodeOnly(ev)+ |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1155 |
", hex=0x"+Integer.toHexString(XKeysym.getLegacyJavaKeycodeOnly(ev))+"; " |
2 | 1156 |
); |
1157 |
} |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1158 |
|
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1159 |
int jkeyToReturn = XKeysym.getLegacyJavaKeycodeOnly(ev); // someway backward compatible |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1160 |
int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ? |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1161 |
primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) : |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1162 |
jkc.getJavaKeycode(); |
2 | 1163 |
postKeyEvent( java.awt.event.KeyEvent.KEY_PRESSED, |
1164 |
ev.get_time(), |
|
14163
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1165 |
isDeadKey ? jkeyExtended : jkeyToReturn, |
2 | 1166 |
(unicodeKey == 0 ? java.awt.event.KeyEvent.CHAR_UNDEFINED : unicodeKey), |
1167 |
jkc.getKeyLocation(), |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1168 |
ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)(ev.get_keycode()), |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1169 |
unicodeFromPrimaryKeysym, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1170 |
jkeyExtended); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1171 |
|
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1172 |
|
14163
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1173 |
if (unicodeKey > 0 && !isDeadKey) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1174 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1175 |
keyEventLog.fine("fire _TYPED on "+unicodeKey); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1176 |
} |
2 | 1177 |
postKeyEvent( java.awt.event.KeyEvent.KEY_TYPED, |
1178 |
ev.get_time(), |
|
1179 |
java.awt.event.KeyEvent.VK_UNDEFINED, |
|
1180 |
unicodeKey, |
|
1181 |
java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN, |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1182 |
ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)0, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1183 |
unicodeFromPrimaryKeysym, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1184 |
java.awt.event.KeyEvent.VK_UNDEFINED); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1185 |
|
2 | 1186 |
} |
1187 |
||
1188 |
||
1189 |
} |
|
1190 |
||
1191 |
public void handleKeyRelease(XEvent xev) { |
|
1192 |
super.handleKeyRelease(xev); |
|
1193 |
XKeyEvent ev = xev.get_xkey(); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1194 |
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1195 |
eventLog.fine(ev.toString()); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1196 |
} |
2 | 1197 |
if (isEventDisabled(xev)) { |
1198 |
return; |
|
1199 |
} |
|
1200 |
handleKeyRelease(ev); |
|
1201 |
} |
|
1202 |
// un-private it if you need to call it from elsewhere |
|
1203 |
private void handleKeyRelease(XKeyEvent ev) { |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1204 |
int unicodeKey = 0; |
2 | 1205 |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1206 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1207 |
logIncomingKeyEvent( ev ); |
1208 |
} |
|
1209 |
// Keysym should be converted to Unicode, if possible and necessary, |
|
1210 |
// and Java KeyEvent keycode should be calculated. |
|
1211 |
// For release we should post released event. |
|
1212 |
// |
|
14163
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1213 |
// Preserve modifiers to get Java key code for dead keys |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1214 |
long keysym = xkeycodeToKeysym(ev); |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1215 |
boolean isDeadKey = isDeadKey(keysym); |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1216 |
XKeysym.Keysym2JavaKeycode jkc = isDeadKey ? XKeysym.getJavaKeycode(keysym) |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1217 |
: XKeysym.getJavaKeycode(ev); |
2 | 1218 |
if( jkc == null ) { |
1219 |
jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN); |
|
1220 |
} |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1221 |
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1222 |
keyEventLog.fine(">>>Fire Event:"+ |
1223 |
(ev.get_type() == XConstants.KeyPress ? "KEY_PRESSED; " : "KEY_RELEASED; ")+ |
|
1224 |
"jkeycode:decimal="+jkc.getJavaKeycode()+ |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1225 |
", hex=0x"+Integer.toHexString(jkc.getJavaKeycode())+"; "+ |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1226 |
" legacy jkeycode: decimal="+XKeysym.getLegacyJavaKeycodeOnly(ev)+ |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1227 |
", hex=0x"+Integer.toHexString(XKeysym.getLegacyJavaKeycodeOnly(ev))+"; " |
2 | 1228 |
); |
1229 |
} |
|
1230 |
// We obtain keysym from IM and derive unicodeKey from it for KeyPress only. |
|
1231 |
// We used to cache that value and retrieve it on KeyRelease, |
|
1232 |
// but in case for example of a dead key+vowel pair, a vowel after a deadkey |
|
1233 |
// might never be cached before. |
|
1234 |
// Also, switching between keyboard layouts, we might cache a wrong letter. |
|
1235 |
// That's why we use the same procedure as if there was no IM instance: do-it-yourself unicode. |
|
1236 |
unicodeKey = keysymToUnicode( xkeycodeToKeysym(ev), ev.get_state() ); |
|
1237 |
||
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1238 |
// Take a first keysym from a keysym array associated with the XKeyevent |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1239 |
// and convert it to Unicode. Then, even if Java keycode for the keystroke |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1240 |
// is undefined, we still will have a guess of what was engraved on a keytop. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1241 |
int unicodeFromPrimaryKeysym = keysymToUnicode( xkeycodeToPrimaryKeysym(ev) ,0); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1242 |
|
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1243 |
int jkeyToReturn = XKeysym.getLegacyJavaKeycodeOnly(ev); // someway backward compatible |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1244 |
int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ? |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1245 |
primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) : |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1246 |
jkc.getJavaKeycode(); |
2 | 1247 |
postKeyEvent( java.awt.event.KeyEvent.KEY_RELEASED, |
1248 |
ev.get_time(), |
|
14163
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1249 |
isDeadKey ? jkeyExtended : jkeyToReturn, |
2 | 1250 |
(unicodeKey == 0 ? java.awt.event.KeyEvent.CHAR_UNDEFINED : unicodeKey), |
1251 |
jkc.getKeyLocation(), |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1252 |
ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)(ev.get_keycode()), |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1253 |
unicodeFromPrimaryKeysym, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1254 |
jkeyExtended); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1255 |
|
2 | 1256 |
|
1257 |
} |
|
1258 |
||
14163
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1259 |
|
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1260 |
private boolean isDeadKey(long keysym){ |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1261 |
return XKeySymConstants.XK_dead_grave <= keysym && keysym <= XKeySymConstants.XK_dead_semivoiced_sound; |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1262 |
} |
87f1bc730fe2
8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents:
13604
diff
changeset
|
1263 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1264 |
/* |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1265 |
* XmNiconic and Map/UnmapNotify (that XmNiconic relies on) are |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1266 |
* unreliable, since mapping changes can happen for a virtual desktop |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1267 |
* switch or MacOS style shading that became quite popular under X as |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1268 |
* well. Yes, it probably should not be this way, as it violates |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1269 |
* ICCCM, but reality is that quite a lot of window managers abuse |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1270 |
* mapping state. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1271 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1272 |
int getWMState() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1273 |
if (stateChanged) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1274 |
stateChanged = false; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1275 |
WindowPropertyGetter getter = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1276 |
new WindowPropertyGetter(window, XWM.XA_WM_STATE, 0, 1, false, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1277 |
XWM.XA_WM_STATE); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1278 |
try { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1279 |
int status = getter.execute(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1280 |
if (status != XConstants.Success || getter.getData() == 0) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1281 |
return savedState = XUtilConstants.WithdrawnState; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1282 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1283 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1284 |
if (getter.getActualType() != XWM.XA_WM_STATE.getAtom() && getter.getActualFormat() != 32) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1285 |
return savedState = XUtilConstants.WithdrawnState; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1286 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1287 |
savedState = (int)Native.getCard32(getter.getData()); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1288 |
} finally { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1289 |
getter.dispose(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1290 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1291 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1292 |
return savedState; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1293 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1294 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1295 |
/** |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1296 |
* Override this methods to get notifications when top-level window state changes. The state is |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1297 |
* meant in terms of ICCCM: WithdrawnState, IconicState, NormalState |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1298 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1299 |
protected void stateChanged(long time, int oldState, int newState) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1300 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1301 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1302 |
@Override |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1303 |
public void handlePropertyNotify(XEvent xev) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1304 |
super.handlePropertyNotify(xev); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1305 |
XPropertyEvent ev = xev.get_xproperty(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1306 |
if (ev.get_atom() == XWM.XA_WM_STATE.getAtom()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1307 |
// State has changed, invalidate saved value |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1308 |
stateChanged = true; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1309 |
stateChanged(ev.get_time(), savedState, getWMState()); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1310 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1311 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1312 |
|
2 | 1313 |
public void reshape(Rectangle bounds) { |
1314 |
reshape(bounds.x, bounds.y, bounds.width, bounds.height); |
|
1315 |
} |
|
1316 |
||
1317 |
public void reshape(int x, int y, int width, int height) { |
|
1318 |
if (width <= 0) { |
|
1319 |
width = 1; |
|
1320 |
} |
|
1321 |
if (height <= 0) { |
|
1322 |
height = 1; |
|
1323 |
} |
|
1324 |
this.x = x; |
|
1325 |
this.y = y; |
|
1326 |
this.width = width; |
|
1327 |
this.height = height; |
|
1328 |
xSetBounds(x, y, width, height); |
|
1329 |
// Fixed 6322593, 6304251, 6315137: |
|
1330 |
// XWindow's SurfaceData should be invalidated and recreated as part |
|
1331 |
// of the process of resizing the window |
|
1332 |
// see the evaluation of the bug 6304251 for more information |
|
1333 |
validateSurface(); |
|
1334 |
layout(); |
|
1335 |
} |
|
1336 |
||
1337 |
public void layout() {} |
|
1338 |
||
1339 |
boolean isShowing() { |
|
1340 |
return visible; |
|
1341 |
} |
|
1342 |
||
1343 |
boolean isResizable() { |
|
1344 |
return true; |
|
1345 |
} |
|
1346 |
||
1347 |
boolean isLocationByPlatform() { |
|
1348 |
return false; |
|
1349 |
} |
|
1350 |
||
1351 |
void updateSizeHints() { |
|
1352 |
updateSizeHints(x, y, width, height); |
|
1353 |
} |
|
1354 |
||
1355 |
void updateSizeHints(int x, int y, int width, int height) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1356 |
long flags = XUtilConstants.PSize | (isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition)); |
2 | 1357 |
if (!isResizable()) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1358 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1359 |
log.finer("Window {0} is not resizable", this); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1360 |
} |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1361 |
flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize; |
2 | 1362 |
} else { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1363 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1364 |
log.finer("Window {0} is resizable", this); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1365 |
} |
2 | 1366 |
} |
1367 |
setSizeHints(flags, x, y, width, height); |
|
1368 |
} |
|
1369 |
||
1370 |
void updateSizeHints(int x, int y) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1371 |
long flags = isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition); |
2 | 1372 |
if (!isResizable()) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1373 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1374 |
log.finer("Window {0} is not resizable", this); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1375 |
} |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1376 |
flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize | XUtilConstants.PSize; |
2 | 1377 |
} else { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
1378 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1379 |
log.finer("Window {0} is resizable", this); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
14888
diff
changeset
|
1380 |
} |
2 | 1381 |
} |
1382 |
setSizeHints(flags, x, y, width, height); |
|
1383 |
} |
|
1384 |
||
2805
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1385 |
void validateSurface() { |
2 | 1386 |
if ((width != oldWidth) || (height != oldHeight)) { |
2805
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1387 |
doValidateSurface(); |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1388 |
|
2 | 1389 |
oldWidth = width; |
1390 |
oldHeight = height; |
|
1391 |
} |
|
1392 |
} |
|
1393 |
||
2805
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1394 |
final void doValidateSurface() { |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1395 |
SurfaceData oldData = surfaceData; |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1396 |
if (oldData != null) { |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1397 |
surfaceData = graphicsConfig.createSurfaceData(this); |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1398 |
oldData.invalidate(); |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1399 |
} |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1400 |
} |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2643
diff
changeset
|
1401 |
|
2 | 1402 |
public SurfaceData getSurfaceData() { |
1403 |
return surfaceData; |
|
1404 |
} |
|
1405 |
||
1406 |
public void dispose() { |
|
1407 |
SurfaceData oldData = surfaceData; |
|
1408 |
surfaceData = null; |
|
1409 |
if (oldData != null) { |
|
1410 |
oldData.invalidate(); |
|
1411 |
} |
|
1412 |
XToolkit.targetDisposedPeer(target, this); |
|
1413 |
destroy(); |
|
1414 |
} |
|
1415 |
||
1416 |
public Point getLocationOnScreen() { |
|
1417 |
synchronized (target.getTreeLock()) { |
|
1418 |
Component comp = target; |
|
1419 |
||
1420 |
while (comp != null && !(comp instanceof Window)) { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4285
diff
changeset
|
1421 |
comp = AWTAccessor.getComponentAccessor().getParent(comp); |
2 | 1422 |
} |
1423 |
||
1424 |
// applets, embedded, etc - translate directly |
|
1425 |
// XXX: override in subclass? |
|
1426 |
if (comp == null || comp instanceof sun.awt.EmbeddedFrame) { |
|
1427 |
return toGlobal(0, 0); |
|
1428 |
} |
|
1429 |
||
1430 |
XToolkit.awtLock(); |
|
1431 |
try { |
|
1432 |
Object wpeer = XToolkit.targetToPeer(comp); |
|
1433 |
if (wpeer == null |
|
1434 |
|| !(wpeer instanceof XDecoratedPeer) |
|
1435 |
|| ((XDecoratedPeer)wpeer).configure_seen) |
|
1436 |
{ |
|
1437 |
return toGlobal(0, 0); |
|
1438 |
} |
|
1439 |
||
1440 |
// wpeer is an XDecoratedPeer not yet fully adopted by WM |
|
1441 |
Point pt = toOtherWindow(getContentWindow(), |
|
1442 |
((XDecoratedPeer)wpeer).getContentWindow(), |
|
1443 |
0, 0); |
|
1444 |
||
1445 |
if (pt == null) { |
|
1446 |
pt = new Point(((XBaseWindow)wpeer).getAbsoluteX(), ((XBaseWindow)wpeer).getAbsoluteY()); |
|
1447 |
} |
|
1448 |
pt.x += comp.getX(); |
|
1449 |
pt.y += comp.getY(); |
|
1450 |
return pt; |
|
1451 |
} finally { |
|
1452 |
XToolkit.awtUnlock(); |
|
1453 |
} |
|
1454 |
} |
|
1455 |
} |
|
1456 |
||
1457 |
||
1458 |
static void setBData(KeyEvent e, byte[] data) { |
|
13604 | 1459 |
AWTAccessor.getAWTEventAccessor().setBData(e, data); |
2 | 1460 |
} |
1461 |
||
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1462 |
public void postKeyEvent(int id, long when, int keyCode, int keyChar, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1463 |
int keyLocation, int state, long event, int eventSize, long rawCode, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1464 |
int unicodeFromPrimaryKeysym, int extendedKeyCode) |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1465 |
|
2 | 1466 |
{ |
1467 |
long jWhen = XToolkit.nowMillisUTC_offset(when); |
|
1468 |
int modifiers = getModifiers(state, 0, keyCode); |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1469 |
|
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
1470 |
KeyEvent ke = new KeyEvent(getEventSource(), id, jWhen, |
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2472
diff
changeset
|
1471 |
modifiers, keyCode, (char)keyChar, keyLocation); |
2 | 1472 |
if (event != 0) { |
1473 |
byte[] data = Native.toBytes(event, eventSize); |
|
1474 |
setBData(ke, data); |
|
1475 |
} |
|
13604 | 1476 |
|
1477 |
AWTAccessor.KeyEventAccessor kea = AWTAccessor.getKeyEventAccessor(); |
|
1478 |
kea.setRawCode(ke, rawCode); |
|
1479 |
kea.setPrimaryLevelUnicode(ke, (long)unicodeFromPrimaryKeysym); |
|
1480 |
kea.setExtendedKeyCode(ke, (long)extendedKeyCode); |
|
2 | 1481 |
postEventToEventQueue(ke); |
1482 |
} |
|
1483 |
||
1484 |
static native int getAWTKeyCodeForKeySym(int keysym); |
|
1485 |
static native int getKeySymForAWTKeyCode(int keycode); |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1486 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1487 |
/* These two methods are actually applicable to toplevel windows only. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1488 |
* However, the functionality is required by both the XWindowPeer and |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1489 |
* XWarningWindow, both of which have the XWindow as a common ancestor. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1490 |
* See XWM.setMotifDecor() for details. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1491 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1492 |
public PropMwmHints getMWMHints() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1493 |
if (mwm_hints == null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1494 |
mwm_hints = new PropMwmHints(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1495 |
if (!XWM.XA_MWM_HINTS.getAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS)) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1496 |
mwm_hints.zero(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1497 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1498 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1499 |
return mwm_hints; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1500 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1501 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1502 |
public void setMWMHints(PropMwmHints hints) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1503 |
mwm_hints = hints; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1504 |
if (hints != null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1505 |
XWM.XA_MWM_HINTS.setAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1506 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1507 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1508 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1509 |
protected final void initWMProtocols() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1510 |
wm_protocols.setAtomListProperty(this, getWMProtocols()); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1511 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1512 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1513 |
/** |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1514 |
* Returns list of protocols which should be installed on this window. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1515 |
* Descendants can override this method to add class-specific protocols |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1516 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1517 |
protected XAtomList getWMProtocols() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1518 |
// No protocols on simple window |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1519 |
return new XAtomList(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1520 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
1962
diff
changeset
|
1521 |
|
4256
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1522 |
/** |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1523 |
* Indicates if the window is currently in the FSEM. |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1524 |
* Synchronization: state lock. |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1525 |
*/ |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1526 |
private boolean fullScreenExclusiveModeState = false; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1527 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1528 |
// Implementation of the X11ComponentPeer |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1529 |
@Override |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1530 |
public void setFullScreenExclusiveModeState(boolean state) { |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1531 |
synchronized (getStateLock()) { |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1532 |
fullScreenExclusiveModeState = state; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1533 |
} |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1534 |
} |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1535 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1536 |
public final boolean isFullScreenExclusiveMode() { |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1537 |
synchronized (getStateLock()) { |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1538 |
return fullScreenExclusiveModeState; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1539 |
} |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1540 |
} |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
2810
diff
changeset
|
1541 |
|
2 | 1542 |
} |