mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 18:39:48 +01:00
gtk-primary-selection: track resources
This commit is contained in:
parent
b9a2e4ba4c
commit
eaafd65a12
2 changed files with 16 additions and 3 deletions
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
struct wlr_primary_selection_device_manager {
|
struct wlr_primary_selection_device_manager {
|
||||||
struct wl_global *global;
|
struct wl_global *global;
|
||||||
|
struct wl_list resources;
|
||||||
|
|
||||||
struct wl_listener display_destroy;
|
struct wl_listener display_destroy;
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,7 @@ void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: make all offers inert
|
||||||
if (seat->primary_selection_source) {
|
if (seat->primary_selection_source) {
|
||||||
wl_list_remove(&seat->primary_selection_source_destroy.link);
|
wl_list_remove(&seat->primary_selection_source_destroy.link);
|
||||||
seat->primary_selection_source->cancel(seat->primary_selection_source);
|
seat->primary_selection_source->cancel(seat->primary_selection_source);
|
||||||
|
@ -355,6 +356,11 @@ device_manager_impl = {
|
||||||
.destroy = device_manager_handle_destroy,
|
.destroy = device_manager_handle_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void device_manager_handle_resource_destroy(
|
||||||
|
struct wl_resource *resource) {
|
||||||
|
wl_list_remove(wl_resource_get_link(resource));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void primary_selection_device_manager_bind(struct wl_client *client,
|
static void primary_selection_device_manager_bind(struct wl_client *client,
|
||||||
void *data, uint32_t version, uint32_t id) {
|
void *data, uint32_t version, uint32_t id) {
|
||||||
|
@ -367,7 +373,9 @@ static void primary_selection_device_manager_bind(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wl_resource_set_implementation(resource, &device_manager_impl, manager,
|
wl_resource_set_implementation(resource, &device_manager_impl, manager,
|
||||||
NULL);
|
device_manager_handle_resource_destroy);
|
||||||
|
|
||||||
|
wl_list_insert(&manager->resources, wl_resource_get_link(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
@ -392,6 +400,7 @@ struct wlr_primary_selection_device_manager *
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_list_init(&manager->resources);
|
||||||
wl_signal_init(&manager->events.destroy);
|
wl_signal_init(&manager->events.destroy);
|
||||||
|
|
||||||
manager->display_destroy.notify = handle_display_destroy;
|
manager->display_destroy.notify = handle_display_destroy;
|
||||||
|
@ -407,7 +416,10 @@ void wlr_primary_selection_device_manager_destroy(
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&manager->events.destroy, manager);
|
wlr_signal_emit_safe(&manager->events.destroy, manager);
|
||||||
wl_list_remove(&manager->display_destroy.link);
|
wl_list_remove(&manager->display_destroy.link);
|
||||||
// TODO: free resources
|
struct wl_resource *resource, *resource_tmp;
|
||||||
|
wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
|
||||||
|
wl_resource_destroy(resource);
|
||||||
|
}
|
||||||
wl_global_destroy(manager->global);
|
wl_global_destroy(manager->global);
|
||||||
free(manager);
|
free(manager);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue