mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 06:35:58 +01:00
Gracefully deal with outputs being removed
This commit is contained in:
parent
f444a0d14c
commit
8c98c18880
2 changed files with 31 additions and 12 deletions
|
@ -14,6 +14,7 @@ struct roots_layer_surface {
|
||||||
struct wl_listener map;
|
struct wl_listener map;
|
||||||
struct wl_listener unmap;
|
struct wl_listener unmap;
|
||||||
struct wl_listener surface_commit;
|
struct wl_listener surface_commit;
|
||||||
|
struct wl_listener output_destroy;
|
||||||
|
|
||||||
bool configured;
|
bool configured;
|
||||||
struct wlr_box geo;
|
struct wlr_box geo;
|
||||||
|
|
|
@ -114,13 +114,34 @@ static void arrange_layers(struct wlr_output *_output) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_layer_surface *layer =
|
||||||
|
wl_container_of(listener, layer, output_destroy);
|
||||||
|
layer->layer_surface->output = NULL;
|
||||||
|
wl_resource_destroy(layer->layer_surface->resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_layer_surface *layer =
|
||||||
|
wl_container_of(listener, layer, surface_commit);
|
||||||
|
struct wlr_layer_surface *layer_surface = layer->layer_surface;
|
||||||
|
struct wlr_output *wlr_output = layer_surface->output;
|
||||||
|
if (wlr_output != NULL) {
|
||||||
|
struct roots_output *output = wlr_output->data;
|
||||||
|
output_damage_from_local_surface(output, layer_surface->surface,
|
||||||
|
layer->geo.x, layer->geo.y, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void unmap(struct wlr_layer_surface *layer_surface) {
|
static void unmap(struct wlr_layer_surface *layer_surface) {
|
||||||
struct roots_layer_surface *layer = layer_surface->data;
|
struct roots_layer_surface *layer = layer_surface->data;
|
||||||
wl_list_remove(&layer->link);
|
wl_list_remove(&layer->link);
|
||||||
|
|
||||||
struct wlr_output *wlr_output = layer_surface->output;
|
struct wlr_output *wlr_output = layer_surface->output;
|
||||||
struct roots_output *output = wlr_output->data;
|
if (wlr_output != NULL) {
|
||||||
wlr_output_damage_add_box(output->damage, &layer->geo);
|
struct roots_output *output = wlr_output->data;
|
||||||
|
wlr_output_damage_add_box(output->damage, &layer->geo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
@ -129,19 +150,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
if (layer->layer_surface->mapped) {
|
if (layer->layer_surface->mapped) {
|
||||||
unmap(layer->layer_surface);
|
unmap(layer->layer_surface);
|
||||||
}
|
}
|
||||||
|
wl_list_remove(&layer->output_destroy.link);
|
||||||
free(layer);
|
free(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|
||||||
struct roots_layer_surface *layer =
|
|
||||||
wl_container_of(listener, layer, surface_commit);
|
|
||||||
struct wlr_layer_surface *layer_surface = layer->layer_surface;
|
|
||||||
struct wlr_output *wlr_output = layer_surface->output;
|
|
||||||
struct roots_output *output = wlr_output->data;
|
|
||||||
output_damage_from_local_surface(output, layer_surface->surface,
|
|
||||||
layer->geo.x, layer->geo.y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_map(struct wl_listener *listener, void *data) {
|
static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_layer_surface *layer_surface = data;
|
struct wlr_layer_surface *layer_surface = data;
|
||||||
struct roots_layer_surface *layer = layer_surface->data;
|
struct roots_layer_surface *layer = layer_surface->data;
|
||||||
|
@ -174,9 +186,15 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
if (!roots_surface) {
|
if (!roots_surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&layer_surface->surface->events.commit,
|
wl_signal_add(&layer_surface->surface->events.commit,
|
||||||
&roots_surface->surface_commit);
|
&roots_surface->surface_commit);
|
||||||
|
|
||||||
|
roots_surface->output_destroy.notify = handle_output_destroy;
|
||||||
|
wl_signal_add(&layer_surface->output->events.destroy,
|
||||||
|
&roots_surface->output_destroy);
|
||||||
|
|
||||||
roots_surface->destroy.notify = handle_destroy;
|
roots_surface->destroy.notify = handle_destroy;
|
||||||
wl_signal_add(&layer_surface->events.destroy, &roots_surface->destroy);
|
wl_signal_add(&layer_surface->events.destroy, &roots_surface->destroy);
|
||||||
roots_surface->map.notify = handle_map;
|
roots_surface->map.notify = handle_map;
|
||||||
|
|
Loading…
Reference in a new issue