author | prr |
Thu, 08 Nov 2018 10:34:49 -0800 | |
changeset 52542 | 8c7638601045 |
parent 47216 | 71c04702a3d5 |
child 57480 | 321bddd9afdf |
permissions | -rw-r--r-- |
2 | 1 |
/* |
44130
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
2 |
* Copyright (c) 1999, 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 |
#ifdef HEADLESS |
|
27 |
#error This file should not be included in headless library |
|
28 |
#endif |
|
29 |
||
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
30 |
#include "jvm_md.h" |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
31 |
#include <dlfcn.h> |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
32 |
|
2 | 33 |
#include "awt_p.h" |
34 |
#include "awt_GraphicsEnv.h" |
|
35 |
#define XK_MISCELLANY |
|
36 |
#include <X11/keysymdef.h> |
|
37 |
#include <X11/Xutil.h> |
|
38 |
#include <X11/Xmd.h> |
|
39 |
#include <X11/extensions/xtestext1.h> |
|
40 |
#include <X11/extensions/XTest.h> |
|
41 |
#include <X11/extensions/XInput.h> |
|
42 |
#include <X11/extensions/XI.h> |
|
43 |
#include <jni.h> |
|
18232 | 44 |
#include <sizecalc.h> |
2 | 45 |
#include "canvas.h" |
46 |
#include "wsutils.h" |
|
47 |
#include "list.h" |
|
48 |
#include "multiVis.h" |
|
37711
972001566d66
8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents:
37699
diff
changeset
|
49 |
#include "gtk_interface.h" |
32282 | 50 |
|
52542
8c7638601045
8210776: Upgrade X Window System 6.8.2 to the latest XWD 1.0.7
prr
parents:
47216
diff
changeset
|
51 |
#include "java_awt_event_InputEvent.h" |
8c7638601045
8210776: Upgrade X Window System 6.8.2 to the latest XWD 1.0.7
prr
parents:
47216
diff
changeset
|
52 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
53 |
#if defined(__linux__) || defined(MACOSX) |
2 | 54 |
#include <sys/socket.h> |
55 |
#endif |
|
56 |
||
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
57 |
static Bool (*compositeQueryExtension) (Display*, int*, int*); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
58 |
static Status (*compositeQueryVersion) (Display*, int*, int*); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
59 |
static Window (*compositeGetOverlayWindow) (Display *, Window); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
60 |
|
2 | 61 |
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; |
62 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
63 |
static jint * masks; |
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
64 |
static jint num_buttons; |
2 | 65 |
|
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
66 |
static void *xCompositeHandle; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
67 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
68 |
static const char* XCOMPOSITE = JNI_LIB_NAME("Xcomposite"); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
69 |
static const char* XCOMPOSITE_VERSIONED = VERSIONED_JNI_LIB_NAME("Xcomposite", "1"); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
70 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
71 |
static Bool checkXCompositeFunctions(void) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
72 |
return (compositeQueryExtension != NULL && |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
73 |
compositeQueryVersion != NULL && |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
74 |
compositeGetOverlayWindow != NULL); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
75 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
76 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
77 |
static void initXCompositeFunctions(void) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
78 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
79 |
if (xCompositeHandle == NULL) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
80 |
xCompositeHandle = dlopen(XCOMPOSITE, RTLD_LAZY | RTLD_GLOBAL); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
81 |
if (xCompositeHandle == NULL) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
82 |
xCompositeHandle = dlopen(XCOMPOSITE_VERSIONED, RTLD_LAZY | RTLD_GLOBAL); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
83 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
84 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
85 |
//*(void **)(&asyncGetCallTraceFunction) |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
86 |
if (xCompositeHandle != NULL) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
87 |
*(void **)(&compositeQueryExtension) = dlsym(xCompositeHandle, "XCompositeQueryExtension"); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
88 |
*(void **)(&compositeQueryVersion) = dlsym(xCompositeHandle, "XCompositeQueryVersion"); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
89 |
*(void **)(&compositeGetOverlayWindow) = dlsym(xCompositeHandle, "XCompositeGetOverlayWindow"); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
90 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
91 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
92 |
if (xCompositeHandle && !checkXCompositeFunctions()) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
93 |
dlclose(xCompositeHandle); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
94 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
95 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
96 |
|
2 | 97 |
static int32_t isXTestAvailable() { |
98 |
int32_t major_opcode, first_event, first_error; |
|
99 |
int32_t event_basep, error_basep, majorp, minorp; |
|
100 |
int32_t isXTestAvailable; |
|
101 |
||
102 |
/* check if XTest is available */ |
|
103 |
isXTestAvailable = XQueryExtension(awt_display, XTestExtensionName, &major_opcode, &first_event, &first_error); |
|
104 |
if (isXTestAvailable) { |
|
40148
f590f972ba1a
8161742: [parfait] Uninitialised memory in isXTestAvailable of awt_Robot.c:65
vadim
parents:
39852
diff
changeset
|
105 |
DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XTEST) returns major_opcode = %d, first_event = %d, first_error = %d", |
f590f972ba1a
8161742: [parfait] Uninitialised memory in isXTestAvailable of awt_Robot.c:65
vadim
parents:
39852
diff
changeset
|
106 |
major_opcode, first_event, first_error); |
2 | 107 |
/* check if XTest version is OK */ |
108 |
XTestQueryExtension(awt_display, &event_basep, &error_basep, &majorp, &minorp); |
|
109 |
DTRACE_PRINTLN4("RobotPeer: XTestQueryExtension returns event_basep = %d, error_basep = %d, majorp = %d, minorp = %d", |
|
110 |
event_basep, error_basep, majorp, minorp); |
|
111 |
if (majorp < 2 || (majorp == 2 && minorp < 2)) { |
|
112 |
/* bad version*/ |
|
113 |
DTRACE_PRINTLN2("XRobotPeer: XTEST version is %d.%d \n", majorp, minorp); |
|
114 |
if (majorp == 2 && minorp == 1) { |
|
115 |
DTRACE_PRINTLN("XRobotPeer: XTEST is 2.1 - no grab is available\n"); |
|
116 |
} else { |
|
117 |
isXTestAvailable = False; |
|
118 |
} |
|
119 |
} else { |
|
120 |
/* allow XTest calls even if someone else has the grab; e.g. during |
|
121 |
* a window resize operation. Works only with XTEST2.2*/ |
|
122 |
XTestGrabControl(awt_display, True); |
|
123 |
} |
|
124 |
} else { |
|
125 |
DTRACE_PRINTLN("RobotPeer: XTEST extension is unavailable"); |
|
126 |
} |
|
127 |
||
128 |
return isXTestAvailable; |
|
129 |
} |
|
130 |
||
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
131 |
static Bool hasXCompositeOverlayExtension(Display *display) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
132 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
133 |
int xoverlay = False; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
134 |
int eventBase, errorBase; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
135 |
if (checkXCompositeFunctions() && |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
136 |
compositeQueryExtension(display, &eventBase, &errorBase)) |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
137 |
{ |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
138 |
int major = 0; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
139 |
int minor = 0; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
140 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
141 |
compositeQueryVersion(display, &major, &minor); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
142 |
if (major > 0 || minor >= 3) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
143 |
xoverlay = True; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
144 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
145 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
146 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
147 |
return xoverlay; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
148 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
149 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
150 |
static jboolean isXCompositeDisplay(Display *display, int screenNumber) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
151 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
152 |
char NET_WM_CM_Sn[25]; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
153 |
snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
154 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
155 |
Atom managerSelection = XInternAtom(display, NET_WM_CM_Sn, 0); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
156 |
Window owner = XGetSelectionOwner(display, managerSelection); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
157 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
158 |
return owner != 0; |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
159 |
} |
2 | 160 |
|
161 |
static XImage *getWindowImage(Display * display, Window window, |
|
162 |
int32_t x, int32_t y, |
|
163 |
int32_t w, int32_t h) { |
|
164 |
XImage *image; |
|
165 |
int32_t transparentOverlays; |
|
166 |
int32_t numVisuals; |
|
167 |
XVisualInfo *pVisuals; |
|
168 |
int32_t numOverlayVisuals; |
|
169 |
OverlayInfo *pOverlayVisuals; |
|
170 |
int32_t numImageVisuals; |
|
171 |
XVisualInfo **pImageVisuals; |
|
172 |
list_ptr vis_regions; /* list of regions to read from */ |
|
173 |
list_ptr vis_image_regions ; |
|
174 |
int32_t allImage = 0 ; |
|
175 |
int32_t format = ZPixmap; |
|
176 |
||
177 |
/* prevent user from moving stuff around during the capture */ |
|
178 |
XGrabServer(display); |
|
179 |
||
180 |
/* |
|
181 |
* The following two functions live in multiVis.c-- they are pretty |
|
182 |
* much verbatim taken from the source to the xwd utility from the |
|
183 |
* X11 source. This version of the xwd source was somewhat better written |
|
184 |
* for reuse compared to Sun's version. |
|
185 |
* |
|
186 |
* ftp.x.org/pub/R6.3/xc/programs/xwd |
|
187 |
* |
|
188 |
* We use these functions since they do the very tough job of capturing |
|
189 |
* the screen correctly when it contains multiple visuals. They take into |
|
190 |
* account the depth/colormap of each visual and produce a capture as a |
|
191 |
* 24-bit RGB image so we don't have to fool around with colormaps etc. |
|
192 |
*/ |
|
193 |
||
194 |
GetMultiVisualRegions( |
|
195 |
display, |
|
196 |
window, |
|
197 |
x, y, w, h, |
|
198 |
&transparentOverlays, |
|
199 |
&numVisuals, |
|
200 |
&pVisuals, |
|
201 |
&numOverlayVisuals, |
|
202 |
&pOverlayVisuals, |
|
203 |
&numImageVisuals, |
|
204 |
&pImageVisuals, |
|
205 |
&vis_regions, |
|
206 |
&vis_image_regions, |
|
207 |
&allImage ); |
|
208 |
||
209 |
image = ReadAreaToImage( |
|
210 |
display, |
|
211 |
window, |
|
212 |
x, y, w, h, |
|
213 |
numVisuals, |
|
214 |
pVisuals, |
|
215 |
numOverlayVisuals, |
|
216 |
pOverlayVisuals, |
|
217 |
numImageVisuals, |
|
218 |
pImageVisuals, |
|
219 |
vis_regions, |
|
220 |
vis_image_regions, |
|
221 |
format, |
|
222 |
allImage ); |
|
223 |
||
224 |
/* allow user to do stuff again */ |
|
225 |
XUngrabServer(display); |
|
226 |
||
227 |
/* make sure the grab/ungrab is flushed */ |
|
228 |
XSync(display, False); |
|
229 |
||
230 |
return image; |
|
231 |
} |
|
232 |
||
233 |
/*********************************************************************************************/ |
|
234 |
||
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
235 |
// this should be called from XRobotPeer constructor |
2 | 236 |
JNIEXPORT void JNICALL |
6825 | 237 |
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons, jintArray buttonDownMasks) |
238 |
{ |
|
2 | 239 |
int32_t xtestAvailable; |
6825 | 240 |
jint *tmp; |
241 |
int i; |
|
2 | 242 |
|
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
243 |
DTRACE_PRINTLN("RobotPeer: setup()"); |
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
244 |
|
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
245 |
num_buttons = numberOfButtons; |
6825 | 246 |
tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE); |
24130
db72fc72f87b
8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents:
23010
diff
changeset
|
247 |
CHECK_NULL(tmp); |
db72fc72f87b
8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents:
23010
diff
changeset
|
248 |
|
18232 | 249 |
masks = (jint *)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), num_buttons); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
250 |
if (masks == (jint *) NULL) { |
24130
db72fc72f87b
8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents:
23010
diff
changeset
|
251 |
(*env)->ExceptionClear(env); |
db72fc72f87b
8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents:
23010
diff
changeset
|
252 |
(*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
253 |
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL); |
6825 | 254 |
return; |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
255 |
} |
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
256 |
for (i = 0; i < num_buttons; i++) { |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
257 |
masks[i] = tmp[i]; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
258 |
} |
6825 | 259 |
(*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
260 |
|
2 | 261 |
AWT_LOCK(); |
262 |
xtestAvailable = isXTestAvailable(); |
|
263 |
DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable); |
|
264 |
if (!xtestAvailable) { |
|
265 |
JNU_ThrowByName(env, "java/awt/AWTException", "java.awt.Robot requires your X server support the XTEST extension version 2.2"); |
|
266 |
} |
|
267 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
268 |
AWT_UNLOCK(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
269 |
} |
2 | 270 |
|
271 |
||
272 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
273 |
Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, |
2 | 274 |
jclass cls, |
275 |
jobject xgc, |
|
32282 | 276 |
jint jx, |
277 |
jint jy, |
|
278 |
jint jwidth, |
|
279 |
jint jheight, |
|
280 |
jintArray pixelArray, |
|
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
281 |
jboolean useGtk) { |
2 | 282 |
XImage *image; |
283 |
jint *ary; /* Array of jints for sending pixel values back |
|
284 |
* to parent process. |
|
285 |
*/ |
|
9660
73dd0c7a8658
7043455: Taking a screenshot may fail on X11 after 6903034
anthony
parents:
8949
diff
changeset
|
286 |
Window rootWindow; |
32282 | 287 |
XWindowAttributes attr; |
2 | 288 |
AwtGraphicsConfigDataPtr adata; |
289 |
||
32282 | 290 |
DTRACE_PRINTLN6("RobotPeer: getRGBPixelsImpl(%lx, %d, %d, %d, %d, %x)", xgc, jx, jy, jwidth, jheight, pixelArray); |
2 | 291 |
|
32282 | 292 |
if (jwidth <= 0 || jheight <= 0) { |
2 | 293 |
return; |
294 |
} |
|
295 |
||
296 |
adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData); |
|
297 |
DASSERT(adata != NULL); |
|
298 |
||
32282 | 299 |
AWT_LOCK(); |
300 |
||
9660
73dd0c7a8658
7043455: Taking a screenshot may fail on X11 after 6903034
anthony
parents:
8949
diff
changeset
|
301 |
rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen); |
2 | 302 |
|
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
303 |
if (!useGtk) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
304 |
if (hasXCompositeOverlayExtension(awt_display) && |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
305 |
isXCompositeDisplay(awt_display, adata->awt_visInfo.screen)) |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
306 |
{ |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
307 |
rootWindow = compositeGetOverlayWindow(awt_display, rootWindow); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
308 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
309 |
} |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
310 |
|
32282 | 311 |
if (!XGetWindowAttributes(awt_display, rootWindow, &attr) |
44130
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
312 |
|| jx + jwidth <= attr.x |
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
313 |
|| attr.x + attr.width <= jx |
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
314 |
|| jy + jheight <= attr.y |
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
315 |
|| attr.y + attr.height <= jy) { |
32282 | 316 |
|
2 | 317 |
AWT_UNLOCK(); |
32282 | 318 |
return; // Does not intersect with root window |
2 | 319 |
} |
32282 | 320 |
|
321 |
gboolean gtk_failed = TRUE; |
|
322 |
jint _x, _y; |
|
323 |
||
44130
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
324 |
jint x = MAX(jx, attr.x); |
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
325 |
jint y = MAX(jy, attr.y); |
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
326 |
jint width = MIN(jx + jwidth, attr.x + attr.width) - x; |
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
327 |
jint height = MIN(jy + jheight, attr.y + attr.height) - y; |
32282 | 328 |
|
44130
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
329 |
int dx = attr.x > jx ? attr.x - jx : 0; |
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
330 |
int dy = attr.y > jy ? attr.y - jy : 0; |
32282 | 331 |
|
332 |
int index; |
|
333 |
||
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
334 |
if (useGtk) { |
37711
972001566d66
8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents:
37699
diff
changeset
|
335 |
gtk->gdk_threads_enter(); |
972001566d66
8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents:
37699
diff
changeset
|
336 |
gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width, |
44130
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
337 |
height, jwidth, dx, dy, 1); |
37711
972001566d66
8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents:
37699
diff
changeset
|
338 |
gtk->gdk_threads_leave(); |
2 | 339 |
} |
32282 | 340 |
|
341 |
if (gtk_failed) { |
|
44130
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
342 |
image = getWindowImage(awt_display, rootWindow, x, y, width, height); |
32282 | 343 |
|
344 |
ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL); |
|
345 |
||
346 |
if (!ary) { |
|
347 |
XDestroyImage(image); |
|
348 |
AWT_UNLOCK(); |
|
349 |
return; |
|
350 |
} |
|
2 | 351 |
|
32282 | 352 |
/* convert to Java ARGB pixels */ |
353 |
for (_y = 0; _y < height; _y++) { |
|
354 |
for (_x = 0; _x < width; _x++) { |
|
44130
f3516efccffa
8162959: [HiDPI] screenshot artifacts using AWT Robot
pkbalakr
parents:
40148
diff
changeset
|
355 |
jint pixel = (jint) XGetPixel(image, _x, _y); |
34395 | 356 |
/* Note ignore upper |
32282 | 357 |
* 32-bits on 64-bit |
358 |
* OSes. |
|
359 |
*/ |
|
360 |
pixel |= 0xff000000; /* alpha - full opacity */ |
|
2 | 361 |
|
32282 | 362 |
index = (_y + dy) * jwidth + (_x + dx); |
363 |
ary[index] = pixel; |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
XDestroyImage(image); |
|
368 |
(*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0); |
|
369 |
} |
|
2 | 370 |
AWT_UNLOCK(); |
371 |
} |
|
372 |
||
373 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
374 |
Java_sun_awt_X11_XRobotPeer_keyPressImpl (JNIEnv *env, |
2 | 375 |
jclass cls, |
376 |
jint keycode) { |
|
377 |
||
378 |
AWT_LOCK(); |
|
379 |
||
380 |
DTRACE_PRINTLN1("RobotPeer: keyPressImpl(%i)", keycode); |
|
381 |
||
382 |
XTestFakeKeyEvent(awt_display, |
|
383 |
XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)), |
|
384 |
True, |
|
385 |
CurrentTime); |
|
386 |
||
387 |
XSync(awt_display, False); |
|
388 |
||
389 |
AWT_UNLOCK(); |
|
390 |
||
391 |
} |
|
392 |
||
393 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
394 |
Java_sun_awt_X11_XRobotPeer_keyReleaseImpl (JNIEnv *env, |
2 | 395 |
jclass cls, |
396 |
jint keycode) { |
|
397 |
AWT_LOCK(); |
|
398 |
||
399 |
DTRACE_PRINTLN1("RobotPeer: keyReleaseImpl(%i)", keycode); |
|
400 |
||
401 |
XTestFakeKeyEvent(awt_display, |
|
402 |
XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)), |
|
403 |
False, |
|
404 |
CurrentTime); |
|
405 |
||
406 |
XSync(awt_display, False); |
|
407 |
||
408 |
AWT_UNLOCK(); |
|
409 |
} |
|
410 |
||
411 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
412 |
Java_sun_awt_X11_XRobotPeer_mouseMoveImpl (JNIEnv *env, |
2 | 413 |
jclass cls, |
414 |
jobject xgc, |
|
415 |
jint root_x, |
|
416 |
jint root_y) { |
|
417 |
||
418 |
AwtGraphicsConfigDataPtr adata; |
|
419 |
||
420 |
AWT_LOCK(); |
|
421 |
||
422 |
DTRACE_PRINTLN3("RobotPeer: mouseMoveImpl(%lx, %i, %i)", xgc, root_x, root_y); |
|
423 |
||
424 |
adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData); |
|
425 |
DASSERT(adata != NULL); |
|
426 |
||
427 |
XWarpPointer(awt_display, None, XRootWindow(awt_display, adata->awt_visInfo.screen), 0, 0, 0, 0, root_x, root_y); |
|
428 |
XSync(awt_display, False); |
|
429 |
||
430 |
AWT_UNLOCK(); |
|
431 |
} |
|
432 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
433 |
/* |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
434 |
* Function joining the code of mousePressImpl and mouseReleaseImpl |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
435 |
*/ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
436 |
void mouseAction(JNIEnv *env, |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
437 |
jclass cls, |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
438 |
jint buttonMask, |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
439 |
Bool isMousePress) |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
440 |
{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
441 |
AWT_LOCK(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
442 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
443 |
DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
444 |
DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
445 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
446 |
if (buttonMask & java_awt_event_InputEvent_BUTTON1_MASK || |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
447 |
buttonMask & java_awt_event_InputEvent_BUTTON1_DOWN_MASK ) |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
448 |
{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
449 |
XTestFakeButtonEvent(awt_display, 1, isMousePress, CurrentTime); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
450 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
451 |
if ((buttonMask & java_awt_event_InputEvent_BUTTON2_MASK || |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
452 |
buttonMask & java_awt_event_InputEvent_BUTTON2_DOWN_MASK) && |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
453 |
(num_buttons >= 2)) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
454 |
XTestFakeButtonEvent(awt_display, 2, isMousePress, CurrentTime); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
455 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
456 |
if ((buttonMask & java_awt_event_InputEvent_BUTTON3_MASK || |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
457 |
buttonMask & java_awt_event_InputEvent_BUTTON3_DOWN_MASK) && |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
458 |
(num_buttons >= 3)) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
459 |
XTestFakeButtonEvent(awt_display, 3, isMousePress, CurrentTime); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
460 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
461 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
462 |
if (num_buttons > 3){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
463 |
int32_t i; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
464 |
int32_t button = 0; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
465 |
for (i = 3; i<num_buttons; i++){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
466 |
if ((buttonMask & masks[i])) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
467 |
// arrays starts from zero index => +1 |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
468 |
// users wants to affect 4 or 5 button but they are assigned |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
469 |
// to the wheel so => we have to shift it to the right by 2. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
470 |
button = i + 3; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
471 |
XTestFakeButtonEvent(awt_display, button, isMousePress, CurrentTime); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
472 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
473 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
474 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
475 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
476 |
XSync(awt_display, False); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
477 |
AWT_UNLOCK(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
478 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
479 |
|
1965
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
480 |
JNIEXPORT void JNICALL |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
481 |
Java_sun_awt_X11_XRobotPeer_mousePressImpl (JNIEnv *env, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
482 |
jclass cls, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
483 |
jint buttonMask) { |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
484 |
mouseAction(env, cls, buttonMask, True); |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
485 |
} |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
486 |
|
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
487 |
JNIEXPORT void JNICALL |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
488 |
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl (JNIEnv *env, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
489 |
jclass cls, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
490 |
jint buttonMask) { |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
491 |
mouseAction(env, cls, buttonMask, False); |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
492 |
} |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
493 |
|
2 | 494 |
JNIEXPORT void JNICALL |
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
495 |
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl (JNIEnv *env, |
2 | 496 |
jclass cls, |
497 |
jint wheelAmt) { |
|
498 |
/* Mouse wheel is implemented as a button press of button 4 and 5, so it */ |
|
499 |
/* probably could have been hacked into robot_mouseButtonEvent, but it's */ |
|
500 |
/* cleaner to give it its own command type, in case the implementation */ |
|
501 |
/* needs to be changed later. -bchristi, 6/20/01 */ |
|
502 |
||
503 |
int32_t repeat = abs(wheelAmt); |
|
504 |
int32_t button = wheelAmt < 0 ? 4 : 5; /* wheel up: button 4 */ |
|
505 |
/* wheel down: button 5 */ |
|
506 |
int32_t loopIdx; |
|
507 |
||
508 |
AWT_LOCK(); |
|
509 |
||
510 |
DTRACE_PRINTLN1("RobotPeer: mouseWheelImpl(%i)", wheelAmt); |
|
511 |
||
512 |
for (loopIdx = 0; loopIdx < repeat; loopIdx++) { /* do nothing for */ |
|
513 |
/* wheelAmt == 0 */ |
|
514 |
XTestFakeButtonEvent(awt_display, button, True, CurrentTime); |
|
515 |
XTestFakeButtonEvent(awt_display, button, False, CurrentTime); |
|
516 |
} |
|
517 |
XSync(awt_display, False); |
|
518 |
||
519 |
AWT_UNLOCK(); |
|
520 |
} |
|
39852
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
521 |
|
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
522 |
JNIEXPORT void JNICALL |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
523 |
Java_sun_awt_X11_XRobotPeer_loadNativeLibraries (JNIEnv *env, jclass cls) { |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
524 |
initXCompositeFunctions(); |
7da63510ba70
8150954: Taking screenshots on x11 composite desktop produce wrong result
neugens
parents:
37715
diff
changeset
|
525 |
} |