Top | ![]() |
![]() |
![]() |
![]() |
GdkEvent | |
enum | GdkEventType |
enum | GdkEventMask |
enum | GdkScrollDirection |
enum | GdkCrossingMode |
enum | GdkNotifyType |
#define | GDK_CURRENT_TIME |
#define | GDK_PRIORITY_EVENTS |
#define | GDK_PRIORITY_REDRAW |
#define | GDK_EVENT_PROPAGATE |
#define | GDK_EVENT_STOP |
#define | GDK_BUTTON_PRIMARY |
#define | GDK_BUTTON_MIDDLE |
#define | GDK_BUTTON_SECONDARY |
GdkEventSequence |
This section describes functions dealing with events from the window system.
In GTK+ applications the events are handled automatically in
gtk_main_do_event()
and passed on to the appropriate widgets,
so these functions are rarely needed.
GdkEvent *
gdk_event_new (GdkEventType type
);
Creates a new event of the given type. All fields are set to 0.
GdkEvent *
gdk_event_copy (const GdkEvent *event
);
Copies a GdkEvent, copying or incrementing the reference count of the resources associated with it (e.g. GdkSurface’s and strings).
gboolean gdk_event_get_axes (GdkEvent *event
,gdouble **axes
,guint *n_axes
);
Extracts all axis values from an event.
event |
a GdkEvent |
|
axes |
the array of values for all axes. |
[transfer none][out][array length=n_axes] |
n_axes |
the length of array. |
[out] |
gboolean gdk_event_get_axis (const GdkEvent *event
,GdkAxisUse axis_use
,gdouble *value
);
Extract the axis value for a particular axis use from an event structure.
event |
a GdkEvent |
|
axis_use |
the axis use to look for |
|
value |
location to store the value found. |
[out] |
gboolean gdk_event_get_button (const GdkEvent *event
,guint *button
);
Extract the button number from an event.
gboolean gdk_event_get_click_count (const GdkEvent *event
,guint *click_count
);
Extracts the click count from an event.
gboolean gdk_event_get_coords (const GdkEvent *event
,gdouble *x_win
,gdouble *y_win
);
Extract the event surface relative x/y coordinates from an event.
event |
a GdkEvent |
|
x_win |
location to put event surface x coordinate. |
[out][optional] |
y_win |
location to put event surface y coordinate. |
[out][optional] |
gboolean gdk_event_get_keycode (const GdkEvent *event
,guint16 *keycode
);
Extracts the hardware keycode from an event.
Also see gdk_event_get_scancode()
.
gboolean gdk_event_get_keyval (const GdkEvent *event
,guint *keyval
);
Extracts the keyval from an event.
gboolean gdk_event_get_root_coords (const GdkEvent *event
,gdouble *x_root
,gdouble *y_root
);
Extract the root window relative x/y coordinates from an event.
event |
a GdkEvent |
|
x_root |
location to put root window x coordinate. |
[out][optional] |
y_root |
location to put root window y coordinate. |
[out][optional] |
gboolean gdk_event_get_scroll_direction (const GdkEvent *event
,GdkScrollDirection *direction
);
Extracts the scroll direction from an event.
gboolean gdk_event_get_scroll_deltas (const GdkEvent *event
,gdouble *delta_x
,gdouble *delta_y
);
Retrieves the scroll deltas from a GdkEvent
event |
a GdkEvent |
|
delta_x |
return location for X delta. |
[out] |
delta_y |
return location for Y delta. |
[out] |
gboolean
gdk_event_is_scroll_stop_event (const GdkEvent *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.
Stop scroll events always have a a delta of 0/0.
gboolean gdk_event_get_state (const GdkEvent *event
,GdkModifierType *state
);
If the event contains a “state” field, puts that field in state
.
Otherwise stores an empty state (0).
event
may be NULL
, in which case it’s treated
as if the event had no state field.
guint32
gdk_event_get_time (const GdkEvent *event
);
Returns the time stamp from event
, if there is one; otherwise
returns GDK_CURRENT_TIME. If event
is NULL
, returns GDK_CURRENT_TIME.
GdkSurface *
gdk_event_get_surface (const GdkEvent *event
);
Extracts the GdkSurface associated with an event.
GdkEventType
gdk_event_get_event_type (const GdkEvent *event
);
Retrieves the type of the event.
GdkEventSequence *
gdk_event_get_event_sequence (const GdkEvent *event
);
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
.
gboolean gdk_events_get_angle (GdkEvent *event1
,GdkEvent *event2
,gdouble *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.
gboolean gdk_events_get_center (GdkEvent *event1
,GdkEvent *event2
,gdouble *x
,gdouble *y
);
If both events contain X/Y information, the center of both coordinates
will be returned in x
and y
.
gboolean gdk_events_get_distance (GdkEvent *event1
,GdkEvent *event2
,gdouble *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.
gboolean
gdk_event_triggers_context_menu (const GdkEvent *event
);
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.
This function should always be used instead of simply checking for
event->button == GDK_BUTTON_SECONDARY
.
GdkSeat *
gdk_event_get_seat (const GdkEvent *event
);
Returns the GdkSeat this event was generated for.
int
gdk_event_get_scancode (GdkEvent *event
);
Gets the keyboard low-level scancode of a key event.
This is usually hardware_keycode. On Windows this is the high word of WM_KEY{DOWN,UP} lParam which contains the scancode and some extended flags.
gboolean
gdk_event_get_pointer_emulated (GdkEvent *event
);
Returns whether this event is an 'emulated' pointer event (typically from a touch event), as opposed to a real one.
gboolean gdk_event_get_crossing_detail (const GdkEvent *event
,GdkNotifyType *detail
);
Extracts the crossing detail from an event.
gboolean gdk_event_get_crossing_mode (const GdkEvent *event
,GdkCrossingMode *mode
);
Extracts the crossing mode from an event.
GdkDrop *
gdk_event_get_drop (const GdkEvent *event
);
Gets the GdkDrop from a DND event.
gboolean gdk_event_get_focus_in (const GdkEvent *event
,gboolean *focus_in
);
Extracts whether this is a focus-in or focus-out event.
gboolean gdk_event_get_grab_surface (const GdkEvent *event
,GdkSurface **surface
);
Extracts the grab surface from a grab broken event.
GList *
gdk_event_get_motion_history (const GdkEvent *event
);
Retrieves the history of the event
motion, as a list of time and
coordinates.
gboolean gdk_event_get_key_group (const GdkEvent *event
,guint *group
);
Extracts the key group from an event.
gboolean gdk_event_get_key_is_modifier (const GdkEvent *event
,gboolean *is_modifier
);
Extracts whether the event is a key event for a modifier key.
gboolean gdk_event_get_pad_axis_value (const GdkEvent *event
,guint *index
,gdouble *value
);
Extracts the information from a pad event.
event |
a GdkEvent |
|
index |
Return location for the axis index. |
[out] |
value |
Return location for the axis value. |
[out] |
gboolean gdk_event_get_pad_button (const GdkEvent *event
,guint *button
);
Extracts information about the pressed button from a pad event.
gboolean gdk_event_get_pad_group_mode (const GdkEvent *event
,guint *group
,guint *mode
);
Extracts group and mode information from a pad event.
event |
a GdkEvent |
|
group |
return location for the group. |
[out] |
mode |
return location for the mode. |
[out] |
gboolean gdk_event_get_touch_emulating_pointer (const GdkEvent *event
,gboolean *emulating
);
Extracts whether a touch event is emulating a pointer event.
gboolean gdk_event_get_touchpad_angle_delta (const GdkEvent *event
,double *delta
);
Extracts the angle from a touchpad event.
gboolean gdk_event_get_touchpad_deltas (const GdkEvent *event
,double *dx
,double *dy
);
Extracts delta information from a touchpad event.
gboolean gdk_event_get_touchpad_gesture_n_fingers (const GdkEvent *event
,guint *n_fingers
);
Extracts the number of fingers from a touchpad event.
gboolean gdk_event_get_touchpad_gesture_phase (const GdkEvent *event
,GdkTouchpadGesturePhase *phase
);
Extracts the touchpad gesture phase from a touchpad event.
gboolean gdk_event_get_touchpad_scale (const GdkEvent *event
,double *scale
);
Extracts the scale from a touchpad event.
gboolean
gdk_event_is_sent (const GdkEvent *event
);
Returns whether the event was sent explicitly.
gboolean
gdk_get_show_events (void
);
Gets whether event debugging output is enabled.
void
gdk_set_show_events (gboolean show_events
);
Sets whether a trace of received events is output.
Note that GTK+ must be compiled with debugging (that is,
configured using the --enable-debug
option)
to use this option.
void gdk_event_set_display (GdkEvent *event
,GdkDisplay *display
);
Sets the display that an event is associated with.
GdkDisplay *
gdk_event_get_display (const GdkEvent *event
);
Retrieves the GdkDisplay associated to the event
.
GdkDevice *
gdk_event_get_device (const GdkEvent *event
);
If the event contains a “device” field, this function will return
it, else it will return NULL
.
void gdk_event_set_device (GdkEvent *event
,GdkDevice *device
);
Sets the device for event
to device
. The event must
have been allocated by GTK+, for instance, by
gdk_event_copy()
.
GdkDevice *
gdk_event_get_source_device (const GdkEvent *event
);
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 GdkSurface updates its
geometry or a grab is acquired/released.
If the event does not contain a device field, this function will
return NULL
.
void gdk_event_set_source_device (GdkEvent *event
,GdkDevice *device
);
Sets the slave device for event
to device
.
The event must have been allocated by GTK+,
for instance by gdk_event_copy()
.
GdkDeviceTool *
gdk_event_get_device_tool (const GdkEvent *event
);
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.
Note: the GdkDeviceTool<!-- -->s will be constant during
the application lifetime, if settings must be stored
persistently across runs, see gdk_device_tool_get_serial()
Specifies the type of the event.
Do not confuse these events with the signals that GTK+ widgets emit. Although many of these events result in corresponding signals being emitted, the events are often transformed or filtered along the way.
a special code to indicate a null event. |
||
the window manager has requested that the toplevel surface be hidden or destroyed, usually when the user clicks on a special icon in the title bar. |
||
the surface has been destroyed. |
||
the pointer (usually a mouse) has moved. |
||
a mouse button has been pressed. |
||
a mouse button has been released. |
||
a key has been pressed. |
||
a key has been released. |
||
the pointer has entered the surface. |
||
the pointer has left the surface. |
||
the keyboard focus has entered or left the surface. |
||
the size, position or stacking order of the surface has changed.
Note that GTK+ discards these events for |
||
an input device has moved into contact with a sensing surface (e.g. a touchscreen or graphics tablet). |
||
an input device has moved out of contact with a sensing surface. |
||
the mouse has entered the surface while a drag is in progress. |
||
the mouse has left the surface while a drag is in progress. |
||
the mouse has moved in the surface while a drag is in progress. |
||
a drop operation onto the surface has started. |
||
the scroll wheel was turned |
||
a pointer or keyboard grab was broken. This event type was added in 2.8. |
||
A new touch event sequence has just started. This event type was added in 3.4. |
||
A touch event sequence has been updated. This event type was added in 3.4. |
||
A touch event sequence has finished. This event type was added in 3.4. |
||
A touch event sequence has been canceled. This event type was added in 3.4. |
||
A touchpad swipe gesture event, the current state is determined by its phase field. This event type was added in 3.18. |
||
A touchpad pinch gesture event, the current state is determined by its phase field. This event type was added in 3.18. |
||
A tablet pad button press event. This event type was added in 3.22. |
||
A tablet pad button release event. This event type was added in 3.22. |
||
A tablet pad axis event from a "ring". This event type was added in 3.22. |
||
A tablet pad axis event from a "strip". This event type was added in 3.22. |
||
A tablet pad group mode change. This event type was added in 3.22. |
||
marks the end of the GdkEventType enumeration. Added in 2.18 |
A set of bit-flags to indicate which events a surface is to receive. Most of these masks map onto one or more of the GdkEventType event types above.
See the input handling overview for details of event masks and event propagation.
If GDK_TOUCH_MASK
is enabled, the surface will receive touch events
from touch-enabled devices. Those will come as sequences of GdkEventTouch
with type GDK_TOUCH_UPDATE
, enclosed by two events with
type GDK_TOUCH_BEGIN
and GDK_TOUCH_END
(or GDK_TOUCH_CANCEL
).
gdk_event_get_event_sequence()
returns the event sequence for these
events, so different sequences may be distinguished.
receive expose events |
||
receive all pointer motion events |
||
receive pointer motion events while any button is pressed |
||
receive pointer motion events while 1 button is pressed |
||
receive pointer motion events while 2 button is pressed |
||
receive pointer motion events while 3 button is pressed |
||
receive button press events |
||
receive button release events |
||
receive key press events |
||
receive key release events |
||
receive surface enter events |
||
receive surface leave events |
||
receive focus change events |
||
receive events about surface configuration change |
||
receive property change events |
||
receive proximity in events |
||
receive proximity out events |
||
receive events about surface configuration changes of child surfaces |
||
receive scroll events |
||
receive touch events |
||
receive smooth scrolling events |
||
receive touchpad gesture events |
||
receive tablet pad events |
||
the combination of all the above event masks. |
Specifies the direction for scroll events.
the surface is scrolled up. |
||
the surface is scrolled down. |
||
the surface is scrolled to the left. |
||
the surface is scrolled to the right. |
||
the scrolling is determined by the delta values
in scroll events. See |
Specifies the crossing mode for enter and leave events.
crossing because of pointer motion. |
||
crossing because a grab is activated. |
||
crossing because a grab is deactivated. |
||
crossing because a GTK+ grab is activated. |
||
crossing because a GTK+ grab is deactivated. |
||
crossing because a GTK+ widget changed state (e.g. sensitivity). |
||
crossing because a touch sequence has begun, this event is synthetic as the pointer might have not left the surface. |
||
crossing because a touch sequence has ended, this event is synthetic as the pointer might have not left the surface. |
||
crossing because of a device switch (i.e. a mouse taking control of the pointer after a touch device), this event is synthetic as the pointer didn’t leave the surface. |
Specifies the kind of crossing for enter and leave events.
See the X11 protocol specification of LeaveNotify for full details of crossing event generation.
the surface is entered from an ancestor or left towards an ancestor. |
||
the pointer moves between an ancestor and an inferior of the surface. |
||
the surface is entered from an inferior or left towards an inferior. |
||
the surface is entered from or left towards a surface which is neither an ancestor nor an inferior. |
||
the pointer moves between two surfaces which are not ancestors of each other and the surface is part of the ancestor chain between one of these surfaces and their least common ancestor. |
||
an unknown type of enter/leave event occurred. |
#define GDK_CURRENT_TIME 0L
Represents the current time, and can be used anywhere a time is expected.
#define GDK_PRIORITY_EVENTS (G_PRIORITY_DEFAULT)
This is the priority that events from the X server are given in the GLib Main Loop.
#define GDK_PRIORITY_REDRAW (G_PRIORITY_HIGH_IDLE + 20)
This is the priority that the idle handler processing surface updates is given in the GLib Main Loop.
#define GDK_EVENT_PROPAGATE (FALSE)
Use this macro as the return value for continuing the propagation of an event handler.
#define GDK_EVENT_STOP (TRUE)
Use this macro as the return value for stopping the propagation of an event handler.
#define GDK_BUTTON_PRIMARY (1)
The primary button. This is typically the left mouse button, or the right button in a left-handed setup.
#define GDK_BUTTON_SECONDARY (3)
The secondary button. This is typically the right mouse button, or the left button in a left-handed setup.
“event-type”
property“event-type” GdkEventType
Event type.
Flags: Read / Write / Construct Only
Default value: GDK_NOTHING