Merge pull request #434 from acrisci/refactor/remove-client-bound-signal

wlr-seat: remove client bound and unbound signal
master
Drew DeVault 7 years ago committed by GitHub
commit fae8d6289a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -71,7 +71,7 @@ struct wlr_drag_icon {
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
struct wl_listener seat_client_unbound;
struct wl_listener seat_client_destroy;
};
struct wlr_drag {
@ -94,7 +94,7 @@ struct wlr_drag {
struct wl_listener point_destroy;
struct wl_listener source_destroy;
struct wl_listener seat_client_unbound;
struct wl_listener seat_client_destroy;
struct wl_listener icon_destroy;
};

@ -21,6 +21,10 @@ struct wlr_seat_client {
struct wl_resource *touch;
struct wl_resource *data_device;
struct {
struct wl_signal destroy;
} events;
struct wl_list link;
};
@ -182,9 +186,6 @@ struct wlr_seat {
struct wl_listener selection_data_source_destroy;
struct {
struct wl_signal client_bound;
struct wl_signal client_unbound;
struct wl_signal pointer_grab_begin;
struct wl_signal pointer_grab_end;

@ -352,15 +352,13 @@ static void data_device_release(struct wl_client *client,
wl_resource_destroy(resource);
}
static void drag_client_seat_unbound(struct wl_listener *listener, void *data) {
static void handle_drag_seat_client_destroy(struct wl_listener *listener,
void *data) {
struct wlr_drag *drag =
wl_container_of(listener, drag, seat_client_unbound);
struct wlr_seat_client *unbound_client = data;
wl_container_of(listener, drag, seat_client_destroy);
if (drag->focus_client == unbound_client) {
drag->focus_client = NULL;
wl_list_remove(&drag->seat_client_unbound.link);
}
wl_list_remove(&drag->seat_client_destroy.link);
}
static void wlr_drag_set_focus(struct wlr_drag *drag,
@ -370,7 +368,7 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
}
if (drag->focus_client && drag->focus_client->data_device) {
wl_list_remove(&drag->seat_client_unbound.link);
wl_list_remove(&drag->seat_client_destroy.link);
wl_data_device_send_leave(drag->focus_client->data_device);
drag->focus_client = NULL;
drag->focus = NULL;
@ -430,9 +428,9 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
drag->focus = surface;
drag->focus_client = focus_client;
drag->seat_client_unbound.notify = drag_client_seat_unbound;
wl_signal_add(&focus_client->seat->events.client_unbound,
&drag->seat_client_unbound);
drag->seat_client_destroy.notify = handle_drag_seat_client_destroy;
wl_signal_add(&focus_client->events.destroy,
&drag->seat_client_destroy);
}
static void wlr_drag_end(struct wlr_drag *drag) {
@ -622,7 +620,7 @@ static void wlr_drag_icon_destroy(struct wlr_drag_icon *icon) {
wl_signal_emit(&icon->events.destroy, icon);
wl_list_remove(&icon->surface_commit.link);
wl_list_remove(&icon->surface_destroy.link);
wl_list_remove(&icon->seat_client_unbound.link);
wl_list_remove(&icon->seat_client_destroy.link);
wl_list_remove(&icon->link);
free(icon);
}
@ -642,16 +640,13 @@ static void handle_drag_icon_surface_commit(struct wl_listener *listener,
icon->sy += icon->surface->current->sy;
}
static void handle_drag_icon_seat_client_unbound(struct wl_listener *listener,
static void handle_drag_icon_seat_client_destroy(struct wl_listener *listener,
void *data) {
struct wlr_drag_icon *icon =
wl_container_of(listener, icon, seat_client_unbound);
struct wlr_seat_client *client = data;
wl_container_of(listener, icon, seat_client_destroy);
if (client == icon->client) {
wlr_drag_icon_destroy(icon);
}
}
static struct wlr_drag_icon *wlr_drag_icon_create(
struct wlr_surface *icon_surface, struct wlr_seat_client *client,
@ -676,8 +671,8 @@ static struct wlr_drag_icon *wlr_drag_icon_create(
wl_signal_add(&icon->surface->events.commit, &icon->surface_commit);
icon->surface_commit.notify = handle_drag_icon_surface_commit;
wl_signal_add(&client->seat->events.client_unbound, &icon->seat_client_unbound);
icon->seat_client_unbound.notify = handle_drag_icon_seat_client_unbound;
wl_signal_add(&client->events.destroy, &icon->seat_client_destroy);
icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy;
return icon;
}

@ -181,7 +181,7 @@ static void wl_seat_get_touch(struct wl_client *client,
static void wlr_seat_client_resource_destroy(struct wl_resource *resource) {
struct wlr_seat_client *client = wl_resource_get_user_data(resource);
wl_signal_emit(&client->seat->events.client_unbound, client);
wl_signal_emit(&client->events.destroy, client);
if (client == client->seat->pointer_state.focused_client) {
client->seat->pointer_state.focused_client = NULL;
@ -240,7 +240,7 @@ static void wl_seat_bind(struct wl_client *client, void *_wlr_seat,
wl_seat_send_name(seat_client->wl_resource, wlr_seat->name);
}
wl_seat_send_capabilities(seat_client->wl_resource, wlr_seat->capabilities);
wl_signal_emit(&wlr_seat->events.client_bound, seat_client);
wl_signal_init(&seat_client->events.destroy);
}
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
@ -406,9 +406,6 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
wl_list_init(&wlr_seat->clients);
wl_list_init(&wlr_seat->drag_icons);
wl_signal_init(&wlr_seat->events.client_bound);
wl_signal_init(&wlr_seat->events.client_unbound);
wl_signal_init(&wlr_seat->events.request_set_cursor);
wl_signal_init(&wlr_seat->events.selection);

Loading…
Cancel
Save