summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/panels/panel.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c
index 2a2d603..2c89ac7 100644
--- a/src/gui/panels/panel.c
+++ b/src/gui/panels/panel.c
@@ -725,6 +725,7 @@ static gboolean g_panel_item_draw_mask(GtkWidget *widget, cairo_t *cr, GPanelIte
void g_panel_item_switch_to_updating_mask(GPanelItem *item)
{
GtkWidget *content; /* Composant à faire évoluer */
+ GdkWindow *window; /* Fenêtre au contenu à copier */
int width; /* Largeur du composant actuel */
int height; /* Hauteur du composant actuel */
cairo_t *cr; /* Pinceau pour les dessins */
@@ -734,22 +735,28 @@ void g_panel_item_switch_to_updating_mask(GPanelItem *item)
/* Copie de l'affichage courant */
+ assert(item->surface == NULL);
+
content = GTK_WIDGET(gtk_builder_get_object(item->builder, "content"));
- width = gtk_widget_get_allocated_width(content);
- height = gtk_widget_get_allocated_height(content);
+ window = gtk_widget_get_window(content);
- assert(item->surface == NULL);
+ if (window != NULL)
+ {
+ width = gtk_widget_get_allocated_width(content);
+ height = gtk_widget_get_allocated_height(content);
+
+ item->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
- item->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create(item->surface);
- cr = cairo_create(item->surface);
+ gdk_cairo_set_source_window(cr, window, 0, 0);
- gdk_cairo_set_source_window(cr, gtk_widget_get_window(content), 0, 0);
+ cairo_paint(cr);
- cairo_paint(cr);
+ cairo_destroy(cr);
- cairo_destroy(cr);
+ }
/* Sauvegarde de l'éventuelle position */
@@ -771,7 +778,8 @@ void g_panel_item_switch_to_updating_mask(GPanelItem *item)
gtk_spinner_start(GTK_SPINNER(mask));
- g_signal_connect(mask, "draw", G_CALLBACK(g_panel_item_draw_mask), item);
+ if (item->surface != NULL)
+ g_signal_connect(mask, "draw", G_CALLBACK(g_panel_item_draw_mask), item);
gtk_stack_set_visible_child(stack, mask);
@@ -825,7 +833,10 @@ void g_panel_item_switch_to_updated_content(GPanelItem *item)
/* Supression de la copie d'affichage */
- cairo_surface_destroy(item->surface);
- item->surface = NULL;
+ if (item->surface != NULL)
+ {
+ cairo_surface_destroy(item->surface);
+ item->surface = NULL;
+ }
}