Commit Graph

53 Commits

Author SHA1 Message Date
Matthias Clasen
70bfb02fde GtkGesture: Don't leak the group link
Found in a valgrind log.
2014-06-28 20:15:12 -04:00
Carlos Garnacho
80d6735ffc gesture: Consume the event triggering ::begin if reset within the handler
If the event triggers GtkGesture::begin, and the handler ends up resetting
the gesture (say, due to taking a grab somewhere else within the handler),
still take the event as "managed", as it actually triggered recognition,
even if just to end abruptly.

https://bugzilla.gnome.org/show_bug.cgi?id=731711
2014-06-25 18:36:44 +02:00
Carlos Garnacho
c773859c99 gesture: Ensure late gestures handling the sequence get the group state
It might happen that a gesture claims a sequence before any other gesture
in its group even handled a single event from that sequence. In that case,
ensure the state is set accordingly right when the sequence is handled in
those.

The "group" gesture testcase has been updated to observe this behavior.
2014-06-03 15:59:03 +02:00
Carlos Garnacho
e0fd901722 gesture: Fix wrong assert in gtk_gesture_set_window
The window must be part of the event controller widget, so
fix the inverted logic.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
2e903243c6 eventcontroller: Make the event-mask property and methods private.
This will rarely have any use if no subclassing is allowed, so just make it
private for our own.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
485da90a2e gesture: Use GdkEventSequence GType in signals 2014-05-23 19:54:33 +02:00
Carlos Garnacho
7e61216105 gesture: Introspection fixes
Set annotations on return values for gtk_gesture_get_device() and
gtk_gesture_get_window().
2014-05-23 19:54:33 +02:00
Matthias Clasen
0442431943 Docs: Cosmetic fixes 2014-05-23 19:54:33 +02:00
Matthias Clasen
9f3f634c16 docs: Correct a reference 2014-05-23 19:54:33 +02:00
Matthias Clasen
c83d3f054b Revert "docs: More GtkEventController removal"
This reverts commit 75f503fb1fc9068c9e1a0d02126c55addbe8eb3e.
2014-05-23 19:54:32 +02:00
Matthias Clasen
ae5f930d1b Docs: Add information about event propagation 2014-05-23 19:54:32 +02:00
Matthias Clasen
aead8a360b Docs: Minor changes 2014-05-23 19:54:32 +02:00
Matthias Clasen
729a3a98d9 Document gtk_gesture_set_state 2014-05-23 19:54:32 +02:00
Matthias Clasen
01cd5cf382 docs: More GtkEventController removal 2014-05-23 19:54:32 +02:00
Carlos Garnacho
f322e55e19 gesture: Declare GtkGesture:window as an object property 2014-05-23 19:54:32 +02:00
Carlos Garnacho
1c48cc253d gesture: Add GTK_PHASE_TARGET
This phase is meant to run in the default widget handlers, as opposed
to externally as in the bubble/capture phase. This will be most usually
the expected phase for every controller replacing code in event handlers
in GTK+, just so invocation and triggering order is kept unaltered.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
3d34f26a6a gesture: Handle GdkEventGrabBroken
That may happen separately from grab-notify, and also due to external
reasons, so ensure all sequences are cancelled if a grab is taken
in some GdkWindows that would obscure events on the controller.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
fe9685bca1 widget: tighten the conditions at which a press event is emulated
Make it really sure that the event is only emitted after every gesture
that consumed the button press is done with the sequence.
The event must only be emulated if a gesture in the capture phase happened
to consume the event, be cancelled, and
2014-05-23 19:54:30 +02:00
Carlos Garnacho
2a0bf33bc9 gesture: Prevent against sequence cancellation within gtk_gesture_set_state()
Sequences may be cancelled within the ::sequence-state-changed handler, which
would change the points hashtable as it's being iterated in this function. So
iterate over a list of sequences and let the hashtable change freely.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
44a960199b gesture: Make gtk_gesture_get_last_update_time() private 2014-05-23 19:54:29 +02:00
Carlos Garnacho
83d5795154 gesture: Remove gtk_gesture_get_last_event_type 2014-05-23 19:54:29 +02:00
Carlos Garnacho
8ab35016a6 gesture: make gtk_gesture_cancel_sequence() private 2014-05-23 19:54:29 +02:00
Carlos Garnacho
0288fd0a88 gesture: Make gtk_gesture_check() private 2014-05-23 19:54:29 +02:00
Carlos Garnacho
5369c77029 gesture: Simplify gesture/widget interaction public API
The propagation phase property/methods in GtkEventController are gone,
This is now set directly on the GtkWidget add/remove controller API,
which has been made private.

The only public bit now are the new functions gtk_gesture_attach() and
gtk_gesture_detach() that will use the private API underneath.

All callers have been updated.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
db55f8a4e5 gesture: Add explanatory note in GtkGesture::end
Explain that this signal may be triggered by an extra touch that causes
the gesture to surpass GtkGesture:n-points.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
5c9f4bd078 gesture: Cancel sequences that make a gesture exceed the number of touches as they happen
This makes it possible to track those through gtk_gesture_handles_sequence(),
without guessing from last event type or sequence state.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
e080eafef8 gesture: Handle GDK_TOUCH_CANCEL events
The wayland windowing backend emits such events for instance, so
have gestures cancel the sequence as those events get through.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
d9e6395ee9 gesture: Protect against odd window hierarchies
If no match is found with the gesture widget when poking the event
window parents, bail out safely instead of falling in an infinite
loop. This was seen on Mutter.
2014-05-23 19:54:29 +02:00
Matthias Clasen
42df9eda2d Prevent subclassing of gestures
For now, at least. We do this by hiding the instance and
class structures in private headers.
2014-05-23 19:54:28 +02:00
Carlos Garnacho
ec50d776ce gesture: doc fixes 2014-05-23 19:54:27 +02:00
Carlos Garnacho
ac8dcccb32 gesture: Add missing documentation 2014-05-23 19:54:27 +02:00
Carlos Garnacho
b0a23dbfbd gesture: Add grouping API
This API eliminates the need for overriding
GtkWidget::sequence-state-changed virtually everywhere. Grouped
gestures share common states for a same GdkEventSequence, so the
state of sequences stay in sync across those.
2014-05-23 19:54:25 +02:00
Carlos Garnacho
6433a5452e gesture: Add gtk_gesture_set_state() helper.
This function sets the state on all sequences where it actually
can, just a helper function to avoid iterating over sequences
yourself.
2014-05-23 19:54:25 +02:00
Carlos Garnacho
72f8c673da gesture: emit the current state on ::sequence-state-changed 2014-05-23 19:54:25 +02:00
Carlos Garnacho
ae241714c4 gesture: group continue conditions together 2014-05-23 19:54:25 +02:00
Carlos Garnacho
8ebcca2ef6 gesture: return TRUE if the sequence state was already set 2014-05-23 19:54:25 +02:00
Carlos Garnacho
f3257e1a54 gesture: fix compiler warning 2014-05-23 19:54:25 +02:00
Carlos Garnacho
4570837e48 gesture: ignore events if now widget window was found 2014-05-23 19:54:25 +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
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
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
c4944b0376 gesture: Remove the touch-only property
This is handled in GtkGestureSingle.
2014-05-23 19:54:22 +02:00