src/video/wayland/SDL_waylandtouch.c
changeset 12996 b4a7e94357f2
parent 12979 bbbb30026158
child 13201 c88f111dc41f
equal deleted inserted replaced
12995:db8413ae083c 12996:b4a7e94357f2
    24 #include "../../SDL_internal.h"
    24 #include "../../SDL_internal.h"
    25 
    25 
    26 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    26 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    27 
    27 
    28 #include "SDL_log.h"
    28 #include "SDL_log.h"
       
    29 #include "SDL_mouse.h"
       
    30 #include "SDL_keyboard.h"
    29 #include "SDL_waylandtouch.h"
    31 #include "SDL_waylandtouch.h"
    30 #include "../../events/SDL_touch_c.h"
    32 #include "../../events/SDL_touch_c.h"
    31 
    33 
    32 struct SDL_WaylandTouch {
    34 struct SDL_WaylandTouch {
    33     struct qt_touch_extension *touch_extension;
    35     struct qt_touch_extension *touch_extension;
    86     uint32_t sentPointCount = state >> 16;
    88     uint32_t sentPointCount = state >> 16;
    87     uint32_t touchFlags = flags & 0xFFFF;
    89     uint32_t touchFlags = flags & 0xFFFF;
    88     uint32_t capabilities = flags >> 16;
    90     uint32_t capabilities = flags >> 16;
    89     */
    91     */
    90 
    92 
       
    93     SDL_Window* window = NULL;
       
    94 
    91     SDL_TouchID deviceId = 1;
    95     SDL_TouchID deviceId = 1;
    92     if (SDL_AddTouch(deviceId, SDL_TOUCH_DEVICE_DIRECT, "qt_touch_extension") < 0) {
    96     if (SDL_AddTouch(deviceId, SDL_TOUCH_DEVICE_DIRECT, "qt_touch_extension") < 0) {
    93          SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
    97          SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
    94     }
    98     }
    95 
    99 
       
   100     /* FIXME: This should be the window the given wayland surface is associated
       
   101      * with, but how do we get the wayland surface? */
       
   102     window = SDL_GetMouseFocus();
       
   103     if (window == NULL) {
       
   104         window = SDL_GetKeyboardFocus();
       
   105     }
       
   106 
    96     switch (touchState) {
   107     switch (touchState) {
    97         case QtWaylandTouchPointPressed:
   108         case QtWaylandTouchPointPressed:
    98         case QtWaylandTouchPointReleased:
   109         case QtWaylandTouchPointReleased:
    99             SDL_SendTouch(deviceId, (SDL_FingerID)id, /* FIXME: window */,
   110             SDL_SendTouch(deviceId, (SDL_FingerID)id, window,
   100                     (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE,
   111                     (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE,
   101                     xf, yf, pressuref);
   112                     xf, yf, pressuref);
   102             break;
   113             break;
   103         case QtWaylandTouchPointMoved:
   114         case QtWaylandTouchPointMoved:
   104             SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, /* FIXME: window */, xf, yf, pressuref);
   115             SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, window, xf, yf, pressuref);
   105             break;
   116             break;
   106         default:
   117         default:
   107             /* Should not happen */
   118             /* Should not happen */
   108             break;
   119             break;
   109     }
   120     }