x11: capture pointer when a button is pressed

This commit is contained in:
Thomas Bernard 2019-02-05 09:55:13 +01:00
parent 463105b0d5
commit 73f5f1d214
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 8 additions and 1 deletions

View File

@ -1739,6 +1739,10 @@ int Get_input(int sleep_time)
}
break;
case ButtonPress: // left = 1, middle = 2, right = 3, wheelup = 4, wheeldown = 5
XGrabPointer(X11_display, X11_window, True,
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync,
X11_window, None, CurrentTime);
//printf("Press button = %d state = 0x%08x\n", event.xbutton.button, event.xbutton.state);
if (event.xkey.state & ShiftMask)
mod |= MOD_SHIFT;
@ -1777,6 +1781,7 @@ int Get_input(int sleep_time)
}
break;
case ButtonRelease:
XUngrabPointer(X11_display, CurrentTime);
//printf("Release button = %d\n", event.xbutton.button);
if(event.xbutton.button == 1 || event.xbutton.button == 3)
{

View File

@ -333,5 +333,7 @@ void Define_icon(void)
void Set_mouse_position(void)
{
/// @todo implement screen capture and set position for x11.
XWarpPointer(X11_display, None, X11_window,
0, 0, 0, 0,
Mouse_X * Pixel_width, Mouse_Y * Pixel_height);
}