Fixed grab interaction with Windows Classic theme Testing: * For each theme in Windows 7, Windows 7 Basic, and Windows 7 Classic: - Ran testsprite2 - Pressed Ctrl-G to grab the mouse - Alt-tabbed away, verified mouse is no longer grabbed - Alt-tabbed back, verified that mouse was grabbed - Alt-tabbed away - Clicked in the window, verified mouse was grabbed - Alt-tabbed away - Grabbed the title bar and dragged the window around successfully, verified that mouse was grabbed when move modal loop completed - Alt-tabbed away - Clicked the minimize button on the title bar, the window was successfully minimized - Clicked on the icon in the task bar, the window was restored and the mouse grabbed again - Alt-tabbed away - Clicked the close button on the title bar, the window was successfully closed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index e08d029..6c0b9b2 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -196,6 +196,11 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
void
WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button)
{
+ if (data->focus_click_pending && button == SDL_BUTTON_LEFT && !bwParamMousePressed) {
+ data->focus_click_pending = SDL_FALSE;
+ WIN_UpdateClipCursor(data->window);
+ }
+
if (bwParamMousePressed && !bSDLMousePressed) {
SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button);
} else if (!bwParamMousePressed && bSDLMousePressed) {
@@ -371,11 +376,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
minimized = HIWORD(wParam);
if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
+ data->focus_click_pending = (GetAsyncKeyState(VK_LBUTTON) != 0);
+
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
if (SDL_GetKeyboardFocus() != data->window) {
SDL_SetKeyboardFocus(data->window);
}
- WIN_UpdateClipCursor(data->window);
GetCursorPos(&cursorPos);
ScreenToClient(hwnd, &cursorPos);
@@ -584,32 +590,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_NCLBUTTONDOWN:
{
data->in_title_click = SDL_TRUE;
- WIN_UpdateClipCursor(data->window);
}
break;
- case WM_NCMOUSELEAVE:
+ case WM_CAPTURECHANGED:
{
data->in_title_click = SDL_FALSE;
- WIN_UpdateClipCursor(data->window);
- }
- break;
-
- case WM_ENTERSIZEMOVE:
- case WM_ENTERMENULOOP:
- {
- data->in_modal_loop = SDL_TRUE;
- WIN_UpdateClipCursor(data->window);
- }
- break;
-
- case WM_EXITSIZEMOVE:
- case WM_EXITMENULOOP:
- {
- data->in_modal_loop = SDL_FALSE;
- WIN_UpdateClipCursor(data->window);
- /* The mouse may have been released during the modal loop */
+ /* The mouse may have been released during a modal loop */
WIN_CheckAsyncMouseRelease(data);
}
break;
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 14e99b4..2966590 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -188,7 +188,7 @@ WIN_WarpMouse(SDL_Window * window, int x, int y)
POINT pt;
/* Don't warp the mouse while we're doing a modal interaction */
- if (data->in_title_click || data->in_modal_loop) {
+ if (data->in_title_click || data->focus_click_pending) {
return;
}
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 0cbfe78..15ae1a1 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -751,9 +751,7 @@ WIN_UpdateClipCursor(SDL_Window *window)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_Mouse *mouse = SDL_GetMouse();
- /* Don't clip the cursor while we're in the modal resize or move loop */
- if (data->in_title_click || data->in_modal_loop) {
- ClipCursor(NULL);
+ if (data->focus_click_pending) {
return;
}
diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h
index 0da8682..a9fa65d 100644
--- a/src/video/windows/SDL_windowswindow.h
+++ b/src/video/windows/SDL_windowswindow.h
@@ -40,7 +40,7 @@ typedef struct
SDL_bool expected_resize;
SDL_bool in_border_change;
SDL_bool in_title_click;
- SDL_bool in_modal_loop;
+ SDL_bool focus_click_pending;
struct SDL_VideoData *videodata;
#if SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface;