gtkmm: Gdk::Event Class Reference

Functions for handling events from the window system. More...

#include <gdkmm/event.h>

Public Types

enum  Type {

  Type::DELETE,

  Type::MOTION_NOTIFY,

  Type::BUTTON_PRESS,

  Type::BUTTON_RELEASE,

  Type::KEY_PRESS,

  Type::KEY_RELEASE,

  Type::ENTER_NOTIFY,

  Type::LEAVE_NOTIFY,

  Type::FOCUS_CHANGE,

  Type::PROXIMITY_IN,

  Type::PROXIMITY_OUT,

  Type::DRAG_ENTER,

  Type::DRAG_LEAVE,

  Type::DRAG_MOTION,

  Type::DROP_START,

  Type::SCROLL,

  Type::GRAB_BROKEN,

  Type::TOUCH_BEGIN,

  Type::TOUCH_UPDATE,

  Type::TOUCH_END,

  Type::TOUCH_CANCEL,

  Type::TOUCHPAD_SWIPE,

  Type::TOUCHPAD_PINCH,

  Type::PAD_BUTTON_PRESS,

  Type::PAD_BUTTON_RELEASE,

  Type::PAD_RING,

  Type::PAD_STRIP,

  Type::PAD_GROUP_MODE,

  Type::EVENT_LAST

}
 Specifies the type of the event. More...

 

Public Member Functions

void reference () const
 Increment the reference count for this object. More...

 
void unreference () const
 Decrement the reference count for this object. More...

 
GdkEvent* gobj ()
 Provides access to the underlying C instance. More...

 
const GdkEvent* gobj () const
 Provides access to the underlying C instance. More...

 
GdkEvent* gobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...

 
 Event ()=delete
 
 Event (const Event&)=delete
 
Eventoperator= (const Event&)=delete
 
Type get_event_type () const
 Retrieves the type of the event. More...

 
Glib::RefPtr< Surfaceget_surface ()
 Extracts the Gdk::Surface associated with an event. More...

 
Glib::RefPtr< const Surfaceget_surface () const
 Extracts the Gdk::Surface associated with an event. More...

 
Glib::RefPtr< Seatget_seat ()
 Returns the seat that originated the event. More...

 
Glib::RefPtr< const Seatget_seat () const
 Returns the seat that originated the event. More...

 
Glib::RefPtr< Deviceget_device ()
 Returns the device of an event. More...

 
Glib::RefPtr< const Deviceget_device () const
 Returns the device of an event. More...

 
Glib::RefPtr< DeviceToolget_device_tool ()
 If the event was generated by a device that supports different tools (eg. More...

 
Glib::RefPtr< const DeviceToolget_device_tool () const
 If the event was generated by a device that supports different tools (eg. More...

 
guint32 get_time () const
 Returns the time stamp from event, if there is one; otherwise returns GDK_CURRENT_TIME. More...

 
Glib::RefPtr< Displayget_display ()
 Retrieves the Gdk::Display associated to the event. More...

 
Glib::RefPtr< const Displayget_display () const
 Retrieves the Gdk::Display associated to the event. More...

 
const EventSequence* get_event_sequence () const
 If event is a touch event, returns the Gdk::EventSequence to which the event belongs. More...

 
ModifierType get_modifier_state () const
 Returns the modifier state field of an event. More...

 
bool get_position (double& x, double& y) const
 Extract the event surface relative x/y coordinates from an event. More...

 
std::vector< double > get_axes () const
 Extracts all axis values from an event. More...

 
bool get_axis (Gdk::AxisUse axis_use, double& value) const
 Extract the axis value for a particular axis use from an event structure. More...

 
bool get_pointer_emulated () const
 Returns whether this event is an 'emulated' pointer event (typically from a touch event), as opposed to a real one. More...

 
guint get_button () const
 Extract the button number from a button event. More...

 
ScrollDirection get_direction () const
 Extracts the direction of a scroll event. More...

 
void get_deltas (double& delta_x, double& delta_y) const
 Extracts the scroll deltas of a scroll event. More...

 
bool is_scroll_stop () const
 Check whether a scroll event is a stop scroll event. More...

 
guint get_keyval () const
 Extracts the keyval from a key event. More...

 
guint get_keycode () const
 Extracts the keycode from a key event. More...

 
ModifierType get_consumed_modifiers () const
 Extracts the consumed modifiers from a key event. More...

 
guint get_layout () const
 Extracts the layout from a key event. More...

 
guint get_level () const
 Extracts the shift level from a key event. More...

 
bool is_modifier () const
 Extracts whether the key event is for a modifier key. More...

 
bool get_focus_in () const
 Extracts whether this event is about focus entering or leaving the surface. More...

 
bool get_touch_emulating_pointer () const
 Extracts whether a touch event is emulating a pointer event. More...

 
CrossingMode get_crossing_mode () const
 Extracts the crossing mode from a crossing event. More...

 
NotifyType get_crossing_detail () const
 Extracts the notify detail from a crossing event. More...

 
bool get_crossing_focus () const
 Checks if the event surface is the focus surface. More...

 
TouchpadGesturePhase get_touchpad_gesture_phase () const
 Extracts the touchpad gesture phase from a touchpad event. More...

 
guint get_touchpad_n_fingers () const
 Extracts the number of fingers from a touchpad event. More...

 
void get_touchpad_deltas (double& dx, double& dy) const
 Extracts delta information from a touchpad event. More...

 
double get_touchpad_pinch_angle_delta () const
 Extracts the angle delta from a touchpad pinch event. More...

 
double get_touchpad_pinch_scale () const
 Extracts the scale from a touchpad pinch event. More...

 
guint get_pad_button () const
 Extracts information about the pressed button from a pad event. More...

 
void get_pad_axis_value (guint& index, double& value) const
 Extracts the information from a pad strip or ring event. More...

 
void get_pad_group_mode (guint& group, guint& mode) const
 Extracts group and mode information from a pad event. More...

 
Glib::RefPtr< Dropget_dnd_drop ()
 Gets the Gdk::Drop from a DND event. More...

 
Glib::RefPtr< const Dropget_dnd_drop () const
 Gets the Gdk::Drop from a DND event. More...

 
Glib::RefPtr< Surfaceget_grab_broken_grab_surface ()
 Extracts the grab surface from a grab broken event. More...

 
Glib::RefPtr< const Surfaceget_grab_broken_grab_surface () const
 Extracts the grab surface from a grab broken event. More...

 
bool get_grab_broken_implicit () const
 Checks whether the grab broken event is for an implicit grab. More...

 
std::vector< TimeCoordget_history () const
 Retrieves the history of the event, as a vector of time and coordinates. More...

 
bool triggers_context_menu () const
 This function returns whether a Gdk::Event should trigger a context menu, according to platform conventions. More...

 
bool get_distance (const Glib::RefPtr< const Event >& event2, double&distance) const
 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. More...

 
bool get_angle (const Glib::RefPtr< const Event >& event2, double& angle) const
 If both events contain X/Y information, this function will return true and return in angle the relative angle from event1 to event2. More...

 
bool get_center (const Glib::RefPtr< const Event >& event2, double& x, double& y) const
 If both events contain X/Y information, the center of both coordinates will be returned in x and y. More...

 
KeyMatch matches (guint keyval, ModifierType modifiers) const
 Matches a key event against a keyboard shortcut that is specified as a keyval and modifiers. More...

 
bool get_match (guint& keyval, ModifierType& modifiers) const
 Gets a keyval and modifier combination that will cause gdk_key_event_matches() to successfully match the given event. More...

 

Protected Member Functions

void operator delete (void*, std::size_t)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gdk::Eventwrap (GdkEvent* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Detailed Description

Functions for handling events from the window system.

In GTK applications the events are handled automatically by toplevel widgets and passed on to the event controllers of appropriate widgets, so these functions are rarely needed.

Key values are the codes which are sent whenever a key is pressed or released. The complete list of key values can be found in the gdk/gdkkeysyms.h header file. They are prefixed with GDK_KEY_.

Constructor & Destructor Documentation

Gdk::Event::Event ( )
delete
Gdk::Event::Event ( const Event )
delete

Member Function Documentation

bool Gdk::Event::get_angle ( const Glib::RefPtr< const Event >&  event2,
double &  angle 
) const

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.

Parameters
event2Second Gdk::Event.
angleReturn location for the relative angle between both events.
Returns
true if the angle could be calculated.
std::vector<double> Gdk::Event::get_axes ( ) const

Extracts all axis values from an event.

Returns
A vector of values for all axes. An empty vector in case of failure.
bool Gdk::Event::get_axis ( Gdk::AxisUse  axis_use,
double &  value 
) const

Extract the axis value for a particular axis use from an event structure.

Parameters
axis_useThe axis use to look for.
valueLocation to store the value found.
Returns
true if the specified axis was found, otherwise false.
guint Gdk::Event::get_button ( ) const

Extract the button number from a button event.

Returns
The button of event.
bool Gdk::Event::get_center ( const Glib::RefPtr< const Event >&  event2,
double &  x,
double &  y 
) const

If both events contain X/Y information, the center of both coordinates will be returned in x and y.

Parameters
event2Second Gdk::Event.
xReturn location for the X coordinate of the center.
yReturn location for the Y coordinate of the center.
Returns
true if the center could be calculated.
ModifierType Gdk::Event::get_consumed_modifiers ( ) const

Extracts the consumed modifiers from a key event.

Returns
The consumed modifiers or event.
NotifyType Gdk::Event::get_crossing_detail ( ) const

Extracts the notify detail from a crossing event.

Returns
The notify detail of event.
bool Gdk::Event::get_crossing_focus ( ) const

Checks if the event surface is the focus surface.

Returns
true if the surface is the focus surface.
CrossingMode Gdk::Event::get_crossing_mode ( ) const

Extracts the crossing mode from a crossing event.

Returns
The mode of event.
void Gdk::Event::get_deltas ( double &  delta_x,
double &  delta_y 
) const

Extracts the scroll deltas of a scroll event.

The deltas will be zero unless the scroll direction is Gdk::ScrollDirection::SMOOTH.

Parameters
delta_xReturn location for x scroll delta.
delta_yReturn location for y scroll delta.
Glib::RefPtr<Device> Gdk::Event::get_device ( )

Returns the device of an event.

Since gtkmm 3.94:
Returns
A Gdk::Device.
Glib::RefPtr<const Device> Gdk::Event::get_device ( ) const

Returns the device of an event.

Since gtkmm 3.94:
Returns
A Gdk::Device.
Glib::RefPtr<DeviceTool> 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 Gdk::DeviceTool representing the tool that caused the event. Otherwise, nullptr will be returned.

Note
the Gdk::DeviceTools will be constant during the application lifetime, if settings must be stored persistently across runs, see Gdk::DeviceTool::get_serial()
Returns
The current device tool, or nullptr.
Glib::RefPtr<const DeviceTool> Gdk::Event::get_device_tool ( ) const

If the event was generated by a device that supports different tools (eg.

a tablet), this function will return a Gdk::DeviceTool representing the tool that caused the event. Otherwise, nullptr will be returned.

Note
the Gdk::DeviceTools will be constant during the application lifetime, if settings must be stored persistently across runs, see Gdk::DeviceTool::get_serial()
Returns
The current device tool, or nullptr.
ScrollDirection Gdk::Event::get_direction ( ) const

Extracts the direction of a scroll event.

Returns
The scroll direction of event.
Glib::RefPtr<Display> Gdk::Event::get_display ( )

Retrieves the Gdk::Display associated to the event.

Returns
A Gdk::Display.
Glib::RefPtr<const Display> Gdk::Event::get_display ( ) const

Retrieves the Gdk::Display associated to the event.

Returns
A Gdk::Display.
bool Gdk::Event::get_distance ( const Glib::RefPtr< const Event >&  event2,
double &  distance 
) const

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.

Parameters
event2Second Gdk::Event.
distanceReturn location for the distance.
Returns
true if the distance could be calculated.
Glib::RefPtr<Drop> Gdk::Event::get_dnd_drop ( )

Gets the Gdk::Drop from a DND event.

Returns
The drop.
Glib::RefPtr<const Drop> Gdk::Event::get_dnd_drop ( ) const

Gets the Gdk::Drop from a DND event.

Returns
The drop.
const EventSequence* Gdk::Event::get_event_sequence ( ) const

If event is a touch event, returns the Gdk::EventSequence to which the event belongs.

Otherwise, return nullptr.

Returns
The event sequence that the event belongs to.
Type Gdk::Event::get_event_type ( ) const

Retrieves the type of the event.

Returns
A Gdk::Event::Type.
bool Gdk::Event::get_focus_in ( ) const

Extracts whether this event is about focus entering or leaving the surface.

Returns
true of the focus is entering.
Glib::RefPtr<Surface> Gdk::Event::get_grab_broken_grab_surface ( )

Extracts the grab surface from a grab broken event.

Returns
The grab surface of event.
Glib::RefPtr<const Surface> Gdk::Event::get_grab_broken_grab_surface ( ) const

Extracts the grab surface from a grab broken event.

Returns
The grab surface of event.
bool Gdk::Event::get_grab_broken_implicit ( ) const

Checks whether the grab broken event is for an implicit grab.

Returns
true if the an implicit grab was broken.
std::vector<TimeCoord> Gdk::Event::get_history ( ) const

Retrieves the history of the event, as a vector of time and coordinates.

The history includes events that are not delivered to the application because they occurred in the same frame as this event.

Note that only motion and scroll events record history, and motion events only if one of the mouse buttons is down.

Returns
A vector of time and coordinates.
guint Gdk::Event::get_keycode ( ) const

Extracts the keycode from a key event.

Returns
The keycode of event.
guint Gdk::Event::get_keyval ( ) const

Extracts the keyval from a key event.

Returns
The keyval of event.
guint Gdk::Event::get_layout ( ) const

Extracts the layout from a key event.

Returns
The layout of event.
guint Gdk::Event::get_level ( ) const

Extracts the shift level from a key event.

Returns
The shift level of event.
bool Gdk::Event::get_match ( guint &  keyval,
ModifierType modifiers 
) const

Gets a keyval and modifier combination that will cause gdk_key_event_matches() to successfully match the given event.

Parameters
keyvalReturn location for a keyval.
modifiersReturn location for modifiers.
Returns
true on success.
ModifierType Gdk::Event::get_modifier_state ( ) const

Returns the modifier state field of an event.

Returns
The modifier state of event.
void Gdk::Event::get_pad_axis_value ( guint &  index,
double &  value 
) const

Extracts the information from a pad strip or ring event.

Parameters
indexReturn location for the axis index.
valueReturn location for the axis value.
guint Gdk::Event::get_pad_button ( ) const

Extracts information about the pressed button from a pad event.

Returns
The button of event.
void Gdk::Event::get_pad_group_mode ( guint &  group,
guint &  mode 
) const

Extracts group and mode information from a pad event.

Parameters
groupReturn location for the group.
modeReturn location for the mode.
bool Gdk::Event::get_pointer_emulated ( ) const

Returns whether this event is an 'emulated' pointer event (typically from a touch event), as opposed to a real one.

Returns
true if this event is emulated.
bool Gdk::Event::get_position ( double &  x,
double &  y 
) const

Extract the event surface relative x/y coordinates from an event.

Parameters
xLocation to put event surface x coordinate.
yLocation to put event surface y coordinate.
Glib::RefPtr<Seat> Gdk::Event::get_seat ( )

Returns the seat that originated the event.

Returns
A Gdk::Seat.
Glib::RefPtr<const Seat> Gdk::Event::get_seat ( ) const

Returns the seat that originated the event.

Returns
A Gdk::Seat.
Glib::RefPtr<Surface> Gdk::Event::get_surface ( )

Extracts the Gdk::Surface associated with an event.

Returns
The Gdk::Surface associated with the event.
Glib::RefPtr<const Surface> Gdk::Event::get_surface ( ) const

Extracts the Gdk::Surface associated with an event.

Returns
The Gdk::Surface associated with the event.
guint32 Gdk::Event::get_time ( ) const

Returns the time stamp from event, if there is one; otherwise returns GDK_CURRENT_TIME.

Returns
Time stamp field from event.
bool Gdk::Event::get_touch_emulating_pointer ( ) const

Extracts whether a touch event is emulating a pointer event.

Returns
true if event is emulating.
void Gdk::Event::get_touchpad_deltas ( double &  dx,
double &  dy 
) const

Extracts delta information from a touchpad event.

Parameters
dxReturn location for x.
dyReturn location for y.
TouchpadGesturePhase Gdk::Event::get_touchpad_gesture_phase ( ) const

Extracts the touchpad gesture phase from a touchpad event.

Returns
The gesture phase of event.
guint Gdk::Event::get_touchpad_n_fingers ( ) const

Extracts the number of fingers from a touchpad event.

Returns
The number of fingers for event.
double Gdk::Event::get_touchpad_pinch_angle_delta ( ) const

Extracts the angle delta from a touchpad pinch event.

Returns
The angle delta of event.
double Gdk::Event::get_touchpad_pinch_scale ( ) const

Extracts the scale from a touchpad pinch event.

Returns
The scale of event.
GdkEvent* Gdk::Event::gobj ( )

Provides access to the underlying C instance.

const GdkEvent* Gdk::Event::gobj ( ) const

Provides access to the underlying C instance.

GdkEvent* Gdk::Event::gobj_copy ( ) const

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gdk::Event::is_modifier ( ) const

Extracts whether the key event is for a modifier key.

Returns
true if the event is for a modifier key.
bool Gdk::Event::is_scroll_stop ( ) const

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 delta of 0/0.

Returns
true if the event is a scroll stop event.
KeyMatch Gdk::Event::matches ( guint  keyval,
ModifierType  modifiers 
) const

Matches a key event against a keyboard shortcut that is specified as a keyval and modifiers.

Partial matches are possible where the combination matches if the currently active group is ignored.

Note that we ignore Caps Lock for matching.

Parameters
keyvalThe keyval to match.
modifiersThe modifiers to match.
Returns
A GdkKeyMatch value describing whether event matches.
void Gdk::Event::operator delete ( void *  ,
std::size_t   
)
protected
Event& Gdk::Event::operator= ( const Event )
delete
void Gdk::Event::reference ( ) const

Increment the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

bool Gdk::Event::triggers_context_menu ( ) const

This function returns whether a Gdk::Event should trigger a context menu, according to platform conventions.

The right mouse button always triggers context menus.

This function should always be used instead of simply checking for event->button == GDK_BUTTON_SECONDARY.

Returns
true if the event should trigger a context menu.
void Gdk::Event::unreference ( ) const

Decrement the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

Friends And Related Function Documentation

Glib::RefPtr< Gdk::Event > wrap ( GdkEvent *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.