Commit Graph

31262 Commits

Author SHA1 Message Date
Carlos Garnacho
939ed582ec spinbutton: Set GDK_SCROLL_MASK explicitly
selecting for button press/release doesn't suffice anymore to
get scroll events.
2012-03-01 16:29:00 -05:00
Carlos Garnacho
2927218a26 calendar: Set GDK_SCROLL_MASK explicitly
selecting for button press/release doesn't suffice anymore to
get scroll events.
2012-03-01 16:29:00 -05:00
Carlos Garnacho
a5c394e901 menu: Handle smooth scrolling
event->scroll.delta_y will be used to scroll the menu contents,
GDK_SMOOTH_SCROLL_MASK has been set as well
2012-03-01 16:29:00 -05:00
Carlos Garnacho
f34a236814 viewport: set GDK_SMOOTH_SCROLL_MASK
This is so smooth scroll events are send/handled by the
parent GtkScrolledWindow if any.
2012-03-01 16:28:59 -05:00
Carlos Garnacho
faa1d9b8f8 treeview: set GDK_SMOOTH_SCROLL_MASK
This is so smooth scroll events are send/handled by the
parent GtkScrolledWindow if any.
2012-03-01 16:28:59 -05:00
Carlos Garnacho
76462df59f layout: set GDK_SMOOTH_SCROLL_MASK
This is so smooth scroll events are send/handled by the
parent GtkScrolledWindow if any.
2012-03-01 16:28:59 -05:00
Carlos Garnacho
7381a2788b iconview: set GDK_SMOOTH_SCROLL_MASK
This is so smooth scroll events are send/handled by the
parent GtkScrolledWindow if any.
2012-03-01 16:28:59 -05:00
Michael Natterer
2a72e7b7b8 gtk: Implement smooth scrolling in scrolledwindow/range
If delta_x/y information is provided in scroll events, use it
to modify the underlying adjustment in steps proportional to
the deltas provided.

If the child widget of a scrolledwindow doesn't set
GDK_SMOOTH_SCROLL_MASK, regular scroll events will be dispatched,
and still handled by these 2 widgets.
2012-03-01 16:28:58 -05:00
Carlos Garnacho
147cdd8465 devicemanager,xi2: Implement smooth scrolling
XInput >= 2.1 allows for implementing smooth scrolling,
reporting the different scrolling axes as valuators.
Any change in those will be reported as GdkEventScroll
events with delta_x/y information.

the older kind of scroll events is still handled, and
emulated in devices able to provide smooth scrolling,
setting _gdk_event_set_pointer_emulated() in that case.
2012-03-01 16:28:58 -05:00
Carlos Garnacho
f941c78969 devicemanager,x11: Initialize event->scroll.delta_x/y to 0 on core events 2012-03-01 16:28:58 -05:00
Michael Natterer
d0b032e3be quartz: Implement smooth scrolling
nsevent scrollingDeltaX/Y (available on OSX >= Lion) is used to
provide the smooth scrolling values. In any case, old fashioned
events are still sent, setting _gdk_event_set_pointer_emulated()
if the event contains both smooth and non-smooth values.
2012-03-01 16:28:58 -05:00
Carlos Garnacho
77cbc98044 gdk: update csw event mask filter to handle smooth scroll
Events of type GDK_SCROLL will be received if the client side window
event mask has either GDK_SCROLL_MASK or GDK_SMOOTH_SCROLL_MASK.

GDK_BUTTON_PRESS_MASK has been removed from type_masks[GDK_SCROLL]
as that bit is often set for other-than-scrolling purposes, and
yet have the window receive scroll events. In GTK+, this forces
non-smooth events bubbling, even if the widgets above want smooth
events, and legitimately set GDK_[SMOOTH_]SCROLL_MASK.
2012-03-01 16:28:57 -05:00
Carlos Garnacho
b177bd92aa gdk: Filter out either smooth or non-smooth event depending on the evmask
If a device provides both smooth and non-smooth events, the latter will be
flagged with _gdk_event_set_pointer_emulated() so the client side window
receives one or the other. If a device is only able to deliver non-smooth
events, those will be sent, so both direction/deltas may need to be handled.
2012-03-01 16:28:57 -05:00
Carlos Garnacho
4b1e16cac6 gdk: Add GDK_SMOOTH_SCROLL_MASK
By setting this event, a GdkWindow will receive scroll events
that provide delta values.
2012-03-01 16:28:57 -05:00
Michael Natterer
c41b52b4f6 gdk: transfer event->scroll.delta_x/y through csw 2012-03-01 16:28:57 -05:00
Carlos Garnacho
f47e470e58 gdk: deal with GDK_SMOOTH_SCROLL events as not having a direction
gdk_event_get_scroll_direction() will return FALSE on these, so
gdk_event_get_scroll_deltas() has to be used to retrieve dx/dy
2012-03-01 16:28:57 -05:00
Michael Natterer
0efbbc6435 gdk: Add delta_x/y to scroll events
gdk_event_get_scroll_deltas() can be used to retrieve those
values on smooth scroll events.
2012-03-01 16:28:56 -05:00
Carlos Garnacho
7b48a3c0bd gdk: Add GDK_SCROLL_SMOOTH to GdkScrollDirection
This value will be used for smooth scroll events, as they'll
express the scrolling direction in terms of dx/dy.
2012-03-01 16:28:56 -05:00
Carlos Garnacho
28e7d3c148 gdk: Get the right event window for pointer emulated events
get_event_window() just checked on GDK_TOUCH_MASK, including for emulated
pointer events, so at the very least those should also match evmasks with
no touch events whatsoever
2012-03-01 16:25:28 -05:00
Carlos Garnacho
0bb2e6f264 gdk: Set correct GdkModifierType on pointer emulated events 2012-03-01 16:25:27 -05:00
Carlos Garnacho
fcbcac0ca3 gdk: translate correctly from touch events into emulated pointer events 2012-03-01 16:25:27 -05:00
Matthias Clasen
11fdf1667c gdk: Don't treat touch events as button events
One more place where we assumed that touch events have a button
field.
2012-03-01 16:25:27 -05:00
Matthias Clasen
3880b12196 gdk: Use the last alive grab in order to get the event window
If an active grab kicks in on a different window, _gdk_display_has_device_grab()
would still find the former implicit grab for the window below the pointer, thus
sending events to an unrelated place.
2012-03-01 16:25:27 -05:00
Carlos Garnacho
9c6f71bfc7 gdk: Don't mutate pointer events to touch events just because a grab says so
If a grab with GDK_TOUCH_MASK kicks in due to a touch sequence emulating pointer
events, don't mutate the sequence into emitting touch events right away.
2012-03-01 16:25:27 -05:00
Carlos Garnacho
5942fee240 gdk: Let implicit touch grabs coexist with an implicit pointer grab
Create the backing GdkTouchGrabInfo for touches even if the pointer
emulating touch sequence is already holding an implicit grab on a
window that didn't select for touch events.
2012-03-01 16:25:26 -05:00
Carlos Garnacho
b897ba0cd8 gdk: Don't fully destroy the implicit touch grab on ::grab-broken
the backing GdkTouchGrabInfo will be needed if the overriding device
grab finishes before the touch does in order to send events back to
the implicit grab window. Instead, wait until the touch is physically
finished before removing the matching GdkTouchGrabInfo
2012-03-01 16:25:26 -05:00
Carlos Garnacho
6efe116715 gdk: Listen to touch events by default on the native window
GDK will only receive touch events when dealing with a multitouch
device, so these must be transformed to pointer events if the
client-side window receiving the event doesn't listen to touch
events, and the touch sequence the event is from does emulate
the pointer.

If a sequence emulates pointer events, it will result in a
button-press, N motions with GDK_BUTTON1_MASK set and a
button-release event, and it will deliver crossing events
as specified by the current device grab.
2012-03-01 16:25:26 -05:00
Carlos Garnacho
0a80c26cdf gdk: Only trigger motion hints machinery on motion events
Touch events have no need for it, plus the concept behind
gdk_event_request_motions() doesn't wrap around multiple
touches within a device.
2012-03-01 16:25:26 -05:00
Carlos Garnacho
2f2774b7a9 gdk: Have touch grabs behave like the implicit grab wrt crossing events
These are equivalent to an implicit grab (with !owner_events), so
if the touch leaves or enters the grab window, the other window
won't receive the corresponding counter-event.
2012-03-01 16:25:25 -05:00
Carlos Garnacho
c72a77b04c gdk: handle implicit touch grabs
If the touch sequence happens on a window with GDK_TOUCH_MASK set,
a GdkTouchGrabInfo is created to back it up. Else a device grab is
only created if the sequence emulates the pointer.

If both a device and a touch grab are present on a window, the later
of them both is obeyed, Any grab on the device happening after a
touch grab generates grab-broken on all the windows an implicit
touch grab was going on.
2012-03-01 16:25:25 -05:00
Carlos Garnacho
b5cfdf2db4 gdk: Add internal API to deal with touch implicit grabs
The necessary information about a touch implicit grab is stored in
GdkTouchGrabInfo structs, these are meant to be transient to the
touch sequence.
2012-03-01 16:25:25 -05:00
Carlos Garnacho
b5de12debd gdk: Don't change window_under_pointer for pure touch events
Only touch events that emulate the pointer do change it.
2012-03-01 16:25:25 -05:00
Carlos Garnacho
2ccf29f6b3 button: Handle touch events
Touch events don't generate crossing events themselves, so
do not rely on these to determine whether the button release
happened within the event window.
2012-03-01 16:25:25 -05:00
Carlos Garnacho
518a579838 range: Have slider jump to the pointer coordinates on touch devices
This widget is too narrow to make touch interaction tricky enough, so
don't add the penalty of having the slider run farther from the touch
coordinates if it happens to miss the slider.
2012-03-01 16:25:24 -05:00
Carlos Garnacho
535b4150fd menus: Don't popdown submenus on button release for touch devices
This is so submenus stay open as the parent menu item is
pressed/released, since the user would typically lift the
finger in order to select a submenu item.
2012-03-01 16:25:24 -05:00
Carlos Garnacho
0e8c2db131 settings: Deprecate gtk-touchscreen-mode
It's not used anywhere in GTK+ anymore.
2012-03-01 16:25:24 -05:00
Carlos Garnacho
6427fdb291 range: Remove gtk-touchscreen-mode usage
Emulated crossing events with mode GDK_CROSSING_TOUCH_PRESS/RELEASE
already cater dynamically for the "don't prelight on touch devices"
usecase.
2012-03-01 16:25:24 -05:00
Carlos Garnacho
87f6bb32ed togglebutton: Remove gtk-touchcreen-mode usage
Emulated crossing events with mode GDK_CROSSING_TOUCH_PRESS/RELEASE
already cater dynamically for the "don't prelight on touch devices"
usecase.
2012-03-01 16:25:24 -05:00
Carlos Garnacho
24e9a19abe menushell: Remove gtk-touchscreen-mode usage
This usage in a keybinding signal is hardly related to touchscreens,
so just remove it.
2012-03-01 16:25:23 -05:00
Carlos Garnacho
5b08ececa2 menus: Remove gtk-touchscreen-mode from scrolling code
Scrolling is handled via ::captured-event dynamically, so remove
this now unused code.
2012-03-01 16:25:23 -05:00
Carlos Garnacho
c49fc433de menus: Select the first item for touch devices
This was done through gtk-touchscreen-mode. Now it is handled
dynamically on the current event source device.
2012-03-01 16:25:23 -05:00
Carlos Garnacho
47f9435e99 menus: Implement scrolling through event capture for touch devices
This makes overflown menus scrollable via direct manipulation.
Once past the threshold, the item below the pointer is unselected
and scrolling starts.
2012-03-01 16:25:23 -05:00
Carlos Garnacho
5139617b91 menus: Handle item selection for touch devices dynamically
Instead of using gtk-touchscreen-mode, the behavior changes depending
on the source device in use.
2012-03-01 16:25:22 -05:00
Carlos Garnacho
51189ae260 tooltips: Use the source device instead of gtk-touchscreen-mode
This makes tooltips behavior dynamic based on the interacting device.
2012-03-01 16:25:22 -05:00
Carlos Garcia Campos
1a26b9a90a tests: Add new test for kinetic scrolling 2012-03-01 16:25:22 -05:00
Carlos Garcia Campos
8cde1e38a2 tests: Add checkbox to enable kinetic scrolling in scrolled window test 2012-03-01 16:25:22 -05:00
Matthias Clasen
42c75d28b8 viewport: select for touch events
This makes kinetic scrolling work with viewports where the
content does not otherwise select for button or touch events,
such as testscrolledwindow's label.
2012-03-01 16:25:22 -05:00
Carlos Garcia Campos
f6393199be scrolledwindow: Kinetic scrolling support
Kinetic scrolling is only done on touch devices, since it is
sort of meaningless on pointer devices, besides it implies
a different input event handling on child widgets that is
unnecessary there.

If the scrolling doesn't start after a long press, the scrolling is
cancelled and events are handled by child widgets normally.

When clicked again close to the previous button press location
(assuming it had ~0 movement), the scrolled window will allow
the child to handle the events immediately.

This is so the user doesn't have to wait to the press-and-hold
timeout in order to operate on the scrolledwindow child.

The innermost scrolled window always gets to capture the events, all
scrolled windows above it just let the event go through. Ideally
reaching a limit on the innermost scrolled window would propagate
the dragging up the hierarchy in order to keep following the touch
coords, although that'd involve rather evil hacks just to cater
for broken UIs.
2012-03-01 16:25:21 -05:00
Carlos Garnacho
8689921b90 gdk: Generate crossing events around touch devices' press/release
Anytime a touch device interacts, the crossing events generation
will change to a touch mode where only events with mode
GDK_CROSSING_TOUCH_BEGIN/END are handled, and those are sent
around touch begin/end. Those are virtual as the master
device may still stay on the window.

Whenever there is a switch of slave device (the user starts
using another non-touch device), a crossing event with mode
GDK_CROSSING_DEVICE_SWITCH may generated if needed, and the normal
crossing event handling is resumed.
2012-03-01 16:25:21 -05:00
Carlos Garcia Campos
9f4bfff1b0 gtk: Add a way to do event capture
This patch adds a capture phase to GTK+'s event propagation
model. Events are first propagated from the toplevel (or the
grab widget, if a grab is in place) down to the target widget
 and then back up. The second phase is using the existing
::event signal, the new capture phase is using a private
API instead of a public signal for now.

This mechanism can be used in many places where we currently
have to prevent child widgets from getting events by putting
an input-only window over them. It will also be used to implement
kinetic scrolling in subsequent patches.

http://bugzilla.gnome.org/show_bug.cgi?id=641836

We automatically request more motion events in behalf of
the original widget if it listens to motion hints. So
the capturing widget doesn't need to handle such
implementation details.

We are not making event capture part of the public API for 3.4,
which is why there is no ::captured-event signal.
2012-03-01 16:25:21 -05:00