mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
wlr_seat: Extract seat_client_create() function
This commit is contained in:
parent
eac2eaa6a9
commit
1689a3503b
1 changed files with 43 additions and 31 deletions
|
@ -114,26 +114,12 @@ static const struct wl_seat_interface seat_impl = {
|
||||||
.release = seat_handle_release,
|
.release = seat_handle_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void seat_handle_bind(struct wl_client *client, void *_wlr_seat,
|
static struct wlr_seat_client *seat_client_create(struct wlr_seat *wlr_seat,
|
||||||
uint32_t version, uint32_t id) {
|
struct wl_client *client, struct wl_resource *wl_resource) {
|
||||||
struct wlr_seat *wlr_seat = _wlr_seat;
|
|
||||||
assert(client && wlr_seat);
|
|
||||||
|
|
||||||
struct wl_resource *wl_resource =
|
|
||||||
wl_resource_create(client, &wl_seat_interface, version, id);
|
|
||||||
if (wl_resource == NULL) {
|
|
||||||
wl_client_post_no_memory(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_seat_client *seat_client =
|
struct wlr_seat_client *seat_client =
|
||||||
wlr_seat_client_for_wl_client(wlr_seat, client);
|
calloc(1, sizeof(struct wlr_seat_client));
|
||||||
if (seat_client == NULL) {
|
if (!seat_client) {
|
||||||
seat_client = calloc(1, sizeof(struct wlr_seat_client));
|
return NULL;
|
||||||
if (seat_client == NULL) {
|
|
||||||
wl_resource_destroy(wl_resource);
|
|
||||||
wl_client_post_no_memory(client);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
seat_client->client = client;
|
seat_client->client = client;
|
||||||
|
@ -160,6 +146,32 @@ static void seat_handle_bind(struct wl_client *client, void *_wlr_seat,
|
||||||
wl_resource_get_client(keyboard_focus->resource) == client) {
|
wl_resource_get_client(keyboard_focus->resource) == client) {
|
||||||
wlr_seat->keyboard_state.focused_client = seat_client;
|
wlr_seat->keyboard_state.focused_client = seat_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return seat_client;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void seat_handle_bind(struct wl_client *client, void *_wlr_seat,
|
||||||
|
uint32_t version, uint32_t id) {
|
||||||
|
struct wlr_seat *wlr_seat = _wlr_seat;
|
||||||
|
assert(client && wlr_seat);
|
||||||
|
|
||||||
|
struct wl_resource *wl_resource =
|
||||||
|
wl_resource_create(client, &wl_seat_interface, version, id);
|
||||||
|
if (wl_resource == NULL) {
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_seat_client *seat_client =
|
||||||
|
wlr_seat_client_for_wl_client(wlr_seat, client);
|
||||||
|
if (!seat_client) {
|
||||||
|
seat_client = seat_client_create(wlr_seat, client, wl_resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seat_client == NULL) {
|
||||||
|
wl_resource_destroy(wl_resource);
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_resource_set_implementation(wl_resource, &seat_impl,
|
wl_resource_set_implementation(wl_resource, &seat_impl,
|
||||||
|
|
Loading…
Reference in a new issue