diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 8949daecb8..47d340b5eb 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -386,6 +386,8 @@ struct _GdkWindow GdkWindowInvalidateHandlerFunc invalidate_handler; GdkDrawingContext *drawing_context; + + cairo_region_t *opaque_region; }; #define GDK_WINDOW_TYPE(d) ((((GdkWindow *)(d)))->window_type) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 1c7ea5340c..c0e0a7d4b2 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -588,6 +588,9 @@ gdk_window_finalize (GObject *object) if (window->devices_inside) g_list_free (window->devices_inside); + if (window->opaque_region) + cairo_region_destroy (window->opaque_region); + G_OBJECT_CLASS (gdk_window_parent_class)->finalize (object); } @@ -11879,6 +11882,14 @@ gdk_window_set_opaque_region (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (!GDK_WINDOW_DESTROYED (window)); + if (cairo_region_equal (window->opaque_region, region)) + return; + + g_clear_pointer (&window->opaque_region, cairo_region_destroy); + + if (region != NULL) + window->opaque_region = cairo_region_reference (region); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); if (impl_class->set_opaque_region)