Package: gtk

Class gtk:gesture

Superclasses

gtk:event-controller, gobject:object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

Direct Slots

n-points
The n-points property of type :int (Read / Write / Construct only)
The number of touch points that trigger recognition on this gesture.
Allowed values: >= 1
Default value: 1

Details

The gtk:gesture object is the base object for gesture recognition. Although this object is quite generalized to serve as a base for multi-touch gestures, it is suitable to implement single-touch and pointer-based gestures.

The number of touches that a gtk:gesture object need to be recognized is controlled by the n-points property, if a gesture is keeping track of less or more than that number of event sequences, it will not check whether the gesture is recognized.

As soon as the gesture has the expected number of touches, it will check regularly if it is recognized, the criteria to consider a gesture as "recognized" is left to gtk:gesture subclasses.

A recognized gesture will then emit the following signals:
  • The "begin" signal when the gesture is recognized.
  • A number of "update" signals, whenever an input event is processed.
  • The "end" signal when the gesture is no longer recognized.
Event propagation
In order to receive events, a gesture needs to set a propagation phase through the gtk:event-controller-propagation-phase function.

In the capture phase, events are propagated from the toplevel down to the target widget, and gestures that are attached to containers above the widget get a chance to interact with the event before it reaches the target.

In the bubble phase, events are propagated up from the target widget to the toplevel, and gestures that are attached to containers above the widget get a chance to interact with events that have not been handled yet.

States of an event sequence
Whenever input interaction happens, a single event may trigger a cascade of gestures, both across the parents of the widget receiving the event and in parallel within an individual widget. It is a responsibility of the widgets using those gestures to set the state of touch sequences accordingly in order to enable cooperation of gestures around the event sequences triggering those.

Within a widget, gestures can be grouped through the gtk:gesture-group function, grouped gestures synchronize the state of event sequences, so calling the gtk:gesture-set-state function on one will effectively propagate the state throughout the group.

By default, all event sequences start out in the :none state, event sequences in this state trigger the gesture event handler, but event propagation will continue unstopped by gestures.

If an event sequence enters into the :denied state, the gesture group will effectively ignore the event sequence, letting events go unstopped through the gesture, but the "slot" will still remain occupied while the touch is active.

If an event sequence enters in the :claimed state, the gesture group will grab all interaction on the event sequence, by:
  • Setting the same event sequence to :denied on every other gesture group within the widget, and every gesture on parent widgets in the propagation chain.
  • Calling the "cancel" signal on every gesture in widgets underneath in the propagation chain.
  • Stopping event propagation after the gesture group handles the event.
Note: If an event sequence is set early to :claimed on :touch-begin or :button-press events, so those events are captured before reaching the event widget, this implies :phase-capture, one similar event will emulated if the event sequence changes to :denied. This way event coherence is preserved before event propagation is unstopped again.

Event sequence states can not be changed freely, see the gtk:gesture-set-state function to know about the possible lifetimes of a gdk:event-sequence instance.

Touchpad gestures
On the platforms that support it, the gtk:gesture object will handle transparently touchpad gesture events. The only precautions users of the gtk:gesture object should do to enable this support are:

Signal Details

The "begin" signal
lambda (gesture sequence)    :run-last      
gesture
The gtk:gesture object that received the signal.
sequence
The gdk:event-sequence event that made the gesture to be recognized.
The signal is emitted when the gesture is recognized. This means the number of touch sequences matches the n-points value. Note: These conditions may also happen when an extra touch, for example, a third touch on a 2-touches gesture, is lifted, in that situation sequence will not pertain to the current set of active touches, so do not rely on this being true.
The "cancel" signal
lambda (gesture sequence)    :run-last      
gesture
The gtk:gesture object that received the signal.
sequence
The gdk:event-sequence instance that was cancelled.
The signal is emitted whenever an event sequence is cancelled. This usually happens on active touches when the gtk:event-controller-reset function is called on gesture, manually, due to grabs, and so on, or the individual event sequence was claimed by controllers of the parent widgets, see the gtk:gesture-set-state function. The gesture argument must forget everything about sequence as a reaction to the signal.
The "end" signal
lambda (gesture sequence)    :run-last      
gesture
The gtk:gesture object that received the signal.
sequence
The gdk:event-sequence instance that made gesture recognition to finish.
The signal is emitted when gesture either stopped recognizing the event sequences as something to be handled, or the number of touch sequences became higher or lower than the n-points value. Note: The sequence argument might not pertain to the group of event sequences that were previously triggering recognition on gesture, that is a just pressed touch sequence that exceeds the n-points value. This situation may be detected by checking through the gtk:gesture-handles-sequence function.
The "sequence-state-changed" signal
lambda (gesture sequence state)    :run-last      
gesture
The gtk:gesture object that received the signal.
sequence
The gdk:event-sequence instance that was cancelled.
state
The new gtk:event-sequence-state value.
The signal is emitted whenever an event sequence state changes. See the gtk:gesture-sequence-state function to know more about the expectable event sequence lifetimes.
The "update" signal
lambda (gesture sequence)    :run-last      
gesture
The gtk:gesture object that received the signal.
sequence
The gdk:event-sequence instance that was updated.
The signal is emitted whenever an event is handled while the gesture is recognized. The sequence argument is guaranteed to pertain to the set of active touches.
 

Slot Access Functions

Inherited Slot Access Functions

See also

2026-09-21