diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-09-12 21:37:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 21:37:30 +0200 |
commit | fe78aa0c3096b0e74255ad1aaf0acf8a8befea58 (patch) | |
tree | d1dcd8a3c3f9cca9c3beb8d4932023821ac51510 | |
parent | 9de03997ecfacd7d3e5d2e65536a2fe50e8c79b7 (diff) | |
parent | 7d6364d431a16e619db7cd1092192ea647dc11b8 (diff) |
Merge pull request #21753 from guilhermefelipecgs/fix_confined_mode
Fixes to mouse mode confined and captured
-rw-r--r-- | platform/x11/os_x11.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 20c9dd6290..b80a20ce40 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -744,12 +744,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; } @@ -2067,6 +2070,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(); |