Gtk.OffscreenWindow.prototype.get_surface

function get_surface():cairo.Surface {
    // Gjs wrapper for gtk_offscreen_window_get_surface()
}

Retrieves a snapshot of the contained widget in the form of a #cairo_surface_t. If you need to keep this around over window resizes then you should add a reference to it.

Since 2.20

Returns

A #cairo_surface_t pointer to the offscreen surface, or null.