[2.1] Fix custom cursor when it's hidden

Port of #18075
This commit is contained in:
Guilherme Felipe 2018-04-22 12:05:33 -03:00
parent 83d5db294d
commit 6217457b14
3 changed files with 19 additions and 5 deletions

View File

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

View File

@ -757,7 +757,9 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetCursor(NULL);
} else {
if (hCursor != NULL) {
SetCursor(hCursor);
CursorShape c = cursor_shape;
cursor_shape = CURSOR_MAX;
set_cursor_shape(c);
hCursor = NULL;
}
}
@ -1348,7 +1350,9 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) {
if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) {
hCursor = SetCursor(NULL);
} else {
SetCursor(hCursor);
CursorShape c = cursor_shape;
cursor_shape = CURSOR_MAX;
set_cursor_shape(c);
}
}
@ -1948,6 +1952,11 @@ void OS_Windows::set_cursor_shape(CursorShape p_shape) {
if (cursor_shape == p_shape)
return;
if (mouse_mode != MOUSE_MODE_VISIBLE) {
cursor_shape = p_shape;
return;
}
static const LPCTSTR win_cursors[CURSOR_MAX] = {
IDC_ARROW,
IDC_IBEAM,
@ -2012,7 +2021,7 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap
}
// Finally, create the icon
ICONINFO iconinfo = {0};
ICONINFO iconinfo = { 0 };
iconinfo.fIcon = FALSE;
iconinfo.xHotspot = p_hotspot.x;
iconinfo.yHotspot = p_hotspot.y;
@ -2072,7 +2081,7 @@ void OS_Windows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent,
SetBkColor(hXorMaskDC, RGB(0, 0, 0));
SetTextColor(hXorMaskDC, RGB(255, 255, 255));
BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hAndMaskDC, 0, 0, SRCCOPY);
BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0,0, SRCAND);
BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0, 0, SRCAND);
// Deselect bitmaps from the helper DC
SelectObject(hMainDC, hOldMainBitmap);

View File

@ -582,7 +582,7 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
if (mouse_mode == MOUSE_MODE_CAPTURED)
XUngrabPointer(x11_display, CurrentTime);
if (mouse_mode != MOUSE_MODE_VISIBLE && p_mode == MOUSE_MODE_VISIBLE)
XUndefineCursor(x11_display, x11_window);
XDefineCursor(x11_display, x11_window, cursors[current_cursor]);
if (p_mode != MOUSE_MODE_VISIBLE && mouse_mode == MOUSE_MODE_VISIBLE) {
XDefineCursor(x11_display, x11_window, null_cursor);
}