summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-08-29 01:43:21 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-08-29 01:43:21 -0300
commit3a59747c6292265a2a7ac60720e7d8401b02d77d (patch)
tree274204be5cd88d7bc9a664e882fb555ce6f8322c /platform/x11
parentb0be30d9efb11aba10fd97c71fec47e34ea88ca1 (diff)
-fixes to capture mode
-ability to drag spinboxes and tree ranges to change values, like in Unity or Unreal
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/os_x11.cpp53
-rw-r--r--platform/x11/os_x11.h1
2 files changed, 52 insertions, 2 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index b34d1ba7c8..16632c6627 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -504,6 +504,23 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
mouse_mode=p_mode;
if (mouse_mode==MOUSE_MODE_CAPTURED) {
+
+ while(true) {
+ //flush pending motion events
+
+ if (XPending(x11_display) > 0) {
+ XEvent event;
+ XPeekEvent(x11_display, &event);
+ if (event.type==MotionNotify) {
+ XNextEvent(x11_display,&event);
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
if (XGrabPointer(x11_display, x11_window, True,
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask, GrabModeAsync, GrabModeAsync,
@@ -518,6 +535,8 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
0,0,0,0, (int)center.x, (int)center.y);
input->set_mouse_pos(center);
+ } else {
+ do_mouse_warp=false;
}
}
@@ -1131,7 +1150,7 @@ void OS_X11::process_xevents() {
//printf("checking events %i\n", XPending(x11_display));
- bool do_mouse_warp=false;
+ do_mouse_warp=false;
while (XPending(x11_display) > 0) {
XEvent event;
@@ -1244,8 +1263,38 @@ void OS_X11::process_xevents() {
} break;
case MotionNotify: {
-
+
+ // FUCK YOU X11 API YOU SERIOUSLY GROSS ME OUT
+ // YOU ARE AS GROSS AS LOOKING AT A PUTRID PILE
+ // OF POOP STICKING OUT OF A CLOGGED TOILET
+ // HOW THE FUCK I AM SUPPOSED TO KNOW WHICH ONE
+ // OF THE MOTION NOTIFY EVENTS IS THE ONE GENERATED
+ // BY WARPING THE MOUSE POINTER?
+ // YOU ARE FORCING ME TO FILTER ONE BY ONE TO FIND IT
+ // PLEASE DO ME A FAVOR AND DIE DROWNED IN A FECAL
+ // MOUNTAIN BECAUSE THAT'S WHERE YOU BELONG.
+
+ while(true) {
+ if (mouse_mode==MOUSE_MODE_CAPTURED && event.xmotion.x==current_videomode.width/2 && event.xmotion.y==current_videomode.height/2) {
+ //this is likely the warp event since it was warped here
+ center=Vector2(event.xmotion.x,event.xmotion.y);
+ break;
+ }
+
+ if (XPending(x11_display) > 0) {
+ XEvent tevent;
+ XPeekEvent(x11_display, &tevent);
+ if (tevent.type==MotionNotify) {
+ XNextEvent(x11_display,&event);
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
last_timestamp=event.xmotion.time;
// Motion is also simple.
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 261a54dd25..12f0aec611 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -114,6 +114,7 @@ class OS_X11 : public OS_Unix {
bool minimized;
int dpad_last[2];
+ bool do_mouse_warp;
const char *cursor_theme;
int cursor_size;