SDL_waylandevents.c
Go to the documentation of this file.
/*
Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_WAYLAND
#include "SDL_stdinc.h"
#include "SDL_assert.h"
#include "SDL_log.h"
#include "../../core/unix/SDL_poll.h"
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "../../events/scancodes_xfree86.h"
#include "SDL_waylandvideo.h"
#include "SDL_waylandevents_c.h"
#include "SDL_waylandwindow.h"
#include "SDL_waylanddyn.h"
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "xdg-shell-unstable-v6-client-protocol.h"
#include <linux/input.h>
#include <sys/select.h>
#include <sys/mman.h>
#include <poll.h>
#include <unistd.h>
#include <xkbcommon/xkbcommon.h>
struct SDL_WaylandInput {
SDL_VideoData *display;
struct wl_seat *seat;
struct wl_pointer *pointer;
struct wl_touch *touch;
struct wl_keyboard *keyboard;
SDL_WaylandDataDevice *data_device;
struct zwp_relative_pointer_v1 *relative_pointer;
SDL_WindowData *pointer_focus;
SDL_WindowData *keyboard_focus;
/* Last motion location */
wl_fixed_t sx_w;
wl_fixed_t sy_w;
double dx_frac;
double dy_frac;
struct {
struct xkb_keymap *keymap;
struct xkb_state *state;
} xkb;
};
struct SDL_WaylandTouchPoint {
SDL_TouchID id;
float x;
float y;
struct wl_surface* surface;
struct SDL_WaylandTouchPoint* prev;
struct SDL_WaylandTouchPoint* next;
};
struct SDL_WaylandTouchPointList {
struct SDL_WaylandTouchPoint* head;
struct SDL_WaylandTouchPoint* tail;
};
static struct SDL_WaylandTouchPointList touch_points = {NULL, NULL};
static void
touch_add(SDL_TouchID id, float x, float y, struct wl_surface *surface)
{
struct SDL_WaylandTouchPoint* tp = SDL_malloc(sizeof(struct SDL_WaylandTouchPoint));
tp->id = id;
tp->x = x;
tp->y = y;
tp->surface = surface;
if (touch_points.tail) {
touch_points.tail->next = tp;
tp->prev = touch_points.tail;
} else {
touch_points.head = tp;
tp->prev = NULL;
}
touch_points.tail = tp;
tp->next = NULL;
}
static void
touch_update(SDL_TouchID id, float x, float y)
{
struct SDL_WaylandTouchPoint* tp = touch_points.head;
while (tp) {
if (tp->id == id) {
tp->x = x;
tp->y = y;
}
tp = tp->next;
}
}
static void
touch_del(SDL_TouchID id, float* x, float* y)
{
struct SDL_WaylandTouchPoint* tp = touch_points.head;
while (tp) {
if (tp->id == id) {
*x = tp->x;
*y = tp->y;
if (tp->prev) {
tp->prev->next = tp->next;
} else {
touch_points.head = tp->next;
}
if (tp->next) {
tp->next->prev = tp->prev;
} else {
touch_points.tail = tp->prev;
}
SDL_free(tp);
}
tp = tp->next;
}
}
static struct wl_surface*
touch_surface(SDL_TouchID id)
{
struct SDL_WaylandTouchPoint* tp = touch_points.head;
while (tp) {
if (tp->id == id) {
return tp->surface;
}
tp = tp->next;
}
return NULL;
}
void
Wayland_PumpEvents(_THIS)
{
SDL_VideoData *d = _this->driverdata;
if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_FALSE, 0)) {
WAYLAND_wl_display_dispatch(d->display);
}
else
{
WAYLAND_wl_display_dispatch_pending(d->display);
}
}
static void
pointer_handle_enter(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface,
wl_fixed_t sx_w, wl_fixed_t sy_w)
{
struct SDL_WaylandInput *input = data;
SDL_WindowData *window;
if (!surface) {
/* enter event for a window we've just destroyed */
return;
}
/* This handler will be called twice in Wayland 1.4
* Once for the window surface which has valid user data
* and again for the mouse cursor surface which does not have valid user data
* We ignore the later
*/
window = (SDL_WindowData *)wl_surface_get_user_data(surface);
if (window) {
input->pointer_focus = window;
SDL_SetMouseFocus(window->sdlwindow);
}
}
static void
pointer_handle_leave(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface)
{
struct SDL_WaylandInput *input = data;
if (input->pointer_focus) {
SDL_SetMouseFocus(NULL);
input->pointer_focus = NULL;
}
}
static void
pointer_handle_motion(void *data, struct wl_pointer *pointer,
uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
{
struct SDL_WaylandInput *input = data;
SDL_WindowData *window = input->pointer_focus;
input->sx_w = sx_w;
input->sy_w = sy_w;
if (input->pointer_focus) {
const int sx = wl_fixed_to_int(sx_w);
const int sy = wl_fixed_to_int(sy_w);
SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy);
}
}
static SDL_bool
ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
{
SDL_WindowData *window_data = input->pointer_focus;
SDL_Window *window = window_data->sdlwindow;
if (window->hit_test) {
const SDL_Point point = { wl_fixed_to_int(input->sx_w), wl_fixed_to_int(input->sy_w) };
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
static const uint32_t directions_wl[] = {
WL_SHELL_SURFACE_RESIZE_TOP_LEFT, WL_SHELL_SURFACE_RESIZE_TOP,
WL_SHELL_SURFACE_RESIZE_TOP_RIGHT, WL_SHELL_SURFACE_RESIZE_RIGHT,
WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, WL_SHELL_SURFACE_RESIZE_BOTTOM,
WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT, WL_SHELL_SURFACE_RESIZE_LEFT
};
/* the names are different (ZXDG_TOPLEVEL_V6_RESIZE_EDGE_* vs
WL_SHELL_SURFACE_RESIZE_*), but the values are the same. */
const uint32_t *directions_zxdg = directions_wl;
switch (rc) {
case SDL_HITTEST_DRAGGABLE:
if (input->display->shell.zxdg) {
zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial);
} else {
wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial);
}
return SDL_TRUE;
case SDL_HITTEST_RESIZE_TOPLEFT:
case SDL_HITTEST_RESIZE_TOP:
case SDL_HITTEST_RESIZE_TOPRIGHT:
case SDL_HITTEST_RESIZE_RIGHT:
case SDL_HITTEST_RESIZE_BOTTOMRIGHT:
case SDL_HITTEST_RESIZE_BOTTOM:
case SDL_HITTEST_RESIZE_BOTTOMLEFT:
case SDL_HITTEST_RESIZE_LEFT:
if (input->display->shell.zxdg) {
zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
} else {
wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
}
return SDL_TRUE;
default: return SDL_FALSE;
}
}
return SDL_FALSE;
}
static void
pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial,
uint32_t time, uint32_t button, uint32_t state_w)
{
SDL_WindowData *window = input->pointer_focus;
enum wl_pointer_button_state state = state_w;
uint32_t sdl_button;
if (input->pointer_focus) {
switch (button) {
case BTN_LEFT:
sdl_button = SDL_BUTTON_LEFT;
if (ProcessHitTest(input, serial)) {
return; /* don't pass this event on to app. */
}
break;
case BTN_MIDDLE:
sdl_button = SDL_BUTTON_MIDDLE;
break;
case BTN_RIGHT:
sdl_button = SDL_BUTTON_RIGHT;
break;
case BTN_SIDE:
sdl_button = SDL_BUTTON_X1;
break;
case BTN_EXTRA:
sdl_button = SDL_BUTTON_X2;
break;
default:
return;
}
Wayland_data_device_set_serial(input->data_device, serial);
SDL_SendMouseButton(window->sdlwindow, 0,
state ? SDL_PRESSED : SDL_RELEASED, sdl_button);
}
}
static void
pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
uint32_t time, uint32_t button, uint32_t state_w)
{
struct SDL_WaylandInput *input = data;
pointer_handle_button_common(input, serial, time, button, state_w);
}
static void
pointer_handle_axis_common(struct SDL_WaylandInput *input,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
SDL_WindowData *window = input->pointer_focus;
enum wl_pointer_axis a = axis;
float x, y;
if (input->pointer_focus) {
switch (a) {
case WL_POINTER_AXIS_VERTICAL_SCROLL:
x = 0;
y = 0 - (float)wl_fixed_to_double(value);
break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
x = 0 - (float)wl_fixed_to_double(value);
y = 0;
break;
default:
return;
}
SDL_SendMouseWheel(window->sdlwindow, 0, x, y, SDL_MOUSEWHEEL_NORMAL);
}
}
static void
pointer_handle_axis(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
struct SDL_WaylandInput *input = data;
pointer_handle_axis_common(input, time, axis, value);
}
static const struct wl_pointer_listener pointer_listener = {
pointer_handle_enter,
pointer_handle_leave,
pointer_handle_motion,
pointer_handle_button,
pointer_handle_axis,
NULL, /* frame */
NULL, /* axis_source */
NULL, /* axis_stop */
NULL, /* axis_discrete */
};
static void
touch_handler_down(void *data, struct wl_touch *touch, unsigned int serial,
unsigned int timestamp, struct wl_surface *surface,
int id, wl_fixed_t fx, wl_fixed_t fy)
{
float x, y;
SDL_WindowData* window;
window = (SDL_WindowData *)wl_surface_get_user_data(surface);
x = wl_fixed_to_double(fx) / window->sdlwindow->w;
y = wl_fixed_to_double(fy) / window->sdlwindow->h;
touch_add(id, x, y, surface);
SDL_SendTouch(1, (SDL_FingerID)id, SDL_TRUE, x, y, 1.0f);
}
static void
touch_handler_up(void *data, struct wl_touch *touch, unsigned int serial,
unsigned int timestamp, int id)
{
float x = 0, y = 0;
touch_del(id, &x, &y);
SDL_SendTouch(1, (SDL_FingerID)id, SDL_FALSE, x, y, 0.0f);
}
static void
touch_handler_motion(void *data, struct wl_touch *touch, unsigned int timestamp,
int id, wl_fixed_t fx, wl_fixed_t fy)
{
float x, y;
SDL_WindowData* window;
window = (SDL_WindowData *)wl_surface_get_user_data(touch_surface(id));
x = wl_fixed_to_double(fx) / window->sdlwindow->w;
y = wl_fixed_to_double(fy) / window->sdlwindow->h;
touch_update(id, x, y);
SDL_SendTouchMotion(1, (SDL_FingerID)id, x, y, 1.0f);
}
static void
touch_handler_frame(void *data, struct wl_touch *touch)
{
}
static void
touch_handler_cancel(void *data, struct wl_touch *touch)
{
}
static const struct wl_touch_listener touch_listener = {
touch_handler_down,
touch_handler_up,
touch_handler_motion,
touch_handler_frame,
touch_handler_cancel,
NULL, /* shape */
NULL, /* orientation */
};
static void
keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
uint32_t format, int fd, uint32_t size)
{
struct SDL_WaylandInput *input = data;
char *map_str;
if (!data) {
close(fd);
return;
}
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
close(fd);
return;
}
map_str = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (map_str == MAP_FAILED) {
close(fd);
return;
}
input->xkb.keymap = WAYLAND_xkb_keymap_new_from_string(input->display->xkb_context,
map_str,
XKB_KEYMAP_FORMAT_TEXT_V1,
0);
munmap(map_str, size);
close(fd);
if (!input->xkb.keymap) {
fprintf(stderr, "failed to compile keymap\n");
return;
}
input->xkb.state = WAYLAND_xkb_state_new(input->xkb.keymap);
if (!input->xkb.state) {
fprintf(stderr, "failed to create XKB state\n");
WAYLAND_xkb_keymap_unref(input->xkb.keymap);
input->xkb.keymap = NULL;
return;
}
}
static void
keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface,
struct wl_array *keys)
{
struct SDL_WaylandInput *input = data;
SDL_WindowData *window;
if (!surface) {
/* enter event for a window we've just destroyed */
return;
}
window = wl_surface_get_user_data(surface);
if (window) {
input->keyboard_focus = window;
window->keyboard_device = input;
SDL_SetKeyboardFocus(window->sdlwindow);
}
}
static void
keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface)
{
SDL_SetKeyboardFocus(NULL);
}
static void
keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t time, uint32_t key,
uint32_t state_w)
{
struct SDL_WaylandInput *input = data;
SDL_WindowData *window = input->keyboard_focus;
enum wl_keyboard_key_state state = state_w;
const xkb_keysym_t *syms;
uint32_t scancode;
char text[8];
int size;
if (key < SDL_arraysize(xfree86_scancode_table2)) {
scancode = xfree86_scancode_table2[key];
// TODO when do we get WL_KEYBOARD_KEY_STATE_REPEAT?
if (scancode != SDL_SCANCODE_UNKNOWN)
SDL_SendKeyboardKey(state == WL_KEYBOARD_KEY_STATE_PRESSED ?
SDL_PRESSED : SDL_RELEASED, scancode);
}
if (!window || window->keyboard_device != input || !input->xkb.state)
return;
// TODO can this happen?
if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1)
return;
if (state) {
size = WAYLAND_xkb_keysym_to_utf8(syms[0], text, sizeof text);
if (size > 0) {
text[size] = 0;
Wayland_data_device_set_serial(input->data_device, serial);
SDL_SendKeyboardText(text);
}
}
}
static void
keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t mods_depressed,
uint32_t mods_latched, uint32_t mods_locked,
uint32_t group)
{
struct SDL_WaylandInput *input = data;
WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched,
mods_locked, 0, 0, group);
}
static const struct wl_keyboard_listener keyboard_listener = {
keyboard_handle_keymap,
keyboard_handle_enter,
keyboard_handle_leave,
keyboard_handle_key,
keyboard_handle_modifiers,
NULL, /* repeat_info */
};
static void
seat_handle_capabilities(void *data, struct wl_seat *seat,
enum wl_seat_capability caps)
{
struct SDL_WaylandInput *input = data;
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
input->pointer = wl_seat_get_pointer(seat);
input->display->pointer = input->pointer;
wl_pointer_set_user_data(input->pointer, input);
wl_pointer_add_listener(input->pointer, &pointer_listener,
input);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
wl_pointer_destroy(input->pointer);
input->pointer = NULL;
input->display->pointer = NULL;
}
if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->touch) {
SDL_AddTouch(1, "wayland_touch");
input->touch = wl_seat_get_touch(seat);
wl_touch_set_user_data(input->touch, input);
wl_touch_add_listener(input->touch, &touch_listener,
input);
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
SDL_DelTouch(1);
wl_touch_destroy(input->touch);
input->touch = NULL;
}
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
input->keyboard = wl_seat_get_keyboard(seat);
wl_keyboard_set_user_data(input->keyboard, input);
wl_keyboard_add_listener(input->keyboard, &keyboard_listener,
input);
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
wl_keyboard_destroy(input->keyboard);
input->keyboard = NULL;
}
}
static const struct wl_seat_listener seat_listener = {
seat_handle_capabilities,
NULL, /* name */
};
static void
data_source_handle_target(void *data, struct wl_data_source *wl_data_source,
const char *mime_type)
{
}
static void
data_source_handle_send(void *data, struct wl_data_source *wl_data_source,
const char *mime_type, int32_t fd)
{
Wayland_data_source_send((SDL_WaylandDataSource *)data, mime_type, fd);
}
static void
data_source_handle_cancelled(void *data, struct wl_data_source *wl_data_source)
{
Wayland_data_source_destroy(data);
}
static void
data_source_handle_dnd_drop_performed(void *data, struct wl_data_source *wl_data_source)
{
}
static void
data_source_handle_dnd_finished(void *data, struct wl_data_source *wl_data_source)
{
}
static void
data_source_handle_action(void *data, struct wl_data_source *wl_data_source,
uint32_t dnd_action)
{
}
static const struct wl_data_source_listener data_source_listener = {
data_source_handle_target,
data_source_handle_send,
data_source_handle_cancelled,
data_source_handle_dnd_drop_performed, // Version 3
data_source_handle_dnd_finished, // Version 3
data_source_handle_action, // Version 3
};
SDL_WaylandDataSource*
Wayland_data_source_create(_THIS)
{
SDL_WaylandDataSource *data_source = NULL;
SDL_VideoData *driver_data = NULL;
struct wl_data_source *id = NULL;
if (_this == NULL || _this->driverdata == NULL) {
SDL_SetError("Video driver uninitialized");
} else {
driver_data = _this->driverdata;
if (driver_data->data_device_manager != NULL) {
id = wl_data_device_manager_create_data_source(
driver_data->data_device_manager);
}
if (id == NULL) {
SDL_SetError("Wayland unable to create data source");
} else {
data_source = SDL_calloc(1, sizeof *data_source);
if (data_source == NULL) {
SDL_OutOfMemory();
wl_data_source_destroy(id);
} else {
WAYLAND_wl_list_init(&(data_source->mimes));
data_source->source = id;
wl_data_source_set_user_data(id, data_source);
wl_data_source_add_listener(id, &data_source_listener,
data_source);
}
}
}
return data_source;
}
static void
data_offer_handle_offer(void *data, struct wl_data_offer *wl_data_offer,
const char *mime_type)
{
SDL_WaylandDataOffer *offer = data;
Wayland_data_offer_add_mime(offer, mime_type);
}
static void
data_offer_handle_source_actions(void *data, struct wl_data_offer *wl_data_offer,
uint32_t source_actions)
{
}
static void
data_offer_handle_actions(void *data, struct wl_data_offer *wl_data_offer,
uint32_t dnd_action)
{
}
static const struct wl_data_offer_listener data_offer_listener = {
data_offer_handle_offer,
data_offer_handle_source_actions, // Version 3
data_offer_handle_actions, // Version 3
};
static void
data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device,
struct wl_data_offer *id)
{
SDL_WaylandDataOffer *data_offer = NULL;
data_offer = SDL_calloc(1, sizeof *data_offer);
if (data_offer == NULL) {
SDL_OutOfMemory();
} else {
data_offer->offer = id;
data_offer->data_device = data;
WAYLAND_wl_list_init(&(data_offer->mimes));
wl_data_offer_set_user_data(id, data_offer);
wl_data_offer_add_listener(id, &data_offer_listener, data_offer);
}
}
static void
data_device_handle_enter(void *data, struct wl_data_device *wl_data_device,
uint32_t serial, struct wl_surface *surface,
wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id)
{
SDL_WaylandDataDevice *data_device = data;
SDL_bool has_mime = SDL_FALSE;
uint32_t dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
data_device->drag_serial = serial;
if (id != NULL) {
data_device->drag_offer = wl_data_offer_get_user_data(id);
/* TODO: SDL Support more mime types */
has_mime = Wayland_data_offer_has_mime(
data_device->drag_offer, FILE_MIME);
/* If drag_mime is NULL this will decline the offer */
wl_data_offer_accept(id, serial,
(has_mime == SDL_TRUE) ? FILE_MIME : NULL);
/* SDL only supports "copy" style drag and drop */
if (has_mime == SDL_TRUE) {
dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
}
wl_data_offer_set_actions(data_device->drag_offer->offer,
dnd_action, dnd_action);
}
}
static void
data_device_handle_leave(void *data, struct wl_data_device *wl_data_device)
{
SDL_WaylandDataDevice *data_device = data;
SDL_WaylandDataOffer *offer = NULL;
if (data_device->selection_offer != NULL) {
data_device->selection_offer = NULL;
Wayland_data_offer_destroy(offer);
}
}
static void
data_device_handle_motion(void *data, struct wl_data_device *wl_data_device,
uint32_t time, wl_fixed_t x, wl_fixed_t y)
{
}
static void
data_device_handle_drop(void *data, struct wl_data_device *wl_data_device)
{
SDL_WaylandDataDevice *data_device = data;
void *buffer = NULL;
size_t length = 0;
const char *current_uri = NULL;
const char *last_char = NULL;
char *current_char = NULL;
if (data_device->drag_offer != NULL) {
/* TODO: SDL Support more mime types */
buffer = Wayland_data_offer_receive(data_device->drag_offer,
&length, FILE_MIME, SDL_FALSE);
/* uri-list */
current_uri = (const char *)buffer;
last_char = (const char *)buffer + length;
for (current_char = buffer; current_char < last_char; ++current_char) {
if (*current_char == '\n' || *current_char == 0) {
if (*current_uri != 0 && *current_uri != '#') {
*current_char = 0;
SDL_SendDropFile(NULL, current_uri);
}
current_uri = (const char *)current_char + 1;
}
}
SDL_free(buffer);
}
}
static void
data_device_handle_selection(void *data, struct wl_data_device *wl_data_device,
struct wl_data_offer *id)
{
SDL_WaylandDataDevice *data_device = data;
SDL_WaylandDataOffer *offer = NULL;
if (id != NULL) {
offer = wl_data_offer_get_user_data(id);
}
if (data_device->selection_offer != offer) {
Wayland_data_offer_destroy(data_device->selection_offer);
data_device->selection_offer = offer;
}
SDL_SendClipboardUpdate();
}
static const struct wl_data_device_listener data_device_listener = {
data_device_handle_data_offer,
data_device_handle_enter,
data_device_handle_leave,
data_device_handle_motion,
data_device_handle_drop,
data_device_handle_selection
};
void
Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
{
struct SDL_WaylandInput *input;
SDL_WaylandDataDevice *data_device = NULL;
input = SDL_calloc(1, sizeof *input);
if (input == NULL)
return;
input->display = d;
input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1);
input->sx_w = wl_fixed_from_int(0);
input->sy_w = wl_fixed_from_int(0);
d->input = input;
if (d->data_device_manager != NULL) {
data_device = SDL_calloc(1, sizeof *data_device);
if (data_device == NULL) {
return;
}
data_device->data_device = wl_data_device_manager_get_data_device(
d->data_device_manager, input->seat
);
data_device->video_data = d;
if (data_device->data_device == NULL) {
SDL_free(data_device);
} else {
wl_data_device_set_user_data(data_device->data_device, data_device);
wl_data_device_add_listener(data_device->data_device,
&data_device_listener, data_device);
input->data_device = data_device;
}
}
wl_seat_add_listener(input->seat, &seat_listener, input);
wl_seat_set_user_data(input->seat, input);
WAYLAND_wl_display_flush(d->display);
}
void Wayland_display_destroy_input(SDL_VideoData *d)
{
struct SDL_WaylandInput *input = d->input;
if (!input)
return;
if (input->data_device != NULL) {
Wayland_data_device_clear_selection(input->data_device);
if (input->data_device->selection_offer != NULL) {
Wayland_data_offer_destroy(input->data_device->selection_offer);
}
if (input->data_device->drag_offer != NULL) {
Wayland_data_offer_destroy(input->data_device->drag_offer);
}
if (input->data_device->data_device != NULL) {
wl_data_device_release(input->data_device->data_device);
}
SDL_free(input->data_device);
}
if (input->keyboard)
wl_keyboard_destroy(input->keyboard);
if (input->pointer)
wl_pointer_destroy(input->pointer);
if (input->touch) {
SDL_DelTouch(1);
wl_touch_destroy(input->touch);
}
if (input->seat)
wl_seat_destroy(input->seat);
if (input->xkb.state)
WAYLAND_xkb_state_unref(input->xkb.state);
if (input->xkb.keymap)
WAYLAND_xkb_keymap_unref(input->xkb.keymap);
SDL_free(input);
d->input = NULL;
}
SDL_WaylandDataDevice* Wayland_get_data_device(struct SDL_WaylandInput *input)
{
if (input == NULL) {
return NULL;
}
return input->data_device;
}
/* !!! FIXME: just merge these into display_handle_global(). */
void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
{
d->relative_pointer_manager =
wl_registry_bind(d->registry, id,
&zwp_relative_pointer_manager_v1_interface, 1);
}
void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d)
{
if (d->relative_pointer_manager)
zwp_relative_pointer_manager_v1_destroy(d->relative_pointer_manager);
}
void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id)
{
d->pointer_constraints =
wl_registry_bind(d->registry, id,
&zwp_pointer_constraints_v1_interface, 1);
}
void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d)
{
if (d->pointer_constraints)
zwp_pointer_constraints_v1_destroy(d->pointer_constraints);
}
static void
relative_pointer_handle_relative_motion(void *data,
struct zwp_relative_pointer_v1 *pointer,
uint32_t time_hi,
uint32_t time_lo,
wl_fixed_t dx_w,
wl_fixed_t dy_w,
wl_fixed_t dx_unaccel_w,
wl_fixed_t dy_unaccel_w)
{
struct SDL_WaylandInput *input = data;
SDL_VideoData *d = input->display;
SDL_WindowData *window = input->pointer_focus;
double dx_unaccel;
double dy_unaccel;
double dx;
double dy;
dx_unaccel = wl_fixed_to_double(dx_unaccel_w);
dy_unaccel = wl_fixed_to_double(dy_unaccel_w);
/* Add left over fraction from last event. */
dx_unaccel += input->dx_frac;
dy_unaccel += input->dy_frac;
input->dx_frac = modf(dx_unaccel, &dx);
input->dy_frac = modf(dy_unaccel, &dy);
if (input->pointer_focus && d->relative_mouse_mode) {
SDL_SendMouseMotion(window->sdlwindow, 0, 1, (int)dx, (int)dy);
}
}
static const struct zwp_relative_pointer_v1_listener relative_pointer_listener = {
relative_pointer_handle_relative_motion,
};
static void
locked_pointer_locked(void *data,
struct zwp_locked_pointer_v1 *locked_pointer)
{
}
static void
locked_pointer_unlocked(void *data,
struct zwp_locked_pointer_v1 *locked_pointer)
{
}
static const struct zwp_locked_pointer_v1_listener locked_pointer_listener = {
locked_pointer_locked,
locked_pointer_unlocked,
};
static void
lock_pointer_to_window(SDL_Window *window,
struct SDL_WaylandInput *input)
{
SDL_WindowData *w = window->driverdata;
SDL_VideoData *d = input->display;
struct zwp_locked_pointer_v1 *locked_pointer;
if (w->locked_pointer)
return;
locked_pointer =
zwp_pointer_constraints_v1_lock_pointer(d->pointer_constraints,
w->surface,
input->pointer,
NULL,
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
zwp_locked_pointer_v1_add_listener(locked_pointer,
&locked_pointer_listener,
window);
w->locked_pointer = locked_pointer;
}
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
{
SDL_VideoDevice *vd = SDL_GetVideoDevice();
SDL_VideoData *d = input->display;
SDL_Window *window;
struct zwp_relative_pointer_v1 *relative_pointer;
if (!d->relative_pointer_manager)
return -1;
if (!d->pointer_constraints)
return -1;
if (!input->relative_pointer) {
relative_pointer =
zwp_relative_pointer_manager_v1_get_relative_pointer(
d->relative_pointer_manager,
input->pointer);
zwp_relative_pointer_v1_add_listener(relative_pointer,
&relative_pointer_listener,
input);
input->relative_pointer = relative_pointer;
}
for (window = vd->windows; window; window = window->next)
lock_pointer_to_window(window, input);
d->relative_mouse_mode = 1;
return 0;
}
int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input)
{
SDL_VideoDevice *vd = SDL_GetVideoDevice();
SDL_VideoData *d = input->display;
SDL_Window *window;
SDL_WindowData *w;
for (window = vd->windows; window; window = window->next) {
w = window->driverdata;
if (w->locked_pointer)
zwp_locked_pointer_v1_destroy(w->locked_pointer);
w->locked_pointer = NULL;
}
zwp_relative_pointer_v1_destroy(input->relative_pointer);
input->relative_pointer = NULL;
d->relative_mouse_mode = 0;
return 0;
}
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
/* vi: set ts=4 sw=4 expandtab: */
wl_data_device_manager_create_data_source
static struct wl_data_source * wl_data_device_manager_create_data_source(struct wl_data_device_manager *wl_data_device_manager)
Definition: wayland-client-protocol.h:2680
SDL_Window::next
SDL_Window * next
Definition: SDL_sysvideo.h:114
Wayland_data_source_send
ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, const char *mime_type, int fd)
Wayland_input_unlock_pointer
int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input)
group
GLboolean GLuint group
Definition: SDL_opengl_glext.h:4996
WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT
Definition: wayland-client-protocol.h:2818
Wayland_display_destroy_pointer_constraints
void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d)
id
GLuint id
Definition: SDL_opengl_glext.h:528
zxdg_toplevel_v6_resize
static void zxdg_toplevel_v6_resize(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial, uint32_t edges)
Definition: xdg-shell-unstable-v6-client-protocol.h:1377
SDL_HITTEST_RESIZE_TOPRIGHT
Definition: SDL_video.h:999
SDL_VideoData::relative_pointer_manager
struct zwp_relative_pointer_manager_v1 * relative_pointer_manager
Definition: SDL_waylandvideo.h:51
SDL_zxdg_shell_surface::toplevel
struct zxdg_toplevel_v6 * toplevel
Definition: SDL_waylandwindow.h:37
zwp_locked_pointer_v1_listener
Definition: pointer-constraints-unstable-v1-client-protocol.h:389
button
SDL_Texture * button
Definition: testgamecontroller.c:67
SDL_TRUE
Definition: SDL_stdinc.h:142
Wayland_display_destroy_relative_pointer_manager
void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d)
SDL_IOReady
int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
Definition: SDL_poll.c:38
SDL_SetKeyboardFocus
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:630
time
EGLSurface EGLnsecsANDROID time
Definition: eglext.h:518
wl_seat_capability
wl_seat_capability
Definition: wayland-client-protocol.h:3751
SDL_HITTEST_RESIZE_LEFT
Definition: SDL_video.h:1004
Wayland_data_offer_has_mime
SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, const char *mime_type)
SDL_log.h
SDL_Window::w
int w
Definition: SDL_sysvideo.h:80
SDL_Window::hit_test_data
void * hit_test_data
Definition: SDL_sysvideo.h:107
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
int32_t
signed int int32_t
Definition: SDL_config_windows.h:62
SDL_HITTEST_RESIZE_BOTTOMRIGHT
Definition: SDL_video.h:1001
SDL_WindowData::wl
struct wl_shell_surface * wl
Definition: SDL_waylandwindow.h:49
wl_data_source_listener
Definition: wayland-client-protocol.h:2078
wl_pointer_destroy
static void wl_pointer_destroy(struct wl_pointer *wl_pointer)
Definition: wayland-client-protocol.h:4400
SDL_FingerID
Sint64 SDL_FingerID
Definition: SDL_touch.h:42
WL_KEYBOARD_KEY_STATE_PRESSED
Definition: wayland-client-protocol.h:4502
SDL_SendDropFile
int SDL_SendDropFile(SDL_Window *window, const char *file)
Definition: SDL_dropevents.c:80
SDL_VideoData::display
struct wl_display * display
Definition: SDL_waylandvideo.h:40
zwp_relative_pointer_manager_v1_interface
const struct wl_interface zwp_relative_pointer_manager_v1_interface
Definition: relative-pointer-unstable-v1-protocol.c:50
Wayland_display_add_pointer_constraints
void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id)
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_MOUSEWHEEL_NORMAL
Definition: SDL_mouse.h:68
SDL_BUTTON_RIGHT
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:284
state
struct xkb_state * state
Definition: SDL_waylandsym.h:113
surface
EGLSurface surface
Definition: eglext.h:248
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:48
SDL_waylandwindow.h
wl_registry_bind
static void * wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version)
Definition: wayland-client-protocol.h:1075
SDL_VideoDevice::driverdata
void * driverdata
Definition: SDL_sysvideo.h:377
SDL_HITTEST_RESIZE_TOP
Definition: SDL_video.h:998
SDL_HITTEST_RESIZE_BOTTOM
Definition: SDL_video.h:1002
SDL_SendTouch
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure)
Definition: SDL_touch.c:222
wl_data_device_manager_get_data_device
static struct wl_data_device * wl_data_device_manager_get_data_device(struct wl_data_device_manager *wl_data_device_manager, struct wl_seat *seat)
Definition: wayland-client-protocol.h:2696
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT
Definition: pointer-constraints-unstable-v1-client-protocol.h:247
wl_data_offer_set_user_data
static void wl_data_offer_set_user_data(struct wl_data_offer *wl_data_offer, void *user_data)
Definition: wayland-client-protocol.h:1913
wl_data_source_add_listener
static int wl_data_source_add_listener(struct wl_data_source *wl_data_source, const struct wl_data_source_listener *listener, void *data)
Definition: wayland-client-protocol.h:2202
f
GLfloat f
Definition: SDL_opengl_glext.h:1870
xfree86_scancode_table2
static const SDL_Scancode xfree86_scancode_table2[]
Definition: scancodes_xfree86.h:179
SDL_WaylandDataOffer::mimes
struct wl_list mimes
Definition: SDL_waylanddatamanager.h:47
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
Wayland_input_lock_pointer
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
axis
SDL_Texture * axis
Definition: testgamecontroller.c:67
SDL_BUTTON_X1
#define SDL_BUTTON_X1
Definition: SDL_mouse.h:285
SDL_SetMouseFocus
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:151
wl_keyboard_key_state
wl_keyboard_key_state
Definition: wayland-client-protocol.h:4494
SDL_WaylandDataSource::source
struct wl_data_source * source
Definition: SDL_waylanddatamanager.h:41
SDL_WaylandDataDevice
Definition: SDL_waylanddatamanager.h:51
SDL_HITTEST_RESIZE_RIGHT
Definition: SDL_video.h:1000
SDL_VideoData::input
struct SDL_WaylandInput * input
Definition: SDL_waylandvideo.h:60
wl_shell_surface_resize
wl_shell_surface_resize
Definition: wayland-client-protocol.h:2782
zwp_relative_pointer_v1_add_listener
static int zwp_relative_pointer_v1_add_listener(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1, const struct zwp_relative_pointer_v1_listener *listener, void *data)
Definition: relative-pointer-unstable-v1-client-protocol.h:240
wl_seat_destroy
static void wl_seat_destroy(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3883
wl_seat_get_touch
static struct wl_touch * wl_seat_get_touch(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3944
SDL_WindowData::surface
SDL_Surface * surface
Definition: SDL_emscriptenvideo.h:41
SDL_SendKeyboardKey
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
Definition: SDL_keyboard.c:679
wl_data_offer_listener
Definition: wayland-client-protocol.h:1788
SDL_SendTouchMotion
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
Definition: SDL_touch.c:284
SDL_WindowData
Definition: SDL_androidwindow.h:35
WL_SEAT_CAPABILITY_KEYBOARD
Definition: wayland-client-protocol.h:3759
Wayland_display_add_relative_pointer_manager
void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_HitTestResult
SDL_HitTestResult
Possible return values from the SDL_HitTest callback.
Definition: SDL_video.h:993
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
wl_data_offer_accept
static void wl_data_offer_accept(struct wl_data_offer *wl_data_offer, uint32_t serial, const char *mime_type)
Definition: wayland-client-protocol.h:1950
SDL_WindowData::keyboard_device
struct SDL_WaylandInput * keyboard_device
Definition: SDL_waylandwindow.h:52
wl_data_offer_listener::offer
void(* offer)(void *data, struct wl_data_offer *wl_data_offer, const char *mime_type)
Definition: wayland-client-protocol.h:1796
Wayland_data_offer_destroy
void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer)
zwp_pointer_constraints_v1_interface
const struct wl_interface zwp_pointer_constraints_v1_interface
Definition: pointer-constraints-unstable-v1-protocol.c:60
zwp_relative_pointer_v1_listener
Definition: relative-pointer-unstable-v1-client-protocol.h:182
wl_touch_listener
Definition: wayland-client-protocol.h:4700
SDL_VideoData::relative_mouse_mode
int relative_mouse_mode
Definition: SDL_waylandvideo.h:70
wl_pointer_listener
Definition: wayland-client-protocol.h:4072
key
GLuint64 key
Definition: gl2ext.h:2192
wl_data_device_listener
Definition: wayland-client-protocol.h:2337
SDL_VideoData::data_device_manager
struct wl_data_device_manager * data_device_manager
Definition: SDL_waylandvideo.h:53
input
GLenum GLenum GLenum input
Definition: SDL_opengl_glext.h:9374
wl_data_offer_get_user_data
static void * wl_data_offer_get_user_data(struct wl_data_offer *wl_data_offer)
Definition: wayland-client-protocol.h:1920
wl_seat_listener
Definition: wayland-client-protocol.h:3771
SDL_SendMouseMotion
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
Definition: SDL_mouse.c:237
SDL_BUTTON_LEFT
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:282
d
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
Definition: SDL_dynapi_procs.h:117
zwp_pointer_constraints_v1_destroy
static void zwp_pointer_constraints_v1_destroy(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1)
Definition: pointer-constraints-unstable-v1-client-protocol.h:296
Wayland_data_source_destroy
void Wayland_data_source_destroy(SDL_WaylandDataSource *source)
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
SDL_SendClipboardUpdate
int SDL_SendClipboardUpdate(void)
Definition: SDL_clipboardevents.c:31
SDL_SendKeyboardText
int SDL_SendKeyboardText(const char *text)
Definition: SDL_keyboard.c:789
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
FILE_MIME
#define FILE_MIME
Definition: SDL_waylanddatamanager.h:31
Wayland_data_device_set_serial
int Wayland_data_device_set_serial(SDL_WaylandDataDevice *device, uint32_t serial)
WL_SHELL_SURFACE_RESIZE_TOP_RIGHT
Definition: wayland-client-protocol.h:2814
zwp_pointer_constraints_v1_lock_pointer
static struct zwp_locked_pointer_v1 * zwp_pointer_constraints_v1_lock_pointer(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1, struct wl_surface *surface, struct wl_pointer *pointer, struct wl_region *region, uint32_t lifetime)
Definition: pointer-constraints-unstable-v1-client-protocol.h:343
SDL_WindowData::sdlwindow
SDL_Window * sdlwindow
Definition: SDL_waylandwindow.h:43
wl_pointer_axis
wl_pointer_axis
Definition: wayland-client-protocol.h:4008
WL_SHELL_SURFACE_RESIZE_LEFT
Definition: wayland-client-protocol.h:2798
SDL_WaylandDataOffer
Definition: SDL_waylanddatamanager.h:45
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_WaylandDataDevice::drag_serial
uint32_t drag_serial
Definition: SDL_waylanddatamanager.h:56
WL_SEAT_CAPABILITY_TOUCH
Definition: wayland-client-protocol.h:3763
SDL_DelTouch
void SDL_DelTouch(SDL_TouchID id)
Definition: SDL_touch.c:337
SDL_TouchID
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
WL_POINTER_AXIS_HORIZONTAL_SCROLL
Definition: wayland-client-protocol.h:4016
wl_pointer_button_state
wl_pointer_button_state
Definition: wayland-client-protocol.h:3988
relative-pointer-unstable-v1-client-protocol.h
Wayland_data_source_create
SDL_WaylandDataSource * Wayland_data_source_create(_THIS)
SDL_BUTTON_MIDDLE
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:283
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_HITTEST_DRAGGABLE
Definition: SDL_video.h:996
wl_seat_set_user_data
static void wl_seat_set_user_data(struct wl_seat *wl_seat, void *user_data)
Definition: wayland-client-protocol.h:3863
SDL_waylanddyn.h
zwp_relative_pointer_manager_v1_destroy
static void zwp_relative_pointer_manager_v1_destroy(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1)
Definition: relative-pointer-unstable-v1-client-protocol.h:153
SDL_VideoDevice::windows
SDL_Window * windows
Definition: SDL_sysvideo.h:313
wl_seat_get_pointer
static struct wl_pointer * wl_seat_get_pointer(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3900
wl_touch_add_listener
static int wl_touch_add_listener(struct wl_touch *wl_touch, const struct wl_touch_listener *listener, void *data)
Definition: wayland-client-protocol.h:4858
pointer
GLsizei const void * pointer
Definition: SDL_opengl_glext.h:378
wl_touch_set_user_data
static void wl_touch_set_user_data(struct wl_touch *wl_touch, void *user_data)
Definition: wayland-client-protocol.h:4903
wl_data_offer_set_actions
static void wl_data_offer_set_actions(struct wl_data_offer *wl_data_offer, uint32_t dnd_actions, uint32_t preferred_action)
Definition: wayland-client-protocol.h:2054
wl_pointer_add_listener
static int wl_pointer_add_listener(struct wl_pointer *wl_pointer, const struct wl_pointer_listener *listener, void *data)
Definition: wayland-client-protocol.h:4322
wl_data_offer_add_listener
static int wl_data_offer_add_listener(struct wl_data_offer *wl_data_offer, const struct wl_data_offer_listener *listener, void *data)
Definition: wayland-client-protocol.h:1864
SDL_AddTouch
int SDL_AddTouch(SDL_TouchID touchID, const char *name)
Definition: SDL_touch.c:136
SDL_WaylandDataSource::mimes
struct wl_list mimes
Definition: SDL_waylanddatamanager.h:42
Wayland_data_offer_add_mime
int Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, const char *mime_type)
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:537
wl_seat_add_listener
static int wl_seat_add_listener(struct wl_seat *wl_seat, const struct wl_seat_listener *listener, void *data)
Definition: wayland-client-protocol.h:3823
SDL_WaylandDataOffer::data_device
void * data_device
Definition: SDL_waylanddatamanager.h:48
SDL_WindowData::locked_pointer
struct zwp_locked_pointer_v1 * locked_pointer
Definition: SDL_waylandwindow.h:54
Wayland_display_add_input
void Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
wl_surface_get_user_data
static void * wl_surface_get_user_data(struct wl_surface *wl_surface)
Definition: wayland-client-protocol.h:3375
SDL_Window::h
int h
Definition: SDL_sysvideo.h:80
SDL_WindowData::shell_surface
union SDL_WindowData::@38 shell_surface
Wayland_get_data_device
SDL_WaylandDataDevice * Wayland_get_data_device(struct SDL_WaylandInput *input)
SDL_WaylandDataDevice::video_data
SDL_VideoData * video_data
Definition: SDL_waylanddatamanager.h:53
wl_data_device_release
static void wl_data_device_release(struct wl_data_device *wl_data_device)
Definition: wayland-client-protocol.h:2576
zwp_relative_pointer_v1_destroy
static void zwp_relative_pointer_v1_destroy(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1)
Definition: relative-pointer-unstable-v1-client-protocol.h:283
SDL_waylandvideo.h
wl_keyboard_listener
Definition: wayland-client-protocol.h:4510
NULL
#define NULL
Definition: begin_code.h:164
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
buffer
GLuint buffer
Definition: SDL_opengl_glext.h:533
tail
SDL_EventEntry * tail
Definition: SDL_events.c:83
zwp_locked_pointer_v1_add_listener
static int zwp_locked_pointer_v1_add_listener(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1, const struct zwp_locked_pointer_v1_listener *listener, void *data)
Definition: pointer-constraints-unstable-v1-client-protocol.h:416
SDL_HITTEST_RESIZE_BOTTOMLEFT
Definition: SDL_video.h:1003
SDL_SendMouseWheel
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction)
Definition: SDL_mouse.c:512
SDL_Window::hit_test
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:106
WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE
Definition: wayland-client-protocol.h:2618
uint32_t
unsigned int uint32_t
Definition: SDL_config_windows.h:63
wl_data_device_set_user_data
static void wl_data_device_set_user_data(struct wl_data_device *wl_data_device, void *user_data)
Definition: wayland-client-protocol.h:2492
WL_POINTER_AXIS_VERTICAL_SCROLL
Definition: wayland-client-protocol.h:4012
SDL_WaylandDataDevice::data_device
struct wl_data_device * data_device
Definition: SDL_waylanddatamanager.h:52
SDL_SCANCODE_UNKNOWN
Definition: SDL_scancode.h:45
wl_keyboard_add_listener
static int wl_keyboard_add_listener(struct wl_keyboard *wl_keyboard, const struct wl_keyboard_listener *listener, void *data)
Definition: wayland-client-protocol.h:4618
WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT
Definition: wayland-client-protocol.h:2806
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
zwp_locked_pointer_v1_destroy
static void zwp_locked_pointer_v1_destroy(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1)
Definition: pointer-constraints-unstable-v1-client-protocol.h:476
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
WL_SHELL_SURFACE_RESIZE_TOP
Definition: wayland-client-protocol.h:2790
SDL_WaylandDataDevice::selection_offer
SDL_WaylandDataOffer * selection_offer
Definition: SDL_waylanddatamanager.h:58
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
wl_data_device_add_listener
static int wl_data_device_add_listener(struct wl_data_device *wl_data_device, const struct wl_data_device_listener *listener, void *data)
Definition: wayland-client-protocol.h:2441
zxdg_toplevel_v6_move
static void zxdg_toplevel_v6_move(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial)
Definition: xdg-shell-unstable-v6-client-protocol.h:1336
SDL_WindowData::zxdg
SDL_zxdg_shell_surface zxdg
Definition: SDL_waylandwindow.h:48
Wayland_display_destroy_input
void Wayland_display_destroy_input(SDL_VideoData *d)
Wayland_PumpEvents
void Wayland_PumpEvents(_THIS)
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_stdinc.h
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1
Definition: wayland-client-protocol.h:4482
xdg-shell-unstable-v6-client-protocol.h
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:73
wl_keyboard_destroy
static void wl_keyboard_destroy(struct wl_keyboard *wl_keyboard)
Definition: wayland-client-protocol.h:4679
WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY
Definition: wayland-client-protocol.h:2622
SDL_zxdg_shell_surface::roleobj
union SDL_zxdg_shell_surface::@37 roleobj
SDL_VideoData::registry
struct wl_registry * registry
Definition: SDL_waylandvideo.h:41
SDL_WaylandDataOffer::offer
struct wl_data_offer * offer
Definition: SDL_waylanddatamanager.h:46
WL_SHELL_SURFACE_RESIZE_RIGHT
Definition: wayland-client-protocol.h:2810
SDL_VideoDevice
Definition: SDL_sysvideo.h:147
wl_data_source_destroy
static void wl_data_source_destroy(struct wl_data_source *wl_data_source)
Definition: wayland-client-protocol.h:2291
SDL_VideoData
Definition: SDL_androidvideo.h:35
SDL_waylandevents_c.h
SDL_GetVideoDevice
SDL_VideoDevice * SDL_GetVideoDevice(void)
Definition: SDL_video.c:586
wl_seat_interface
const struct wl_interface wl_seat_interface
Definition: wayland-protocol.c:385
zwp_relative_pointer_manager_v1_get_relative_pointer
static struct zwp_relative_pointer_v1 * zwp_relative_pointer_manager_v1_get_relative_pointer(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1, struct wl_pointer *pointer)
Definition: relative-pointer-unstable-v1-client-protocol.h:168
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93
Wayland_data_device_clear_selection
int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *device)
wl_data_source_set_user_data
static void wl_data_source_set_user_data(struct wl_data_source *wl_data_source, void *user_data)
Definition: wayland-client-protocol.h:2253
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111
wl_pointer_set_user_data
static void wl_pointer_set_user_data(struct wl_pointer *wl_pointer, void *user_data)
Definition: wayland-client-protocol.h:4380
SDL_PRESSED
#define SDL_PRESSED
Definition: SDL_events.h:50
wl_keyboard_set_user_data
static void wl_keyboard_set_user_data(struct wl_keyboard *wl_keyboard, void *user_data)
Definition: wayland-client-protocol.h:4659
head
SDL_EventEntry * head
Definition: SDL_events.c:82
length
GLuint GLsizei GLsizei * length
Definition: SDL_opengl_glext.h:669
SDL_BUTTON_X2
#define SDL_BUTTON_X2
Definition: SDL_mouse.h:286
SDL_VideoData::pointer_constraints
struct zwp_pointer_constraints_v1 * pointer_constraints
Definition: SDL_waylandvideo.h:52
SDL_HITTEST_RESIZE_TOPLEFT
Definition: SDL_video.h:997
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
SDL_RELEASED
#define SDL_RELEASED
Definition: SDL_events.h:49
Wayland_data_offer_receive
void * Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, size_t *length, const char *mime_type, SDL_bool null_terminate)
wl_shell_surface_move
static void wl_shell_surface_move(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial)
Definition: wayland-client-protocol.h:3050
SDL_SendMouseButton
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
Definition: SDL_mouse.c:506
WL_SHELL_SURFACE_RESIZE_TOP_LEFT
Definition: wayland-client-protocol.h:2802
WL_SEAT_CAPABILITY_POINTER
Definition: wayland-client-protocol.h:3755
SDL_WaylandDataDevice::drag_offer
SDL_WaylandDataOffer * drag_offer
Definition: SDL_waylanddatamanager.h:57
fd
GLuint64 GLenum GLint fd
Definition: gl2ext.h:1508
SDL_WaylandDataSource
Definition: SDL_waylanddatamanager.h:40
WL_SHELL_SURFACE_RESIZE_BOTTOM
Definition: wayland-client-protocol.h:2794
wl_seat_get_keyboard
static struct wl_keyboard * wl_seat_get_keyboard(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3922
SDL_assert.h
pointer-constraints-unstable-v1-client-protocol.h
wl_touch_destroy
static void wl_touch_destroy(struct wl_touch *wl_touch)
Definition: wayland-client-protocol.h:4923