--- gtk-4.20.0/gdk/win32/gdkcairocontext-win32.c.orig	2025-09-01 08:19:20.298889200 +0200
+++ gtk-4.20.0/gdk/win32/gdkcairocontext-win32.c	2025-09-01 08:19:29.681150600 +0200
@@ -134,8 +134,9 @@
 {
   GdkWin32CairoContext *self = GDK_WIN32_CAIRO_CONTEXT (context);
   GdkSurface *surface = gdk_draw_context_get_surface (context);
+  GdkWin32Display *display = GDK_WIN32_DISPLAY (gdk_draw_context_get_display (context));
 
-  if (!GDK_SURFACE_DESTROYED (surface))
+  if (!GDK_SURFACE_DESTROYED (surface) && gdk_win32_display_get_dcomp_device (display))
     gdk_win32_surface_set_dcomp_content (GDK_WIN32_SURFACE (surface), NULL);
 
   gdk_win32_com_clear (&self->staging_texture);
