GdkDrawingContext: GDK 4 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
GdkDrawContext * | paint-context | Read / Write / Construct Only
GdkWindow * | window | Read / Write / Construct Only

## Types and Values

| GdkDrawingContext

## Object Hierarchy

        GObject
        ╰── GdkDrawingContext

## Includes

    #include <gdk/gdk.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 `context` must have been created without a GdkDrawContext for this function to work. If `gdk_drawing_context_get_paint_context()` does not return `NULL`, then this function will.

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()`.

#### Parameters

context | a GdkDrawingContext created with a `NULL` paint context |

#### 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. `NULL` is returned when a paint context is in used.

[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

## Types and Values

### GdkDrawingContext

    typedef struct _GdkDrawingContext GdkDrawingContext;

## Property Details

### The `“clip”` property

      “clip”                     CairoRegion *

The clip region applied to the drawing context.

Flags: Read / Write / Construct Only

Since: 3.22

### The `“paint-context”` property

      “paint-context”            GdkDrawContext *

The GdkDrawContext used to draw or `NULL` if Cairo is used.

Flags: Read / Write / Construct Only

Since: 3.90

### The `“window”` property

      “window”                   GdkWindow *

The GdkWindow that created the drawing context.

Flags: Read / Write / Construct Only

Since: 3.22