LINUX: Fixed warp ignores
This commit is contained in:
parent
84eae4c6f6
commit
b641b66e12
|
@ -54,6 +54,8 @@
|
|||
*/
|
||||
extern bool releaseInput(void);
|
||||
|
||||
extern void resetCursor(int x, int y);
|
||||
|
||||
/*
|
||||
* Various functions to release/acquire keyboard and mouse
|
||||
*/
|
||||
|
|
|
@ -93,8 +93,8 @@ static void transformCursorPos(int x, int y) {
|
|||
setCursorPos(x, y);
|
||||
}
|
||||
|
||||
static void centerCursor() {
|
||||
transformCursorPos(getWindowWidth()/2, getWindowHeight()/2);
|
||||
void resetCursor(int x, int y) {
|
||||
transformCursorPos(x, y);
|
||||
last_x = current_x;
|
||||
last_y = current_y;
|
||||
}
|
||||
|
@ -161,18 +161,18 @@ void updatePointerGrab(void) {
|
|||
}
|
||||
|
||||
static void doWarpPointer(void ) {
|
||||
// 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();
|
||||
// Tell event loop to start ignoring motion events
|
||||
ignore_warp_guard.xmotion.state = 1;
|
||||
XSendEvent(getDisplay(), getCurrentWindow(), False, 0, &ignore_warp_guard);
|
||||
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
|
||||
XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, getWindowWidth()/2, getWindowHeight()/2);
|
||||
// Tell event loop to stop ignoring motion events
|
||||
ignore_warp_guard.xmotion.state = 0;
|
||||
XSendEvent(getDisplay(), getCurrentWindow(), False, 0, &ignore_warp_guard);
|
||||
|
||||
centerCursor();
|
||||
/* XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, current_x, current_y);
|
||||
/* centerCursor();
|
||||
XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, current_x, current_y);
|
||||
XEvent event;
|
||||
// Try to catch the warp pointer event
|
||||
for (i = 0; i < WARP_RETRY; i++) {
|
||||
|
|
|
@ -157,8 +157,11 @@ 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)
|
||||
} else if (ignore_motion_events) {
|
||||
resetCursor(event->x, event->y);
|
||||
} else {
|
||||
handlePointerMotion(event);
|
||||
}
|
||||
}
|
||||
|
||||
static void handleMessages() {
|
||||
|
@ -418,7 +421,7 @@ static void dumpVisualInfo(XVisualInfo *vis_info) {
|
|||
glXGetConfig(getDisplay(), vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers);
|
||||
glXGetConfig(getDisplay(), vis_info, GLX_SAMPLES_ARB, &samples);
|
||||
}
|
||||
printf("Pixel format info: r = %d, g = %d, b = %d, a = %d, depth = %d, stencil = %d, sample buffers = %d, samples = %d\n", r, g, b, alpha, depth, stencil, sample_buffers, samples);
|
||||
printfDebug("Pixel format info: r = %d, g = %d, b = %d, a = %d, depth = %d, stencil = %d, sample buffers = %d, samples = %d\n", r, g, b, alpha, depth, stencil, sample_buffers, samples);
|
||||
}
|
||||
|
||||
static void destroy(void) {
|
||||
|
|
Loading…
Reference in New Issue