summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Felipe <guilhermefelipecgs@gmail.com>2018-09-04 10:11:37 -0300
committerGuilherme Felipe <guilhermefelipecgs@gmail.com>2018-09-05 11:24:06 -0300
commit7d6364d431a16e619db7cd1092192ea647dc11b8 (patch)
tree0207104bb927ab6d215e96f798e430ddc3fce8f2
parenta1b578562a6db61db668c0ea620df9f23989d23f (diff)
Fixes to mouse mode confined and captured
These modes will work on Linux in the same way as Windows.
-rw-r--r--platform/x11/os_x11.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index a57a8c6bb9..56eddb5ca4 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -742,12 +742,15 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
ERR_PRINT("NO GRAB");
}
- center.x = current_videomode.width / 2;
- center.y = current_videomode.height / 2;
- XWarpPointer(x11_display, None, x11_window,
- 0, 0, 0, 0, (int)center.x, (int)center.y);
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+ center.x = current_videomode.width / 2;
+ center.y = current_videomode.height / 2;
+
+ XWarpPointer(x11_display, None, x11_window,
+ 0, 0, 0, 0, (int)center.x, (int)center.y);
- input->set_mouse_position(center);
+ input->set_mouse_position(center);
+ }
} else {
do_mouse_warp = false;
}
@@ -2044,6 +2047,10 @@ void OS_X11::process_xevents() {
Point2i rel = pos - last_mouse_pos;
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+ pos = Point2i(current_videomode.width / 2, current_videomode.height / 2);
+ }
+
Ref<InputEventMouseMotion> mm;
mm.instance();