Fix touch-related compile errors on Linux.
authorAlex Szpakowski <slime73@gmail.com>
Sun, 04 Aug 2019 16:56:40 -0300
changeset 12996b4a7e94357f2
parent 12995 db8413ae083c
child 12997 35e9649605cb
Fix touch-related compile errors on Linux.
src/core/linux/SDL_evdev.c
src/video/wayland/SDL_waylandtouch.c
     1.1 --- a/src/core/linux/SDL_evdev.c	Sun Aug 04 14:56:02 2019 +0300
     1.2 +++ b/src/core/linux/SDL_evdev.c	Sun Aug 04 16:56:40 2019 -0300
     1.3 @@ -401,18 +401,21 @@
     1.4                                  norm_pressure = 1.0f;
     1.5                              }
     1.6  
     1.7 +                            /* FIXME: the touch's window shouldn't be null, but
     1.8 +                             * the coordinate space of touch positions needs to
     1.9 +                             * be window-relative in that case. */
    1.10                              switch(item->touchscreen_data->slots[j].delta) {
    1.11                              case EVDEV_TOUCH_SLOTDELTA_DOWN:
    1.12 -                                SDL_SendTouch(item->fd, item->touchscreen_data->slots[j].tracking_id, /* FIXME: window */, SDL_TRUE, norm_x, norm_y, norm_pressure);
    1.13 +                                SDL_SendTouch(item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_TRUE, norm_x, norm_y, norm_pressure);
    1.14                                  item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
    1.15                                  break;
    1.16                              case EVDEV_TOUCH_SLOTDELTA_UP:
    1.17 -                                SDL_SendTouch(item->fd, item->touchscreen_data->slots[j].tracking_id, /* FIXME: window */, SDL_FALSE, norm_x, norm_y, norm_pressure);
    1.18 +                                SDL_SendTouch(item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_FALSE, norm_x, norm_y, norm_pressure);
    1.19                                  item->touchscreen_data->slots[j].tracking_id = -1;
    1.20                                  item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
    1.21                                  break;
    1.22                              case EVDEV_TOUCH_SLOTDELTA_MOVE:
    1.23 -                                SDL_SendTouchMotion(item->fd, item->touchscreen_data->slots[j].tracking_id, /* FIXME: window */, norm_x, norm_y, norm_pressure);
    1.24 +                                SDL_SendTouchMotion(item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, norm_x, norm_y, norm_pressure);
    1.25                                  item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
    1.26                                  break;
    1.27                              default:
     2.1 --- a/src/video/wayland/SDL_waylandtouch.c	Sun Aug 04 14:56:02 2019 +0300
     2.2 +++ b/src/video/wayland/SDL_waylandtouch.c	Sun Aug 04 16:56:40 2019 -0300
     2.3 @@ -26,6 +26,8 @@
     2.4  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
     2.5  
     2.6  #include "SDL_log.h"
     2.7 +#include "SDL_mouse.h"
     2.8 +#include "SDL_keyboard.h"
     2.9  #include "SDL_waylandtouch.h"
    2.10  #include "../../events/SDL_touch_c.h"
    2.11  
    2.12 @@ -88,20 +90,29 @@
    2.13      uint32_t capabilities = flags >> 16;
    2.14      */
    2.15  
    2.16 +    SDL_Window* window = NULL;
    2.17 +
    2.18      SDL_TouchID deviceId = 1;
    2.19      if (SDL_AddTouch(deviceId, SDL_TOUCH_DEVICE_DIRECT, "qt_touch_extension") < 0) {
    2.20           SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
    2.21      }
    2.22  
    2.23 +    /* FIXME: This should be the window the given wayland surface is associated
    2.24 +     * with, but how do we get the wayland surface? */
    2.25 +    window = SDL_GetMouseFocus();
    2.26 +    if (window == NULL) {
    2.27 +        window = SDL_GetKeyboardFocus();
    2.28 +    }
    2.29 +
    2.30      switch (touchState) {
    2.31          case QtWaylandTouchPointPressed:
    2.32          case QtWaylandTouchPointReleased:
    2.33 -            SDL_SendTouch(deviceId, (SDL_FingerID)id, /* FIXME: window */,
    2.34 +            SDL_SendTouch(deviceId, (SDL_FingerID)id, window,
    2.35                      (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE,
    2.36                      xf, yf, pressuref);
    2.37              break;
    2.38          case QtWaylandTouchPointMoved:
    2.39 -            SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, /* FIXME: window */, xf, yf, pressuref);
    2.40 +            SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, window, xf, yf, pressuref);
    2.41              break;
    2.42          default:
    2.43              /* Should not happen */