author | prr |
Sat, 19 Sep 2015 15:45:59 -0700 | |
changeset 32865 | f9cb6e427f9e |
parent 32282 | 9c9ff2c42e0d |
child 34395 | 2ac7e99f7f4a |
permissions | -rw-r--r-- |
2 | 1 |
/* |
32282 | 2 |
* Copyright (c) 2003, 2015, 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 |
package sun.awt.X11; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
import java.awt.peer.*; |
|
6825 | 29 |
|
30 |
import sun.awt.AWTAccessor; |
|
31 |
import sun.awt.SunToolkit; |
|
32282 | 32 |
import sun.awt.UNIXToolkit; |
2 | 33 |
import sun.awt.X11GraphicsConfig; |
34 |
||
35 |
class XRobotPeer implements RobotPeer { |
|
6825 | 36 |
|
32282 | 37 |
private static volatile boolean isGtkSupported; |
2 | 38 |
private X11GraphicsConfig xgc = null; |
39 |
/* |
|
40 |
* native implementation uses some static shared data (pipes, processes) |
|
41 |
* so use a class lock to synchronize native method calls |
|
42 |
*/ |
|
43 |
static Object robotLock = new Object(); |
|
44 |
||
45 |
XRobotPeer(GraphicsConfiguration gc) { |
|
46 |
this.xgc = (X11GraphicsConfig)gc; |
|
3337
45c02b7c01b6
6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents:
2810
diff
changeset
|
47 |
SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); |
32282 | 48 |
setup(tk.getNumberOfButtons(), |
49 |
AWTAccessor.getInputEventAccessor().getButtonDownMasks()); |
|
50 |
||
51 |
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
|
52 |
if (!isGtkSupported) { |
|
53 |
if (toolkit instanceof UNIXToolkit |
|
54 |
&& ((UNIXToolkit) toolkit).loadGTK()) { |
|
55 |
isGtkSupported = true; |
|
56 |
} |
|
57 |
} |
|
2 | 58 |
} |
59 |
||
32282 | 60 |
@Override |
2 | 61 |
public void dispose() { |
9660
73dd0c7a8658
7043455: Taking a screenshot may fail on X11 after 6903034
anthony
parents:
8949
diff
changeset
|
62 |
// does nothing |
2 | 63 |
} |
64 |
||
32282 | 65 |
@Override |
2 | 66 |
public void mouseMove(int x, int y) { |
67 |
mouseMoveImpl(xgc, x, y); |
|
68 |
} |
|
69 |
||
32282 | 70 |
@Override |
2 | 71 |
public void mousePress(int buttons) { |
72 |
mousePressImpl(buttons); |
|
73 |
} |
|
74 |
||
32282 | 75 |
@Override |
2 | 76 |
public void mouseRelease(int buttons) { |
77 |
mouseReleaseImpl(buttons); |
|
78 |
} |
|
79 |
||
32282 | 80 |
@Override |
2 | 81 |
public void mouseWheel(int wheelAmt) { |
32282 | 82 |
mouseWheelImpl(wheelAmt); |
2 | 83 |
} |
84 |
||
32282 | 85 |
@Override |
2 | 86 |
public void keyPress(int keycode) { |
87 |
keyPressImpl(keycode); |
|
88 |
} |
|
89 |
||
32282 | 90 |
@Override |
2 | 91 |
public void keyRelease(int keycode) { |
92 |
keyReleaseImpl(keycode); |
|
93 |
} |
|
94 |
||
32282 | 95 |
@Override |
2 | 96 |
public int getRGBPixel(int x, int y) { |
97 |
int pixelArray[] = new int[1]; |
|
32282 | 98 |
getRGBPixelsImpl(xgc, x, y, 1, 1, pixelArray, isGtkSupported); |
2 | 99 |
return pixelArray[0]; |
100 |
} |
|
101 |
||
32282 | 102 |
@Override |
2 | 103 |
public int [] getRGBPixels(Rectangle bounds) { |
104 |
int pixelArray[] = new int[bounds.width*bounds.height]; |
|
32282 | 105 |
getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, |
106 |
pixelArray, isGtkSupported); |
|
2 | 107 |
return pixelArray; |
108 |
} |
|
109 |
||
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
110 |
private static synchronized native void setup(int numberOfButtons, int[] buttonDownMasks); |
2 | 111 |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
112 |
private static synchronized native void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y); |
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
113 |
private static synchronized native void mousePressImpl(int buttons); |
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
114 |
private static synchronized native void mouseReleaseImpl(int buttons); |
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
115 |
private static synchronized native void mouseWheelImpl(int wheelAmt); |
2 | 116 |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
117 |
private static synchronized native void keyPressImpl(int keycode); |
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
118 |
private static synchronized native void keyReleaseImpl(int keycode); |
2 | 119 |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32282
diff
changeset
|
120 |
private static synchronized native void getRGBPixelsImpl(X11GraphicsConfig xgc, |
32282 | 121 |
int x, int y, int width, int height, int pixelArray[], boolean isGtkSupported); |
2 | 122 |
} |