Events

Events — Event handling

Functions

Types and Values

Object Hierarchy

    GBoxed
    ╰── GrxEvent

Includes

#include <grx-3.0.h>

Description

TODO

Functions

grx_event_new ()

GrxEvent *
grx_event_new (GrxEventType type);

Allocates a new GrxEvent.

Parameters

type

the event type

 

Returns

the event struct.

[transfer full]


grx_events_pending ()

gboolean
grx_events_pending (void);

Checks if there are any events in the queue.

Returns

TRUE if there are events, otherwise FALSE


grx_event_peek ()

GrxEvent *
grx_event_peek (void);

Gets the first event in the queue, but does not remove the event from the queue.

Returns

the event.

[transfer none]


grx_event_get ()

GrxEvent *
grx_event_get (void);

Gets the first event in the queue, and removes that event from the queue.

Free the event with grx_event_free().

Returns

the event.

[transfer full]


grx_event_put ()

void
grx_event_put (GrxEvent *event);

Adds a copy of event to the end of the queue.

Parameters

event

the event

 

grx_event_copy ()

GrxEvent *
grx_event_copy (GrxEvent *event);

Creates a copy of event .

Parameters

event

the event to copy

 

Returns

a copy of event .

[transfer full]


grx_event_free ()

void
grx_event_free (GrxEvent *event);

Frees event .

Parameters

event

the event.

[transfer full]

grx_event_get_event_type ()

GrxEventType
grx_event_get_event_type (GrxEvent *event);

Gets the type of event.

Parameters

event

the event

 

Returns

the event type


grx_event_get_modifiers ()

GrxModifierFlags
grx_event_get_modifiers (GrxEvent *event);

Gets the modifier keys for the event.

Events that do not support modifier keys will always return 0.

Parameters

event

the event

 

Returns

the modifier keys (as bit flags)


grx_event_get_device ()

GrxDevice *
grx_event_get_device (GrxEvent *event);

Gets the device associated with the event.

Parameters

event

the event

 

Returns

the device or NULL.

[transfer none]


grx_event_get_keysym ()

GrxKey
grx_event_get_keysym (GrxEvent *event);

Gets the key symbol for a key event.

Parameters

event

the event

 

Returns

the key symbol or GRX_KEY_VOID_SYMBOL if event is not a GrxKeyEvent


grx_event_get_keychar ()

gunichar
grx_event_get_keychar (GrxEvent *event);

Gets the unicode character for a key event.

Parameters

event

the event

 

Returns

the unicode character or 0 if event is not a GrxKeyEvent


grx_event_get_keycode ()

guint32
grx_event_get_keycode (GrxEvent *event);

Gets the platform dependant key code for the event.

Parameters

event

the event

 

Returns

the key code or 0 if event is not a GrxKeyEvent


grx_event_get_coords ()

void
grx_event_get_coords (GrxEvent *event,
                      gint *x,
                      gint *y);

Gets the screen coordinates of an event.

x and y are set to -1 if event is not a GrxButtonEvent, GrxMotionEvent or GrxTouchEvent.

Parameters

event

the event

 

x

the x coordinate.

[out]

y

the y coordinate.

[out]

grx_event_get_button ()

guint32
grx_event_get_button (GrxEvent *event);

Gets the button for a button event

Parameters

event

the event

 

Returns

the button index or 0 if event is not a GrxButtonEvent.


GrxEventHandlerFunc ()

void
(*GrxEventHandlerFunc) (GrxEvent *event,
                        gpointer user_data);

Specifies the type of function passed to grx_event_handler_add().

Parameters

event

pointer to the event

 

user_data

data passed to the function, set when the source was created

 

grx_event_handler_source_new ()

GSource *
grx_event_handler_source_new (void);

Creates a new source that will be dispatched when events occur.

The source will not initially be associated with any GMainContext and must be added to one with g_source_attach() before it will be executed. The callback function (set with g_source_set_callback()) is expected to be a GrxEventHandlerFunc.

Generally, you will want to use grx_event_handler_add() instead.

Returns

a new GSource


grx_event_handler_add ()

guint
grx_event_handler_add (GrxEventHandlerFunc callback,
                       gpointer user_data,
                       GDestroyNotify notify);

Creates a new event source and adds it to the default main context.

Parameters

callback

the function to be called when an event occurs

 

user_data

user data passed to callback .

[transfer full][nullable]

notify

callback to destroy user_data when source is removed.

[nullable]

Returns

the source id

Types and Values

enum GrxModifierFlags

Keyboard key modifier flags.

Members

GRX_MODIFIER_SHIFT

shift modifier

 

GRX_MODIFIER_CTRL

control modifier

 

GRX_MODIFIER_ALT

alt (option) modifier

 

GRX_MODIFIER_SUPER

super (windows/command key) modifier

 

enum GrxEventType

Indicates the type of event.

Members

GRX_EVENT_TYPE_NONE

indicates there is no event

 

GRX_EVENT_TYPE_APP_ACTIVATE

application activated event, for example, this is triggered by console switching by the linuxfb video driver or when using a graphical desktop driver such as gtk3, this is triggered when the window becomes the active window on the desktop window is the active window

 

GRX_EVENT_TYPE_APP_DEACTIVATE

application deactivated event, for example, this is triggered by console switching by the linuxfb video driver or when using a graphical desktop driver such as gtk3, this is triggered when the window is no longer the active window on the desktop

 

GRX_EVENT_TYPE_APP_QUIT

application request to quit event, for example, this is triggered the window is closed in a desktop application

 

GRX_EVENT_TYPE_KEY_DOWN

key press event

 

GRX_EVENT_TYPE_KEY_UP

key release event

 

GRX_EVENT_TYPE_POINTER_MOTION

pointer (mouse) motion event

 

GRX_EVENT_TYPE_BUTTON_PRESS

button press event

 

GRX_EVENT_TYPE_BUTTON_RELEASE

button release event

 

GRX_EVENT_TYPE_BUTTON_DOUBLE_PRESS

button double-press event

 

GRX_EVENT_TYPE_TOUCH_DOWN

begin touch event

 

GRX_EVENT_TYPE_TOUCH_MOTION

touch motion event

 

GRX_EVENT_TYPE_TOUCH_UP

end touch event

 

GRX_EVENT_TYPE_TOUCH_CANCEL

cancel touch event

 

GrxKeyEvent

typedef struct {
    GrxEventType type;
    GrxKey keysym;
    gunichar unichar;
    guint32 code;
    GrxModifierFlags modifiers;
    GrxDevice *device;
} GrxKeyEvent;

Structure that holds information about a keyboard key event.

Members

GrxEventType type;

GRX_EVENT_TYPE_KEY_DOWN or GRX_EVENT_TYPE_KEY_UP

 

GrxKey keysym;

the key symbol (translated using keymap)

 

gunichar unichar;

the UTF-32 character

 

guint32 code;

the platform dependent raw key code

 

GrxModifierFlags modifiers;

modifier key flags

 

GrxDevice *device;

the originating device

 

GrxMotionEvent

typedef struct {
    GrxEventType type;
    gint32 x;
    gint32 y;
    GrxModifierFlags modifiers;
    GrxDevice *device;
} GrxMotionEvent;

Structure that holds information about a pointer motion event.

Members

GrxEventType type;

GRX_EVENT_TYPE_POINTER_MOTION

 

gint32 x;

the pointer position along the x axis

 

gint32 y;

the pointer position along the y axis

 

GrxModifierFlags modifiers;

modifier key flags

 

GrxDevice *device;

the originating device

 

GrxButtonEvent

typedef struct {
    GrxEventType type;
    guint32 button;
    gint32 x;
    gint32 y;
    GrxModifierFlags modifiers;
    GrxDevice *device;
} GrxButtonEvent;

Structure that holds information about a pointer button press event.

Members

GrxEventType type;

GRX_EVENT_TYPE_BUTTON_PRESS , GRX_EVENT_TYPE_BUTTON_RELEASE or GRX_EVENT_TYPE_BUTTON_DOUBLE_PRESS

 

guint32 button;

the platform dependent button code

 

gint32 x;

the pointer position along the x axis

 

gint32 y;

the pointer position along the y axis

 

GrxModifierFlags modifiers;

modifier key flags

 

GrxDevice *device;

the originating device

 

GrxTouchEvent

typedef struct {
    GrxEventType type;
    gint32 id;
    gint32 x;
    gint32 y;
    GrxModifierFlags modifiers;
    GrxDevice *device;
} GrxTouchEvent;

Structure that holds information about a touch event.

Members

GrxEventType type;

GRX_EVENT_TYPE_TOUCH_DOWN , GRX_EVENT_TYPE_TOUCH_MOTION , GRX_EVENT_TYPE_TOUCH_UP or GRX_EVENT_TYPE_TOUCH_CANCEL

 

gint32 id;

the touch point id (for multi-touch devices)

 

gint32 x;

the X coordinate of the touch event

 

gint32 y;

the Y coordinate of the touch event

 

GrxModifierFlags modifiers;

modifier key flags

 

GrxDevice *device;

the originating device

 

GrxEvent

A union of all event types.

Members

GrxEventType type;

the type of the event

 

GrxKeyEvent key;

the event as GrxKeyEvent

 

GrxMotionEvent motion;

the event as GrxMotionEvent

 

GrxButtonEvent button;

the event as GrxButtonEvent

 

GrxTouchEvent touch;

the event as GrxTouchEvent