jdk/src/solaris/native/sun/awt/awt_Robot.c
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 6825 795e9fe949d3
child 8949 a07c7c410e02
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6825
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3337
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3337
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3337
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3337
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3337
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
    #error This file should not be included in headless library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "awt_p.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#define XK_MISCELLANY
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <X11/keysymdef.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <X11/Intrinsic.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <X11/Xutil.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include <X11/Xmd.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include <X11/extensions/xtestext1.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include <X11/extensions/XTest.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include <X11/extensions/XInput.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include <X11/extensions/XI.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "robot_common.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include "canvas.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include "wsutils.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include "list.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include "multiVis.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#ifdef __linux__
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include <sys/socket.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
    54
static jint * masks;
3337
45c02b7c01b6 6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents: 2810
diff changeset
    55
static jint num_buttons;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
static int32_t isXTestAvailable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    int32_t major_opcode, first_event, first_error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    int32_t  event_basep, error_basep, majorp, minorp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    int32_t isXTestAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /* check if XTest is available */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    isXTestAvailable = XQueryExtension(awt_display, XTestExtensionName, &major_opcode, &first_event, &first_error);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XTEST) returns major_opcode = %d, first_event = %d, first_error = %d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                    major_opcode, first_event, first_error);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    if (isXTestAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        /* check if XTest version is OK */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        XTestQueryExtension(awt_display, &event_basep, &error_basep, &majorp, &minorp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        DTRACE_PRINTLN4("RobotPeer: XTestQueryExtension returns event_basep = %d, error_basep = %d, majorp = %d, minorp = %d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                        event_basep, error_basep, majorp, minorp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        if (majorp < 2 || (majorp == 2 && minorp < 2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            /* bad version*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            DTRACE_PRINTLN2("XRobotPeer: XTEST version is %d.%d \n", majorp, minorp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            if (majorp == 2 && minorp == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                DTRACE_PRINTLN("XRobotPeer: XTEST is 2.1 - no grab is available\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                isXTestAvailable = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            /* allow XTest calls even if someone else has the grab; e.g. during
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
             * a window resize operation. Works only with XTEST2.2*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            XTestGrabControl(awt_display, True);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        DTRACE_PRINTLN("RobotPeer: XTEST extension is unavailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    return isXTestAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
static XImage *getWindowImage(Display * display, Window window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                              int32_t x, int32_t y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                              int32_t w, int32_t h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    XImage         *image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    int32_t        transparentOverlays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    int32_t        numVisuals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    XVisualInfo    *pVisuals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    int32_t        numOverlayVisuals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    OverlayInfo    *pOverlayVisuals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    int32_t        numImageVisuals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    XVisualInfo    **pImageVisuals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    list_ptr       vis_regions;    /* list of regions to read from */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    list_ptr       vis_image_regions ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    int32_t        allImage = 0 ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    int32_t        format = ZPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /* prevent user from moving stuff around during the capture */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    XGrabServer(display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * The following two functions live in multiVis.c-- they are pretty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * much verbatim taken from the source to the xwd utility from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * X11 source. This version of the xwd source was somewhat better written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * for reuse compared to Sun's version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *        ftp.x.org/pub/R6.3/xc/programs/xwd
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * We use these functions since they do the very tough job of capturing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * the screen correctly when it contains multiple visuals. They take into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * account the depth/colormap of each visual and produce a capture as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * 24-bit RGB image so we don't have to fool around with colormaps etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    GetMultiVisualRegions(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        x, y, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        &transparentOverlays,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        &numVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        &pVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        &numOverlayVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        &pOverlayVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        &numImageVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        &pImageVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        &vis_regions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        &vis_image_regions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        &allImage );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    image = ReadAreaToImage(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        x, y, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        numVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        pVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        numOverlayVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        pOverlayVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        numImageVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        pImageVisuals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        vis_regions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        vis_image_regions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        format,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        allImage );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /* allow user to do stuff again */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    XUngrabServer(display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /* make sure the grab/ungrab is flushed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    XSync(display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    return image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
/*********************************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
3337
45c02b7c01b6 6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents: 2810
diff changeset
   166
// this should be called from XRobotPeer constructor
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
JNIEXPORT void JNICALL
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   168
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons, jintArray buttonDownMasks)
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   169
{
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    int32_t xtestAvailable;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   171
    jint *tmp;
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   172
    int i;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
3337
45c02b7c01b6 6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents: 2810
diff changeset
   174
    DTRACE_PRINTLN("RobotPeer: setup()");
45c02b7c01b6 6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents: 2810
diff changeset
   175
45c02b7c01b6 6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents: 2810
diff changeset
   176
    num_buttons = numberOfButtons;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   177
    tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE);
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   178
    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
   179
    if (masks == (jint *) NULL) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   180
        JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   181
        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   182
        return;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   183
    }
3337
45c02b7c01b6 6856929: Frame is not getting resized using Robot in OpenSolaris and Ubuntu
dcherepanov
parents: 2810
diff changeset
   184
    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
   185
        masks[i] = tmp[i];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   186
    }
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   187
    (*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
   188
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    xtestAvailable = isXTestAvailable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    if (!xtestAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        JNU_ThrowByName(env, "java/awt/AWTException", "java.awt.Robot requires your X server support the XTEST extension version 2.2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   196
    AWT_UNLOCK();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   197
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
JNIEXPORT void JNICALL
1175
026b52c440fe 6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents: 2
diff changeset
   201
Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                             jclass cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                             jobject xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                             jint x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                             jint y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                             jint width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                             jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                             jintArray pixelArray) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    XImage *image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    jint *ary;               /* Array of jints for sending pixel values back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                              * to parent process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                              */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    Window rootWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    AwtGraphicsConfigDataPtr adata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    DTRACE_PRINTLN6("RobotPeer: getRGBPixelsImpl(%lx, %d, %d, %d, %d, %x)", xgc, x, y, width, height, pixelArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /* avoid a lot of work for empty rectangles */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    if ((width * height) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    DASSERT(width * height > 0); /* only allow positive size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    DASSERT(adata != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    image = getWindowImage(awt_display, rootWindow, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /* Array to use to crunch around the pixel values */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    ary = (jint *) malloc(width * height * sizeof (jint));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    if (ary == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        XDestroyImage(image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /* convert to Java ARGB pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    for (y = 0; y < height; y++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        for (x = 0; x < width; x++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            jint pixel = (jint) XGetPixel(image, x, y); /* Note ignore upper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                                                         * 32-bits on 64-bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                                                         * OSes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                                         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            pixel |= 0xff000000; /* alpha - full opacity */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            ary[(y * width) + x] = pixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    (*env)->SetIntArrayRegion(env, pixelArray, 0, height * width, ary);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    free(ary);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    XDestroyImage(image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
JNIEXPORT void JNICALL
1175
026b52c440fe 6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents: 2
diff changeset
   264
Java_sun_awt_X11_XRobotPeer_keyPressImpl (JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                         jclass cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                         jint keycode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    DTRACE_PRINTLN1("RobotPeer: keyPressImpl(%i)", keycode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    XTestFakeKeyEvent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                      XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                      True,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                      CurrentTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
JNIEXPORT void JNICALL
1175
026b52c440fe 6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents: 2
diff changeset
   284
Java_sun_awt_X11_XRobotPeer_keyReleaseImpl (JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                           jclass cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                           jint keycode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    DTRACE_PRINTLN1("RobotPeer: keyReleaseImpl(%i)", keycode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    XTestFakeKeyEvent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                      XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                      False,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                      CurrentTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
JNIEXPORT void JNICALL
1175
026b52c440fe 6706121: makefile: unnecessary Motif classes compilation in JDK7
yan
parents: 2
diff changeset
   302
Java_sun_awt_X11_XRobotPeer_mouseMoveImpl (JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                          jclass cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                          jobject xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                          jint root_x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                          jint root_y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    AwtGraphicsConfigDataPtr adata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    DTRACE_PRINTLN3("RobotPeer: mouseMoveImpl(%lx, %i, %i)", xgc, root_x, root_y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    DASSERT(adata != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    XWarpPointer(awt_display, None, XRootWindow(awt_display, adata->awt_visInfo.screen), 0, 0, 0, 0, root_x, root_y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   323
/*
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   324
  * 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
   325
  */
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   326
void mouseAction(JNIEnv *env,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   327
                 jclass cls,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   328
                 jint buttonMask,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   329
                 Bool isMousePress)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   330
{
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   331
    AWT_LOCK();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   332
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   333
    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
   334
    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
   335
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   336
    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
   337
        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
   338
    {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   339
        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
   340
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   341
    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
   342
         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
   343
        (num_buttons >= 2)) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   344
        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
   345
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   346
    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
   347
         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
   348
        (num_buttons >= 3)) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   349
        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
   350
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   351
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   352
    if (num_buttons > 3){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   353
        int32_t i;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   354
        int32_t button = 0;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   355
        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
   356
            if ((buttonMask & masks[i])) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   357
                // 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
   358
                // 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
   359
                // 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
   360
                button = i + 3;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   361
                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
   362
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   363
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   364
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   365
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   366
    XSync(awt_display, False);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   367
    AWT_UNLOCK();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   368
}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   369
1965
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   370
JNIEXPORT void JNICALL
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   371
Java_sun_awt_X11_XRobotPeer_mousePressImpl (JNIEnv *env,
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   372
                           jclass cls,
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   373
                           jint buttonMask) {
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   374
    mouseAction(env, cls, buttonMask, True);
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   375
}
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   376
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   377
JNIEXPORT void JNICALL
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   378
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl (JNIEnv *env,
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   379
                             jclass cls,
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   380
                             jint buttonMask) {
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   381
    mouseAction(env, cls, buttonMask, False);
726a2bc97146 6755110: Solaris build has corrupted with extra mouse buttons RFE
dav
parents: 1962
diff changeset
   382
}
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1175
diff changeset
   383
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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_mouseWheelImpl (JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                           jclass cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                           jint wheelAmt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
/* Mouse wheel is implemented as a button press of button 4 and 5, so it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
/* probably could have been hacked into robot_mouseButtonEvent, but it's */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
/* cleaner to give it its own command type, in case the implementation   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
/* needs to be changed later.  -bchristi, 6/20/01                        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    int32_t repeat = abs(wheelAmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    int32_t button = wheelAmt < 0 ? 4 : 5;  /* wheel up:   button 4 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                                                 /* wheel down: button 5 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    int32_t loopIdx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    DTRACE_PRINTLN1("RobotPeer: mouseWheelImpl(%i)", wheelAmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    for (loopIdx = 0; loopIdx < repeat; loopIdx++) { /* do nothing for   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                                                     /* wheelAmt == 0    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        XTestFakeButtonEvent(awt_display, button, True, CurrentTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        XTestFakeButtonEvent(awt_display, button, False, CurrentTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
}