gtkmm  4.8.0
Public Types | Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gdk::Event Class Referencefinal

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

#include <gdkmm/event.h>

Public Types

enum class  Type {
  DELETE ,
  MOTION_NOTIFY ,
  BUTTON_PRESS ,
  BUTTON_RELEASE ,
  KEY_PRESS ,
  KEY_RELEASE ,
  ENTER_NOTIFY ,
  LEAVE_NOTIFY ,
  FOCUS_CHANGE ,
  PROXIMITY_IN ,
  PROXIMITY_OUT ,
  DRAG_ENTER ,
  DRAG_LEAVE ,
  DRAG_MOTION ,
  DROP_START ,
  SCROLL ,
  GRAB_BROKEN ,
  TOUCH_BEGIN ,
  TOUCH_UPDATE ,
  TOUCH_END ,
  TOUCH_CANCEL ,
  TOUCHPAD_SWIPE ,
  TOUCHPAD_PINCH ,
  PAD_BUTTON_PRESS ,
  PAD_BUTTON_RELEASE ,
  PAD_RING ,
  PAD_STRIP ,
  PAD_GROUP_MODE ,
  TOUCHPAD_HOLD ,
  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 surface associated with an event. More...
 
Glib::RefPtr< const Surfaceget_surface () const
 Extracts the 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 ()
 Returns a Gdk::DeviceTool representing the tool that caused the event. More...
 
Glib::RefPtr< const DeviceToolget_device_tool () const
 Returns a Gdk::DeviceTool representing the tool that caused the event. More...
 
guint32 get_time () const
 Returns the timestamp of event. More...
 
Glib::RefPtr< Displayget_display ()
 Retrieves the display associated to the event. More...
 
Glib::RefPtr< const Displayget_display () const
 Retrieves the display associated to the event. More...
 
const EventSequence * get_event_sequence () const
 Retuns the event sequence 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. 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...
 
ScrollUnit get_scroll_unit () const
 Extracts the scroll delta unit 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 object from a DND event. More...
 
Glib::RefPtr< const Dropget_dnd_drop () const
 Gets the Gdk::Drop object 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
 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
 Returns the distance between the event locations. More...
 
bool get_angle (const Glib::RefPtr< const Event > & event2, double & angle) const
 Returns the relative angle from event1 to event2. More...
 
bool get_center (const Glib::RefPtr< const Event > & event2, double & x, double & y) const
 Returns the point halfway between the events' positions. More...
 
KeyMatch matches (guint keyval, ModifierType modifiers) const
 Matches a key event against a keyval and modifiers. More...
 
bool get_match (guint & keyval, ModifierType & modifiers) const
 Gets a keyval and modifier combination that will match the 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

◆ Event() [1/2]

Gdk::Event::Event ( )
delete

◆ Event() [2/2]

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

Member Function Documentation

◆ get_angle()

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

Returns the relative angle from event1 to event2.

The relative angle is the angle between the X axis and the line through both events' positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

This assumes that both events have X/Y information. If not, this function returns false.

Parameters
event2Second Gdk::Event.
angleReturn location for the relative angle between both events.
Returns
true if the angle could be calculated.

◆ get_axes()

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.

◆ get_axis()

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.

To find out which axes are used, use Gdk::DeviceTool::get_axes() on the device tool returned by get_device_tool().

Parameters
axis_useThe axis use to look for.
valueLocation to store the value found.
Returns
true if the specified axis was found, otherwise false.

◆ get_button()

guint Gdk::Event::get_button ( ) const

Extract the button number from a button event.

Returns
The button of event.

◆ get_center()

bool Gdk::Event::get_center ( const Glib::RefPtr< const Event > &  event2,
double &  x,
double &  y 
) const

Returns the point halfway between the events' positions.

This assumes that both events have X/Y information. If not, this function returns false.

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.

◆ get_consumed_modifiers()

ModifierType Gdk::Event::get_consumed_modifiers ( ) const

Extracts the consumed modifiers from a key event.

Returns
The consumed modifiers or event.

◆ get_crossing_detail()

NotifyType Gdk::Event::get_crossing_detail ( ) const

Extracts the notify detail from a crossing event.

Returns
The notify detail of event.

◆ get_crossing_focus()

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.

◆ get_crossing_mode()

CrossingMode Gdk::Event::get_crossing_mode ( ) const

Extracts the crossing mode from a crossing event.

Returns
The mode of event.

◆ get_deltas()

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.

For the representation unit of these deltas, see get_unit().

Parameters
delta_xReturn location for x scroll delta.
delta_yReturn location for y scroll delta.

◆ get_device() [1/2]

Glib::RefPtr<Device> Gdk::Event::get_device ( )

Returns the device of an event.

Since gtkmm 3.94:
Returns
A Gdk::Device.

◆ get_device() [2/2]

Glib::RefPtr<const Device> Gdk::Event::get_device ( ) const

Returns the device of an event.

Since gtkmm 3.94:
Returns
A Gdk::Device.

◆ get_device_tool() [1/2]

Glib::RefPtr<DeviceTool> Gdk::Event::get_device_tool ( )

Returns a Gdk::DeviceTool representing the tool that caused the event.

If the was not generated by a device that supports different tools (such as a tablet), this function will return nullptr.

Note
the Gdk::DeviceTool 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.

◆ get_device_tool() [2/2]

Glib::RefPtr<const DeviceTool> Gdk::Event::get_device_tool ( ) const

Returns a Gdk::DeviceTool representing the tool that caused the event.

If the was not generated by a device that supports different tools (such as a tablet), this function will return nullptr.

Note
the Gdk::DeviceTool 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.

◆ get_direction()

ScrollDirection Gdk::Event::get_direction ( ) const

Extracts the direction of a scroll event.

Returns
The scroll direction of event.

◆ get_display() [1/2]

Glib::RefPtr<Display> Gdk::Event::get_display ( )

Retrieves the display associated to the event.

Returns
A Gdk::Display.

◆ get_display() [2/2]

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

Retrieves the display associated to the event.

Returns
A Gdk::Display.

◆ get_distance()

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

Returns the distance between the event locations.

This assumes that both events have X/Y information. If not, this function returns false.

Parameters
event2Second Gdk::Event.
distanceReturn location for the distance.
Returns
true if the distance could be calculated.

◆ get_dnd_drop() [1/2]

Glib::RefPtr<Drop> Gdk::Event::get_dnd_drop ( )

Gets the Gdk::Drop object from a DND event.

Returns
The drop.

◆ get_dnd_drop() [2/2]

Glib::RefPtr<const Drop> Gdk::Event::get_dnd_drop ( ) const

Gets the Gdk::Drop object from a DND event.

Returns
The drop.

◆ get_event_sequence()

const EventSequence* Gdk::Event::get_event_sequence ( ) const

Retuns the event sequence to which the event belongs.

Related touch events are connected in a sequence. Other events typically don't have event sequence information.

Returns
The event sequence that the event belongs to.

◆ get_event_type()

Type Gdk::Event::get_event_type ( ) const

Retrieves the type of the event.

Returns
A Gdk::EventType.

◆ get_focus_in()

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.

◆ get_grab_broken_grab_surface() [1/2]

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.

◆ get_grab_broken_grab_surface() [2/2]

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.

◆ get_grab_broken_implicit()

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.

◆ get_history()

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.

◆ get_keycode()

guint Gdk::Event::get_keycode ( ) const

Extracts the keycode from a key event.

Returns
The keycode of event.

◆ get_keyval()

guint Gdk::Event::get_keyval ( ) const

Extracts the keyval from a key event.

Returns
The keyval of event.

◆ get_layout()

guint Gdk::Event::get_layout ( ) const

Extracts the layout from a key event.

Returns
The layout of event.

◆ get_level()

guint Gdk::Event::get_level ( ) const

Extracts the shift level from a key event.

Returns
The shift level of event.

◆ get_match()

bool Gdk::Event::get_match ( guint &  keyval,
ModifierType modifiers 
) const

Gets a keyval and modifier combination that will match the event.

See matches().

Parameters
keyvalReturn location for a keyval.
modifiersReturn location for modifiers.
Returns
true on success.

◆ get_modifier_state()

ModifierType Gdk::Event::get_modifier_state ( ) const

Returns the modifier state field of an event.

Returns
The modifier state of event.

◆ get_pad_axis_value()

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.

◆ get_pad_button()

guint Gdk::Event::get_pad_button ( ) const

Extracts information about the pressed button from a pad event.

Returns
The button of event.

◆ get_pad_group_mode()

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.

◆ get_pointer_emulated()

bool Gdk::Event::get_pointer_emulated ( ) const

Returns whether this event is an 'emulated' pointer event.

Emulated pointer events typically originate from a touch events.

Returns
true if this event is emulated.

◆ get_position()

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.

◆ get_scroll_unit()

ScrollUnit Gdk::Event::get_scroll_unit ( ) const

Extracts the scroll delta unit of a scroll event.

The unit will always be Gdk::ScrollUnit::WHEEL if the scroll direction is not Gdk::ScrollDirection::SMOOTH.

Since gtkmm 4.8:
Returns
The scroll unit.

◆ get_seat() [1/2]

Glib::RefPtr<Seat> Gdk::Event::get_seat ( )

Returns the seat that originated the event.

Returns
A Gdk::Seat.

◆ get_seat() [2/2]

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

Returns the seat that originated the event.

Returns
A Gdk::Seat.

◆ get_surface() [1/2]

Glib::RefPtr<Surface> Gdk::Event::get_surface ( )

Extracts the surface associated with an event.

Returns
The Gdk::Surface associated with the event.

◆ get_surface() [2/2]

Glib::RefPtr<const Surface> Gdk::Event::get_surface ( ) const

Extracts the surface associated with an event.

Returns
The Gdk::Surface associated with the event.

◆ get_time()

guint32 Gdk::Event::get_time ( ) const

Returns the timestamp of event.

Not all events have timestamps. In that case, this function returns GDK_CURRENT_TIME.

Returns
Timestamp field from event.

◆ get_touch_emulating_pointer()

bool Gdk::Event::get_touch_emulating_pointer ( ) const

Extracts whether a touch event is emulating a pointer event.

Returns
true if event is emulating.

◆ get_touchpad_deltas()

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.

◆ get_touchpad_gesture_phase()

TouchpadGesturePhase Gdk::Event::get_touchpad_gesture_phase ( ) const

Extracts the touchpad gesture phase from a touchpad event.

Returns
The gesture phase of event.

◆ get_touchpad_n_fingers()

guint Gdk::Event::get_touchpad_n_fingers ( ) const

Extracts the number of fingers from a touchpad event.

Returns
The number of fingers for event.

◆ get_touchpad_pinch_angle_delta()

double Gdk::Event::get_touchpad_pinch_angle_delta ( ) const

Extracts the angle delta from a touchpad pinch event.

Returns
The angle delta of event.

◆ get_touchpad_pinch_scale()

double Gdk::Event::get_touchpad_pinch_scale ( ) const

Extracts the scale from a touchpad pinch event.

Returns
The scale of event.

◆ gobj() [1/2]

GdkEvent* Gdk::Event::gobj ( )

Provides access to the underlying C instance.

◆ gobj() [2/2]

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

Provides access to the underlying C instance.

◆ gobj_copy()

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.

◆ is_modifier()

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.

◆ is_scroll_stop()

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.

◆ matches()

KeyMatch Gdk::Event::matches ( guint  keyval,
ModifierType  modifiers 
) const

Matches a key event against a keyval and modifiers.

This is typically used to trigger keyboard shortcuts such as Ctrl-C.

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 Gdk::KeyMatch value describing whether event matches.

◆ operator delete()

void Gdk::Event::operator delete ( void *  ,
std::size_t   
)
protected

◆ operator=()

Event& Gdk::Event::operator= ( const Event )
delete

◆ reference()

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.

◆ triggers_context_menu()

bool Gdk::Event::triggers_context_menu ( ) const

Returns whether a Gdk::Event should trigger a context menu, according to platform conventions.

The right mouse button typically 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.

◆ unreference()

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

◆ wrap()

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.