Merge pull request #18075 from guilhermefelipecgs/fix_3086

Fix custom cursor when it's hidden
This commit is contained in:
Rémi Verschelde 2018-04-09 21:47:22 +02:00 committed by GitHub
commit 62e5be8651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -1474,6 +1474,11 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) {
if (cursor_shape == p_shape) if (cursor_shape == p_shape)
return; return;
if (mouse_mode != MOUSE_MODE_VISIBLE) {
cursor_shape = p_shape;
return;
}
if (cursors[p_shape] != NULL) { if (cursors[p_shape] != NULL) {
[cursors[p_shape] set]; [cursors[p_shape] set];
} else { } else {

View File

@ -1299,7 +1299,9 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) {
if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) { if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) {
hCursor = SetCursor(NULL); hCursor = SetCursor(NULL);
} else { } else {
SetCursor(hCursor); CursorShape c = cursor_shape;
cursor_shape = CURSOR_MAX;
set_cursor_shape(c);
} }
} }
@ -1863,6 +1865,11 @@ void OS_Windows::set_cursor_shape(CursorShape p_shape) {
if (cursor_shape == p_shape) if (cursor_shape == p_shape)
return; return;
if (mouse_mode != MOUSE_MODE_VISIBLE) {
cursor_shape = p_shape;
return;
}
static const LPCTSTR win_cursors[CURSOR_MAX] = { static const LPCTSTR win_cursors[CURSOR_MAX] = {
IDC_ARROW, IDC_ARROW,
IDC_IBEAM, IDC_IBEAM,
@ -1888,6 +1895,7 @@ void OS_Windows::set_cursor_shape(CursorShape p_shape) {
} else { } else {
SetCursor(LoadCursor(hInstance, win_cursors[p_shape])); SetCursor(LoadCursor(hInstance, win_cursors[p_shape]));
} }
cursor_shape = p_shape; cursor_shape = p_shape;
} }

View File

@ -634,7 +634,7 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED); bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
if (showCursor) { if (showCursor) {
XUndefineCursor(x11_display, x11_window); // show cursor XDefineCursor(x11_display, x11_window, cursors[current_cursor]); // show cursor
} else { } else {
XDefineCursor(x11_display, x11_window, null_cursor); // hide cursor XDefineCursor(x11_display, x11_window, null_cursor); // hide cursor
} }