Commit Graph

339 Commits

Author SHA1 Message Date
Peter Hutterer
48aa1bb08f wayland: add gdk_event_is_scroll_stop_event()
And use it to handle kinetic scrolling in the GtkScrolledWindow.

However, dropping the delta check causes the X11-based kinetic
scroll to break since we don't have the stop event here. Correct handling of
xf86-input-libinput-based scroll events is still being discussed.

https://bugzilla.gnome.org/show_bug.cgi?id=756729
2016-01-18 21:36:23 +01:00
Cosimo Cecchi
f357ef5610 scrolledwindow: add missing deprecation flag 2015-12-30 10:44:12 -08:00
Cosimo Cecchi
79c045ed80 scrolledwindow: port to use a gadget 2015-12-29 13:51:06 -08:00
Cosimo Cecchi
7c0f0e882a scrolledwindow: deprecate scrollbars-within-bevel style property
These days all the themes set it to TRUE, and it's not clear what
happens with overlay scrollbars...
2015-12-29 13:51:06 -08:00
Carlos Garnacho
e2c8d3c680 scrolledwindow: Remove unneeded code
We no longer take a grab here, no need to undo it on grab_notify
2015-12-16 19:47:06 +01:00
Timm Bäder
2182fe7d9d Don't pass widget state flags to GtkStyleContext API 2015-11-22 17:11:35 +01:00
Matthias Clasen
cf7f23f4dd scrolledwindow: Document overlay scrolling style classes
Document which style classes are used on scrollbars to
implement overlay scrolling.
2015-11-06 23:35:20 -05:00
Matthias Clasen
353bfb0092 scrolledwindow: Set positional classes on scrollbars
This might be useful for some themes.
2015-11-06 23:28:22 -05:00
Matthias Clasen
f900bec4fa scrolled window: Drop unnecessary transient nodes
We already add the .frame style class to the context depending
on the shadow property. No need to save the context and add it
again all the time.
2015-11-06 22:58:08 -05:00
Matthias Clasen
f327ef3cf1 scrolledwindow: Use permanent CSS nodes
This avoids false inheritance due to gtk_style_context_save_named(),
and is generally the right thing to do.
2015-11-05 10:32:04 -05:00
Krzesimir Nowak
4fe04ab54a scrolledwindow: Fix a typo 2015-11-04 14:19:13 +01:00
Matthias Clasen
80af6ff130 scrolledwindow: Port to CSS nodes
Change GtkScrolledWindow to use transient named CSS nodes for
drawing the overshoot, undershoot and scrollbar junction.
2015-11-04 07:38:15 -05:00
Matthias Clasen
dd3f4f2904 scrolled window: Protect against nameless devices
It seems that gdk_device_get_name() can return NULL.
We should not crash if that happens.

https://bugzilla.gnome.org/show_bug.cgi?id=756625
2015-10-15 16:06:15 -04:00
Carlos Garnacho
5b6360ebb2 scrolledwindow: Set the scrollbar as "over" immediately during slider grabs
Otherwise it's attempted through a timeout, which gets cancelled early after,
and the slider disappears after a while with no mouse activity despite the
ongoing implicit grab.

Once the grab is finished, check_update_scrollbar_proximity() will be called
again on both scrollbars, and the fade out animation will be triggered as a
result.

https://bugzilla.gnome.org/show_bug.cgi?id=754745
2015-09-16 19:14:10 +02:00
Carlos Garnacho
e1694a719f scrolledwindow: Cancel kinetic/overshoot animation on captured scroll events
This ensures the animation is cancelled if the child widget happens to
GDK_EVENT_STOP scroll events.

https://bugzilla.gnome.org/show_bug.cgi?id=745315
2015-09-14 19:31:56 +02:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Matthias Clasen
e3025f2325 scrolled window: Convert to g_object_notify_by_pspec 2015-09-08 08:07:32 -04:00
Carlos Garnacho
8599f209c1 gtkscrolledwindow: Fold kinetic deceleration handling into scroll_event()
In order to play along with child widgets that use scroll events for anything
else than scrolling, it will be better to do this in the bubble phase, so
the child widget has an opportunity to GDK_EVENT_STOP the event before we
trigger kinetic scrolling.

This of course won't work for widgets that choose to reimplement scroll event
handling themselves, they should be smart at resorting to GtkScrolledWindow's
scroll event handling.

This fixes kinetic scrolling kicking in too pervasively on widgets that eg.
implement zoom on scroll events.

https://bugzilla.gnome.org/show_bug.cgi?id=753495
2015-08-19 21:54:51 +02:00
Marek Kasik
359534ee59 GtkScrolledWindow: Don't handle key event when can't scroll
Don't return that a key event was handled when the corresponding
scrollbar can not scroll.

https://bugzilla.gnome.org/show_bug.cgi?id=753256
2015-08-05 17:15:52 +02:00
Carlos Garnacho
dec95caf94 scrolledwindow: Keep scrollbars out of GtkScrollable::get_border
It looks a bit odd that scrollbars stay over treeview headers and
similar, seems nicer to just avoid the border regions.

https://bugzilla.gnome.org/show_bug.cgi?id=751805
2015-07-06 16:37:31 +02:00
Cosimo Cecchi
6ff19bcedc scrolledwindow: fix copy/paste typo
fc28303948 refactored code into the
get_scroll_unit() function but introduced a copy/paste typo.
2015-05-24 12:06:42 -07:00
Carlos Garnacho
48bfabe59e scrolledwindow: Trigger builtin kinetic deceleration on libinput devices
The libinput driver will send a 0/0 scroll event on touchpads and other
devices where it knows scrolling stopped for sure. Use these events to
trigger kinetic scrolling from there.

The mechanism is similar to GtkGestureSwipe, we keep a backlog of the
latest dx/dy till a previous point in time, and calculate the final
velocities from there, with the difference we're dealing with scroll
units, and not pixel distances.

https://bugzilla.gnome.org/show_bug.cgi?id=749770
2015-05-24 16:58:35 +02:00
Carlos Garnacho
fc28303948 scrolledwindow: Refactor scroll unit guessing into a separate function
Makes it clearer, and will be used in further places.

https://bugzilla.gnome.org/show_bug.cgi?id=749770
2015-05-24 16:58:35 +02:00
Carlos Garnacho
f00214e922 scrolledwindow: reset more Indicator state on ::unmap
If a GtkScrolledWindow is just unmapped and promptly mapped again, the
indicators are left in a semi-visible state, so the GdkWindow isn't raised
properly above scrolledwindow content. This inconsistent state went away
the next time the indicator is hidden.

So, reset all state about indicator window visibility, animation
progress and conceil timer on ::unmap, this will be enough to make the
indicators start out hidden like on newly created scrolledwindows.
2015-05-22 21:16:36 +02:00
Carlos Garnacho
4eb8157cfa scrolledwindow: Do not round dx/dy to int
Libinput will use 0.0f on the "scrolling finished" event, so check for this
instead of rounding (<1 values are sort of frequent on touchpads). This
impedes bug #745315 to resurface after commit d563b943ed.
2015-04-16 22:45:54 +02:00
Carlos Garnacho
6d19162c43 scrolledwindow: Ensure the animation is cancelled on arriving scroll events
When the scrolledwindow receives scroll events, it ensures the timeout to
maybe start the "snap back to edges" animation is reset, but it does nothing
about the animation source. It must be reset just the same, to maybe be
started after the timeout fires up.
2015-04-16 18:40:32 +02:00
Carlos Garnacho
71c0efb361 scrolledwindow: Show scrollbars on tablet devices
The code managing scrollbars visibility was too pervasively checking for
mouse devices, leaving pen/eraser/cursor devices with no scrollbars at
all. Relax these checks a bit, and actually toggle full-width scrollbars
on pen/eraser devices, so it is an easier target.

https://bugzilla.gnome.org/show_bug.cgi?id=747608
2015-04-13 17:27:04 +02:00
Matthias Clasen
4c80ac0733 Fix indicator proximity checks
The coordinate translations here were not working properly
for window widgets inside the scrolled window, as can be
seen e.g. for the horizontal scrollbar of the 'Tree View'
example in gtk3-demo.

https://bugzilla.gnome.org/show_bug.cgi?id=747406
2015-04-06 21:27:17 -04:00
Matthias Clasen
cfb5f160f2 Make indicators pop out when needed
When moving over a non-expanded indicator from the outside, we were
not expanding it, due to on_scrollbar being true. This can be seen
e.g. when moving from the content pane over to the sidebar indicator
in gtk3-demo. We must still ensure that the indicator is expanded
when receiving motion events over the indicator.

https://bugzilla.gnome.org/show_bug.cgi?id=747407
2015-04-06 19:37:14 -04:00
Carlos Garnacho
b1696436d1 scrolledwindow: Ignore 0/0 scroll events when possibly cancelling animation
These should be used eventually to start kinetic scrolling, so should definitely
be ignored on cancellation.

https://bugzilla.gnome.org/show_bug.cgi?id=747133
2015-04-01 16:24:36 +02:00
Carlos Garnacho
960c229220 scrolledwindow: Remove needless "dragging" field from Indicator struct
The "over" state already stays set while scrollbar dragging happens, there's
no need to double track that.

https://bugzilla.gnome.org/show_bug.cgi?id=746961
2015-03-31 13:18:35 +02:00
Carlos Garnacho
eb26208c08 scrolledwindow: Check the event widget on captured motion events
This path is only intended to be triggered on events directed towards the
child of the scrolledwindow, so make it explicitly so. This avoids scrollbar
"over" state flashing when dragging finishes within the slider.

https://bugzilla.gnome.org/show_bug.cgi?id=746961
2015-03-31 13:18:35 +02:00
Hans de Goede
36baf9207e scrolledwindow: Extend trackpoint heuristic to ALPS trackpoints
These have a different characteristic device name, look for it too
in order to enable trackpoint features.
2015-03-26 19:46:56 +01:00
Matthias Clasen
d823c39caf scrolled window: Use shift to modify scroll direction
It has been a long-standing request to interpret scroll events
with Shift held down as horizontal instead of vertical, and
some applications are already doing this on their own.

https://bugzilla.gnome.org/show_bug.cgi?id=132197
2015-03-17 20:50:24 -04:00
Matthias Clasen
6e7ad732fc scrolled window: Fix size requisition with overlay scrolling
When the scrollbars are overlayed, the size requisition of the
scrolled window should not depend on whether the scrollbars are
visible or not. This was not quite the case, because we forgot
one case where scrollbar size was still added to the requisition.
2015-03-07 14:18:13 -05:00
Carlos Garnacho
3ccfcf5b9f scrolledwindow: Cancel kinetic/overshoot animation on captured scroll events
This ensures the animation is cancelled if the child widget happens to
GDK_EVENT_STOP scroll events.

https://bugzilla.gnome.org/show_bug.cgi?id=745315
2015-03-02 17:42:04 +01:00
Carlos Garnacho
1feaa6f301 scrolledwindow: Add motion mask to the widget window
This is not specified specifically by the attached controllers, so let
the scrolledwindow set the mask, as motion events with no buttons pressed
are interesting to it.

https://bugzilla.gnome.org/show_bug.cgi?id=745344
2015-03-02 15:49:40 +01:00
Carlos Garnacho
0c903156ef scrolledwindow: Only start fade animation on "visible" scrollbars
If a scrollbar is not shown (because of policies, or because it isn't
necessary), it doesn't make sense to start fade animations on its window
on captured motion events.
2015-02-24 14:55:23 +01:00
Matthias Clasen
3a671994d4 scrolled window: Avoid a crash
gtk_scrolled_window_allocate_scrollbar was calling
gtk_scrolled_window_allocate_child just to get the relative
allocation, overlooking the fact that that function is only
safe to call if the scrolled window _has_ a child. Unfortunately,
gtk_scrolled_window_allocate_scrollbar will sometimes get called
when that is not the case. Since we are really only interested
in the relative allocation, just get that directly. This
fixes a segfault in the style-properties-nth-child reftest.
2015-02-20 08:28:58 -05:00
Matthias Clasen
4fc98ae345 scrolled window: Drop dead code
The allocation is never used in this function, so don't bother
getting it.
2015-02-20 08:28:58 -05:00
Carlos Garnacho
5a907cc094 scrolledwindow: Ensure indicator windows are created at the right place
At the time of creating the indicator window, the scrollbar allocation is
poked and reused as the initial window dimensions. This usually happens
on two circumstances, either initially (so a ::size-allocate is emitted,
relocating the windows in the right places), or post-initialization when
calling set_overlay_scrolling() (so the scrollbars already have a valid
size allocation)

However, if the scrolledwindow is unrealized, and later re-realized again,
the scrollbars will already have a valid allocation, although 0,0 based
due to being contained in the previous indicator window. This comes out
wrong then, and the indicator window is given 0,0 based coordinates too.

Fix this by refactoring the scrollbar allocation code out of size_allocate,
and also use that given size at the time of creating the indicator windows,
this will provide the right widget-relative allocation anytime.
2015-02-17 16:32:36 +01:00
Carlos Garnacho
c473afbdc9 scrolledwindow: Fully reset indicators' state on unrealize
This avoids timers to run after realize(), and inconsistent initial states
if the scrolledwindow is just realized again.
2015-02-17 16:32:36 +01:00
Carlos Garnacho
6b82ad48f6 scrolledwindow: Don't hover the scrollbars while a button is being pressed
This avoids showing the scrollbars if we are positive the child widget
is being manipulated, regardless of the pointer being close to any of these.
On the next motion event after finishing the operation, the scrollbar will
be shown if necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=743894
2015-02-05 17:24:29 +01:00
Carlos Garnacho
93ae728cc6 scrolledwindow: Don't hide indicators if leaving towards a child
In that case the scrolledwindow still gets events through the captured
handler, and can thus still control visibility, so hiding the indicators
in this case can only lead to flashing.
2015-02-02 13:01:52 +01:00
Cosimo Cecchi
404e2753c4 scrolledwindow: add a new edge-reached signal
This will be used to just detect when an edge of the scrollable area is
reached - as opposed to the edge-overshot signal that is emitted when
the user scrolls past the edge.

https://bugzilla.gnome.org/show_bug.cgi?id=742848
2015-01-31 23:08:17 +00:00
Carlos Garnacho
dc952e3d94 scrolledwindow: Don't displace invalidation by the widget allocation
This was left unmodified when GtkScrolledWindow was made a windowed widget.
Displacing here by the widget allocation is not necessary anymore, since
we are invalidating the window set at these coordinates.

This patch is a simplification of a previous one by Timm Bäder.

https://bugzilla.gnome.org/show_bug.cgi?id=742243
2015-01-19 13:06:27 +01:00
Matthias Clasen
9e1f870680 scrolled window: Reduce the hover proximity distance further 2015-01-18 20:01:55 -05:00
Matthias Clasen
9fde44ac10 Fine-tune the proximity hovering for scrollbars
Reduce the distance at which we expand the scrollbar,
and add some hysteresis.
2015-01-18 14:28:47 -05:00
Matthias Clasen
9fcbae2d85 GtkScrolledWindow: Don't start fading right away
When we get a leave event, we need to remove the over bit,
since we may not get motion events that tell us when we lose
proximity, but we don't have to fade out right away - that
will happen on its on due to inactivity a bit later. Having
the indicator stay visible for a bit feels more relaxed.
2015-01-09 21:15:07 -05:00
Matthias Clasen
206f0bbf7f GtkScrolledWindow: Factor out a constant
Define INDICATOR_CLOSE_DISTANCE instead of hardcoding the same
number of pixels in 4 different places.
2015-01-09 21:15:06 -05:00