src/video/wayland/SDL_waylandtouch.c
changeset 12996 b4a7e94357f2
parent 12979 bbbb30026158
child 13201 c88f111dc41f
     1.1 --- a/src/video/wayland/SDL_waylandtouch.c	Sun Aug 04 14:56:02 2019 +0300
     1.2 +++ b/src/video/wayland/SDL_waylandtouch.c	Sun Aug 04 16:56:40 2019 -0300
     1.3 @@ -26,6 +26,8 @@
     1.4  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
     1.5  
     1.6  #include "SDL_log.h"
     1.7 +#include "SDL_mouse.h"
     1.8 +#include "SDL_keyboard.h"
     1.9  #include "SDL_waylandtouch.h"
    1.10  #include "../../events/SDL_touch_c.h"
    1.11  
    1.12 @@ -88,20 +90,29 @@
    1.13      uint32_t capabilities = flags >> 16;
    1.14      */
    1.15  
    1.16 +    SDL_Window* window = NULL;
    1.17 +
    1.18      SDL_TouchID deviceId = 1;
    1.19      if (SDL_AddTouch(deviceId, SDL_TOUCH_DEVICE_DIRECT, "qt_touch_extension") < 0) {
    1.20           SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
    1.21      }
    1.22  
    1.23 +    /* FIXME: This should be the window the given wayland surface is associated
    1.24 +     * with, but how do we get the wayland surface? */
    1.25 +    window = SDL_GetMouseFocus();
    1.26 +    if (window == NULL) {
    1.27 +        window = SDL_GetKeyboardFocus();
    1.28 +    }
    1.29 +
    1.30      switch (touchState) {
    1.31          case QtWaylandTouchPointPressed:
    1.32          case QtWaylandTouchPointReleased:
    1.33 -            SDL_SendTouch(deviceId, (SDL_FingerID)id, /* FIXME: window */,
    1.34 +            SDL_SendTouch(deviceId, (SDL_FingerID)id, window,
    1.35                      (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE,
    1.36                      xf, yf, pressuref);
    1.37              break;
    1.38          case QtWaylandTouchPointMoved:
    1.39 -            SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, /* FIXME: window */, xf, yf, pressuref);
    1.40 +            SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, window, xf, yf, pressuref);
    1.41              break;
    1.42          default:
    1.43              /* Should not happen */