--- old/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java 2015-07-23 19:29:59.412157140 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java 2015-07-23 19:29:59.212157135 +0300 @@ -25,15 +25,16 @@ package sun.awt.X11; import java.awt.*; -import java.awt.event.InputEvent; import java.awt.peer.*; import sun.awt.AWTAccessor; import sun.awt.SunToolkit; +import sun.awt.UNIXToolkit; import sun.awt.X11GraphicsConfig; class XRobotPeer implements RobotPeer { + private static volatile boolean isGtkSupported; private X11GraphicsConfig xgc = null; /* * native implementation uses some static shared data (pipes, processes) @@ -44,46 +45,65 @@ XRobotPeer(GraphicsConfiguration gc) { this.xgc = (X11GraphicsConfig)gc; SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); - setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks()); + setup(tk.getNumberOfButtons(), + AWTAccessor.getInputEventAccessor().getButtonDownMasks()); + + Toolkit toolkit = Toolkit.getDefaultToolkit(); + if (!isGtkSupported) { + if (toolkit instanceof UNIXToolkit + && ((UNIXToolkit) toolkit).loadGTK()) { + isGtkSupported = true; + } + } } + @Override public void dispose() { // does nothing } + @Override public void mouseMove(int x, int y) { mouseMoveImpl(xgc, x, y); } + @Override public void mousePress(int buttons) { mousePressImpl(buttons); } + @Override public void mouseRelease(int buttons) { mouseReleaseImpl(buttons); } + @Override public void mouseWheel(int wheelAmt) { - mouseWheelImpl(wheelAmt); + mouseWheelImpl(wheelAmt); } + @Override public void keyPress(int keycode) { keyPressImpl(keycode); } + @Override public void keyRelease(int keycode) { keyReleaseImpl(keycode); } + @Override public int getRGBPixel(int x, int y) { int pixelArray[] = new int[1]; - getRGBPixelsImpl(xgc, x, y, 1, 1, pixelArray); + getRGBPixelsImpl(xgc, x, y, 1, 1, pixelArray, isGtkSupported); return pixelArray[0]; } + @Override public int [] getRGBPixels(Rectangle bounds) { int pixelArray[] = new int[bounds.width*bounds.height]; - getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, pixelArray); + getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, + pixelArray, isGtkSupported); return pixelArray; } @@ -97,5 +117,6 @@ private static native synchronized void keyPressImpl(int keycode); private static native synchronized void keyReleaseImpl(int keycode); - private static native synchronized void getRGBPixelsImpl(X11GraphicsConfig xgc, int x, int y, int width, int height, int pixelArray[]); + private static native synchronized void getRGBPixelsImpl(X11GraphicsConfig xgc, + int x, int y, int width, int height, int pixelArray[], boolean isGtkSupported); }