From: Mikko Rasa Date: Sat, 29 Oct 2016 12:01:01 +0000 (+0300) Subject: Improve cursor hiding logic on Windows X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=504de8687a39943f94ff02b20acb647e9185b488;p=libs%2Fgui.git Improve cursor hiding logic on Windows Only hide it when it's in the client area of the window --- diff --git a/source/graphics/windows/window.cpp b/source/graphics/windows/window.cpp index cc36472..3f564de 100644 --- a/source/graphics/windows/window.cpp +++ b/source/graphics/windows/window.cpp @@ -85,6 +85,9 @@ void Window::platform_init() this); if(!priv->window) throw system_error("CreateWindowEx"); + + priv->cursor_in_client_area = false; + priv->cursor_visible = true; } void Window::platform_cleanup() @@ -127,7 +130,9 @@ void Window::platform_reconfigure(bool fullscreen_changed) void Window::show_cursor(bool s) { - ShowCursor(s); + priv->cursor_visible = s; + if(priv->cursor_in_client_area && !s) + SetCursor(NULL); } void Window::warp_pointer(int, int) @@ -211,6 +216,13 @@ bool Window::event(const Event &evnt) case WM_KILLFOCUS: signal_lost_focus.emit(); break; + case WM_SETCURSOR: + priv->cursor_in_client_area = (LOWORD(evnt.lparam)==HTCLIENT); + if(priv->cursor_in_client_area && !priv->cursor_visible) + SetCursor(NULL); + else + return false; + break; default: return false; } diff --git a/source/graphics/windows/window_platform.h b/source/graphics/windows/window_platform.h index 7d53f55..77f4526 100644 --- a/source/graphics/windows/window_platform.h +++ b/source/graphics/windows/window_platform.h @@ -10,6 +10,8 @@ typedef HWND WindowHandle; struct PlatformWindowPrivate { + bool cursor_in_client_area; + bool cursor_visible; }; struct PlatformEvent