mirror of
https://github.com/artizirk/wdisplays.git
synced 2026-10-03 12:55:42 +03:00
Merge branch 'overlay-crash-fixes'
This commit is contained in:
+10
-4
@@ -308,6 +308,12 @@ static void wd_output_destroy(struct wd_output *output) {
|
||||
if (output->state->layer_shell != NULL) {
|
||||
wd_destroy_overlay(output);
|
||||
}
|
||||
struct wd_head *head;
|
||||
wl_list_for_each(head, &output->state->heads, link) {
|
||||
if (head->output == output) {
|
||||
head->output = NULL;
|
||||
}
|
||||
}
|
||||
zxdg_output_v1_destroy(output->xdg_output);
|
||||
free(output->name);
|
||||
free(output);
|
||||
@@ -676,14 +682,14 @@ void wd_capture_wait(struct wd_state *state, struct wl_display *display) {
|
||||
}
|
||||
|
||||
void wd_state_destroy(struct wd_state *state) {
|
||||
struct wd_head *head, *head_tmp;
|
||||
wl_list_for_each_safe(head, head_tmp, &state->heads, link) {
|
||||
wd_head_destroy(head);
|
||||
}
|
||||
struct wd_output *output, *output_tmp;
|
||||
wl_list_for_each_safe(output, output_tmp, &state->outputs, link) {
|
||||
wd_output_destroy(output);
|
||||
}
|
||||
struct wd_head *head, *head_tmp;
|
||||
wl_list_for_each_safe(head, head_tmp, &state->heads, link) {
|
||||
wd_head_destroy(head);
|
||||
}
|
||||
if (state->layer_shell != NULL) {
|
||||
zwlr_layer_shell_v1_destroy(state->layer_shell);
|
||||
}
|
||||
|
||||
+13
-9
@@ -60,7 +60,12 @@ 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);
|
||||
if (head == NULL)
|
||||
return;
|
||||
|
||||
uint32_t screen_width = head->custom_mode.width;
|
||||
uint32_t screen_height = head->custom_mode.height;
|
||||
@@ -97,9 +102,6 @@ static void resize(struct wd_output *output) {
|
||||
|
||||
struct wl_surface *surface = gdk_wayland_window_get_wl_surface(window);
|
||||
wl_surface_commit(surface);
|
||||
|
||||
GdkDisplay *display = gdk_window_get_display(window);
|
||||
wl_display_roundtrip(gdk_wayland_display_get_wl_display(display));
|
||||
}
|
||||
|
||||
void wd_redraw_overlay(struct wd_output *output) {
|
||||
@@ -136,16 +138,16 @@ void window_map(GtkWidget *widget, gpointer data) {
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);
|
||||
|
||||
resize(output);
|
||||
}
|
||||
|
||||
void window_unmap(GtkWidget *widget, gpointer data) {
|
||||
struct wd_output *output = data;
|
||||
zwlr_layer_surface_v1_destroy(output->overlay_layer_surface);
|
||||
GdkDisplay *display = gdk_window_get_display(window);
|
||||
wl_display_roundtrip(gdk_wayland_display_get_wl_display(display));
|
||||
}
|
||||
|
||||
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);
|
||||
if (head == NULL)
|
||||
return TRUE;
|
||||
|
||||
GtkStyleContext *style_ctx = gtk_widget_get_style_context(widget);
|
||||
GdkRGBA fg;
|
||||
@@ -177,8 +179,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 +190,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