|
|
@ -21,15 +21,16 @@ static void pointer_send_frame(struct wl_resource *resource) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_pointer_set_cursor(struct wl_client *client,
|
|
|
|
static void wl_pointer_set_cursor(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t serial,
|
|
|
|
struct wl_resource *pointer_resource, uint32_t serial,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
int32_t hotspot_x, int32_t hotspot_y) {
|
|
|
|
int32_t hotspot_x, int32_t hotspot_y) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_seat_client *seat_client =
|
|
|
|
|
|
|
|
wl_resource_get_user_data(pointer_resource);
|
|
|
|
struct wlr_surface *surface = NULL;
|
|
|
|
struct wlr_surface *surface = NULL;
|
|
|
|
if (surface_resource != NULL) {
|
|
|
|
if (surface_resource != NULL) {
|
|
|
|
surface = wl_resource_get_user_data(surface_resource);
|
|
|
|
surface = wl_resource_get_user_data(surface_resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (wlr_surface_set_role(surface, "wl_pointer-cursor", resource,
|
|
|
|
if (wlr_surface_set_role(surface, "wl_pointer-cursor", surface_resource,
|
|
|
|
WL_POINTER_ERROR_ROLE) < 0) {
|
|
|
|
WL_POINTER_ERROR_ROLE) < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,13 +41,12 @@ static void wl_pointer_set_cursor(struct wl_client *client,
|
|
|
|
if (event == NULL) {
|
|
|
|
if (event == NULL) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event->client = client;
|
|
|
|
event->seat_client = seat_client;
|
|
|
|
event->seat_handle = handle;
|
|
|
|
|
|
|
|
event->surface = surface;
|
|
|
|
event->surface = surface;
|
|
|
|
event->hotspot_x = hotspot_x;
|
|
|
|
event->hotspot_x = hotspot_x;
|
|
|
|
event->hotspot_y = hotspot_y;
|
|
|
|
event->hotspot_y = hotspot_y;
|
|
|
|
|
|
|
|
|
|
|
|
wl_signal_emit(&handle->wlr_seat->events.request_set_cursor, event);
|
|
|
|
wl_signal_emit(&seat_client->seat->events.request_set_cursor, event);
|
|
|
|
|
|
|
|
|
|
|
|
free(event);
|
|
|
|
free(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -57,28 +57,29 @@ static const struct wl_pointer_interface wl_pointer_impl = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_pointer_destroy(struct wl_resource *resource) {
|
|
|
|
static void wl_pointer_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_seat_client *client = wl_resource_get_user_data(resource);
|
|
|
|
if (handle->pointer) {
|
|
|
|
if (client->pointer) {
|
|
|
|
handle->pointer = NULL;
|
|
|
|
client->pointer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_seat_get_pointer(struct wl_client *client,
|
|
|
|
static void wl_seat_get_pointer(struct wl_client *client,
|
|
|
|
struct wl_resource *_handle, uint32_t id) {
|
|
|
|
struct wl_resource *pointer_resource, uint32_t id) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(_handle);
|
|
|
|
struct wlr_seat_client *seat_client =
|
|
|
|
if (!(handle->wlr_seat->capabilities & WL_SEAT_CAPABILITY_POINTER)) {
|
|
|
|
wl_resource_get_user_data(pointer_resource);
|
|
|
|
|
|
|
|
if (!(seat_client->seat->capabilities & WL_SEAT_CAPABILITY_POINTER)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handle->pointer) {
|
|
|
|
if (seat_client->pointer) {
|
|
|
|
// TODO: this is probably a protocol violation but it simplifies our
|
|
|
|
// TODO: this is probably a protocol violation but it simplifies our
|
|
|
|
// code and it'd be stupid for clients to create several pointers for
|
|
|
|
// code and it'd be stupid for clients to create several pointers for
|
|
|
|
// the same seat
|
|
|
|
// the same seat
|
|
|
|
wl_resource_destroy(handle->pointer);
|
|
|
|
wl_resource_destroy(seat_client->pointer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handle->pointer = wl_resource_create(client, &wl_pointer_interface,
|
|
|
|
seat_client->pointer = wl_resource_create(client, &wl_pointer_interface,
|
|
|
|
wl_resource_get_version(_handle), id);
|
|
|
|
wl_resource_get_version(pointer_resource), id);
|
|
|
|
wl_resource_set_implementation(handle->pointer, &wl_pointer_impl,
|
|
|
|
wl_resource_set_implementation(seat_client->pointer, &wl_pointer_impl,
|
|
|
|
handle, &wl_pointer_destroy);
|
|
|
|
seat_client, &wl_pointer_destroy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_keyboard_interface wl_keyboard_impl = {
|
|
|
|
static const struct wl_keyboard_interface wl_keyboard_impl = {
|
|
|
@ -86,47 +87,49 @@ static const struct wl_keyboard_interface wl_keyboard_impl = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_keyboard_destroy(struct wl_resource *resource) {
|
|
|
|
static void wl_keyboard_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_seat_client *client = wl_resource_get_user_data(resource);
|
|
|
|
if (handle->keyboard) {
|
|
|
|
if (client->keyboard) {
|
|
|
|
handle->keyboard = NULL;
|
|
|
|
client->keyboard = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void seat_handle_send_keymap(struct wlr_seat_handle *handle,
|
|
|
|
static void seat_client_send_keymap(struct wlr_seat_client *client,
|
|
|
|
struct wlr_keyboard *keyboard) {
|
|
|
|
struct wlr_keyboard *keyboard) {
|
|
|
|
if (!keyboard || !handle->keyboard) {
|
|
|
|
if (!keyboard || !client->keyboard) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: We should probably lift all of the keys set by the other
|
|
|
|
// TODO: We should probably lift all of the keys set by the other
|
|
|
|
// keyboard
|
|
|
|
// keyboard
|
|
|
|
wl_keyboard_send_keymap(handle->keyboard,
|
|
|
|
wl_keyboard_send_keymap(client->keyboard,
|
|
|
|
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keyboard->keymap_fd,
|
|
|
|
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keyboard->keymap_fd,
|
|
|
|
keyboard->keymap_size);
|
|
|
|
keyboard->keymap_size);
|
|
|
|
|
|
|
|
|
|
|
|
if (wl_resource_get_version(handle->keyboard) >=
|
|
|
|
if (wl_resource_get_version(client->keyboard) >=
|
|
|
|
WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) {
|
|
|
|
WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) {
|
|
|
|
wl_keyboard_send_repeat_info(handle->keyboard, 25, 600);
|
|
|
|
wl_keyboard_send_repeat_info(client->keyboard, 25, 600);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_seat_get_keyboard(struct wl_client *client,
|
|
|
|
static void wl_seat_get_keyboard(struct wl_client *client,
|
|
|
|
struct wl_resource *_handle, uint32_t id) {
|
|
|
|
struct wl_resource *seat_resource, uint32_t id) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(_handle);
|
|
|
|
struct wlr_seat_client *seat_client =
|
|
|
|
if (!(handle->wlr_seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD)) {
|
|
|
|
wl_resource_get_user_data(seat_resource);
|
|
|
|
|
|
|
|
if (!(seat_client->seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handle->keyboard) {
|
|
|
|
if (seat_client->keyboard) {
|
|
|
|
// TODO: this is probably a protocol violation but it simplifies our
|
|
|
|
// TODO: this is probably a protocol violation but it simplifies our
|
|
|
|
// code and it'd be stupid for clients to create several keyboards for
|
|
|
|
// code and it'd be stupid for clients to create several keyboards for
|
|
|
|
// the same seat
|
|
|
|
// the same seat
|
|
|
|
wl_resource_destroy(handle->keyboard);
|
|
|
|
wl_resource_destroy(seat_client->keyboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handle->keyboard = wl_resource_create(client, &wl_keyboard_interface,
|
|
|
|
seat_client->keyboard = wl_resource_create(client, &wl_keyboard_interface,
|
|
|
|
wl_resource_get_version(_handle), id);
|
|
|
|
wl_resource_get_version(seat_resource), id);
|
|
|
|
wl_resource_set_implementation(handle->keyboard, &wl_keyboard_impl,
|
|
|
|
wl_resource_set_implementation(seat_client->keyboard, &wl_keyboard_impl,
|
|
|
|
handle, &wl_keyboard_destroy);
|
|
|
|
seat_client, &wl_keyboard_destroy);
|
|
|
|
|
|
|
|
|
|
|
|
seat_handle_send_keymap(handle, handle->wlr_seat->keyboard_state.keyboard);
|
|
|
|
seat_client_send_keymap(seat_client,
|
|
|
|
|
|
|
|
seat_client->seat->keyboard_state.keyboard);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO possibly handle the case where this keyboard needs an enter
|
|
|
|
// TODO possibly handle the case where this keyboard needs an enter
|
|
|
|
// right away
|
|
|
|
// right away
|
|
|
@ -137,55 +140,56 @@ static const struct wl_touch_interface wl_touch_impl = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_touch_destroy(struct wl_resource *resource) {
|
|
|
|
static void wl_touch_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_seat_client *client = wl_resource_get_user_data(resource);
|
|
|
|
if (handle->touch) {
|
|
|
|
if (client->touch) {
|
|
|
|
handle->touch = NULL;
|
|
|
|
client->touch = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_seat_get_touch(struct wl_client *client,
|
|
|
|
static void wl_seat_get_touch(struct wl_client *client,
|
|
|
|
struct wl_resource *_handle, uint32_t id) {
|
|
|
|
struct wl_resource *seat_resource, uint32_t id) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(_handle);
|
|
|
|
struct wlr_seat_client *seat_client =
|
|
|
|
if (!(handle->wlr_seat->capabilities & WL_SEAT_CAPABILITY_TOUCH)) {
|
|
|
|
wl_resource_get_user_data(seat_resource);
|
|
|
|
|
|
|
|
if (!(seat_client->seat->capabilities & WL_SEAT_CAPABILITY_TOUCH)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handle->touch) {
|
|
|
|
if (seat_client->touch) {
|
|
|
|
// TODO: this is probably a protocol violation but it simplifies our
|
|
|
|
// TODO: this is probably a protocol violation but it simplifies our
|
|
|
|
// code and it'd be stupid for clients to create several pointers for
|
|
|
|
// code and it'd be stupid for clients to create several pointers for
|
|
|
|
// the same seat
|
|
|
|
// the same seat
|
|
|
|
wl_resource_destroy(handle->touch);
|
|
|
|
wl_resource_destroy(seat_client->touch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handle->touch = wl_resource_create(client, &wl_touch_interface,
|
|
|
|
seat_client->touch = wl_resource_create(client, &wl_touch_interface,
|
|
|
|
wl_resource_get_version(_handle), id);
|
|
|
|
wl_resource_get_version(seat_resource), id);
|
|
|
|
wl_resource_set_implementation(handle->touch, &wl_touch_impl,
|
|
|
|
wl_resource_set_implementation(seat_client->touch, &wl_touch_impl,
|
|
|
|
handle, &wl_touch_destroy);
|
|
|
|
seat_client, &wl_touch_destroy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wlr_seat_handle_resource_destroy(struct wl_resource *resource) {
|
|
|
|
static void wlr_seat_client_resource_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_seat_client *client = wl_resource_get_user_data(resource);
|
|
|
|
wl_signal_emit(&handle->wlr_seat->events.client_unbound, handle);
|
|
|
|
wl_signal_emit(&client->seat->events.client_unbound, client);
|
|
|
|
|
|
|
|
|
|
|
|
if (handle == handle->wlr_seat->pointer_state.focused_handle) {
|
|
|
|
if (client == client->seat->pointer_state.focused_client) {
|
|
|
|
handle->wlr_seat->pointer_state.focused_handle = NULL;
|
|
|
|
client->seat->pointer_state.focused_client = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handle == handle->wlr_seat->keyboard_state.focused_handle) {
|
|
|
|
if (client == client->seat->keyboard_state.focused_client) {
|
|
|
|
handle->wlr_seat->keyboard_state.focused_handle = NULL;
|
|
|
|
client->seat->keyboard_state.focused_client = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (handle->pointer) {
|
|
|
|
if (client->pointer) {
|
|
|
|
wl_resource_destroy(handle->pointer);
|
|
|
|
wl_resource_destroy(client->pointer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handle->keyboard) {
|
|
|
|
if (client->keyboard) {
|
|
|
|
wl_resource_destroy(handle->keyboard);
|
|
|
|
wl_resource_destroy(client->keyboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handle->touch) {
|
|
|
|
if (client->touch) {
|
|
|
|
wl_resource_destroy(handle->touch);
|
|
|
|
wl_resource_destroy(client->touch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handle->data_device) {
|
|
|
|
if (client->data_device) {
|
|
|
|
wl_resource_destroy(handle->data_device);
|
|
|
|
wl_resource_destroy(client->data_device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wl_list_remove(&handle->link);
|
|
|
|
wl_list_remove(&client->link);
|
|
|
|
free(handle);
|
|
|
|
free(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_seat_interface wl_seat_impl = {
|
|
|
|
struct wl_seat_interface wl_seat_impl = {
|
|
|
@ -195,23 +199,25 @@ struct wl_seat_interface wl_seat_impl = {
|
|
|
|
.release = resource_destroy
|
|
|
|
.release = resource_destroy
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void wl_seat_bind(struct wl_client *wl_client, void *_wlr_seat,
|
|
|
|
static void wl_seat_bind(struct wl_client *client, void *_wlr_seat,
|
|
|
|
uint32_t version, uint32_t id) {
|
|
|
|
uint32_t version, uint32_t id) {
|
|
|
|
struct wlr_seat *wlr_seat = _wlr_seat;
|
|
|
|
struct wlr_seat *wlr_seat = _wlr_seat;
|
|
|
|
assert(wl_client && wlr_seat);
|
|
|
|
assert(client && wlr_seat);
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *handle = calloc(1, sizeof(struct wlr_seat_handle));
|
|
|
|
struct wlr_seat_client *seat_client =
|
|
|
|
handle->wl_resource = wl_resource_create(
|
|
|
|
calloc(1, sizeof(struct wlr_seat_client));
|
|
|
|
wl_client, &wl_seat_interface, version, id);
|
|
|
|
seat_client->wl_resource =
|
|
|
|
handle->wlr_seat = wlr_seat;
|
|
|
|
wl_resource_create(client, &wl_seat_interface, version, id);
|
|
|
|
wl_resource_set_implementation(handle->wl_resource, &wl_seat_impl,
|
|
|
|
seat_client->client = client;
|
|
|
|
handle, wlr_seat_handle_resource_destroy);
|
|
|
|
seat_client->seat = wlr_seat;
|
|
|
|
wl_list_insert(&wlr_seat->handles, &handle->link);
|
|
|
|
wl_resource_set_implementation(seat_client->wl_resource, &wl_seat_impl,
|
|
|
|
|
|
|
|
seat_client, wlr_seat_client_resource_destroy);
|
|
|
|
|
|
|
|
wl_list_insert(&wlr_seat->clients, &seat_client->link);
|
|
|
|
if (version >= WL_SEAT_NAME_SINCE_VERSION) {
|
|
|
|
if (version >= WL_SEAT_NAME_SINCE_VERSION) {
|
|
|
|
wl_seat_send_name(handle->wl_resource, wlr_seat->name);
|
|
|
|
wl_seat_send_name(seat_client->wl_resource, wlr_seat->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wl_seat_send_capabilities(handle->wl_resource, wlr_seat->capabilities);
|
|
|
|
wl_seat_send_capabilities(seat_client->wl_resource, wlr_seat->capabilities);
|
|
|
|
wl_signal_emit(&wlr_seat->events.client_bound, handle);
|
|
|
|
wl_signal_emit(&wlr_seat->events.client_bound, seat_client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
|
|
|
|
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
|
|
|
@ -280,7 +286,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_seat->pointer_state.wlr_seat = wlr_seat;
|
|
|
|
wlr_seat->pointer_state.seat = wlr_seat;
|
|
|
|
wl_list_init(&wlr_seat->pointer_state.surface_destroy.link);
|
|
|
|
wl_list_init(&wlr_seat->pointer_state.surface_destroy.link);
|
|
|
|
wl_list_init(&wlr_seat->pointer_state.resource_destroy.link);
|
|
|
|
wl_list_init(&wlr_seat->pointer_state.resource_destroy.link);
|
|
|
|
|
|
|
|
|
|
|
@ -307,7 +313,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
|
|
|
|
wlr_seat->keyboard_state.default_grab = keyboard_grab;
|
|
|
|
wlr_seat->keyboard_state.default_grab = keyboard_grab;
|
|
|
|
wlr_seat->keyboard_state.grab = keyboard_grab;
|
|
|
|
wlr_seat->keyboard_state.grab = keyboard_grab;
|
|
|
|
|
|
|
|
|
|
|
|
wlr_seat->keyboard_state.wlr_seat = wlr_seat;
|
|
|
|
wlr_seat->keyboard_state.seat = wlr_seat;
|
|
|
|
wl_list_init(&wlr_seat->keyboard_state.resource_destroy.link);
|
|
|
|
wl_list_init(&wlr_seat->keyboard_state.resource_destroy.link);
|
|
|
|
wl_list_init(
|
|
|
|
wl_list_init(
|
|
|
|
&wlr_seat->keyboard_state.surface_destroy.link);
|
|
|
|
&wlr_seat->keyboard_state.surface_destroy.link);
|
|
|
@ -321,7 +327,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
|
|
|
|
wlr_seat->wl_global = wl_global;
|
|
|
|
wlr_seat->wl_global = wl_global;
|
|
|
|
wlr_seat->display = display;
|
|
|
|
wlr_seat->display = display;
|
|
|
|
wlr_seat->name = strdup(name);
|
|
|
|
wlr_seat->name = strdup(name);
|
|
|
|
wl_list_init(&wlr_seat->handles);
|
|
|
|
wl_list_init(&wlr_seat->clients);
|
|
|
|
|
|
|
|
|
|
|
|
wl_signal_init(&wlr_seat->events.client_bound);
|
|
|
|
wl_signal_init(&wlr_seat->events.client_bound);
|
|
|
|
wl_signal_init(&wlr_seat->events.client_unbound);
|
|
|
|
wl_signal_init(&wlr_seat->events.client_unbound);
|
|
|
@ -343,10 +349,10 @@ void wlr_seat_destroy(struct wlr_seat *wlr_seat) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *handle, *tmp;
|
|
|
|
struct wlr_seat_client *client, *tmp;
|
|
|
|
wl_list_for_each_safe(handle, tmp, &wlr_seat->handles, link) {
|
|
|
|
wl_list_for_each_safe(client, tmp, &wlr_seat->clients, link) {
|
|
|
|
// will destroy other resources as well
|
|
|
|
// will destroy other resources as well
|
|
|
|
wl_resource_destroy(handle->wl_resource);
|
|
|
|
wl_resource_destroy(client->wl_resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_global_destroy(wlr_seat->wl_global);
|
|
|
|
wl_global_destroy(wlr_seat->wl_global);
|
|
|
@ -357,13 +363,13 @@ void wlr_seat_destroy(struct wlr_seat *wlr_seat) {
|
|
|
|
free(wlr_seat);
|
|
|
|
free(wlr_seat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *wlr_seat_handle_for_client(struct wlr_seat *wlr_seat,
|
|
|
|
struct wlr_seat_client *wlr_seat_client_for_wl_client(struct wlr_seat *wlr_seat,
|
|
|
|
struct wl_client *client) {
|
|
|
|
struct wl_client *wl_client) {
|
|
|
|
assert(wlr_seat);
|
|
|
|
assert(wlr_seat);
|
|
|
|
struct wlr_seat_handle *handle;
|
|
|
|
struct wlr_seat_client *seat_client;
|
|
|
|
wl_list_for_each(handle, &wlr_seat->handles, link) {
|
|
|
|
wl_list_for_each(seat_client, &wlr_seat->clients, link) {
|
|
|
|
if (wl_resource_get_client(handle->wl_resource) == client) {
|
|
|
|
if (seat_client->client == wl_client) {
|
|
|
|
return handle;
|
|
|
|
return seat_client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
@ -372,18 +378,18 @@ struct wlr_seat_handle *wlr_seat_handle_for_client(struct wlr_seat *wlr_seat,
|
|
|
|
void wlr_seat_set_capabilities(struct wlr_seat *wlr_seat,
|
|
|
|
void wlr_seat_set_capabilities(struct wlr_seat *wlr_seat,
|
|
|
|
uint32_t capabilities) {
|
|
|
|
uint32_t capabilities) {
|
|
|
|
wlr_seat->capabilities = capabilities;
|
|
|
|
wlr_seat->capabilities = capabilities;
|
|
|
|
struct wlr_seat_handle *handle;
|
|
|
|
struct wlr_seat_client *client;
|
|
|
|
wl_list_for_each(handle, &wlr_seat->handles, link) {
|
|
|
|
wl_list_for_each(client, &wlr_seat->clients, link) {
|
|
|
|
wl_seat_send_capabilities(handle->wl_resource, capabilities);
|
|
|
|
wl_seat_send_capabilities(client->wl_resource, capabilities);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_seat_set_name(struct wlr_seat *wlr_seat, const char *name) {
|
|
|
|
void wlr_seat_set_name(struct wlr_seat *wlr_seat, const char *name) {
|
|
|
|
free(wlr_seat->name);
|
|
|
|
free(wlr_seat->name);
|
|
|
|
wlr_seat->name = strdup(name);
|
|
|
|
wlr_seat->name = strdup(name);
|
|
|
|
struct wlr_seat_handle *handle;
|
|
|
|
struct wlr_seat_client *client;
|
|
|
|
wl_list_for_each(handle, &wlr_seat->handles, link) {
|
|
|
|
wl_list_for_each(client, &wlr_seat->clients, link) {
|
|
|
|
wl_seat_send_name(handle->wl_resource, name);
|
|
|
|
wl_seat_send_name(client->wl_resource, name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -399,7 +405,7 @@ static void pointer_surface_destroy_notify(struct wl_listener *listener,
|
|
|
|
wl_list_remove(&state->surface_destroy.link);
|
|
|
|
wl_list_remove(&state->surface_destroy.link);
|
|
|
|
wl_list_init(&state->surface_destroy.link);
|
|
|
|
wl_list_init(&state->surface_destroy.link);
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
wlr_seat_pointer_clear_focus(state->wlr_seat);
|
|
|
|
wlr_seat_pointer_clear_focus(state->seat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void pointer_resource_destroy_notify(struct wl_listener *listener,
|
|
|
|
static void pointer_resource_destroy_notify(struct wl_listener *listener,
|
|
|
@ -409,12 +415,12 @@ static void pointer_resource_destroy_notify(struct wl_listener *listener,
|
|
|
|
wl_list_remove(&state->resource_destroy.link);
|
|
|
|
wl_list_remove(&state->resource_destroy.link);
|
|
|
|
wl_list_init(&state->resource_destroy.link);
|
|
|
|
wl_list_init(&state->resource_destroy.link);
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
wlr_seat_pointer_clear_focus(state->wlr_seat);
|
|
|
|
wlr_seat_pointer_clear_focus(state->seat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool wlr_seat_pointer_has_focus_resource(struct wlr_seat *wlr_seat) {
|
|
|
|
static bool wlr_seat_pointer_has_focus_resource(struct wlr_seat *wlr_seat) {
|
|
|
|
return wlr_seat->pointer_state.focused_handle &&
|
|
|
|
return wlr_seat->pointer_state.focused_client &&
|
|
|
|
wlr_seat->pointer_state.focused_handle->pointer;
|
|
|
|
wlr_seat->pointer_state.focused_client->pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
|
|
|
|
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
|
|
|
@ -426,32 +432,32 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *handle = NULL;
|
|
|
|
struct wlr_seat_client *client = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (surface) {
|
|
|
|
if (surface) {
|
|
|
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
|
|
|
struct wl_client *wl_client = wl_resource_get_client(surface->resource);
|
|
|
|
handle = wlr_seat_handle_for_client(wlr_seat, client);
|
|
|
|
client = wlr_seat_client_for_wl_client(wlr_seat, wl_client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *focused_handle =
|
|
|
|
struct wlr_seat_client *focused_client =
|
|
|
|
wlr_seat->pointer_state.focused_handle;
|
|
|
|
wlr_seat->pointer_state.focused_client;
|
|
|
|
struct wlr_surface *focused_surface =
|
|
|
|
struct wlr_surface *focused_surface =
|
|
|
|
wlr_seat->pointer_state.focused_surface;
|
|
|
|
wlr_seat->pointer_state.focused_surface;
|
|
|
|
|
|
|
|
|
|
|
|
// leave the previously entered surface
|
|
|
|
// leave the previously entered surface
|
|
|
|
if (focused_handle && focused_handle->pointer && focused_surface) {
|
|
|
|
if (focused_client && focused_client->pointer && focused_surface) {
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
wl_pointer_send_leave(focused_handle->pointer, serial,
|
|
|
|
wl_pointer_send_leave(focused_client->pointer, serial,
|
|
|
|
focused_surface->resource);
|
|
|
|
focused_surface->resource);
|
|
|
|
pointer_send_frame(focused_handle->pointer);
|
|
|
|
pointer_send_frame(focused_client->pointer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// enter the current surface
|
|
|
|
// enter the current surface
|
|
|
|
if (handle && handle->pointer) {
|
|
|
|
if (client && client->pointer) {
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
wl_pointer_send_enter(handle->pointer, serial, surface->resource,
|
|
|
|
wl_pointer_send_enter(client->pointer, serial, surface->resource,
|
|
|
|
wl_fixed_from_double(sx), wl_fixed_from_double(sy));
|
|
|
|
wl_fixed_from_double(sx), wl_fixed_from_double(sy));
|
|
|
|
pointer_send_frame(handle->pointer);
|
|
|
|
pointer_send_frame(client->pointer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// reinitialize the focus destroy events
|
|
|
|
// reinitialize the focus destroy events
|
|
|
@ -470,7 +476,7 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
|
|
|
|
pointer_surface_destroy_notify;
|
|
|
|
pointer_surface_destroy_notify;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_seat->pointer_state.focused_handle = handle;
|
|
|
|
wlr_seat->pointer_state.focused_client = client;
|
|
|
|
wlr_seat->pointer_state.focused_surface = surface;
|
|
|
|
wlr_seat->pointer_state.focused_surface = surface;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: send focus change event
|
|
|
|
// TODO: send focus change event
|
|
|
@ -486,9 +492,9 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_pointer_send_motion(wlr_seat->pointer_state.focused_handle->pointer,
|
|
|
|
wl_pointer_send_motion(wlr_seat->pointer_state.focused_client->pointer,
|
|
|
|
time, wl_fixed_from_double(sx), wl_fixed_from_double(sy));
|
|
|
|
time, wl_fixed_from_double(sx), wl_fixed_from_double(sy));
|
|
|
|
pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer);
|
|
|
|
pointer_send_frame(wlr_seat->pointer_state.focused_client->pointer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
@ -498,9 +504,9 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
wl_pointer_send_button(wlr_seat->pointer_state.focused_handle->pointer,
|
|
|
|
wl_pointer_send_button(wlr_seat->pointer_state.focused_client->pointer,
|
|
|
|
serial, time, button, state);
|
|
|
|
serial, time, button, state);
|
|
|
|
pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer);
|
|
|
|
pointer_send_frame(wlr_seat->pointer_state.focused_client->pointer);
|
|
|
|
return serial;
|
|
|
|
return serial;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -511,7 +517,7 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_resource *pointer =
|
|
|
|
struct wl_resource *pointer =
|
|
|
|
wlr_seat->pointer_state.focused_handle->pointer;
|
|
|
|
wlr_seat->pointer_state.focused_client->pointer;
|
|
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
if (value) {
|
|
|
|
wl_pointer_send_axis(pointer, time, orientation,
|
|
|
|
wl_pointer_send_axis(pointer, time, orientation,
|
|
|
@ -582,22 +588,22 @@ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
void wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time,
|
|
|
|
uint32_t key, uint32_t state) {
|
|
|
|
uint32_t key, uint32_t state) {
|
|
|
|
struct wlr_seat_handle *handle = wlr_seat->keyboard_state.focused_handle;
|
|
|
|
struct wlr_seat_client *client = wlr_seat->keyboard_state.focused_client;
|
|
|
|
if (!handle || !handle->keyboard) {
|
|
|
|
if (!client || !client->keyboard) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
wl_keyboard_send_key(handle->keyboard, serial,
|
|
|
|
wl_keyboard_send_key(client->keyboard, serial,
|
|
|
|
time, key, state);
|
|
|
|
time, key, state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_keyboard_keymap(struct wl_listener *listener, void *data) {
|
|
|
|
static void handle_keyboard_keymap(struct wl_listener *listener, void *data) {
|
|
|
|
struct wlr_seat_keyboard_state *state =
|
|
|
|
struct wlr_seat_keyboard_state *state =
|
|
|
|
wl_container_of(listener, state, keyboard_keymap);
|
|
|
|
wl_container_of(listener, state, keyboard_keymap);
|
|
|
|
struct wlr_seat_handle *handle;
|
|
|
|
struct wlr_seat_client *client;
|
|
|
|
wl_list_for_each(handle, &state->wlr_seat->handles, link) {
|
|
|
|
wl_list_for_each(client, &state->seat->clients, link) {
|
|
|
|
seat_handle_send_keymap(handle, state->keyboard);
|
|
|
|
seat_client_send_keymap(client, state->keyboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -632,9 +638,9 @@ void wlr_seat_set_keyboard(struct wlr_seat *seat,
|
|
|
|
&seat->keyboard_state.keyboard_keymap);
|
|
|
|
&seat->keyboard_state.keyboard_keymap);
|
|
|
|
seat->keyboard_state.keyboard_keymap.notify = handle_keyboard_keymap;
|
|
|
|
seat->keyboard_state.keyboard_keymap.notify = handle_keyboard_keymap;
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *handle;
|
|
|
|
struct wlr_seat_client *client;
|
|
|
|
wl_list_for_each(handle, &seat->handles, link) {
|
|
|
|
wl_list_for_each(client, &seat->clients, link) {
|
|
|
|
seat_handle_send_keymap(handle, device->keyboard);
|
|
|
|
seat_client_send_keymap(client, device->keyboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
seat->keyboard_state.keyboard = device->keyboard;
|
|
|
|
seat->keyboard_state.keyboard = device->keyboard;
|
|
|
@ -665,7 +671,7 @@ static void keyboard_surface_destroy_notify(struct wl_listener *listener,
|
|
|
|
wl_list_remove(&state->surface_destroy.link);
|
|
|
|
wl_list_remove(&state->surface_destroy.link);
|
|
|
|
wl_list_init(&state->surface_destroy.link);
|
|
|
|
wl_list_init(&state->surface_destroy.link);
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
wlr_seat_keyboard_clear_focus(state->wlr_seat);
|
|
|
|
wlr_seat_keyboard_clear_focus(state->seat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void keyboard_resource_destroy_notify(struct wl_listener *listener,
|
|
|
|
static void keyboard_resource_destroy_notify(struct wl_listener *listener,
|
|
|
@ -675,20 +681,20 @@ static void keyboard_resource_destroy_notify(struct wl_listener *listener,
|
|
|
|
wl_list_remove(&state->resource_destroy.link);
|
|
|
|
wl_list_remove(&state->resource_destroy.link);
|
|
|
|
wl_list_init(&state->resource_destroy.link);
|
|
|
|
wl_list_init(&state->resource_destroy.link);
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
state->focused_surface = NULL;
|
|
|
|
wlr_seat_keyboard_clear_focus(state->wlr_seat);
|
|
|
|
wlr_seat_keyboard_clear_focus(state->seat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
|
|
|
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
|
|
|
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
|
|
|
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
|
|
|
uint32_t group) {
|
|
|
|
uint32_t group) {
|
|
|
|
struct wlr_seat_handle *handle = seat->keyboard_state.focused_handle;
|
|
|
|
struct wlr_seat_client *client = seat->keyboard_state.focused_client;
|
|
|
|
if (!handle || !handle->keyboard) {
|
|
|
|
if (!client || !client->keyboard) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t serial = wl_display_next_serial(seat->display);
|
|
|
|
uint32_t serial = wl_display_next_serial(seat->display);
|
|
|
|
|
|
|
|
|
|
|
|
wl_keyboard_send_modifiers(handle->keyboard, serial,
|
|
|
|
wl_keyboard_send_modifiers(client->keyboard, serial,
|
|
|
|
mods_depressed, mods_latched,
|
|
|
|
mods_depressed, mods_latched,
|
|
|
|
mods_locked, group);
|
|
|
|
mods_locked, group);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -700,35 +706,35 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *handle = NULL;
|
|
|
|
struct wlr_seat_client *client = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (surface) {
|
|
|
|
if (surface) {
|
|
|
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
|
|
|
struct wl_client *wl_client = wl_resource_get_client(surface->resource);
|
|
|
|
handle = wlr_seat_handle_for_client(wlr_seat, client);
|
|
|
|
client = wlr_seat_client_for_wl_client(wlr_seat, wl_client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat_handle *focused_handle =
|
|
|
|
struct wlr_seat_client *focused_client =
|
|
|
|
wlr_seat->keyboard_state.focused_handle;
|
|
|
|
wlr_seat->keyboard_state.focused_client;
|
|
|
|
struct wlr_surface *focused_surface =
|
|
|
|
struct wlr_surface *focused_surface =
|
|
|
|
wlr_seat->keyboard_state.focused_surface;
|
|
|
|
wlr_seat->keyboard_state.focused_surface;
|
|
|
|
|
|
|
|
|
|
|
|
// leave the previously entered surface
|
|
|
|
// leave the previously entered surface
|
|
|
|
if (focused_handle && focused_handle->keyboard && focused_surface) {
|
|
|
|
if (focused_client && focused_client->keyboard && focused_surface) {
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
wl_keyboard_send_leave(focused_handle->keyboard, serial,
|
|
|
|
wl_keyboard_send_leave(focused_client->keyboard, serial,
|
|
|
|
focused_surface->resource);
|
|
|
|
focused_surface->resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// enter the current surface
|
|
|
|
// enter the current surface
|
|
|
|
if (handle && handle->keyboard) {
|
|
|
|
if (client && client->keyboard) {
|
|
|
|
// TODO: read the currently pressed keys out of the active keyboard and
|
|
|
|
// TODO: read the currently pressed keys out of the active keyboard and
|
|
|
|
// put them in this array
|
|
|
|
// put them in this array
|
|
|
|
struct wl_array keys;
|
|
|
|
struct wl_array keys;
|
|
|
|
wl_array_init(&keys);
|
|
|
|
wl_array_init(&keys);
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
|
|
|
wl_keyboard_send_enter(handle->keyboard, serial,
|
|
|
|
wl_keyboard_send_enter(client->keyboard, serial,
|
|
|
|
surface->resource, &keys);
|
|
|
|
surface->resource, &keys);
|
|
|
|
wlr_seat_handle_send_selection(handle);
|
|
|
|
wlr_seat_client_send_selection(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// reinitialize the focus destroy events
|
|
|
|
// reinitialize the focus destroy events
|
|
|
@ -747,7 +753,7 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
|
|
|
|
keyboard_surface_destroy_notify;
|
|
|
|
keyboard_surface_destroy_notify;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_seat->keyboard_state.focused_handle = handle;
|
|
|
|
wlr_seat->keyboard_state.focused_client = client;
|
|
|
|
wlr_seat->keyboard_state.focused_surface = surface;
|
|
|
|
wlr_seat->keyboard_state.focused_surface = surface;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|