LINUX:Improved warp event ignore

This commit is contained in:
Elias Naur 2004-04-12 10:33:39 +00:00
parent 0085c8862c
commit e034c76f19
2 changed files with 22 additions and 3 deletions

View File

@ -161,9 +161,18 @@ void updatePointerGrab(void) {
} }
static void doWarpPointer(void ) { static void doWarpPointer(void ) {
int i; // int i;
XEvent ignore_warp_guard;
ignore_warp_guard.type = MotionNotify;
ignore_warp_guard.xmotion.state = 1; // Tell event loop to start ignoring motion events
centerCursor(); centerCursor();
XSendEvent(getDisplay(), getCurrentWindow(), False, 0, &ignore_warp_guard);
XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, current_x, current_y); XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, current_x, current_y);
ignore_warp_guard.xmotion.state = 0; // Tell event loop to stop ignoring motion events
XSendEvent(getDisplay(), getCurrentWindow(), False, 0, &ignore_warp_guard);
centerCursor();
/* XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, current_x, current_y);
XEvent event; XEvent event;
// Try to catch the warp pointer event // Try to catch the warp pointer event
for (i = 0; i < WARP_RETRY; i++) { for (i = 0; i < WARP_RETRY; i++) {
@ -176,7 +185,7 @@ static void doWarpPointer(void ) {
printfDebug("Skipped event searching for warp event %d, %d\n", event.xmotion.x, event.xmotion.y); printfDebug("Skipped event searching for warp event %d, %d\n", event.xmotion.x, event.xmotion.y);
} }
if (i == WARP_RETRY) if (i == WARP_RETRY)
printfDebug("Never got warp event\n"); printfDebug("Never got warp event\n");*/
} }
static void warpPointer(void) { static void warpPointer(void) {

View File

@ -73,6 +73,7 @@ static bool minimized;
static bool focused; static bool focused;
static bool closerequested; static bool closerequested;
static bool grab; static bool grab;
static bool ignore_motion_events;
static Display *display_connection = NULL; static Display *display_connection = NULL;
static int display_connection_usage = 0; static int display_connection_usage = 0;
@ -152,6 +153,14 @@ void setGrab(bool new_grab) {
updateInputGrab(); updateInputGrab();
} }
static void handleMotion(XMotionEvent *event) {
if (event->send_event == True) {
// We got a warp ignore message
ignore_motion_events = event->state == 1 ? true : false;
} else if (!ignore_motion_events)
handlePointerMotion(event);
}
static void handleMessages() { static void handleMessages() {
XEvent event; XEvent event;
Window win; Window win;
@ -194,7 +203,7 @@ static void handleMessages() {
handleButtonRelease(&(event.xbutton)); handleButtonRelease(&(event.xbutton));
break; break;
case MotionNotify: case MotionNotify:
handlePointerMotion(&(event.xmotion)); handleMotion(&(event.xmotion));
break; break;
case KeyPress: case KeyPress:
case KeyRelease: case KeyRelease:
@ -223,6 +232,7 @@ static void createWindow(JNIEnv* env, int screen, XVisualInfo *vis_info, jstring
closerequested = false; closerequested = false;
vsync_enabled = false; vsync_enabled = false;
grab = false; grab = false;
ignore_motion_events = false;
Window root_win; Window root_win;
Window win; Window win;
XSetWindowAttributes attribs; XSetWindowAttributes attribs;