src/video/wayland/SDL_waylandevents.c
changeset 13805 4709c1dfeabb
parent 13701 3cc182fa6110
child 13878 a9b4bd264f3c
equal deleted inserted replaced
13804:ccd76043c80e 13805:4709c1dfeabb
    63     struct wl_pointer *pointer;
    63     struct wl_pointer *pointer;
    64     struct wl_touch *touch;
    64     struct wl_touch *touch;
    65     struct wl_keyboard *keyboard;
    65     struct wl_keyboard *keyboard;
    66     SDL_WaylandDataDevice *data_device;
    66     SDL_WaylandDataDevice *data_device;
    67     struct zwp_relative_pointer_v1 *relative_pointer;
    67     struct zwp_relative_pointer_v1 *relative_pointer;
       
    68     struct zwp_confined_pointer_v1 *confined_pointer;
    68     SDL_WindowData *pointer_focus;
    69     SDL_WindowData *pointer_focus;
    69     SDL_WindowData *keyboard_focus;
    70     SDL_WindowData *keyboard_focus;
    70 
    71 
    71     /* Last motion location */
    72     /* Last motion location */
    72     wl_fixed_t sx_w;
    73     wl_fixed_t sx_w;
  1261     d->relative_mouse_mode = 0;
  1262     d->relative_mouse_mode = 0;
  1262 
  1263 
  1263     return 0;
  1264     return 0;
  1264 }
  1265 }
  1265 
  1266 
       
  1267 static void
       
  1268 confined_pointer_confined(void *data,
       
  1269                           struct zwp_confined_pointer_v1 *confined_pointer)
       
  1270 {
       
  1271 }
       
  1272 
       
  1273 static void
       
  1274 confined_pointer_unconfined(void *data,
       
  1275                             struct zwp_confined_pointer_v1 *confined_pointer)
       
  1276 {
       
  1277 }
       
  1278 
       
  1279 static const struct zwp_confined_pointer_v1_listener confined_pointer_listener = {
       
  1280     confined_pointer_confined,
       
  1281     confined_pointer_unconfined,
       
  1282 };
       
  1283 
       
  1284 int Wayland_input_confine_pointer(SDL_Window *window, struct SDL_WaylandInput *input)
       
  1285 {
       
  1286     SDL_WindowData *w = window->driverdata;
       
  1287     SDL_VideoData *d = input->display;
       
  1288     struct zwp_confined_pointer_v1 *confined_pointer;
       
  1289 
       
  1290     if (!d->pointer_constraints)
       
  1291         return -1;
       
  1292 
       
  1293     if (!input->pointer)
       
  1294         return -1;
       
  1295 
       
  1296     /* A confine may already be active, in which case we should destroy it and
       
  1297      * create a new one. */
       
  1298     if (input->confined_pointer)
       
  1299         Wayland_input_unconfine_pointer(input);
       
  1300 
       
  1301     confined_pointer =
       
  1302         zwp_pointer_constraints_v1_confine_pointer(d->pointer_constraints,
       
  1303                                                    w->surface,
       
  1304                                                    input->pointer,
       
  1305                                                    NULL,
       
  1306                                                    ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
       
  1307     zwp_confined_pointer_v1_add_listener(confined_pointer,
       
  1308                                          &confined_pointer_listener,
       
  1309                                          window);
       
  1310 
       
  1311     input->confined_pointer = confined_pointer;
       
  1312     return 0;
       
  1313 }
       
  1314 
       
  1315 int Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input)
       
  1316 {
       
  1317     if (input->confined_pointer) {
       
  1318         zwp_confined_pointer_v1_destroy(input->confined_pointer);
       
  1319         input->confined_pointer = NULL;
       
  1320     }
       
  1321 
       
  1322     return 0;
       
  1323 }
       
  1324 
  1266 #endif /* SDL_VIDEO_DRIVER_WAYLAND */
  1325 #endif /* SDL_VIDEO_DRIVER_WAYLAND */
  1267 
  1326 
  1268 /* vi: set ts=4 sw=4 expandtab: */
  1327 /* vi: set ts=4 sw=4 expandtab: */