Merge pull request #22070 from capnm/fix_Input.set_default_cursor_shape_take2

Fix set_default_cursor_shape interaction with Control nodes
This commit is contained in:
Rémi Verschelde 2018-09-19 09:26:21 +02:00 committed by GitHub
commit 0274ded34c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -598,7 +598,13 @@ Input::CursorShape InputDefault::get_default_cursor_shape() {
void InputDefault::set_default_cursor_shape(CursorShape p_shape) {
default_shape = p_shape;
OS::get_singleton()->set_cursor_shape((OS::CursorShape)p_shape);
// The default shape is set in Viewport::_gui_input_event. To instantly
// see the shape in the viewport we need to trigger a mouse motion event.
Ref<InputEventMouseMotion> mm;
mm.instance();
mm->set_position(mouse_pos);
mm->set_global_position(mouse_pos);
parse_input_event(mm);
}
void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {

View File

@ -2524,13 +2524,16 @@ void OS_X11::set_cursor_shape(CursorShape p_shape) {
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
if (p_shape == current_cursor)
if (p_shape == current_cursor) {
return;
if (mouse_mode == MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
if (cursors[p_shape] != None)
}
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
if (cursors[p_shape] != None) {
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
else if (cursors[CURSOR_ARROW] != None)
} else if (cursors[CURSOR_ARROW] != None) {
XDefineCursor(x11_display, x11_window, cursors[CURSOR_ARROW]);
}
}
current_cursor = p_shape;