Fixed bug 3453 - First mouse button input after a drag and drop event is ignored
authorSam Lantinga <slouken@libsdl.org>
Fri, 14 Oct 2016 08:40:21 -0700
changeset 10539bf0989bde198
parent 10538 e093aacd58a7
child 10540 911d940ad2cf
Fixed bug 3453 - First mouse button input after a drag and drop event is ignored

Olav Sorensen

After a drag and drop event, any following mouse button input (down/up) doesn't generate an event. Clicking any mouse button a *second* time generates an event like it should.

Further investigation shows that the new SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH logic also causes this issue in other cases, like the first time you open the program and click the mouse.
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Fri Oct 14 08:27:44 2016 -0700
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Fri Oct 14 08:40:21 2016 -0700
     1.3 @@ -401,20 +401,22 @@
     1.4  
     1.5              minimized = HIWORD(wParam);
     1.6              if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
     1.7 -                if (GetAsyncKeyState(VK_LBUTTON)) {
     1.8 -                    data->focus_click_pending |= SDL_BUTTON_LMASK;
     1.9 -                }
    1.10 -                if (GetAsyncKeyState(VK_RBUTTON)) {
    1.11 -                    data->focus_click_pending |= SDL_BUTTON_RMASK;
    1.12 -                }
    1.13 -                if (GetAsyncKeyState(VK_MBUTTON)) {
    1.14 -                    data->focus_click_pending |= SDL_BUTTON_MMASK;
    1.15 -                }
    1.16 -                if (GetAsyncKeyState(VK_XBUTTON1)) {
    1.17 -                    data->focus_click_pending |= SDL_BUTTON_X1MASK;
    1.18 -                }
    1.19 -                if (GetAsyncKeyState(VK_XBUTTON2)) {
    1.20 -                    data->focus_click_pending |= SDL_BUTTON_X2MASK;
    1.21 +                if (LOWORD(wParam) == WA_CLICKACTIVE) {
    1.22 +                    if (GetAsyncKeyState(VK_LBUTTON)) {
    1.23 +                        data->focus_click_pending |= SDL_BUTTON_LMASK;
    1.24 +                    }
    1.25 +                    if (GetAsyncKeyState(VK_RBUTTON)) {
    1.26 +                        data->focus_click_pending |= SDL_BUTTON_RMASK;
    1.27 +                    }
    1.28 +                    if (GetAsyncKeyState(VK_MBUTTON)) {
    1.29 +                        data->focus_click_pending |= SDL_BUTTON_MMASK;
    1.30 +                    }
    1.31 +                    if (GetAsyncKeyState(VK_XBUTTON1)) {
    1.32 +                        data->focus_click_pending |= SDL_BUTTON_X1MASK;
    1.33 +                    }
    1.34 +                    if (GetAsyncKeyState(VK_XBUTTON2)) {
    1.35 +                        data->focus_click_pending |= SDL_BUTTON_X2MASK;
    1.36 +                    }
    1.37                  }
    1.38                  
    1.39                  SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);