Struct
GdkEvent
Description [src]
union GdkEvent {
GdkEventType type;
GdkEventAny any;
GdkEventExpose expose;
GdkEventVisibility visibility;
GdkEventMotion motion;
GdkEventButton button;
GdkEventTouch touch;
GdkEventScroll scroll;
GdkEventKey key;
GdkEventCrossing crossing;
GdkEventFocus focus_change;
GdkEventConfigure configure;
GdkEventProperty property;
GdkEventSelection selection;
GdkEventOwnerChange owner_change;
GdkEventProximity proximity;
GdkEventDND dnd;
GdkEventWindowState window_state;
GdkEventSetting setting;
GdkEventGrabBroken grab_broken;
GdkEventTouchpadSwipe touchpad_swipe;
GdkEventTouchpadPinch touchpad_pinch;
GdkEventPadButton pad_button;
GdkEventPadAxis pad_axis;
GdkEventPadGroupMode pad_group_mode;
}
A GdkEvent
contains a union of all of the event types,
and allows access to the data fields in a number of ways.
The event type is always the first field in all of the event types, and can always be accessed with the following code, no matter what type of event it is:
GdkEvent *event;
GdkEventType type;
type = event->type;
To access other fields of the event, the pointer to the event
can be cast to the appropriate event type, or the union member
name can be used. For example if the event type is GDK_BUTTON_PRESS
then the x coordinate of the button press can be accessed with:
GdkEvent *event;
gdouble x;
x = ((GdkEventButton*)event)->x;
or:
GdkEvent *event;
gdouble x;
x = event->button.x;
Structure members
type
The
GdkEventType
.any
A
GdkEventAny
.expose
A
GdkEventExpose
.visibility
A
GdkEventVisibility
.motion
A
GdkEventMotion
.button
A
GdkEventButton
.touch
A
GdkEventTouch
.scroll
A
GdkEventScroll
.key
A
GdkEventKey
.crossing
A
GdkEventCrossing
.focus_change
A
GdkEventFocus
.configure
A
GdkEventConfigure
.property
A
GdkEventProperty
.selection
A
GdkEventSelection
.owner_change
A
GdkEventOwnerChange
.proximity
A
GdkEventProximity
.dnd
A
GdkEventDND
.window_state
A
GdkEventWindowState
.setting
A
GdkEventSetting
.grab_broken
A
GdkEventGrabBroken
.touchpad_swipe
A
GdkEventTouchpadSwipe
.touchpad_pinch
A
GdkEventTouchpadPinch
.pad_button
A
GdkEventPadButton
.pad_axis
A
GdkEventPadAxis
.pad_group_mode
A
GdkEventPadGroupMode
.
Functions
gdk_event_get
Checks all open displays for a GdkEvent
to process,to be processed
on, fetching events from the windowing system if necessary.
See gdk_display_get_event().
gdk_event_peek
If there is an event waiting in the event queue of some open display, returns a copy of it. See gdk_display_peek_event().
gdk_event_request_motions
Request more motion notifies if event
is a motion notify hint event.
since: 2.12
Instance methods
gdk_events_get_angle
If both events contain X/Y information, this function will return TRUE
and return in angle
the relative angle from event1
to event2
. The rotation
direction for positive angles is from the positive X axis towards the positive
Y axis.
since: 3.0
gdk_events_get_center
If both events contain X/Y information, the center of both coordinates
will be returned in x
and y
.
since: 3.0
gdk_events_get_distance
If both events have X/Y information, the distance between both coordinates
(as in a straight line going from event1
to event2
) will be returned.
since: 3.0
gdk_event_copy
Copies a GdkEvent
, copying or incrementing the reference count of the
resources associated with it (e.g. GdkWindow
’s and strings).
gdk_event_free
Frees a GdkEvent
, freeing or decrementing any resources associated with it.
Note that this function should only be called with events returned from
functions such as gdk_event_peek(), gdk_event_get(), gdk_event_copy()
and gdk_event_new().
gdk_event_get_device
If the event contains a “device” field, this function will return
it, else it will return NULL
.
since: 3.0
gdk_event_get_device_tool
If the event was generated by a device that supports
different tools (eg. a tablet), this function will
return a GdkDeviceTool
representing the tool that
caused the event. Otherwise, NULL
will be returned.
since: 3.22
gdk_event_get_event_sequence
If event
if of type GDK_TOUCH_BEGIN
, GDK_TOUCH_UPDATE
,
GDK_TOUCH_END
or GDK_TOUCH_CANCEL
, returns the GdkEventSequence
to which the event belongs. Otherwise, return NULL
.
since: 3.4
gdk_event_get_pointer_emulated
event: a GdkEvent
Returns whether this event is an ‘emulated’ pointer event (typically from a touch event), as opposed to a real one.
since: 3.22
gdk_event_get_screen
Returns the screen for the event. The screen is
typically the screen for event->any.window
, but
for events such as mouse events, it is the screen
where the pointer was when the event occurs -
that is, the screen which has the root window
to which event->motion.x_root
and
event->motion.y_root
are relative.
since: 2.2
gdk_event_get_source_device
This function returns the hardware (slave) GdkDevice
that has
triggered the event, falling back to the virtual (master) device
(as in gdk_event_get_device()) if the event wasn’t caused by
interaction with a hardware device. This may happen for example
in synthesized crossing events after a GdkWindow
updates its
geometry or a grab is acquired/released.
since: 3.0
gdk_event_get_state
If the event contains a “state” field, puts that field in state
. Otherwise
stores an empty state (0). Returns TRUE
if there was a state field
in the event. event
may be NULL
, in which case it’s treated
as if the event had no state field.
gdk_event_get_time
Returns the time stamp from event
, if there is one; otherwise
returns #GDK_CURRENT_TIME. If event
is NULL
, returns #GDK_CURRENT_TIME.
gdk_event_is_scroll_stop_event
Check whether a scroll event is a stop scroll event. Scroll sequences with smooth scroll information may provide a stop scroll event once the interaction with the device finishes, e.g. by lifting a finger. This stop scroll event is the signal that a widget may trigger kinetic scrolling based on the current velocity.
since: 3.20
gdk_event_put
Appends a copy of the given event onto the front of the event
queue for event->any.window’s display, or the default event
queue if event->any.window is NULL
. See gdk_display_put_event().
gdk_event_set_device
Sets the device for event
to device
. The event must
have been allocated by GTK+, for instance, by gdk_event_copy().
since: 3.0
gdk_event_set_screen
Sets the screen for event
to screen
. The event must
have been allocated by GTK+, for instance, by gdk_event_copy().
since: 2.2
gdk_event_triggers_context_menu
This function returns whether a GdkEventButton
should trigger a
context menu, according to platform conventions. The right mouse
button always triggers context menus. Additionally, if
gdk_keymap_get_modifier_mask()
returns a non-0 mask for
GDK_MODIFIER_INTENT_CONTEXT_MENU
, then the left mouse button will
also trigger a context menu if this modifier is pressed.
since: 3.4