From 2a6213ad02cde6cda9939c604f9264fbe14c3a56 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 24 Feb 2014 22:49:30 -0800 Subject: [PATCH] Make sure we don't clip the cursor while clicking on the window title bar --- src/video/windows/SDL_windowsevents.c | 14 ++++++++++++++ src/video/windows/SDL_windowswindow.c | 2 +- src/video/windows/SDL_windowswindow.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index a688ef091..b4e51a0bf 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -570,6 +570,20 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; #endif /* WM_INPUTLANGCHANGE */ + case WM_NCLBUTTONDOWN: + { + data->in_title_click = SDL_TRUE; + WIN_UpdateClipCursor(data->window); + } + break; + + case WM_NCMOUSELEAVE: + { + data->in_title_click = SDL_FALSE; + WIN_UpdateClipCursor(data->window); + } + break; + case WM_ENTERSIZEMOVE: case WM_ENTERMENULOOP: { diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 98de45428..425b4da23 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -746,7 +746,7 @@ WIN_UpdateClipCursor(SDL_Window *window) SDL_Mouse *mouse = SDL_GetMouse(); /* Don't clip the cursor while we're in the modal resize or move loop */ - if (data->in_modal_loop) { + if (data->in_title_click || data->in_modal_loop) { ClipCursor(NULL); return; } diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 99ae48878..c42888744 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -38,6 +38,7 @@ typedef struct SDL_bool created; WPARAM mouse_button_flags; BOOL expected_resize; + SDL_bool in_title_click; SDL_bool in_modal_loop; struct SDL_VideoData *videodata; #if SDL_VIDEO_OPENGL_EGL