Merge pull request #21753 from guilhermefelipecgs/fix_confined_mode
Fixes to mouse mode confined and captured
This commit is contained in:
commit
fe78aa0c30
1 changed files with 12 additions and 5 deletions
|
@ -744,12 +744,15 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
|
||||||
ERR_PRINT("NO GRAB");
|
ERR_PRINT("NO GRAB");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mouse_mode == MOUSE_MODE_CAPTURED) {
|
||||||
center.x = current_videomode.width / 2;
|
center.x = current_videomode.width / 2;
|
||||||
center.y = current_videomode.height / 2;
|
center.y = current_videomode.height / 2;
|
||||||
|
|
||||||
XWarpPointer(x11_display, None, x11_window,
|
XWarpPointer(x11_display, None, x11_window,
|
||||||
0, 0, 0, 0, (int)center.x, (int)center.y);
|
0, 0, 0, 0, (int)center.x, (int)center.y);
|
||||||
|
|
||||||
input->set_mouse_position(center);
|
input->set_mouse_position(center);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
do_mouse_warp = false;
|
do_mouse_warp = false;
|
||||||
}
|
}
|
||||||
|
@ -2067,6 +2070,10 @@ void OS_X11::process_xevents() {
|
||||||
|
|
||||||
Point2i rel = pos - last_mouse_pos;
|
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;
|
Ref<InputEventMouseMotion> mm;
|
||||||
mm.instance();
|
mm.instance();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue