mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 18:39:48 +01:00
Listen to display destroy in output
This commit is contained in:
parent
cbf5763c22
commit
0e066f0d76
2 changed files with 13 additions and 0 deletions
|
@ -74,6 +74,8 @@ struct wlr_output {
|
||||||
// the output position in layout space reported to clients
|
// the output position in layout space reported to clients
|
||||||
int32_t lx, ly;
|
int32_t lx, ly;
|
||||||
|
|
||||||
|
struct wl_listener display_destroy;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,12 @@ static void wl_output_bind(struct wl_client *wl_client, void *data,
|
||||||
wl_output_send_to_resource(wl_resource);
|
wl_output_send_to_resource(wl_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_output *output =
|
||||||
|
wl_container_of(listener, output, display_destroy);
|
||||||
|
wlr_output_destroy_global(output);
|
||||||
|
}
|
||||||
|
|
||||||
struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
|
struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
|
||||||
struct wl_display *display) {
|
struct wl_display *display) {
|
||||||
if (wlr_output->wl_global != NULL) {
|
if (wlr_output->wl_global != NULL) {
|
||||||
|
@ -120,6 +126,10 @@ struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
|
||||||
struct wl_global *wl_global = wl_global_create(display,
|
struct wl_global *wl_global = wl_global_create(display,
|
||||||
&wl_output_interface, 3, wlr_output, wl_output_bind);
|
&wl_output_interface, 3, wlr_output, wl_output_bind);
|
||||||
wlr_output->wl_global = wl_global;
|
wlr_output->wl_global = wl_global;
|
||||||
|
|
||||||
|
wlr_output->display_destroy.notify = handle_display_destroy;
|
||||||
|
wl_display_add_destroy_listener(display, &wlr_output->display_destroy);
|
||||||
|
|
||||||
return wl_global;
|
return wl_global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +137,7 @@ void wlr_output_destroy_global(struct wlr_output *wlr_output) {
|
||||||
if (wlr_output->wl_global == NULL) {
|
if (wlr_output->wl_global == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wl_list_remove(&wlr_output->display_destroy.link);
|
||||||
struct wl_resource *resource, *tmp;
|
struct wl_resource *resource, *tmp;
|
||||||
wl_resource_for_each_safe(resource, tmp, &wlr_output->wl_resources) {
|
wl_resource_for_each_safe(resource, tmp, &wlr_output->wl_resources) {
|
||||||
struct wl_list *link = wl_resource_get_link(resource);
|
struct wl_list *link = wl_resource_get_link(resource);
|
||||||
|
|
Loading…
Reference in a new issue