Commit Graph

38359 Commits

Author SHA1 Message Date
Carlos Garnacho
cdcc536ddc longpress: Use xsettings to determine long press duration
GtkSettings::gtk-long-press-time is used to this effect.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
1403ebb097 settings: Add gtk-long-press-time setting
This setting determines the duration of a button/touch press to
be considered a long press.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
61e88c251e window: Use gestures for window moving/resizing
A multipress gesture is used to control all this, replacing
single/double click custom code, and triggering window dragging
when the multipress is stopped, yet active (ie. the sequence remains
pressed).
2014-05-23 19:54:24 +02:00
Carlos Garnacho
185da29b68 treeview: Use multipress gesture for row activation
Replace custom double click detection with multipress gesture
2014-05-23 19:54:24 +02:00
Carlos Garnacho
b0eef458d1 dnd: Use GtkGestureDrag to initiate DnD
This gesture is used by gtk_drag_source_set() to determine
whether dragging moved past the threshold. The gesture events
are handled via the usual ::event callbacks, so we don't mess
up with callers expecting that to happen in a signal handler.

If the sequence gets claimed somewhere else in the event widget
stack, the DnD gesture will be cancelled.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
6c78716531 scrolledwindow: Ensure the dragging sequence gets denied if more touches come in
This allows children to receive an emulated press, and handle it together with
the new touch that made the scrolledwindow sequence denied.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
564789777a scrolledwindow: Fix overshoot coordinates
With gtk_gesture_get_point() returning events in
gtk_event_controller_get_widget() coordinates, we no longer need
to compensate for the overshoot here.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
38e40a55f4 widget: Add gtk_widget_set_gesture_state()
This helper function ensures the state is propagated for
all the active sequences in the given gesture.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
8e1d5f98de widget: Improve button press emulation on sequence denied
Ensure that state being set on pointer emulating touches actually
gets propagated properly on widgets with gestures that only handle
pointer events.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
c49ac32393 swipe: Dont emit swipe() if the gesture was denied rather than finished 2014-05-23 19:54:24 +02:00
Carlos Garnacho
55683c075c drag: Make API offsets based
It is generally more useful to get offsets right away,
than having to calculate those from the start point.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
6cd0e733f5 scrolledwindow: Use GtkGestureSingle API 2014-05-23 19:54:24 +02:00
Carlos Garnacho
cece9cac07 scrolledwindow: Update gesture API change. 2014-05-23 19:54:23 +02:00
Carlos Garnacho
84885c6e26 demo: Update to gesture API change 2014-05-23 19:54:23 +02:00
Carlos Garnacho
a56a9e4a62 widget: Reset gestures on grab-notify
If it is determined that the gesture will stop receiving
events, reset the gesture altogether.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
997f05d99b widget: Make helper gesture API take GtkGestures
GtkEventController may be certainly useful to keep event
handling self-contained in other places than gestures, but
the current widget API is highly related to gestures, so
just using GtkGesture as the argument there will be quite
more convenient. The other places where GtkEventController
make sense as a base object will better provide their own
hooks.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
026b5014e8 Add: GTK_PHASE_NONE value to GtkCapturePhase.
Gestures attached with this phase will expect callers to have it
receive events through gtk_event_controller_handle_event(), but
the gesture will still be notified of sequence state changes,
grabs, etc...
2014-05-23 19:54:23 +02:00
Carlos Garnacho
ed5d73b49a gesture: check the gesture after denying a sequence.
So the gesture emits end() timely.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
03381beacc gesture: Offer always coordinates in the gesture widget coordinate space
Translate events meant for other widgets/windows, so gtk_gesture_get_point()
always returns coordinates based on the gtk_event_controller_get_widget()
allocation.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
4c34d4566c multipress: Remove unused signal argument 2014-05-23 19:54:23 +02:00
Carlos Garnacho
dca169d9f1 swipe: Make a subclass of GtkGestureSingle 2014-05-23 19:54:23 +02:00
Carlos Garnacho
315aedf5c8 drag: Make a subclass of GtkGestureSingle 2014-05-23 19:54:23 +02:00
Carlos Garnacho
000f38ed97 multipress: Make a subclass of GtkGestureSingle
The redundant API has been removed here.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
3db87cb0b7 longpress: Make a subclass of GtkGestureSingle
the redundant API here has been removed.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
5f24d1a519 gesture: Only recognize gestures with as many interacting touches as those handled
If a gesture has denied sequences (so those are presumably handled above/below
the widget), it shouldn't attempt to handle extra touches, even if those end
up matching the expected number of touches.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
b5c319b56f gesture: Limit API calls to non-denied sequences
Gestures do track those internally, but information about those
shouldn't be leaked on calls.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
2285157c7d gesture: Require BUTTON_PRESS/TOUCH_BEGIN for sequences to be initiated.
Gestures should always receive one of such events in order to be activated,
and the propagation mechanism will ensure they do so if the original event
was caught up the widget hierarchy by another gesture that is now declining
the sequence.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
d89e810bd9 gesture: Only track non denied sequences in get_last_updated_sequence() 2014-05-23 19:54:23 +02:00
Carlos Garnacho
b7435a0290 gesture: cancel all ongoing sequences on reset() 2014-05-23 19:54:23 +02:00
Carlos Garnacho
d2c9b9c2aa gesture: Skip non-device events early. 2014-05-23 19:54:23 +02:00
Carlos Garnacho
25ece22013 gesture: Add gtk_gesture_[sg]et_window()
This can be used to restrict a gesture to an specific GdkWindow,
all events will be checked to happen on/within that window.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
7f787e1d3b docs: Add GtkGestureSingle to docs 2014-05-23 19:54:22 +02:00
Carlos Garnacho
c4944b0376 gesture: Remove the touch-only property
This is handled in GtkGestureSingle.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
d4d0f13c3a Add GtkGestureSingle
This is a GtkGesture subclass, specific to single-touch (or
mouse operated) gestures.
2014-05-23 19:54:22 +02:00
Matthias Clasen
49e9ba122a ...and add the right include instead 2014-05-23 19:54:22 +02:00
Matthias Clasen
a1aeaa6b07 Remove a doubled line 2014-05-23 19:54:22 +02:00
Carlos Garnacho
8d2f81cca4 scrolledwindow: Use gesture button/touch press synthesization
This makes scrolled window fully compatible again wrt the
GtkScrolledWindow::capture-button-press property.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
36106c19d4 widget: Propagate touch/button press events when a sequence is denied
If the captured touch begin or button press event have been consumed
for the given sequence, propagate it upwards if the sequence goes from
claimed to denied, so the widgets on the way to the event widget receive
a coherent event stream now that they're going to receive events.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
83dd050ab2 gesture: Add private getter to know whether a touch begin was handled
If GDK_TOUCH_BEGIN was handled/consumed for a sequence, or GDK_BUTTON_PRESS was
handled for the mouse gesture, this function will return TRUE.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
a9fa0151f1 widget: Implement hierarchy-level mechanism to claim/deny sequences
The policy of sequence states has been made tighter on GtkGesture,
so gestures can never return to a "none" state, nor get out of a
"denied" state, a "claimed" sequence can go "denied" though.

The helper API at the widget level will first emit
GtkWidget::sequence-state-changed on the called widget, and then
notify through the same signal to every other widget in the captured
event chain. So the effect of that signal is twofold, on one hand
it lets the original widget set the state on its attached controllers,
and on the other hand it lets the other widgets freely adapt to the
sequence state changing elsewhere in the event widget chain.

By default, that signal updates every controller on the first usecase,
and propagates the default gesture policy to every other widget in the
chain on the second. This means that, by default:

1) Sequences start out on the "none" state, and get propagated through
   all the event widget chain.
2) If a widget in the chain denies the sequence, all other widgets are
   unaffected.
3) If a widget in the chain claims the sequence, then:
  3.1) Every widget below the claiming widget (ie. towards the event widget)
       will get the sequence cancelled.
  3.2) Every widget above the claiming widget that had the sequence as "none"
       will remain as such, if it was claimed it will go denied, but that should
       rarely happen.

This behavior can be tweaked through the GtkWidget::sequence-state-changed and
GtkGesture::event-handled vmethods, although this should be very rarely done.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
4ec1fafe2f docs: Add GtkWidget gesture functions 2014-05-23 19:54:22 +02:00
Carlos Garnacho
83ef067ae1 scrolledwindow: port to GtkGesture
The kinetic scrolling feature is now implemented using a
GtkGestureDrag and a GtkGestureSwipe, plus a GtkGestureLongPress
in order to denying the sequence, so it is possibly handled
underneath.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
76213ab209 widget: Add widget-level handling of touch sequence state.
These functions ATM do nothing but proxying the controller(s) state
with the given sequence.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
f1bb0283dd widget: Hook GtkEventController to widget event processing.
A controller can be optionally hooked on the capture or the bubble
phase, so the controller will automatically receive and handle events
as they arrive without further interaction.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
d0da82fed6 gtk: Remove propagation limit of captured events on the grab widget
Now, all captured events run from the toplevel to the deepmost widget,
regardless of GTK+ grabs. This makes captured events more useful to
event controllers if used together in the hierarchy with widgets doing
old fashioned event handling and GTK+ grabs.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
71e382cf42 gtk-demo: Add simple gestures demo 2014-05-23 19:54:22 +02:00
Carlos Garnacho
73c2964e85 hook GtkGesture* into docs generation 2014-05-23 19:54:21 +02:00
Carlos Garnacho
450c754c7c Add GtkGestureMultiPress
This gesture handles any number of clicks, ensuring multiple presses
stay within thresholds and timeouts. When anything of that happens,
the gesture is reset and press count starts from 1 again.

Optionally, the gesture can be given a rectangle, used in in presses > 1
to ensure the consecutive presses happen on user imposed areas.
2014-05-23 19:54:21 +02:00
Carlos Garnacho
8026bc3651 Add GtkGestureDrag
This gesture interprets and reports drags as an offset to the drag
start point.
2014-05-23 19:54:21 +02:00
Carlos Garnacho
9db3c2d893 Add GtkGestureZoom
This gesture interprets and reports relative scale differences when fed
with events from two different GdkEventSequences.
2014-05-23 19:54:21 +02:00