Commit Graph

365 Commits

Author SHA1 Message Date
Carlos Garnacho
8e6a68c5fc GtkScrolledWindow: reset scroll history if it contained no real history
Scroll history must refer to a timespan for the values to be valid, otherwise
we return FALSE, in this case the stored event(s) should be discarded anyway.
2016-07-27 20:29:38 +02:00
Carlos Garnacho
9eb356d9f2 GtkScrolledWindow: Always uninstall scroll cursor when starting deceleration
It could be the case that the last scroll event is received long after any
previous scroll event, in this case the last scroll event discards all "old"
scroll events, and scroll_history_finish() returns FALSE because there's no
time/offset deltas in the scroll history.

This is desired so we don't trigger the deceleration effect if there was no
effective velocity, we still must reset the installed scroll cursor, so take
it out of this if() condition.
2016-07-27 20:28:23 +02:00
Tristan Van Berkom
a9a59ac55e scrolledwindow: Fix calls to gdk_window_move_resize()
This is a bit of fallout from 34feba1, now that we resolve
the has_indicators value earlier than realize, it becomes
possible to call gdk_window_move_resize() before realization.

Just added the appropriate checks.
2016-06-10 21:16:53 +09:00
Tristan Van Berkom
34feba1e7c scrolledwindow: Resolve whether we use overlay scrollbars early.
Widgets should support size requests before being realized in general,
otherwise this can cause flicker/resize at initial display time as
the toplevel window can make a request before realize/allocate.

This also makes the added testsuite/gtk/scrolledwindow.c test work again,
this was broken because we only ever calculate whether we are going
to use overlay scrollbars once the scrolled window is realized (and
the test case does not realize any window).
2016-06-09 14:57:10 +09:00
Tristan Van Berkom
d7e242eec0 scrolledwindow: Bug 766569 - General size request fixes.
This patch does a couple of things:

  o Removes the obscure 'extra_width' and 'extra_height' variables
    making the request code exceedingly difficult to read

  o Fixes the max-content-size properties introduced in bug 742281
    so that they do not grow the minimum request.

  o Cleanup of request code in general:
    - min/max content sizes are clamped around the child request as needed
    - scrollbar requests are only added in one place, after child request
      sizes are calculated and without the extra_width/height thing.
2016-06-09 14:57:10 +09:00
Kjell Ahlstedt
ff5304ee13 Make gtk_scrolled_window_remove() smart
If gtk_scrolled_window_add() has added a GtkViewport,
  gtk_container_remove (GTK_CONTAINER (scrolled_window), child_widget);
or
  gtk_container_remove(GTK_CONTAINER(scrolled_window),
                       gtk_bin_get_child(GTK_BIN(scrolled_window)));
removes both the added child widget and the viewport.

https://bugzilla.gnome.org/show_bug.cgi?id=710471
2016-06-08 10:30:22 +02:00
Matthias Clasen
dce4003c20 Fix preconditions in set_max_content_size setters
We must allow resetting the properties to -1.
2016-06-07 16:37:09 -04:00
Matthias Clasen
289fc9640b Revert "scrolledwindow: Bug 766569 - Report child natural size unconditionally"
This reverts commit 0943c9f6b2.

The commit caused unexpected breakage in gtk3-widget-factory,
and also broke the just-added max-content-size properties.
2016-06-06 14:35:46 -04:00
Tristan Van Berkom
03742e83fb scrolledwindow: Bug 767238 - Fixing up for max content sizes
Needed to adjust this again after applying commit 4e5ecb7
for bug 742281. Now that we also have max content size properties,
pushed the addition of possible scrollbar sizes to after the
clause which clamps the child request size into min/max content
sizes.
2016-06-06 12:04:58 +09:00
Tristan Van Berkom
0943c9f6b2 scrolledwindow: Bug 766569 - Report child natural size unconditionally
This patch causes the scrolled window default behavior to change in
such a way that the natural size request of the child is unconditionally
reported, which probably should have been the case since day 1.

This should not cause significant fallout since a scrolled window is
normally used to expand/fill, eating up remaining space for scrollable
content - it will however cause the scrolled window to compete for
additional space with siblings, proportionally to the size of the
scrolled window's content.
2016-06-06 11:37:21 +09:00
Matthias Clasen
b4ebe4e5c1 scrolled window: Free gestures and gadgets in finalize
This is the right place for this.
2016-06-05 20:00:43 -04:00
Georges Basile Stavracas Neto
4e5ecb7052 scrolledwindow: add ::max-content-width and -height properties
The GtkScrolledWindow has support to set the minimum content size (both
width and height) which controls the minimum space allocated, but does
not exposes any way to control the maximum size the content can grow.

After the introduction of GtkPopover, which always uses the minimum
size of it's children widgets, the lack of max-content-width and -height
properties became a concrete use case.

This patch introduces the GtkScrolledWindow::max-content-width and
-height properties. The properties will alter the minimum size of
the scrolled window, making it grow up to the set value. They also
respect the previously set ::min-content-width and -height.

https://bugzilla.gnome.org/show_bug.cgi?id=742281
2016-06-05 11:02:59 -03:00
Matthias Clasen
de8af76897 Show a scroll cursor when appropriate
When doing two-finger scrolling or click scrolling using a
trackpoint, show the all-scroll cursor to indicate what is
going on.

https://bugzilla.gnome.org/show_bug.cgi?id=753202
2016-06-01 21:47:31 -04:00
Matthias Clasen
743d18c0f8 scrolled window: Remove trackpoint heuristics
This is now done in GDK, so we can just use the input type here.

https://bugzilla.gnome.org/show_bug.cgi?id=767100
2016-06-01 09:31:18 -04:00
Matthias Clasen
f516faaef8 Revert "scrolledwindow: Better size requisition for GTK_SCROLL_NATURAL children"
This reverts commit 096bea3f0e.

This was accidentally pushed.
2016-05-18 07:52:18 -04:00
Debarshi Ray
096bea3f0e scrolledwindow: Better size requisition for GTK_SCROLL_NATURAL children
GtkScrolledWindow leans towards using the minimum size of its child
widget, unless the scrollbar policy is GTK_POLICY_NEVER. This is
probably fine for most GtkScrollable implementations out there.
Especially when using GTK_SCROLL_MINIMUM, which is the default for all
implementations inside gtk+.

However, this is not good for GTK_SCROLL_NATURAL children. eg.,
VteTerminal's minimum size is 1x1 and natural size is the number of
visible rows and columns requested by the user. We really want to use
the natural size unless the user has resized the window to change that.

https://bugzilla.gnome.org/show_bug.cgi?id=766569
2016-05-17 15:03:51 -04:00
Debarshi Ray
c81cd94b8f scrolledwindow: Remove redundant use of MAX
This code tries to add the minimum content size, if one is set, to the
GtkScrolledWindow's size requisition. This is obvious from the check
for non-negative values of min-content-height and min-content-width.
Using MAX needlessly makes the code harder to read by implying that
there is more to it when there actually isn't.

Fall out from 0d9ebb501d

https://bugzilla.gnome.org/show_bug.cgi?id=766569
2016-05-17 17:04:26 +02:00
Debarshi Ray
df98140e8e scrolledwindow: Fix typo in get_preferred_height calculation
When we are beginning to calculate the height, if the vscrollbar_policy
is not GTK_POLICY_NEVER, and there is no min-content-height, then we
need some small non-zero value to get started. The idea is to always
ask for at least enough to fit the horizontal scrollbar.

Simply put, this should be the mirror image of the corresponding width
calculation code.

Those who got used to the buggy behaviour might notice that their
GtkScrolledWindows are not as tall as they used to be.

Fall out from 55196a705f

https://bugzilla.gnome.org/show_bug.cgi?id=766530
2016-05-17 07:39:24 +02:00
Benjamin Otte
30d2dc49a8 scrolledwindow: destroy children in destroy()
If we don't do that, testsuite/gtk/templates starts failing.
2016-05-14 17:13:52 +02:00
Benjamin Otte
732316aca2 scrolledwindow: Remove child before destroying self
Children tend to call back into the scrolled window while being removed
and that doesn't work too well if the scrolled window is destroyed
already as Christian Hergert found out.
2016-05-10 01:00:41 +02:00
Matthias Clasen
5ee745dfee scrolled window: Use getter for gtk-enable-animations 2016-05-01 00:39:34 -04:00
Matt Watson
5237b7a6b0 scrolledwindow: port indicator fade to progress tracker 2016-04-08 16:09:30 -07:00
Carlos Garnacho
0b840a04a2 GtkScrolledWindow: Do not hover one scrollbar if grabbing on the other
Makes no sense since we're not going to interact with it. It'll be
hovered eventually if the button is released.
2016-03-14 19:18:14 +01:00
Carlos Garnacho
2173b6d483 GtkScrolledWindow: Check proximity on both indicators on grab-end leave events
The implicit grab may be finished so the pointer lies on top of the other
scrollbar, in this case one scrollbar should lose the hovering state, and
the other should gain it. So we must check for proximity in both indicators.
2016-03-14 19:18:14 +01:00
Matthias Clasen
5f00a9b4ec scrolled window: Fix scrollbar size allocation
We were not taking the scrollable borders into account when
requesting size for the scrolled window, which could lead
to underallocating the scrollbars at size allocation time
when we *did* take the borders into account.

This is most notable with treeviews, where we have the
headers as borders, and was causing the treeview-crash-too-wide
reftest to fail.
2016-03-11 21:42:33 -05:00
Cosimo Cecchi
1395f3a838 scrolledwindow: fix left/right thinko for scrollbar style classes
"left" and "right" were inverted, preumably because the position type
parameter refers to the scrolled window position, and not the scrollbar
itself.
2016-03-02 16:08:19 -08:00
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