From 3c9687fcf1efb5f999320b1130d824b70c0d2283 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 14 Feb 2022 02:18:51 -0800 Subject: [PATCH] macos: add helper to check if surface is opaque --- gdk/macos/gdkmacossurface-private.h | 1 + gdk/macos/gdkmacossurface.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/gdk/macos/gdkmacossurface-private.h b/gdk/macos/gdkmacossurface-private.h index ccb8a83179..61ea1ba00d 100644 --- a/gdk/macos/gdkmacossurface-private.h +++ b/gdk/macos/gdkmacossurface-private.h @@ -131,6 +131,7 @@ void _gdk_macos_surface_set_opacity (GdkMacosSurface void _gdk_macos_surface_get_root_coords (GdkMacosSurface *self, int *x, int *y); +gboolean _gdk_macos_surface_is_opaque (GdkMacosSurface *self); G_END_DECLS diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c index a2c7bb485d..42ac59d059 100644 --- a/gdk/macos/gdkmacossurface.c +++ b/gdk/macos/gdkmacossurface.c @@ -603,6 +603,27 @@ _gdk_macos_surface_get_shadow (GdkMacosSurface *self, *right = self->shadow_right; } +gboolean +_gdk_macos_surface_is_opaque (GdkMacosSurface *self) +{ + g_return_val_if_fail (GDK_IS_MACOS_SURFACE (self), FALSE); + + if (self->opaque_region != NULL && + cairo_region_num_rectangles (self->opaque_region) == 1) + { + cairo_rectangle_int_t extents; + + cairo_region_get_extents (self->opaque_region, &extents); + + return (extents.x == 0 && + extents.y == 0 && + extents.width == GDK_SURFACE (self)->width && + extents.height == GDK_SURFACE (self)->height); + } + + return FALSE; +} + const char * _gdk_macos_surface_get_title (GdkMacosSurface *self) { -- 2.30.2