author | anthony |
Fri, 01 Apr 2011 15:43:37 +0400 | |
changeset 8949 | a07c7c410e02 |
parent 7668 | d4a77089c587 |
child 9660 | 73dd0c7a8658 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
7668 | 2 |
* Copyright (c) 1999, 2010, 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 |
||
30 |
#include "awt_p.h" |
|
31 |
#include "awt_Component.h" |
|
32 |
#include "awt_GraphicsEnv.h" |
|
33 |
#define XK_MISCELLANY |
|
34 |
#include <X11/keysymdef.h> |
|
35 |
#include <X11/Intrinsic.h> |
|
36 |
#include <X11/Xutil.h> |
|
37 |
#include <X11/Xmd.h> |
|
38 |
#include <X11/extensions/xtestext1.h> |
|
39 |
#include <X11/extensions/XTest.h> |
|
40 |
#include <X11/extensions/XInput.h> |
|
41 |
#include <X11/extensions/XI.h> |
|
42 |
#include <jni.h> |
|
43 |
#include "robot_common.h" |
|
44 |
#include "canvas.h" |
|
45 |
#include "wsutils.h" |
|
46 |
#include "list.h" |
|
47 |
#include "multiVis.h" |
|
48 |
#ifdef __linux__ |
|
49 |
#include <sys/socket.h> |
|
50 |
#endif |
|
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
51 |
#include <dlfcn.h> |
2 | 52 |
|
53 |
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; |
|
54 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
55 |
static jint * masks; |
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
56 |
static jint num_buttons; |
2 | 57 |
|
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
58 |
static unsigned int s_robotInstanceCounter = 0; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
59 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
60 |
static void* xcompositeLibHandle = NULL; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
61 |
static Bool xcompositeExtAvailable = False; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
62 |
static Bool xcompositeExtTested = False; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
63 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
64 |
typedef Status (*T_XCompositeQueryVersion)(Display *dpy, int *major_versionp, int *minor_versionp); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
65 |
typedef Window (*T_XCompositeGetOverlayWindow)(Display *dpy, Window window); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
66 |
typedef void (*T_XCompositeReleaseOverlayWindow)(Display *dpy, Window window); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
67 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
68 |
static T_XCompositeQueryVersion XCompositeQueryVersion = NULL; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
69 |
static T_XCompositeGetOverlayWindow XCompositeGetOverlayWindow = NULL; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
70 |
static T_XCompositeReleaseOverlayWindow XCompositeReleaseOverlayWindow = NULL; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
71 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
72 |
|
2 | 73 |
static int32_t isXTestAvailable() { |
74 |
int32_t major_opcode, first_event, first_error; |
|
75 |
int32_t event_basep, error_basep, majorp, minorp; |
|
76 |
int32_t isXTestAvailable; |
|
77 |
||
78 |
/* check if XTest is available */ |
|
79 |
isXTestAvailable = XQueryExtension(awt_display, XTestExtensionName, &major_opcode, &first_event, &first_error); |
|
80 |
DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XTEST) returns major_opcode = %d, first_event = %d, first_error = %d", |
|
81 |
major_opcode, first_event, first_error); |
|
82 |
if (isXTestAvailable) { |
|
83 |
/* check if XTest version is OK */ |
|
84 |
XTestQueryExtension(awt_display, &event_basep, &error_basep, &majorp, &minorp); |
|
85 |
DTRACE_PRINTLN4("RobotPeer: XTestQueryExtension returns event_basep = %d, error_basep = %d, majorp = %d, minorp = %d", |
|
86 |
event_basep, error_basep, majorp, minorp); |
|
87 |
if (majorp < 2 || (majorp == 2 && minorp < 2)) { |
|
88 |
/* bad version*/ |
|
89 |
DTRACE_PRINTLN2("XRobotPeer: XTEST version is %d.%d \n", majorp, minorp); |
|
90 |
if (majorp == 2 && minorp == 1) { |
|
91 |
DTRACE_PRINTLN("XRobotPeer: XTEST is 2.1 - no grab is available\n"); |
|
92 |
} else { |
|
93 |
isXTestAvailable = False; |
|
94 |
} |
|
95 |
} else { |
|
96 |
/* allow XTest calls even if someone else has the grab; e.g. during |
|
97 |
* a window resize operation. Works only with XTEST2.2*/ |
|
98 |
XTestGrabControl(awt_display, True); |
|
99 |
} |
|
100 |
} else { |
|
101 |
DTRACE_PRINTLN("RobotPeer: XTEST extension is unavailable"); |
|
102 |
} |
|
103 |
||
104 |
return isXTestAvailable; |
|
105 |
} |
|
106 |
||
107 |
||
108 |
static XImage *getWindowImage(Display * display, Window window, |
|
109 |
int32_t x, int32_t y, |
|
110 |
int32_t w, int32_t h) { |
|
111 |
XImage *image; |
|
112 |
int32_t transparentOverlays; |
|
113 |
int32_t numVisuals; |
|
114 |
XVisualInfo *pVisuals; |
|
115 |
int32_t numOverlayVisuals; |
|
116 |
OverlayInfo *pOverlayVisuals; |
|
117 |
int32_t numImageVisuals; |
|
118 |
XVisualInfo **pImageVisuals; |
|
119 |
list_ptr vis_regions; /* list of regions to read from */ |
|
120 |
list_ptr vis_image_regions ; |
|
121 |
int32_t allImage = 0 ; |
|
122 |
int32_t format = ZPixmap; |
|
123 |
||
124 |
/* prevent user from moving stuff around during the capture */ |
|
125 |
XGrabServer(display); |
|
126 |
||
127 |
/* |
|
128 |
* The following two functions live in multiVis.c-- they are pretty |
|
129 |
* much verbatim taken from the source to the xwd utility from the |
|
130 |
* X11 source. This version of the xwd source was somewhat better written |
|
131 |
* for reuse compared to Sun's version. |
|
132 |
* |
|
133 |
* ftp.x.org/pub/R6.3/xc/programs/xwd |
|
134 |
* |
|
135 |
* We use these functions since they do the very tough job of capturing |
|
136 |
* the screen correctly when it contains multiple visuals. They take into |
|
137 |
* account the depth/colormap of each visual and produce a capture as a |
|
138 |
* 24-bit RGB image so we don't have to fool around with colormaps etc. |
|
139 |
*/ |
|
140 |
||
141 |
GetMultiVisualRegions( |
|
142 |
display, |
|
143 |
window, |
|
144 |
x, y, w, h, |
|
145 |
&transparentOverlays, |
|
146 |
&numVisuals, |
|
147 |
&pVisuals, |
|
148 |
&numOverlayVisuals, |
|
149 |
&pOverlayVisuals, |
|
150 |
&numImageVisuals, |
|
151 |
&pImageVisuals, |
|
152 |
&vis_regions, |
|
153 |
&vis_image_regions, |
|
154 |
&allImage ); |
|
155 |
||
156 |
image = ReadAreaToImage( |
|
157 |
display, |
|
158 |
window, |
|
159 |
x, y, w, h, |
|
160 |
numVisuals, |
|
161 |
pVisuals, |
|
162 |
numOverlayVisuals, |
|
163 |
pOverlayVisuals, |
|
164 |
numImageVisuals, |
|
165 |
pImageVisuals, |
|
166 |
vis_regions, |
|
167 |
vis_image_regions, |
|
168 |
format, |
|
169 |
allImage ); |
|
170 |
||
171 |
/* allow user to do stuff again */ |
|
172 |
XUngrabServer(display); |
|
173 |
||
174 |
/* make sure the grab/ungrab is flushed */ |
|
175 |
XSync(display, False); |
|
176 |
||
177 |
return image; |
|
178 |
} |
|
179 |
||
180 |
/*********************************************************************************************/ |
|
181 |
||
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
182 |
// this should be called from XRobotPeer constructor |
2 | 183 |
JNIEXPORT void JNICALL |
6825 | 184 |
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons, jintArray buttonDownMasks) |
185 |
{ |
|
2 | 186 |
int32_t xtestAvailable; |
6825 | 187 |
jint *tmp; |
188 |
int i; |
|
2 | 189 |
|
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
190 |
DTRACE_PRINTLN("RobotPeer: setup()"); |
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
191 |
|
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
192 |
num_buttons = numberOfButtons; |
6825 | 193 |
tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE); |
194 |
masks = (jint *)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
|
195 |
if (masks == (jint *) NULL) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
196 |
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL); |
6825 | 197 |
(*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0); |
198 |
return; |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
199 |
} |
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
200 |
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
|
201 |
masks[i] = tmp[i]; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
202 |
} |
6825 | 203 |
(*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
|
204 |
|
2 | 205 |
AWT_LOCK(); |
206 |
xtestAvailable = isXTestAvailable(); |
|
207 |
DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable); |
|
208 |
if (!xtestAvailable) { |
|
209 |
JNU_ThrowByName(env, "java/awt/AWTException", "java.awt.Robot requires your X server support the XTEST extension version 2.2"); |
|
210 |
} |
|
211 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
212 |
AWT_UNLOCK(); |
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
213 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
214 |
s_robotInstanceCounter++; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
215 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
216 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
217 |
JNIEXPORT void JNICALL |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
218 |
Java_sun_awt_X11_XRobotPeer__1dispose (JNIEnv * env, jclass cls) |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
219 |
{ |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
220 |
if (--s_robotInstanceCounter) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
221 |
return; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
222 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
223 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
224 |
// This is the last instance of the XRobotPeer being released |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
225 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
226 |
if (xcompositeExtTested && xcompositeExtAvailable && xcompositeLibHandle) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
227 |
// The lib is loaded in IsXCompositeAvailable(). Unload under AWT_LOCK |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
228 |
// so that the shutdown function of the lib behaves correctly. |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
229 |
AWT_LOCK(); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
230 |
dlclose(xcompositeLibHandle); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
231 |
AWT_UNLOCK(); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
232 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
233 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
234 |
xcompositeExtTested = False; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
235 |
xcompositeExtAvailable = False; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
236 |
xcompositeLibHandle = NULL; |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
237 |
} |
2 | 238 |
|
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
239 |
/* |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
240 |
* Returns True only if XCOMPOSITE is of version 0.3 or higher. |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
241 |
* The functions that we need are available since that version. |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
242 |
* |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
243 |
* Must be invoked under AWT_LOCK. |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
244 |
* |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
245 |
* Leaves the library loaded if the version is correct. |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
246 |
*/ |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
247 |
static Bool IsXCompositeAvailable() |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
248 |
{ |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
249 |
if (!xcompositeExtTested) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
250 |
int opcode, eventb, errorb; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
251 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
252 |
if (XQueryExtension(awt_display, "Composite", &opcode, &eventb, &errorb)) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
253 |
xcompositeLibHandle = dlopen("libXcomposite.so.1", RTLD_LAZY | RTLD_GLOBAL); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
254 |
#ifndef __linux__ /* SOLARIS */ |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
255 |
if (xcompositeLibHandle == NULL) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
256 |
xcompositeLibHandle = dlopen("/usr/sfw/lib/libXcomposite.so.1", |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
257 |
RTLD_LAZY | RTLD_GLOBAL); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
258 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
259 |
#endif |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
260 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
261 |
if (xcompositeLibHandle) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
262 |
int major, minor; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
263 |
XCompositeQueryVersion = (T_XCompositeQueryVersion)dlsym(xcompositeLibHandle, "XCompositeQueryVersion"); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
264 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
265 |
if (XCompositeQueryVersion && XCompositeQueryVersion(awt_display, &major, &minor)) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
266 |
if (major >= 0 && minor >= 3) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
267 |
XCompositeGetOverlayWindow = (T_XCompositeGetOverlayWindow)dlsym(xcompositeLibHandle, "XCompositeGetOverlayWindow"); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
268 |
XCompositeReleaseOverlayWindow = (T_XCompositeReleaseOverlayWindow)dlsym(xcompositeLibHandle, "XCompositeReleaseOverlayWindow"); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
269 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
270 |
if (XCompositeGetOverlayWindow && XCompositeReleaseOverlayWindow) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
271 |
xcompositeExtAvailable = True; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
272 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
273 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
274 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
275 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
276 |
if (!xcompositeExtAvailable) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
277 |
dlclose(xcompositeLibHandle); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
278 |
} /* else the lib is unloaded in _dispose() */ |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
279 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
280 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
281 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
282 |
xcompositeExtTested = True; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
283 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
284 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
285 |
return xcompositeExtAvailable; |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
286 |
} |
2 | 287 |
|
288 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
289 |
Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, |
2 | 290 |
jclass cls, |
291 |
jobject xgc, |
|
292 |
jint x, |
|
293 |
jint y, |
|
294 |
jint width, |
|
295 |
jint height, |
|
296 |
jintArray pixelArray) { |
|
297 |
||
298 |
XImage *image; |
|
299 |
jint *ary; /* Array of jints for sending pixel values back |
|
300 |
* to parent process. |
|
301 |
*/ |
|
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
302 |
Window window; |
2 | 303 |
AwtGraphicsConfigDataPtr adata; |
304 |
||
305 |
DTRACE_PRINTLN6("RobotPeer: getRGBPixelsImpl(%lx, %d, %d, %d, %d, %x)", xgc, x, y, width, height, pixelArray); |
|
306 |
||
307 |
AWT_LOCK(); |
|
308 |
||
309 |
/* avoid a lot of work for empty rectangles */ |
|
310 |
if ((width * height) == 0) { |
|
311 |
AWT_UNLOCK(); |
|
312 |
return; |
|
313 |
} |
|
314 |
DASSERT(width * height > 0); /* only allow positive size */ |
|
315 |
||
316 |
adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData); |
|
317 |
DASSERT(adata != NULL); |
|
318 |
||
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
319 |
window = XRootWindow(awt_display, adata->awt_visInfo.screen); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
320 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
321 |
if (IsXCompositeAvailable()) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
322 |
// Use 'composite overlay window' instead of the root window. |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
323 |
// See 6903034 for details. |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
324 |
window = XCompositeGetOverlayWindow(awt_display, window); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
325 |
} |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
326 |
|
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
327 |
image = getWindowImage(awt_display, window, x, y, width, height); |
2 | 328 |
|
329 |
/* Array to use to crunch around the pixel values */ |
|
330 |
ary = (jint *) malloc(width * height * sizeof (jint)); |
|
331 |
if (ary == NULL) { |
|
332 |
JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError"); |
|
333 |
XDestroyImage(image); |
|
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
334 |
if (IsXCompositeAvailable()) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
335 |
XCompositeReleaseOverlayWindow(awt_display, window); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
336 |
} |
2 | 337 |
AWT_UNLOCK(); |
338 |
return; |
|
339 |
} |
|
340 |
/* convert to Java ARGB pixels */ |
|
341 |
for (y = 0; y < height; y++) { |
|
342 |
for (x = 0; x < width; x++) { |
|
343 |
jint pixel = (jint) XGetPixel(image, x, y); /* Note ignore upper |
|
344 |
* 32-bits on 64-bit |
|
345 |
* OSes. |
|
346 |
*/ |
|
347 |
||
348 |
pixel |= 0xff000000; /* alpha - full opacity */ |
|
349 |
||
350 |
ary[(y * width) + x] = pixel; |
|
351 |
} |
|
352 |
} |
|
353 |
(*env)->SetIntArrayRegion(env, pixelArray, 0, height * width, ary); |
|
354 |
free(ary); |
|
355 |
||
356 |
XDestroyImage(image); |
|
8949
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
357 |
if (IsXCompositeAvailable()) { |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
358 |
XCompositeReleaseOverlayWindow(awt_display, window); |
a07c7c410e02
6903034: java.awt.Robot.createScreenCapture() doesn't work for translucent windows
anthony
parents:
7668
diff
changeset
|
359 |
} |
2 | 360 |
|
361 |
AWT_UNLOCK(); |
|
362 |
} |
|
363 |
||
364 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
365 |
Java_sun_awt_X11_XRobotPeer_keyPressImpl (JNIEnv *env, |
2 | 366 |
jclass cls, |
367 |
jint keycode) { |
|
368 |
||
369 |
AWT_LOCK(); |
|
370 |
||
371 |
DTRACE_PRINTLN1("RobotPeer: keyPressImpl(%i)", keycode); |
|
372 |
||
373 |
XTestFakeKeyEvent(awt_display, |
|
374 |
XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)), |
|
375 |
True, |
|
376 |
CurrentTime); |
|
377 |
||
378 |
XSync(awt_display, False); |
|
379 |
||
380 |
AWT_UNLOCK(); |
|
381 |
||
382 |
} |
|
383 |
||
384 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
385 |
Java_sun_awt_X11_XRobotPeer_keyReleaseImpl (JNIEnv *env, |
2 | 386 |
jclass cls, |
387 |
jint keycode) { |
|
388 |
AWT_LOCK(); |
|
389 |
||
390 |
DTRACE_PRINTLN1("RobotPeer: keyReleaseImpl(%i)", keycode); |
|
391 |
||
392 |
XTestFakeKeyEvent(awt_display, |
|
393 |
XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)), |
|
394 |
False, |
|
395 |
CurrentTime); |
|
396 |
||
397 |
XSync(awt_display, False); |
|
398 |
||
399 |
AWT_UNLOCK(); |
|
400 |
} |
|
401 |
||
402 |
JNIEXPORT void JNICALL |
|
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
403 |
Java_sun_awt_X11_XRobotPeer_mouseMoveImpl (JNIEnv *env, |
2 | 404 |
jclass cls, |
405 |
jobject xgc, |
|
406 |
jint root_x, |
|
407 |
jint root_y) { |
|
408 |
||
409 |
AwtGraphicsConfigDataPtr adata; |
|
410 |
||
411 |
AWT_LOCK(); |
|
412 |
||
413 |
DTRACE_PRINTLN3("RobotPeer: mouseMoveImpl(%lx, %i, %i)", xgc, root_x, root_y); |
|
414 |
||
415 |
adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData); |
|
416 |
DASSERT(adata != NULL); |
|
417 |
||
418 |
XWarpPointer(awt_display, None, XRootWindow(awt_display, adata->awt_visInfo.screen), 0, 0, 0, 0, root_x, root_y); |
|
419 |
XSync(awt_display, False); |
|
420 |
||
421 |
AWT_UNLOCK(); |
|
422 |
} |
|
423 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
424 |
/* |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
425 |
* 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
|
426 |
*/ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
427 |
void mouseAction(JNIEnv *env, |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
428 |
jclass cls, |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
429 |
jint buttonMask, |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
430 |
Bool isMousePress) |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
431 |
{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
432 |
AWT_LOCK(); |
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 |
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
|
435 |
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
|
436 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
437 |
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
|
438 |
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
|
439 |
{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
440 |
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
|
441 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
442 |
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
|
443 |
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
|
444 |
(num_buttons >= 2)) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
445 |
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
|
446 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
(num_buttons >= 3)) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
450 |
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
|
451 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
452 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
453 |
if (num_buttons > 3){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
454 |
int32_t i; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
455 |
int32_t button = 0; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
456 |
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
|
457 |
if ((buttonMask & masks[i])) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
458 |
// 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
|
459 |
// 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
|
460 |
// 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
|
461 |
button = i + 3; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
462 |
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
|
463 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
464 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
465 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
466 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
467 |
XSync(awt_display, False); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
468 |
AWT_UNLOCK(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
469 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
470 |
|
1965
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
471 |
JNIEXPORT void JNICALL |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
472 |
Java_sun_awt_X11_XRobotPeer_mousePressImpl (JNIEnv *env, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
473 |
jclass cls, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
474 |
jint buttonMask) { |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
475 |
mouseAction(env, cls, buttonMask, True); |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
476 |
} |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
477 |
|
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
478 |
JNIEXPORT void JNICALL |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
479 |
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl (JNIEnv *env, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
480 |
jclass cls, |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
481 |
jint buttonMask) { |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
482 |
mouseAction(env, cls, buttonMask, False); |
726a2bc97146
6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents:
1962
diff
changeset
|
483 |
} |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1175
diff
changeset
|
484 |
|
2 | 485 |
JNIEXPORT void JNICALL |
1175
026b52c440fe
6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents:
2
diff
changeset
|
486 |
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl (JNIEnv *env, |
2 | 487 |
jclass cls, |
488 |
jint wheelAmt) { |
|
489 |
/* Mouse wheel is implemented as a button press of button 4 and 5, so it */ |
|
490 |
/* probably could have been hacked into robot_mouseButtonEvent, but it's */ |
|
491 |
/* cleaner to give it its own command type, in case the implementation */ |
|
492 |
/* needs to be changed later. -bchristi, 6/20/01 */ |
|
493 |
||
494 |
int32_t repeat = abs(wheelAmt); |
|
495 |
int32_t button = wheelAmt < 0 ? 4 : 5; /* wheel up: button 4 */ |
|
496 |
/* wheel down: button 5 */ |
|
497 |
int32_t loopIdx; |
|
498 |
||
499 |
AWT_LOCK(); |
|
500 |
||
501 |
DTRACE_PRINTLN1("RobotPeer: mouseWheelImpl(%i)", wheelAmt); |
|
502 |
||
503 |
for (loopIdx = 0; loopIdx < repeat; loopIdx++) { /* do nothing for */ |
|
504 |
/* wheelAmt == 0 */ |
|
505 |
XTestFakeButtonEvent(awt_display, button, True, CurrentTime); |
|
506 |
XTestFakeButtonEvent(awt_display, button, False, CurrentTime); |
|
507 |
} |
|
508 |
XSync(awt_display, False); |
|
509 |
||
510 |
AWT_UNLOCK(); |
|
511 |
} |