GdkDrawingContext: GDK 3 Reference Manual

## GdkDrawingContext GdkDrawingContext — Drawing context for GDK windows |

## Functions

GdkWindow * | gdk_drawing_context_get_window ()
cairo_region_t * | gdk_drawing_context_get_clip ()
cairo_t * | gdk_drawing_context_get_cairo_context ()
gboolean | gdk_drawing_context_is_valid ()

## Properties

CairoRegion * | clip | Read / Write / Construct Only
GdkWindow * | window | Read / Write / Construct Only

## Types and Values

| GdkDrawingContext

## Object Hierarchy

        GObject
        ╰── GdkDrawingContext

## Includes

    #include <gdk/gdkwayland.h>

## Description

GdkDrawingContext is an object that represents the current drawing state of a GdkWindow.

It's possible to use a GdkDrawingContext to draw on a GdkWindow via rendering API like Cairo or OpenGL.

A GdkDrawingContext can only be created by calling `gdk_window_begin_draw_frame()` and will be valid until a call to `gdk_window_end_draw_frame()`.

GdkDrawingContext is available since GDK 3.22

## Functions

### gdk_drawing_context_get_window ()

    GdkWindow *
    gdk_drawing_context_get_window (GdkDrawingContext *context);

Retrieves the window that created the drawing `context` .

#### Parameters

context | a GdkDrawingContext |

#### Returns

a GdkWindow.

[transfer none]

Since: 3.22

### gdk_drawing_context_get_clip ()

    cairo_region_t *
    gdk_drawing_context_get_clip (GdkDrawingContext *context);

Retrieves a copy of the clip region used when creating the `context` .

#### Parameters

context | a GdkDrawingContext |

#### Returns

a Cairo region.

[transfer full][nullable]

Since: 3.22

### gdk_drawing_context_get_cairo_context ()

    cairo_t *
    gdk_drawing_context_get_cairo_context (GdkDrawingContext *context);

Retrieves a Cairo context to be used to draw on the GdkWindow that created the GdkDrawingContext.

The returned context is guaranteed to be valid as long as the GdkDrawingContext is valid, that is between a call to `gdk_window_begin_draw_frame()` and `gdk_window_end_draw_frame()`.

#### Returns

a Cairo context to be used to draw the contents of the GdkWindow. The context is owned by the GdkDrawingContext and should not be destroyed.

[transfer none]

Since: 3.22

### gdk_drawing_context_is_valid ()

    gboolean
    gdk_drawing_context_is_valid (GdkDrawingContext *context);

Checks whether the given GdkDrawingContext is valid.

#### Parameters

context | a GdkDrawingContext |

#### Returns

`TRUE` if the context is valid

Since: 3.22

## Property Details

### The `“clip”` property

      “clip”                     CairoRegion *

The clip region applied to the drawing context.

Owner: GdkDrawingContext

Flags: Read / Write / Construct Only

Since: 3.22

### The `“window”` property

      “window”                   GdkWindow *

The GdkWindow that created the drawing context.

Owner: GdkDrawingContext

Flags: Read / Write / Construct Only

Since: 3.22