|
|
|
@ -9,7 +9,6 @@
|
|
|
|
|
#include <wlr/types/wlr_primary_selection.h>
|
|
|
|
|
#include <wlr/types/wlr_seat.h>
|
|
|
|
|
#include <wlr/util/log.h>
|
|
|
|
|
#include "util/defs.h"
|
|
|
|
|
#include "util/signal.h"
|
|
|
|
|
|
|
|
|
|
static void resource_destroy(struct wl_client *client,
|
|
|
|
@ -357,7 +356,6 @@ static const struct wlr_touch_grab_interface default_touch_grab_impl = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_destroy(struct wlr_seat *seat) {
|
|
|
|
|
if (!seat) {
|
|
|
|
|
return;
|
|
|
|
@ -398,7 +396,6 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
|
wlr_seat_destroy(seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
|
|
|
|
|
struct wlr_seat *wlr_seat = calloc(1, sizeof(struct wlr_seat));
|
|
|
|
|
if (!wlr_seat) {
|
|
|
|
@ -492,7 +489,6 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
|
|
|
|
|
return wlr_seat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
struct wlr_seat_client *wlr_seat_client_for_wl_client(struct wlr_seat *wlr_seat,
|
|
|
|
|
struct wl_client *wl_client) {
|
|
|
|
|
assert(wlr_seat);
|
|
|
|
@ -505,7 +501,6 @@ struct wlr_seat_client *wlr_seat_client_for_wl_client(struct wlr_seat *wlr_seat,
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_set_capabilities(struct wlr_seat *wlr_seat,
|
|
|
|
|
uint32_t capabilities) {
|
|
|
|
|
wlr_seat->capabilities = capabilities;
|
|
|
|
@ -515,7 +510,6 @@ void wlr_seat_set_capabilities(struct wlr_seat *wlr_seat,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_set_name(struct wlr_seat *wlr_seat, const char *name) {
|
|
|
|
|
free(wlr_seat->name);
|
|
|
|
|
wlr_seat->name = strdup(name);
|
|
|
|
@ -525,7 +519,6 @@ void wlr_seat_set_name(struct wlr_seat *wlr_seat, const char *name) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat,
|
|
|
|
|
struct wlr_surface *surface) {
|
|
|
|
|
return surface == wlr_seat->pointer_state.focused_surface;
|
|
|
|
@ -549,7 +542,6 @@ static void pointer_resource_destroy_notify(struct wl_listener *listener,
|
|
|
|
|
wlr_seat_pointer_clear_focus(state->seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
|
|
|
|
|
struct wlr_surface *surface, double sx, double sy) {
|
|
|
|
|
assert(wlr_seat);
|
|
|
|
@ -613,12 +605,10 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
|
|
|
|
|
// TODO: send focus change event
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat) {
|
|
|
|
|
wlr_seat_pointer_enter(wlr_seat, NULL, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
double sx, double sy) {
|
|
|
|
|
struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
|
|
|
|
@ -634,7 +624,6 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
uint32_t button, uint32_t state) {
|
|
|
|
|
struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
|
|
|
|
@ -651,7 +640,6 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
return serial;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
enum wlr_axis_orientation orientation, double value) {
|
|
|
|
|
struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
|
|
|
|
@ -672,7 +660,6 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat,
|
|
|
|
|
struct wlr_seat_pointer_grab *grab) {
|
|
|
|
|
assert(wlr_seat);
|
|
|
|
@ -683,7 +670,6 @@ void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat,
|
|
|
|
|
wlr_signal_emit_safe(&wlr_seat->events.pointer_grab_begin, grab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat) {
|
|
|
|
|
struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;
|
|
|
|
|
if (grab != wlr_seat->pointer_state.default_grab) {
|
|
|
|
@ -695,14 +681,12 @@ void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
|
|
|
|
|
struct wlr_surface *surface, double sx, double sy) {
|
|
|
|
|
struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;
|
|
|
|
|
grab->interface->enter(grab, surface, sx, sy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
double sx, double sy) {
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
|
|
|
@ -710,7 +694,6 @@ void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
grab->interface->motion(grab, time, sx, sy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
|
|
|
|
|
uint32_t time, uint32_t button, uint32_t state) {
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
|
|
|
@ -734,7 +717,6 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
|
|
|
|
|
return serial;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
enum wlr_axis_orientation orientation, double value) {
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
|
|
|
@ -742,12 +724,10 @@ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
grab->interface->axis(grab, time, orientation, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
bool wlr_seat_pointer_has_grab(struct wlr_seat *seat) {
|
|
|
|
|
return seat->pointer_state.grab->interface != &default_pointer_grab_impl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
uint32_t key, uint32_t state) {
|
|
|
|
|
struct wlr_seat_client *client = wlr_seat->keyboard_state.focused_client;
|
|
|
|
@ -790,7 +770,6 @@ static void handle_keyboard_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
|
state->keyboard = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_set_keyboard(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_input_device *device) {
|
|
|
|
|
// TODO call this on device key event before the event reaches the
|
|
|
|
@ -835,12 +814,10 @@ void wlr_seat_set_keyboard(struct wlr_seat *seat,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
struct wlr_keyboard *wlr_seat_get_keyboard(struct wlr_seat *seat) {
|
|
|
|
|
return seat->keyboard_state.keyboard;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_start_grab(struct wlr_seat *wlr_seat,
|
|
|
|
|
struct wlr_seat_keyboard_grab *grab) {
|
|
|
|
|
grab->seat = wlr_seat;
|
|
|
|
@ -849,7 +826,6 @@ void wlr_seat_keyboard_start_grab(struct wlr_seat *wlr_seat,
|
|
|
|
|
wlr_signal_emit_safe(&wlr_seat->events.keyboard_grab_begin, grab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_end_grab(struct wlr_seat *wlr_seat) {
|
|
|
|
|
struct wlr_seat_keyboard_grab *grab = wlr_seat->keyboard_state.grab;
|
|
|
|
|
|
|
|
|
@ -880,7 +856,6 @@ static void keyboard_resource_destroy_notify(struct wl_listener *listener,
|
|
|
|
|
wlr_seat_keyboard_clear_focus(state->seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_keyboard_modifiers *modifiers) {
|
|
|
|
|
struct wlr_seat_client *client = seat->keyboard_state.focused_client;
|
|
|
|
@ -901,7 +876,6 @@ void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
|
|
|
|
struct wlr_keyboard_modifiers *modifiers) {
|
|
|
|
@ -981,7 +955,6 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
|
|
|
|
struct wlr_keyboard_modifiers *modifiers) {
|
|
|
|
@ -989,18 +962,15 @@ void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
|
|
|
|
|
grab->interface->enter(grab, surface, keycodes, num_keycodes, modifiers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_clear_focus(struct wlr_seat *seat) {
|
|
|
|
|
// TODO respect grabs here?
|
|
|
|
|
wlr_seat_keyboard_enter(seat, NULL, NULL, 0, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
bool wlr_seat_keyboard_has_grab(struct wlr_seat *seat) {
|
|
|
|
|
return seat->keyboard_state.grab->interface != &default_keyboard_grab_impl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_keyboard_modifiers *modifiers) {
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
|
|
|
@ -1008,7 +978,6 @@ void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat,
|
|
|
|
|
grab->interface->modifiers(grab, modifiers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
|
|
|
|
|
uint32_t key, uint32_t state) {
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
|
|
|
@ -1016,7 +985,6 @@ void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
|
|
|
|
|
grab->interface->key(grab, time, key, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_start_grab(struct wlr_seat *wlr_seat,
|
|
|
|
|
struct wlr_seat_touch_grab *grab) {
|
|
|
|
|
grab->seat = wlr_seat;
|
|
|
|
@ -1025,7 +993,6 @@ void wlr_seat_touch_start_grab(struct wlr_seat *wlr_seat,
|
|
|
|
|
wlr_signal_emit_safe(&wlr_seat->events.touch_grab_begin, grab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_end_grab(struct wlr_seat *wlr_seat) {
|
|
|
|
|
struct wlr_seat_touch_grab *grab = wlr_seat->touch_state.grab;
|
|
|
|
|
|
|
|
|
@ -1105,7 +1072,6 @@ static struct wlr_touch_point *touch_point_create(
|
|
|
|
|
return point;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
struct wlr_touch_point *wlr_seat_touch_get_point(
|
|
|
|
|
struct wlr_seat *seat, int32_t touch_id) {
|
|
|
|
|
struct wlr_touch_point *point = NULL;
|
|
|
|
@ -1118,7 +1084,6 @@ struct wlr_touch_point *wlr_seat_touch_get_point(
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx,
|
|
|
|
|
double sy) {
|
|
|
|
@ -1141,7 +1106,6 @@ uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat,
|
|
|
|
|
return serial;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time,
|
|
|
|
|
int32_t touch_id) {
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
|
|
|
@ -1157,7 +1121,6 @@ void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time,
|
|
|
|
|
touch_point_destroy(point);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time,
|
|
|
|
|
int32_t touch_id, double sx, double sy) {
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
|
|
|
@ -1205,7 +1168,6 @@ static void touch_point_set_focus(struct wlr_touch_point *point,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_point_focus(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx,
|
|
|
|
|
double sy) {
|
|
|
|
@ -1224,7 +1186,6 @@ void wlr_seat_touch_point_focus(struct wlr_seat *seat,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_point_clear_focus(struct wlr_seat *seat, uint32_t time,
|
|
|
|
|
int32_t touch_id) {
|
|
|
|
|
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
|
|
|
|
@ -1236,7 +1197,6 @@ void wlr_seat_touch_point_clear_focus(struct wlr_seat *seat, uint32_t time,
|
|
|
|
|
touch_point_clear_focus(point);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat,
|
|
|
|
|
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx,
|
|
|
|
|
double sy) {
|
|
|
|
@ -1257,7 +1217,6 @@ uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat,
|
|
|
|
|
return serial;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, int32_t touch_id) {
|
|
|
|
|
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
|
|
|
|
|
if (!point) {
|
|
|
|
@ -1273,7 +1232,6 @@ void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, int32_t touch_
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, int32_t touch_id,
|
|
|
|
|
double sx, double sy) {
|
|
|
|
|
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
|
|
|
|
@ -1290,23 +1248,19 @@ void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, int32_t to
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
int wlr_seat_touch_num_points(struct wlr_seat *seat) {
|
|
|
|
|
return wl_list_length(&seat->touch_state.touch_points);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
bool wlr_seat_touch_has_grab(struct wlr_seat *seat) {
|
|
|
|
|
return seat->touch_state.grab->interface != &default_touch_grab_impl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
bool wlr_seat_validate_grab_serial(struct wlr_seat *seat, uint32_t serial) {
|
|
|
|
|
return serial == seat->pointer_state.grab_serial ||
|
|
|
|
|
serial == seat->touch_state.grab_serial;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLR_API
|
|
|
|
|
struct wlr_seat_client *wlr_seat_client_from_resource(
|
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
|
assert(wl_resource_instance_of(resource, &wl_seat_interface,
|
|
|
|
|