author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 49782 | 7cbb8bd1fc29 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
49782 | 2 |
* Copyright (c) 2003, 2017, 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 |
||
49782 | 28 |
import java.awt.GraphicsDevice; |
29 |
import java.awt.GraphicsEnvironment; |
|
2 | 30 |
import java.awt.Point; |
31 |
import java.awt.Window; |
|
32 |
import java.awt.peer.MouseInfoPeer; |
|
49782 | 33 |
|
34 |
import sun.awt.AWTAccessor; |
|
34395 | 35 |
import sun.awt.X11GraphicsDevice; |
2 | 36 |
|
49782 | 37 |
public final class XMouseInfoPeer implements MouseInfoPeer { |
2 | 38 |
|
39 |
/** |
|
40 |
* Package-private constructor to prevent instantiation. |
|
41 |
*/ |
|
42 |
XMouseInfoPeer() { |
|
43 |
} |
|
44 |
||
45 |
public int fillPointWithCoords(Point point) { |
|
46 |
long display = XToolkit.getDisplay(); |
|
47 |
GraphicsEnvironment ge = GraphicsEnvironment. |
|
48 |
getLocalGraphicsEnvironment(); |
|
49 |
GraphicsDevice[] gds = ge.getScreenDevices(); |
|
50 |
int gdslen = gds.length; |
|
51 |
||
52 |
XToolkit.awtLock(); |
|
53 |
try { |
|
54 |
for (int i = 0; i < gdslen; i++) { |
|
55 |
long screenRoot = XlibWrapper.RootWindow(display, i); |
|
56 |
boolean pointerFound = XlibWrapper.XQueryPointer( |
|
57 |
display, screenRoot, |
|
58 |
XlibWrapper.larg1, // root_return |
|
59 |
XlibWrapper.larg2, // child_return |
|
60 |
XlibWrapper.larg3, // xr_return |
|
61 |
XlibWrapper.larg4, // yr_return |
|
62 |
XlibWrapper.larg5, // xw_return |
|
63 |
XlibWrapper.larg6, // yw_return |
|
64 |
XlibWrapper.larg7); // mask_return |
|
65 |
if (pointerFound) { |
|
66 |
point.x = Native.getInt(XlibWrapper.larg3); |
|
67 |
point.y = Native.getInt(XlibWrapper.larg4); |
|
34395 | 68 |
GraphicsDevice device = gds[i]; |
69 |
if (device instanceof X11GraphicsDevice) { |
|
70 |
int scale = ((X11GraphicsDevice) device).getScaleFactor(); |
|
71 |
point.x = XlibUtil.scaleDown(point.x, scale); |
|
72 |
point.y = XlibUtil.scaleDown(point.y, scale); |
|
73 |
} |
|
2 | 74 |
return i; |
75 |
} |
|
76 |
} |
|
77 |
} finally { |
|
78 |
XToolkit.awtUnlock(); |
|
79 |
} |
|
80 |
||
81 |
// this should never happen |
|
82 |
assert false : "No pointer found in the system."; |
|
83 |
return 0; |
|
84 |
} |
|
85 |
||
28231
b608ffcaed74
8066621: Suppress deprecation warnings in java.desktop module
darcy
parents:
25859
diff
changeset
|
86 |
@SuppressWarnings("deprecation") |
2 | 87 |
public boolean isWindowUnderMouse(Window w) { |
49782 | 88 |
if (w == null) { |
89 |
return false; |
|
90 |
} |
|
91 |
XWindow peer = AWTAccessor.getComponentAccessor().getPeer(w); |
|
92 |
if (peer == null) { |
|
93 |
return false; |
|
94 |
} |
|
2 | 95 |
long display = XToolkit.getDisplay(); |
30469 | 96 |
long contentWindow = peer.getContentWindow(); |
2 | 97 |
long parent = XlibUtil.getParentWindow(contentWindow); |
98 |
||
99 |
XToolkit.awtLock(); |
|
100 |
try |
|
101 |
{ |
|
102 |
boolean windowOnTheSameScreen = XlibWrapper.XQueryPointer(display, parent, |
|
103 |
XlibWrapper.larg1, // root_return |
|
104 |
XlibWrapper.larg8, // child_return |
|
105 |
XlibWrapper.larg3, // root_x_return |
|
106 |
XlibWrapper.larg4, // root_y_return |
|
107 |
XlibWrapper.larg5, // win_x_return |
|
108 |
XlibWrapper.larg6, // win_y_return |
|
109 |
XlibWrapper.larg7); // mask_return |
|
110 |
long siblingWindow = Native.getWindow(XlibWrapper.larg8); |
|
111 |
return (siblingWindow == contentWindow && windowOnTheSameScreen); |
|
112 |
} |
|
113 |
finally |
|
114 |
{ |
|
115 |
XToolkit.awtUnlock(); |
|
116 |
} |
|
117 |
} |
|
118 |
} |