< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m

Print this page


   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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  *
  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


 122 
 123         gsButtonEventNumber = (int*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(int), gNumberOfButtons);
 124         if (gsButtonEventNumber == NULL) {
 125             JNU_ThrowOutOfMemoryError(env, NULL);
 126             return;
 127         }
 128 
 129         for (i = 0; i < gNumberOfButtons; ++i) {
 130             gsButtonEventNumber[i] = ROBOT_EVENT_NUMBER_START;
 131         }
 132     }
 133 }
 134 
 135 /*
 136  * Class:     sun_lwawt_macosx_CRobot
 137  * Method:    mouseEvent
 138  * Signature: (IIIIZZ)V
 139  */
 140 JNIEXPORT void JNICALL
 141 Java_sun_lwawt_macosx_CRobot_mouseEvent
 142 (JNIEnv *env, jobject peer,
 143  jint displayID, jint mouseLastX, jint mouseLastY, jint buttonsState,
 144  jboolean isButtonsDownState, jboolean isMouseMove)
 145 {
 146     JNF_COCOA_ENTER(env);
 147 
 148     // This is the native method called when Robot mouse events occur.
 149     // The CRobot tracks the mouse position, and which button was
 150     // pressed. The peer also tracks the mouse button desired state,
 151     // the appropriate key modifier state, and whether the mouse action
 152     // is simply a mouse move with no mouse button state changes.
 153 
 154     // volatile, otherwise it warns that it might be clobbered by 'longjmp'
 155     volatile CGPoint point;
 156 
 157     point.x = mouseLastX;
 158     point.y = mouseLastY;
 159 
 160     __block CGMouseButton button = kCGMouseButtonLeft;
 161     __block CGEventType type = kCGEventMouseMoved;
 162 
 163     void (^HandleRobotButton)(CGMouseButton, CGEventType, CGEventType, CGEventType) =


   1 /*
   2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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  *
  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


 122 
 123         gsButtonEventNumber = (int*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(int), gNumberOfButtons);
 124         if (gsButtonEventNumber == NULL) {
 125             JNU_ThrowOutOfMemoryError(env, NULL);
 126             return;
 127         }
 128 
 129         for (i = 0; i < gNumberOfButtons; ++i) {
 130             gsButtonEventNumber[i] = ROBOT_EVENT_NUMBER_START;
 131         }
 132     }
 133 }
 134 
 135 /*
 136  * Class:     sun_lwawt_macosx_CRobot
 137  * Method:    mouseEvent
 138  * Signature: (IIIIZZ)V
 139  */
 140 JNIEXPORT void JNICALL
 141 Java_sun_lwawt_macosx_CRobot_mouseEvent
 142 (JNIEnv *env, jobject peer, jint mouseLastX, jint mouseLastY, jint buttonsState,

 143  jboolean isButtonsDownState, jboolean isMouseMove)
 144 {
 145     JNF_COCOA_ENTER(env);
 146 
 147     // This is the native method called when Robot mouse events occur.
 148     // The CRobot tracks the mouse position, and which button was
 149     // pressed. The peer also tracks the mouse button desired state,
 150     // the appropriate key modifier state, and whether the mouse action
 151     // is simply a mouse move with no mouse button state changes.
 152 
 153     // volatile, otherwise it warns that it might be clobbered by 'longjmp'
 154     volatile CGPoint point;
 155 
 156     point.x = mouseLastX;
 157     point.y = mouseLastY;
 158 
 159     __block CGMouseButton button = kCGMouseButtonLeft;
 160     __block CGEventType type = kCGEventMouseMoved;
 161 
 162     void (^HandleRobotButton)(CGMouseButton, CGEventType, CGEventType, CGEventType) =


< prev index next >