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
This commit is contained in:
Sam Lantinga 2014-06-23 10:09:15 -07:00
parent 9e2a2639f8
commit 67e55655a3
4 changed files with 12 additions and 26 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;