Commit Graph

38332 Commits

Author SHA1 Message Date
Matthias Clasen
a47d0406a7 inspector: Add more complete gesture support
Add a dedicated tab that shows how gestures are grouped,
and allows changing the propagation phase.
2014-05-23 19:54:32 +02:00
Matthias Clasen
1c5f14a9e4 inspector: Minimal support for gestures
We're just showing them as objects in the tree, for now.
2014-05-23 19:54:32 +02:00
Matthias Clasen
a727c41e4a Add back a private api to list controllers
This will let us show them in the inspector.
2014-05-23 19:54:32 +02:00
Carlos Garnacho
2ba89256f4 texthandle: Make a bigger hit area around texthandles
The hit area now extends to all sides around the handle, instead
of just towards where the text is. This makes it easier to grab
handles once shown.
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
f81f00ed6b widget: 3-way merge ate my g_object_ref()
Move it to the right place.
2014-05-23 19:54:32 +02:00
Carlos Garnacho
d351c52114 scrolledwindow: Handle directional cancellation if there is a single scroll direction
A pan gesture is optionally attached if there is only one scrolling direction, the pan
gesture orientation is changed so movements tangential to the scroll direction get
scrolling cancelled (The pan gesture is automatically denied when that happens, and
that state change spreads to the others gestures in the group). If the pan direction
happens in the expected directions, no cancellation happens, and scrolling eventually
takes place.
2014-05-23 19:54:32 +02:00
Carlos Garnacho
57eca4f445 widget: remove check on whether the controller was already added
Multiple calls are supposedly allowed to change the phase (although
unlikely to happen), so remove the g_return_if_fail() checking whether
the controller was already added.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
bd68db4b25 pan: Remove wrong check
From the very early days where there were a NONE=0 GtkPanOrientation
value. This makes vertical pan operations work as expected.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
e70e3963dd entry: Ensure the cursor text handle is shown after touching to reposition cursor. 2014-05-23 19:54:31 +02:00
Carlos Garnacho
cf7bb9a3bf popover: Hide widget first when disposing
In order to ensure invariants are kept.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
15f7170358 entry: Obey implementations' frame when placing handles/popovers around
Y=0 was assumed in a few places, not necessarily right on eg. vertical
spinbuttons.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
10c47fa6d6 entry: Improve touch popover interaction
Presses alternatively show and dismiss the popover, the popover is still
always shown invariably after any dragging happens (either text selection,
or dragging a text handle)
2014-05-23 19:54:31 +02:00
Carlos Garnacho
bd5fb3a09f textview: Show the magnifier popover a bit farther from the touch position
Somewhat arbitrary at the moment, would be nice to have minimal units
support for this, or at least hidpi support.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
b2d56c588a textview: Improve touch popover interaction
Presses alternatively show and dismiss the popover, the popover is still
always shown invariably after any dragging happens (either text selection,
or dragging a text handle)
2014-05-23 19:54:31 +02:00
Carlos Garnacho
e580c29f07 entry: Use gestures to handle pointer/touch events
Similarly to GtkTextView, a GtkGestureMultiPress gesture handles
button/touch presses to initiate one selection mode or other, and
a GtkGestureDrag is used to handle text selection and DnD checks.

The code from button press/release, motion, and grab_notify handlers
has been shuffled into the actions triggered by those gestures.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
d559cade42 spinbutton: Attach "swipe to spin" controllers to the bubble phase
It is unnecessary to have those process events manually, just attach
those to the bubble phase.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
70ea24b9e8 colorplane: Fully port to GtkGesture
A GtkGestureDrag is used for color selection, removing also the
need to track the pointer state in widget data. The GDK grab performed
just to set the crosshair cursor has been replaced by a call
to gdk_window_set_device_cursor(), which will be unset if the
drag operation is finished, or cancelled due to the implicit grab
being broken.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
a6526eb820 gdk: Lookup both device and global cursor when checking up the hierarchy
When the pointer cursor is updated on CSW, lookup for either a device
cursor, or a global one. It would previously lookup for windows with
a global cursor, and then check if it had a device cursor, which would
skip windows with only device cursors set, and unexpectedly set the
global cursor.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
ced7e7c08d button: Make multipress gesture exclusive
We only want actions to be triggered by a single sequence there,
so buttons trigger no actions on further simultaneous touches
happening.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
0b3f4d5555 gesturesingle: Add an "exclusive" boolean property
All "exclusive" gestures listen for either pointer events, or
"pointer emulating" touch events, so only a single sequence at
a time can make these run.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
fd9925141b button: Use GtkGestureMultiPress for signal emission
It is now useful for that purpose with a ::release signal, so replace
the custom GtkGestureSingle with one of these.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
e638ff7974 drag: Allow gtk_gesture_get_start_point/offset() to be called on ::drag-end 2014-05-23 19:54:30 +02:00
Carlos Garnacho
d2db31ee5e multipress: Add matching ::released signal
This signal will always be paired with a ::pressed signal, unless
the sequence is cancelled, or the controller is reset. the n_press
argument in the signal always matches the ::press signal one, even
if GtkGestureMultiPress::stopped was emitted in between.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
04c8b4c705 multipress: Protect against fleeting touches mistriggering events
The current sequence (as per gtk_gesture_single_get_current_sequence)
is used to find out the coordinates. And only emit ::pressed if the
gesture began through a GDK_BUTTON_PRESS/TOUCH_BEGIN (eg. not due to
an extra touch being lifted)
2014-05-23 19:54:30 +02:00
Carlos Garnacho
24f20864b4 textview: Set up controllers on the GTK_PHASE_TARGET propagation phase
This way events are managed by gestures in the event handlers themselves,
respecting the execution order already assumed by subclasses around.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
dd164502f7 widget: Hook GTK_PHASE_TARGET controllers to the default event handlers
Just call the controllers on that phase if the default widget handlers
are run.

For compatibility reasons, in the touch event handler, let the pointer
emulating touch be transformed to a pointer event as usual, in order to
have widget handlers a chance to run at all. If they have to be managed
by a controller in that phase, it'll have to be through the default pointer
event handlers.
2014-05-23 19:54:30 +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
Matthias Clasen
6a290bdecb GtkColorSwatch: Use gesture for button events too 2014-05-23 19:54:30 +02:00
Matthias Clasen
6896c979a9 GtkWindow: Only use a multipress gesture for toplevels
There is no point in creating and attaching this gesture
for override-redirect windows, so don't do it.
2014-05-23 19:54:30 +02:00
Matthias Clasen
bad1dd4ac7 Be careful about the list of event controllers
We can end up with _gtk_widget_remove_controller getting called
while we are iterating over the list in _gtk_widget_run_controllers.
To avoid trouble, only mark the event controller as dead by
setting data->controller to NULL, and defer the actual freeing
and list manipulation to the loop in _gtk_widget_run_controllers.
Update other places that operate on controllers to handle
data->controller being NULL.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
d97e4bf6b7 textview: Convert gestures' coordinates to text window ones
And make some code shared between multipress/drag gesture.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
f47138b653 textview: Use GtkGestureDrag for text selection/DnD
remaining code in button press/release, motion notify, and grab
notify handlers has been shuffled to be managed by this gesture.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
a4da4f8dfa textview: Use GtkGestureMultiPress for click handling
The button press handler is no longer necessary, and most of its
code has been shuffled into the GtkGestureMultiPress::pressed
handler.
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
6e9b054543 widget: Fix gesture event handler retval for bubbled events
Do not clobber the return value if the regular event handler happens
to return FALSE, even if the gesture meant to consume the event.
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
994c94c25b dnd: Check on the right gesture sequence when starting the drag op 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
f0940c962f widget: Keep a widget reference around _gtk_widget_run_controllers()
The widget may be destroyed within the loop, in reaction to the signals
sent by the controllers. Protect against that.
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
134acf3fda widget: Change slightly the gesture cancellation policy in a same widget
Within a widget, if a gesture accepts a sequence, it would previously
cancel every other gesture that not in the same group. Change this to
only cancelling gestures that previously claimed the gesture, and let
gestures with state=NONE for that sequence remain like that.

This enables late recognition of gestures, even on the presence of
another gesture group that was more eager at claiming the gesture.

One usecase is user-defined panning gestures on scrolledwindows,
if ::capture-button-press is TRUE (eg. the default), the gesture is
claimed early in order to consume the button press, but that would
tipically make every other gesture group deny the sequence. With
this change, the pan gesture can keep state=NONE, and later claim
the sequence for itself if the panning gesture is recognized.

Also, do not propagate state=DENIED to every gesture in the widget,
that was unintended.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
4589f0e0c8 rotate: Ensure delta is between [0..2π] 2014-05-23 19:54:29 +02:00
Carlos Garnacho
c34280d97b pan: make the direction factor less narrow in v/h directions 2014-05-23 19:54:29 +02:00