CdkDrawingContext: CDK 3 Reference Manual

## CdkDrawingContext CdkDrawingContext — Drawing context for CDK windows |

## Functions

CdkWindow * | cdk_drawing_context_get_window ()
cairo_region_t * | cdk_drawing_context_get_clip ()
cairo_t * | cdk_drawing_context_get_cairo_context ()
gboolean | cdk_drawing_context_is_valid ()

## Properties

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

## Types and Values

| CdkDrawingContext

## Object Hierarchy

        GObject
        ╰── CdkDrawingContext

## Includes

    #include <cdk/cdkwayland.h>

## Description

CdkDrawingContext is an object that represents the current drawing state of a CdkWindow.

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

A CdkDrawingContext can only be created by calling `cdk_window_begin_draw_frame()` and will be valid until a call to `cdk_window_end_draw_frame()`.

CdkDrawingContext is available since CDK 3.22

## Functions

### cdk_drawing_context_get_window ()

    CdkWindow *
    cdk_drawing_context_get_window (CdkDrawingContext *context);

Retrieves the window that created the drawing `context` .

#### Parameters

context | a CdkDrawingContext |

#### Returns

a CdkWindow.

[transfer none]

Since: 3.22

### cdk_drawing_context_get_clip ()

    cairo_region_t *
    cdk_drawing_context_get_clip (CdkDrawingContext *context);

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

#### Parameters

context | a CdkDrawingContext |

#### Returns

a Cairo region.

[transfer full][nullable]

Since: 3.22

### cdk_drawing_context_get_cairo_context ()

    cairo_t *
    cdk_drawing_context_get_cairo_context (CdkDrawingContext *context);

Retrieves a Cairo context to be used to draw on the CdkWindow that created the CdkDrawingContext.

The returned context is guaranteed to be valid as long as the CdkDrawingContext is valid, that is between a call to `cdk_window_begin_draw_frame()` and `cdk_window_end_draw_frame()`.

#### Parameters

context | a CdkDrawingContext |

#### Returns

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

[transfer none]

Since: 3.22

### cdk_drawing_context_is_valid ()

    gboolean
    cdk_drawing_context_is_valid (CdkDrawingContext *context);

Checks whether the given CdkDrawingContext is valid.

#### Parameters

context | a CdkDrawingContext |

#### Returns

`TRUE` if the context is valid

Since: 3.22

## Types and Values

### CdkDrawingContext

    typedef struct _CdkDrawingContext CdkDrawingContext;

## Property Details

### The `“clip”` property

      “clip”                     CairoRegion *

The clip region applied to the drawing context.

Owner: CdkDrawingContext

Flags: Read / Write / Construct Only

Since: 3.22

### The `“window”` property

      “window”                   CdkWindow *

The CdkWindow that created the drawing context.

Owner: CdkDrawingContext

Flags: Read / Write / Construct Only

Since: 3.22