0N/A/*
3261N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage sun.awt.X11;
0N/A
0N/Aimport java.awt.*;
2859N/Aimport java.awt.event.InputEvent;
0N/Aimport java.awt.peer.*;
2859N/A
2859N/Aimport sun.awt.AWTAccessor;
2859N/Aimport sun.awt.SunToolkit;
0N/Aimport sun.awt.X11GraphicsConfig;
0N/A
0N/Aclass XRobotPeer implements RobotPeer {
2859N/A
0N/A private X11GraphicsConfig xgc = null;
0N/A /*
0N/A * native implementation uses some static shared data (pipes, processes)
0N/A * so use a class lock to synchronize native method calls
0N/A */
0N/A static Object robotLock = new Object();
0N/A
0N/A XRobotPeer(GraphicsConfiguration gc) {
0N/A this.xgc = (X11GraphicsConfig)gc;
1444N/A SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
2859N/A setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks());
0N/A }
0N/A
0N/A public void dispose() {
4197N/A // does nothing
0N/A }
0N/A
0N/A public void mouseMove(int x, int y) {
0N/A mouseMoveImpl(xgc, x, y);
0N/A }
0N/A
0N/A public void mousePress(int buttons) {
0N/A mousePressImpl(buttons);
0N/A }
0N/A
0N/A public void mouseRelease(int buttons) {
0N/A mouseReleaseImpl(buttons);
0N/A }
0N/A
0N/A public void mouseWheel(int wheelAmt) {
0N/A mouseWheelImpl(wheelAmt);
0N/A }
0N/A
0N/A public void keyPress(int keycode) {
0N/A keyPressImpl(keycode);
0N/A }
0N/A
0N/A public void keyRelease(int keycode) {
0N/A keyReleaseImpl(keycode);
0N/A }
0N/A
0N/A public int getRGBPixel(int x, int y) {
0N/A int pixelArray[] = new int[1];
0N/A getRGBPixelsImpl(xgc, x, y, 1, 1, pixelArray);
0N/A return pixelArray[0];
0N/A }
0N/A
0N/A public int [] getRGBPixels(Rectangle bounds) {
0N/A int pixelArray[] = new int[bounds.width*bounds.height];
0N/A getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, pixelArray);
0N/A return pixelArray;
0N/A }
0N/A
2859N/A private static native synchronized void setup(int numberOfButtons, int[] buttonDownMasks);
0N/A
0N/A private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
0N/A private static native synchronized void mousePressImpl(int buttons);
0N/A private static native synchronized void mouseReleaseImpl(int buttons);
0N/A private static native synchronized void mouseWheelImpl(int wheelAmt);
0N/A
0N/A private static native synchronized void keyPressImpl(int keycode);
0N/A private static native synchronized void keyReleaseImpl(int keycode);
0N/A
0N/A private static native synchronized void getRGBPixelsImpl(X11GraphicsConfig xgc, int x, int y, int width, int height, int pixelArray[]);
0N/A}