When clicking on a window to give it focus, don't pass the mouse click to the application.

Sam Lantinga 2016-09-29 03:59:04 -07:00
parent f33c58b004
commit 8ddb4328b5
2 changed files with 26 additions and 6 deletions

View File

@ -202,9 +202,15 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
void void
WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID) WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID)
{ {
if (data->focus_click_pending && button == SDL_BUTTON_LEFT && !bwParamMousePressed) { if (data->focus_click_pending & SDL_BUTTON(button)) {
data->focus_click_pending = SDL_FALSE; /* Ignore the button click for activation */
WIN_UpdateClipCursor(data->window); if (!bwParamMousePressed) {
data->focus_click_pending &= ~SDL_BUTTON(button);
if (!data->focus_click_pending) {
WIN_UpdateClipCursor(data->window);
}
}
return;
} }
if (bwParamMousePressed && !bSDLMousePressed) { if (bwParamMousePressed && !bSDLMousePressed) {
@ -398,7 +404,21 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
minimized = HIWORD(wParam); minimized = HIWORD(wParam);
if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
data->focus_click_pending = (GetAsyncKeyState(VK_LBUTTON) != 0); if (GetAsyncKeyState(VK_LBUTTON)) {
data->focus_click_pending |= SDL_BUTTON_LMASK;
}
if (GetAsyncKeyState(VK_RBUTTON)) {
data->focus_click_pending |= SDL_BUTTON_RMASK;
}
if (GetAsyncKeyState(VK_MBUTTON)) {
data->focus_click_pending |= SDL_BUTTON_MMASK;
}
if (GetAsyncKeyState(VK_XBUTTON1)) {
data->focus_click_pending |= SDL_BUTTON_X1MASK;
}
if (GetAsyncKeyState(VK_XBUTTON2)) {
data->focus_click_pending |= SDL_BUTTON_X2MASK;
}
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
if (SDL_GetKeyboardFocus() != data->window) { if (SDL_GetKeyboardFocus() != data->window) {

View File

@ -41,7 +41,7 @@ typedef struct
SDL_bool expected_resize; SDL_bool expected_resize;
SDL_bool in_border_change; SDL_bool in_border_change;
SDL_bool in_title_click; SDL_bool in_title_click;
SDL_bool focus_click_pending; Uint8 focus_click_pending;
SDL_bool windowed_mode_was_maximized; SDL_bool windowed_mode_was_maximized;
SDL_bool in_window_deactivation; SDL_bool in_window_deactivation;
struct SDL_VideoData *videodata; struct SDL_VideoData *videodata;