Cursors

Cursors — Standard and pixmap cursors

Functions

Properties

CdkCursorType cursor-type Read / Write / Construct Only
CdkDisplay * display Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── CdkCursor

Includes

#include <cdk/cdk.h>

Description

These functions are used to create and destroy cursors. There is a number of standard cursors, but it is also possible to construct new cursors from pixbufs. There may be limitations as to what kinds of cursors can be constructed on a given display, see cdk_display_supports_cursor_alpha(), cdk_display_supports_cursor_color(), cdk_display_get_default_cursor_size() and cdk_display_get_maximal_cursor_size().

Cursors by themselves are not very interesting, they must be be bound to a window for users to see them. This is done with cdk_window_set_cursor() or by setting the cursor member of the CdkWindowAttr passed to cdk_window_new().

Functions

cdk_cursor_new ()

CdkCursor *
cdk_cursor_new (CdkCursorType cursor_type);

cdk_cursor_new has been deprecated since version 3.16 and should not be used in newly-written code.

Use cdk_cursor_new_for_display() instead.

Creates a new cursor from the set of builtin cursors for the default display. See cdk_cursor_new_for_display().

To make the cursor invisible, use CDK_BLANK_CURSOR.

Parameters

cursor_type

cursor to create

 

Returns

a new CdkCursor


cdk_cursor_new_from_pixbuf ()

CdkCursor *
cdk_cursor_new_from_pixbuf (CdkDisplay *display,
                            GdkPixbuf *pixbuf,
                            gint x,
                            gint y);

Creates a new cursor from a pixbuf.

Not all CDK backends support RGBA cursors. If they are not supported, a monochrome approximation will be displayed. The functions cdk_display_supports_cursor_alpha() and cdk_display_supports_cursor_color() can be used to determine whether RGBA cursors are supported; cdk_display_get_default_cursor_size() and cdk_display_get_maximal_cursor_size() give information about cursor sizes.

If x or y are -1, the pixbuf must have options named “x_hot” and “y_hot”, resp., containing integer values between 0 and the width resp. height of the pixbuf. (Since: 3.0)

On the X backend, support for RGBA cursors requires a sufficently new version of the X Render extension.

Parameters

display

the CdkDisplay for which the cursor will be created

 

pixbuf

the GdkPixbuf containing the cursor image

 

x

the horizontal offset of the “hotspot” of the cursor.

 

y

the vertical offset of the “hotspot” of the cursor.

 

Returns

a new CdkCursor.

Since: 2.4


cdk_cursor_new_from_surface ()

CdkCursor *
cdk_cursor_new_from_surface (CdkDisplay *display,
                             cairo_surface_t *surface,
                             gdouble x,
                             gdouble y);

Creates a new cursor from a cairo image surface.

Not all CDK backends support RGBA cursors. If they are not supported, a monochrome approximation will be displayed. The functions cdk_display_supports_cursor_alpha() and cdk_display_supports_cursor_color() can be used to determine whether RGBA cursors are supported; cdk_display_get_default_cursor_size() and cdk_display_get_maximal_cursor_size() give information about cursor sizes.

On the X backend, support for RGBA cursors requires a sufficently new version of the X Render extension.

Parameters

display

the CdkDisplay for which the cursor will be created

 

surface

the cairo image surface containing the cursor pixel data

 

x

the horizontal offset of the “hotspot” of the cursor

 

y

the vertical offset of the “hotspot” of the cursor

 

Returns

a new CdkCursor.

Since: 3.10


cdk_cursor_new_from_name ()

CdkCursor *
cdk_cursor_new_from_name (CdkDisplay *display,
                          const gchar *name);

Creates a new cursor by looking up name in the current cursor theme.

A recommended set of cursor names that will work across different platforms can be found in the CSS specification:

  • "none"

  • "default"

  • "help"

  • "pointer"

  • "context-menu"

  • "progress"

  • "wait"

  • "cell"

  • "crosshair"

  • "text"

  • "vertical-text"

  • "alias"

  • "copy"

  • "no-drop"

  • "move"

  • "not-allowed"

  • "grab"

  • "grabbing"

  • "all-scroll"

  • "col-resize"

  • "row-resize"

  • "n-resize"

  • "e-resize"

  • "s-resize"

  • "w-resize"

  • "ne-resize"

  • "nw-resize"

  • "sw-resize"

  • "se-resize"

  • "ew-resize"

  • "ns-resize"

  • "nesw-resize"

  • "nwse-resize"

  • "zoom-in"

  • "zoom-out"

Parameters

display

the CdkDisplay for which the cursor will be created

 

name

the name of the cursor

 

Returns

a new CdkCursor, or NULL if there is no cursor with the given name.

[nullable]

Since: 2.8


cdk_cursor_new_for_display ()

CdkCursor *
cdk_cursor_new_for_display (CdkDisplay *display,
                            CdkCursorType cursor_type);

Creates a new cursor from the set of builtin cursors.

Parameters

display

the CdkDisplay for which the cursor will be created

 

cursor_type

cursor to create

 

Returns

a new CdkCursor, or NULL on failure.

[nullable][transfer full]

Since: 2.2


cdk_cursor_get_display ()

CdkDisplay *
cdk_cursor_get_display (CdkCursor *cursor);

Returns the display on which the CdkCursor is defined.

Parameters

cursor

a CdkCursor.

 

Returns

the CdkDisplay associated to cursor .

[transfer none]

Since: 2.2


cdk_cursor_get_image ()

GdkPixbuf *
cdk_cursor_get_image (CdkCursor *cursor);

Returns a GdkPixbuf with the image used to display the cursor.

Note that depending on the capabilities of the windowing system and on the cursor, CDK may not be able to obtain the image data. In this case, NULL is returned.

Parameters

cursor

a CdkCursor

 

Returns

a GdkPixbuf representing cursor , or NULL.

[nullable][transfer full]

Since: 2.8


cdk_cursor_get_surface ()

cairo_surface_t *
cdk_cursor_get_surface (CdkCursor *cursor,
                        gdouble *x_hot,
                        gdouble *y_hot);

Returns a cairo image surface with the image used to display the cursor.

Note that depending on the capabilities of the windowing system and on the cursor, CDK may not be able to obtain the image data. In this case, NULL is returned.

Parameters

cursor

a CdkCursor

 

x_hot

Location to store the hotspot x position, or NULL.

[optional][out]

y_hot

Location to store the hotspot y position, or NULL.

[optional][out]

Returns

a cairo_surface_t representing cursor , or NULL.

[nullable][transfer full]

Since: 3.10


cdk_cursor_get_cursor_type ()

CdkCursorType
cdk_cursor_get_cursor_type (CdkCursor *cursor);

Returns the cursor type for this cursor.

Parameters

cursor

a CdkCursor

 

Returns

a CdkCursorType

Since: 2.22


cdk_cursor_ref ()

CdkCursor *
cdk_cursor_ref (CdkCursor *cursor);

cdk_cursor_ref has been deprecated since version 3.0 and should not be used in newly-written code.

Use g_object_ref() instead

Adds a reference to cursor .

Parameters

cursor

a CdkCursor

 

Returns

Same cursor that was passed in.

[transfer full]


cdk_cursor_unref ()

void
cdk_cursor_unref (CdkCursor *cursor);

cdk_cursor_unref has been deprecated since version 3.0 and should not be used in newly-written code.

Use g_object_unref() instead

Removes a reference from cursor , deallocating the cursor if no references remain.

Parameters

cursor

a CdkCursor

 

Types and Values

CdkCursor

typedef struct _CdkCursor CdkCursor;

A CdkCursor represents a cursor. Its contents are private.


enum CdkCursorType

Predefined cursors.

Note that these IDs are directly taken from the X cursor font, and many of these cursors are either not useful, or are not available on other platforms.

The recommended way to create cursors is to use cdk_cursor_new_from_name().

Members

CDK_X_CURSOR

 

CDK_ARROW

 

CDK_BASED_ARROW_DOWN

 

CDK_BASED_ARROW_UP

 

CDK_BOAT

 

CDK_BOGOSITY

 

CDK_BOTTOM_LEFT_CORNER

 

CDK_BOTTOM_RIGHT_CORNER

 

CDK_BOTTOM_SIDE

 

CDK_BOTTOM_TEE

 

CDK_BOX_SPIRAL

 

CDK_CENTER_PTR

 

CDK_CIRCLE

 

CDK_CLOCK

 

CDK_COFFEE_MUG

 

CDK_CROSS

 

CDK_CROSS_REVERSE

 

CDK_CROSSHAIR

 

CDK_DIAMOND_CROSS

 

CDK_DOT

 

CDK_DOTBOX

 

CDK_DOUBLE_ARROW

 

CDK_DRAFT_LARGE

 

CDK_DRAFT_SMALL

 

CDK_DRAPED_BOX

 

CDK_EXCHANGE

 

CDK_FLEUR

 

CDK_GOBBLER

 

CDK_GUMBY

 

CDK_HAND1

 

CDK_HAND2

 

CDK_HEART

 

CDK_ICON

 

CDK_IRON_CROSS

 

CDK_LEFT_PTR

 

CDK_LEFT_SIDE

 

CDK_LEFT_TEE

 

CDK_LEFTBUTTON

 

CDK_LL_ANGLE

 

CDK_LR_ANGLE

 

CDK_MAN

 

CDK_MIDDLEBUTTON

 

CDK_MOUSE

 

CDK_PENCIL

 

CDK_PIRATE

 

CDK_PLUS

 

CDK_QUESTION_ARROW

 

CDK_RIGHT_PTR

 

CDK_RIGHT_SIDE

 

CDK_RIGHT_TEE

 

CDK_RIGHTBUTTON

 

CDK_RTL_LOGO

 

CDK_SAILBOAT

 

CDK_SB_DOWN_ARROW

 

CDK_SB_H_DOUBLE_ARROW

 

CDK_SB_LEFT_ARROW

 

CDK_SB_RIGHT_ARROW

 

CDK_SB_UP_ARROW

 

CDK_SB_V_DOUBLE_ARROW

 

CDK_SHUTTLE

 

CDK_SIZING

 

CDK_SPIDER

 

CDK_SPRAYCAN

 

CDK_STAR

 

CDK_TARGET

 

CDK_TCROSS

 

CDK_TOP_LEFT_ARROW

 

CDK_TOP_LEFT_CORNER

 

CDK_TOP_RIGHT_CORNER

 

CDK_TOP_SIDE

 

CDK_TOP_TEE

 

CDK_TREK

 

CDK_UL_ANGLE

 

CDK_UMBRELLA

 

CDK_UR_ANGLE

 

CDK_WATCH

 

CDK_XTERM

 

CDK_LAST_CURSOR

last cursor type

 

CDK_BLANK_CURSOR

Blank cursor. Since 2.16

 

CDK_CURSOR_IS_PIXMAP

type of cursors constructed with cdk_cursor_new_from_pixbuf()

 

Property Details

The “cursor-type” property

  “cursor-type”              CdkCursorType

Standard cursor type.

Owner: CdkCursor

Flags: Read / Write / Construct Only

Default value: CDK_X_CURSOR


The “display” property

  “display”                  CdkDisplay *

Display of this cursor.

Owner: CdkCursor

Flags: Read / Write / Construct Only