Skip to content
Permalink
Browse files

When clicking on a window to give it focus, don't pass the mouse clic…

…k to the application.
  • Loading branch information
slouken committed Sep 29, 2016
1 parent f33c58b commit 8ddb4328b5c17876bfae0affc861f461007ef0bc
Showing with 26 additions and 6 deletions.
  1. +25 −5 src/video/windows/SDL_windowsevents.c
  2. +1 −1 src/video/windows/SDL_windowswindow.h
@@ -202,9 +202,15 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
void
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) {
data->focus_click_pending = SDL_FALSE;
WIN_UpdateClipCursor(data->window);
if (data->focus_click_pending & SDL_BUTTON(button)) {
/* Ignore the button click for activation */
if (!bwParamMousePressed) {
data->focus_click_pending &= ~SDL_BUTTON(button);
if (!data->focus_click_pending) {
WIN_UpdateClipCursor(data->window);
}
}
return;
}

if (bwParamMousePressed && !bSDLMousePressed) {
@@ -398,8 +404,22 @@ 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);

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);
if (SDL_GetKeyboardFocus() != data->window) {
SDL_SetKeyboardFocus(data->window);
@@ -41,7 +41,7 @@ typedef struct
SDL_bool expected_resize;
SDL_bool in_border_change;
SDL_bool in_title_click;
SDL_bool focus_click_pending;
Uint8 focus_click_pending;
SDL_bool windowed_mode_was_maximized;
SDL_bool in_window_deactivation;
struct SDL_VideoData *videodata;

0 comments on commit 8ddb432

Please sign in to comment.