mirror of
https://github.com/artizirk/wdisplays.git
synced 2026-10-03 12:55:42 +03:00
Fix crash when overlay surface is destroyed before its role
This commit is contained in:
+7
-7
@@ -60,6 +60,9 @@ static PangoLayout *create_text_layout(struct wd_head *head,
|
||||
}
|
||||
|
||||
static void resize(struct wd_output *output) {
|
||||
if (output->overlay_window == NULL || output->overlay_layer_surface == NULL)
|
||||
return;
|
||||
|
||||
struct wd_head *head = wd_find_head(output->state, output);
|
||||
|
||||
uint32_t screen_width = head->custom_mode.width;
|
||||
@@ -138,11 +141,6 @@ void window_map(GtkWidget *widget, gpointer data) {
|
||||
resize(output);
|
||||
}
|
||||
|
||||
void window_unmap(GtkWidget *widget, gpointer data) {
|
||||
struct wd_output *output = data;
|
||||
zwlr_layer_surface_v1_destroy(output->overlay_layer_surface);
|
||||
}
|
||||
|
||||
gboolean window_draw(GtkWidget *widget, cairo_t *cr, gpointer data) {
|
||||
struct wd_output *output = data;
|
||||
struct wd_head *head = wd_find_head(output->state, output);
|
||||
@@ -177,8 +175,6 @@ void wd_create_overlay(struct wd_output *output) {
|
||||
G_CALLBACK(window_realize), output);
|
||||
g_signal_connect(output->overlay_window, "map",
|
||||
G_CALLBACK(window_map), output);
|
||||
g_signal_connect(output->overlay_window, "unmap",
|
||||
G_CALLBACK(window_unmap), output);
|
||||
g_signal_connect(output->overlay_window, "draw",
|
||||
G_CALLBACK(window_draw), output);
|
||||
|
||||
@@ -190,6 +186,10 @@ void wd_create_overlay(struct wd_output *output) {
|
||||
|
||||
void wd_destroy_overlay(struct wd_output *output) {
|
||||
if (output->overlay_window != NULL) {
|
||||
if (output->overlay_layer_surface != NULL) {
|
||||
zwlr_layer_surface_v1_destroy(output->overlay_layer_surface);
|
||||
output->overlay_layer_surface = NULL;
|
||||
}
|
||||
gtk_widget_destroy(output->overlay_window);
|
||||
output->overlay_window = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user