Bug 4576: remove touch/mouse duplication for Windows
authorSylvain Becker <sylvain.becker@gmail.com>
Tue, 02 Apr 2019 16:58:11 +0200
changeset 12677ed8b457b0a17
parent 12676 994f7540d7f3
child 12678 9fdfbf246f09
Bug 4576: remove touch/mouse duplication for Windows
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Tue Apr 02 16:46:17 2019 +0200
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Tue Apr 02 16:58:11 2019 +0200
     1.3 @@ -494,18 +494,20 @@
     1.4          {
     1.5              SDL_Mouse *mouse = SDL_GetMouse();
     1.6              if (!mouse->relative_mode || mouse->relative_mode_warp) {
     1.7 -                SDL_MouseID mouseID = (((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) ? SDL_TOUCH_MOUSEID : 0);
     1.8 -                SDL_SendMouseMotion(data->window, mouseID, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
     1.9 -                if (isWin10FCUorNewer && mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) {
    1.10 -                    /* To work around #3931, Win10 bug introduced in Fall Creators Update, where
    1.11 -                       SetCursorPos() (SDL_WarpMouseInWindow()) doesn't reliably generate mouse events anymore,
    1.12 -                       after each windows mouse event generate a fake event for the middle of the window
    1.13 -                       if relative_mode_warp is used */
    1.14 -                    int center_x = 0, center_y = 0;
    1.15 -                    SDL_GetWindowSize(data->window, &center_x, &center_y);
    1.16 -                    center_x /= 2;
    1.17 -                    center_y /= 2;
    1.18 -                    SDL_SendMouseMotion(data->window, mouseID, 0, center_x, center_y);
    1.19 +                /* Only generate mouse events for real mouse */
    1.20 +                if ((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) != MOUSEEVENTF_FROMTOUCH) {
    1.21 +                    SDL_SendMouseMotion(data->window, 0, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
    1.22 +                    if (isWin10FCUorNewer && mouse->relative_mode_warp) {
    1.23 +                        /* To work around #3931, Win10 bug introduced in Fall Creators Update, where
    1.24 +                           SetCursorPos() (SDL_WarpMouseInWindow()) doesn't reliably generate mouse events anymore,
    1.25 +                           after each windows mouse event generate a fake event for the middle of the window
    1.26 +                           if relative_mode_warp is used */
    1.27 +                        int center_x = 0, center_y = 0;
    1.28 +                        SDL_GetWindowSize(data->window, &center_x, &center_y);
    1.29 +                        center_x /= 2;
    1.30 +                        center_y /= 2;
    1.31 +                        SDL_SendMouseMotion(data->window, 0, 0, center_x, center_y);
    1.32 +                    }
    1.33                  }
    1.34              }
    1.35          }
    1.36 @@ -525,8 +527,9 @@
    1.37          {
    1.38              SDL_Mouse *mouse = SDL_GetMouse();
    1.39              if (!mouse->relative_mode || mouse->relative_mode_warp) {
    1.40 -                SDL_MouseID mouseID = (((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) ? SDL_TOUCH_MOUSEID : 0);
    1.41 -                WIN_CheckWParamMouseButtons(wParam, data, mouseID);
    1.42 +                if ((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) != MOUSEEVENTF_FROMTOUCH) {
    1.43 +                    WIN_CheckWParamMouseButtons(wParam, data, mouseID);
    1.44 +                }
    1.45              }
    1.46          }
    1.47          break;