]> git.tdb.fi Git - libs/gui.git/commitdiff
Improve cursor hiding logic on Windows
authorMikko Rasa <tdb@tdb.fi>
Sat, 29 Oct 2016 12:01:01 +0000 (15:01 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 29 Oct 2016 12:01:01 +0000 (15:01 +0300)
Only hide it when it's in the client area of the window

source/graphics/windows/window.cpp
source/graphics/windows/window_platform.h

index cc364723d292b109dcce847122f6096881befe1d..3f564dec68ef5a28221bd8c20691f0e37370f7f8 100644 (file)
@@ -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;
        }
index 7d53f555e9c4d8dc5e902103c41b1d1e119ed61c..77f45262987caa6c69119dde43a0b4b835b66cd2 100644 (file)
@@ -10,6 +10,8 @@ typedef HWND WindowHandle;
 
 struct PlatformWindowPrivate
 {
+       bool cursor_in_client_area;
+       bool cursor_visible;
 };
 
 struct PlatformEvent