mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
seat: Provide dummy resources for inert seats
This commit is contained in:
parent
3898bb482d
commit
00489b11a0
5 changed files with 46 additions and 4 deletions
|
@ -10,18 +10,24 @@ extern const struct wlr_touch_grab_interface default_touch_grab_impl;
|
|||
|
||||
void seat_client_create_pointer(struct wlr_seat_client *seat_client,
|
||||
uint32_t version, uint32_t id);
|
||||
void seat_client_create_inert_pointer(struct wl_client *client,
|
||||
uint32_t version, uint32_t id);
|
||||
void seat_client_destroy_pointer(struct wl_resource *resource);
|
||||
void seat_client_send_pointer_leave_raw(struct wlr_seat_client *seat_client,
|
||||
struct wlr_surface *surface);
|
||||
|
||||
void seat_client_create_keyboard(struct wlr_seat_client *seat_client,
|
||||
uint32_t version, uint32_t id);
|
||||
void seat_client_create_inert_keyboard(struct wl_client *client,
|
||||
uint32_t version, uint32_t id);
|
||||
void seat_client_destroy_keyboard(struct wl_resource *resource);
|
||||
void seat_client_send_keyboard_leave_raw(struct wlr_seat_client *seat_client,
|
||||
struct wlr_surface *surface);
|
||||
|
||||
void seat_client_create_touch(struct wlr_seat_client *seat_client,
|
||||
uint32_t version, uint32_t id);
|
||||
void seat_client_create_inert_touch(struct wl_client *client,
|
||||
uint32_t version, uint32_t id);
|
||||
void seat_client_destroy_touch(struct wl_resource *resource);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
|
||||
static void seat_handle_get_pointer(struct wl_client *client,
|
||||
struct wl_resource *seat_resource, uint32_t id) {
|
||||
uint32_t version = wl_resource_get_version(seat_resource);
|
||||
struct wlr_seat_client *seat_client =
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
if (!seat_client) {
|
||||
// The client still needs a resource, so here's a dummy:
|
||||
seat_client_create_inert_pointer(client, version, id);
|
||||
return;
|
||||
}
|
||||
if (!(seat_client->seat->accumulated_capabilities & WL_SEAT_CAPABILITY_POINTER)) {
|
||||
|
@ -27,15 +30,16 @@ static void seat_handle_get_pointer(struct wl_client *client,
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t version = wl_resource_get_version(seat_resource);
|
||||
seat_client_create_pointer(seat_client, version, id);
|
||||
}
|
||||
|
||||
static void seat_handle_get_keyboard(struct wl_client *client,
|
||||
struct wl_resource *seat_resource, uint32_t id) {
|
||||
uint32_t version = wl_resource_get_version(seat_resource);
|
||||
struct wlr_seat_client *seat_client =
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
if (!seat_client) {
|
||||
seat_client_create_inert_keyboard(client, version, id);
|
||||
return;
|
||||
}
|
||||
if (!(seat_client->seat->accumulated_capabilities & WL_SEAT_CAPABILITY_KEYBOARD)) {
|
||||
|
@ -44,15 +48,16 @@ static void seat_handle_get_keyboard(struct wl_client *client,
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t version = wl_resource_get_version(seat_resource);
|
||||
seat_client_create_keyboard(seat_client, version, id);
|
||||
}
|
||||
|
||||
static void seat_handle_get_touch(struct wl_client *client,
|
||||
struct wl_resource *seat_resource, uint32_t id) {
|
||||
uint32_t version = wl_resource_get_version(seat_resource);
|
||||
struct wlr_seat_client *seat_client =
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
if (!seat_client) {
|
||||
seat_client_create_inert_touch(client, version, id);
|
||||
return;
|
||||
}
|
||||
if (!(seat_client->seat->accumulated_capabilities & WL_SEAT_CAPABILITY_TOUCH)) {
|
||||
|
@ -61,7 +66,6 @@ static void seat_handle_get_touch(struct wl_client *client,
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t version = wl_resource_get_version(seat_resource);
|
||||
seat_client_create_touch(seat_client, version, id);
|
||||
}
|
||||
|
||||
|
|
|
@ -438,6 +438,17 @@ void seat_client_create_keyboard(struct wlr_seat_client *seat_client,
|
|||
}
|
||||
}
|
||||
|
||||
void seat_client_create_inert_keyboard(struct wl_client *client,
|
||||
uint32_t version, uint32_t id) {
|
||||
struct wl_resource *resource =
|
||||
wl_resource_create(client, &wl_keyboard_interface, version, id);
|
||||
if (!resource) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(resource, &keyboard_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
void seat_client_destroy_keyboard(struct wl_resource *resource) {
|
||||
struct wlr_seat_client *seat_client =
|
||||
seat_client_from_keyboard_resource(resource);
|
||||
|
|
|
@ -487,7 +487,6 @@ bool wlr_seat_pointer_has_grab(struct wlr_seat *seat) {
|
|||
return seat->pointer_state.grab->interface != &default_pointer_grab_impl;
|
||||
}
|
||||
|
||||
|
||||
void seat_client_create_pointer(struct wlr_seat_client *seat_client,
|
||||
uint32_t version, uint32_t id) {
|
||||
struct wl_resource *resource = wl_resource_create(seat_client->client,
|
||||
|
@ -531,6 +530,17 @@ void seat_client_create_pointer(struct wlr_seat_client *seat_client,
|
|||
}
|
||||
}
|
||||
|
||||
void seat_client_create_inert_pointer(struct wl_client *client,
|
||||
uint32_t version, uint32_t id) {
|
||||
struct wl_resource *resource =
|
||||
wl_resource_create(client, &wl_pointer_interface, version, id);
|
||||
if (!resource) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(resource, &pointer_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
void seat_client_destroy_pointer(struct wl_resource *resource) {
|
||||
struct wlr_seat_client *seat_client =
|
||||
wlr_seat_client_from_pointer_resource(resource);
|
||||
|
|
|
@ -442,6 +442,17 @@ void seat_client_create_touch(struct wlr_seat_client *seat_client,
|
|||
}
|
||||
}
|
||||
|
||||
void seat_client_create_inert_touch(struct wl_client *client, uint32_t version,
|
||||
uint32_t id) {
|
||||
struct wl_resource *resource =
|
||||
wl_resource_create(client, &wl_touch_interface, version, id);
|
||||
if (!resource) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(resource, &touch_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
void seat_client_destroy_touch(struct wl_resource *resource) {
|
||||
struct wlr_seat_client *seat_client =
|
||||
seat_client_from_touch_resource(resource);
|
||||
|
|
Loading…
Reference in a new issue