< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java

Print this page

        

*** 33,44 **** import sun.awt.X11GraphicsConfig; import sun.awt.X11GraphicsEnvironment; class XRobotPeer implements RobotPeer { ! private static volatile boolean isGtkSupported; private X11GraphicsConfig xgc = null; /* * native implementation uses some static shared data (pipes, processes) * so use a class lock to synchronize native method calls */ static Object robotLock = new Object(); --- 33,51 ---- import sun.awt.X11GraphicsConfig; import sun.awt.X11GraphicsEnvironment; class XRobotPeer implements RobotPeer { ! static final boolean tryGtk; ! static { ! loadNativeLibraries(); ! tryGtk = Boolean.getBoolean("awt.robot.gtk"); ! } ! ! private static volatile boolean useGtk; private X11GraphicsConfig xgc = null; + /* * native implementation uses some static shared data (pipes, processes) * so use a class lock to synchronize native method calls */ static Object robotLock = new Object();
*** 47,63 **** this.xgc = (X11GraphicsConfig)gc; SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); 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 --- 54,71 ---- this.xgc = (X11GraphicsConfig)gc; SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks()); ! boolean isGtkSupported = false; ! if (tryGtk && !isGtkSupported) { ! if (tk instanceof UNIXToolkit && ((UNIXToolkit) tk).loadGTK()) { isGtkSupported = true; } } + + useGtk = (tryGtk && isGtkSupported); } @Override public void dispose() { // does nothing
*** 102,124 **** @Override public int getRGBPixel(int x, int y) { int pixelArray[] = new int[1]; getRGBPixelsImpl(xgc, x, y, 1, 1, xgc.getScale(), 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, ! xgc.getScale(), pixelArray, isGtkSupported); return pixelArray; } private static synchronized native void setup(int numberOfButtons, int[] buttonDownMasks); private static synchronized native void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y); private static synchronized native void mousePressImpl(int buttons); private static synchronized native void mouseReleaseImpl(int buttons); private static synchronized native void mouseWheelImpl(int wheelAmt); --- 110,133 ---- @Override public int getRGBPixel(int x, int y) { int pixelArray[] = new int[1]; getRGBPixelsImpl(xgc, x, y, 1, 1, xgc.getScale(), pixelArray, ! useGtk); 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, ! xgc.getScale(), pixelArray, useGtk); return pixelArray; } private static synchronized native void setup(int numberOfButtons, int[] buttonDownMasks); + private static native void loadNativeLibraries(); private static synchronized native void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y); private static synchronized native void mousePressImpl(int buttons); private static synchronized native void mouseReleaseImpl(int buttons); private static synchronized native void mouseWheelImpl(int wheelAmt);
< prev index next >