Commit Graph

579 Commits

Author SHA1 Message Date
Sophie Herold
a546ae32d7 Remove all nicks and blurbs from param specs
Those property features don't seem to be in use anywhere.
They are redundant since the docs cover the same information
and more. They also created unnecessary translation work.

Closes #4904
2022-05-11 18:16:29 +02:00
Alexander Mikhaylenko
52412ca944 scrolledwindow: Pick up gtk-overlay-scrolling changes on the fly 2022-04-16 16:56:17 +04:00
Alexander Mikhaylenko
cd82b18cfd scrolledwindow: Fix :kinetic-scrolling setter 2022-04-16 16:30:33 +04:00
Carlos Garnacho
65839f67f8 gtkscrolledwindow: Do not trigger kinetic helpers on 0 velocity
Doing this is pointless, so it could be skipped.
2022-03-19 12:35:11 +01:00
Carlos Garnacho
df40db137b gtkscrolledwindow: Change lifetime of kinetic scroll helpers
In order to properly accumulate scroll velocities, we need to keep
the kinetic scroll helpers after we have possibly stopped them
in the process of initiating a further scroll flick.

So, instead of stopping (and destroying) those helpers on scroll-begin,
keep them until the next scroll-end if a scroll was initiated before
kinetic scroll finished. This way we can fetch the last velocity when
calculating the extra kick.

In order to ensure the helpers don't live beyond what it is expected,
we now also remove them after a finished hold event.

Fixes the accumulation of scrolling velocity on consecutive scroll
sequences.
2022-03-19 12:35:11 +01:00
Carlos Garnacho
129bc27d53 gtkscrolledwindow: Refactor kinetic scroll animation
Do not depend on the kinetic scroll helpers existing or not before
exiting the animation, as we may want to keep those a little bit
longer after stopped.
2022-03-19 12:35:11 +01:00
panoplie
53956e5389 gtkscrolledwindow: Add scroll unit handling
On the "scroll" signal, the widget uses
gtk_event_controller_scroll_get_unit() to get the
scroll unit.

When the unit is GDK_SCROLL_UNIT_WHEEL, the
behavior is unchanged: the widget scrolls a
certain number of pixels at each wheel detent
click. This number of pixels is determined by the
window dimensions in get_wheel_detent_scroll_step().

When the delta unit is GDK_SCROLL_UNIT_SURFACE, the
widget directly adds the delta to the number of
scrolled pixels no matter the window dimensions.
2022-03-19 00:41:26 +01:00
Carlos Garnacho
33db142eab gtkscrolledwindow: Do not try to doubly trigger deceleration
This may come from different sources at around the same time, e.g.
a hold gesture while on overshoot. Avoid doing that if an
animation is already set.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4730
2022-02-28 20:27:43 +01:00
Christian Hergert
f278f3610b macos: fix kinetic scrolling with overshoot
Previously we had issues on macos where the overshoot would keep showing.
To fix this we need to actually use discrete events instead of the
generated deltas from macOS in the scroll wheel case. Additionally, we need
to drop the kinetic momentum events from macOS and rely on the gtk kinetic
events which are already happening anyway. We also need to submit the
is_stop event for the GDK_SCROLL_SMOOTH case when we detect it.

To keep the discrete scroll events correct, we need to alter the hack in
gtkscrolledwindow.c to use the same path as other platforms except for
when a smooth scroll event is in place. In the future, I would imagine that
this falls into the boundary of high-precision scrolling and would share
the same code paths as other platforms.

With all of these in place, kinetic scrolling with overshoot appears the
same on macOS as other platforms.
2022-02-24 18:58:48 -08:00
José Expósito
44b0d8b330 scrolledwindow: Stop kinetic scrolling on begin
Stop kinetic scrolling when a scroll begin signal is sent during the
event capture phase.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
Matthias Clasen
19b534f7de Avoid copying static debug strings
The g_source_set_name calls were showing up as a
major source of strdups in our profiles. Avoid that
by using new GLib api when available.
2021-07-28 22:42:46 -04:00
Alexander Mikhaylenko
fe633d9ef9 scrolledwindow: Don't check drag threshold when already scrolling
Checkout the drag threshold only makes sense when starting a scroll, after
that it just adds jumps when trying to scroll back and forth.
2021-07-07 19:39:06 +05:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Matthias Clasen
9313d4b6b4 scrolledwindow: Stop using scroll cursors
We used to override cursor to use all-scroll while the
content is being scrolled. Unfortunately, there is several
problems with this:
- It is really only expected certain devices, and we don't
  have the device information on Wayland
- With the way cursor setting works in GTK4, non-NULL cursors
  of the content (eg the text views ibeam) win, making the
  scroll cursor not show up
- Under X11, we seem to miss scroll end events and then
  the scroll cursor gets stuck
Therefore, just remove this feature.
2021-04-09 08:26:09 -04:00
Alexander Mikhaylenko
d7a5dedd4f scrolledwindow: Cancel overshoot on dimension changes
If we scroll down in a list that's still being filled, we hit the edge and
initiate overshoot, and then the adjustment's upper value increases. This
leads to an unwanted bounce back.

Additionally, if in a similar situation the upper value decreases, the
overscroll glow gets stuck.

Update kinetic scrolling upper and lower value on changes, and immediately
cancel it if dimensions on that side change.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3752
2021-04-01 16:37:30 +05:00
Matthias Clasen
3a62b28344 scrolledwindow: Convert docs
Convert link format, add property annotations. General cleanup.
2021-03-11 16:37:33 +00:00
Alexander Mikhaylenko
f63e6394ac dragsource: Use double coordinates for checking drag threshold
If multiple nested widgets have drag sources on them, both using bubble
phase, we need to reliably pick the inner one. Both of them will try to
start dragging, and we need to make sure there are no situations where the
outer widget starts drag earlier and cancels the inner one.

Currently, this can easily happen via integer rounding: start and current
coordinates passed into gtk_drag_check_threshold() are initially doubles
(other than in GtkNotebook and GtkIconView), and are casted to ints. Then
those rounded values are used to calculate deltas to compare to the drag
threshold, losing quite a lot of precision along the way, and often
resulting in the outer widget getting larger deltas.

To avoid it, just don't round it. Introduce a variant of the function that
operates on doubles: gtk_drag_check_threshold_double() and use it instead
of the original everywhere.
2021-01-29 12:01:34 +05:00
Timm Bäder
24c67efdfd scrolledwindow: Use g_clear_handle_id 2021-01-03 11:01:29 +01:00
Carlos Garnacho
e9fe270e94 gtk/scrolledwindow: Handle full scroll sequences only
In order to do this, leverage smooth scroll handling into the capture
phase scroll controller, controlled by ::scroll-begin in the propagation
phase controller.

There's 2 cases here:
- A child widget handles scroll. The scrolled window does not get
  ::scroll-begin, the child widget handles the full scroll sequence.
- No child handles scroll, the scrolled window gets ::scroll-begin,
  and transfers control of scrolling to the capture phase controller.
  As scrolling is performed, the pointer may fall into scrollable children,
  but the scrolled window will be capturing the scroll events, so these
  won't be seen by the child widgets.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/593
2020-12-12 01:42:42 +01:00
Matthias Clasen
2ef72442ec docs: Fix the links for keybinding signals
GtkBindingSignal does not exist anymore, so link to
GtkSignalAction for an explanation of keybinding signals.
2020-11-17 07:34:52 -05:00
Emmanuele Bassi
08d59d3f68 docs: Add "Accessibility" section to various widgets
There are a few widgets that gained an accessible role, which means
adding an "Accessibility" section in their description.
2020-11-12 00:36:32 +00:00
Emmanuele Bassi
40c0826921 a11y: Mark more containers as structural elements
Widgets that just provide grouping and layout to other widgets should
not be relevant to the accessible tree.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
c264254d4b a11y: Parse reference lists using varargs
Using GList is a bit lame, and makes the API more complicated to use
than necessary in the common case.

The only real use case for a GList is gtk_widget_add_mnemonic_label(),
and for that we can use the GValue-based API instead.

Fixes: #3343
2020-11-10 14:31:56 +00:00
Chris Lord
4b459a99be scrolledwindow: Accumulate velocity with kinetic scrolling
Accumulate existing velocity when decelerating from a swipe if the swipe
velocity is above a certain fraction of that existing velocity.
2020-11-09 15:28:32 +00:00
Christian Hergert
07bb07abbe macos: port gtk to GDK_WINDOWING_MACOS
For the various uses of GDK_WINDOWING_QUARTZ, we need to use
alternatives from GDK_WINDOWING_MACOS.

Some minor loss of functionality is here, such as icons sent with
application menus. That can certainly be added back at a future
point.
2020-10-09 20:08:23 -07:00
Carlos Garnacho
7d5accc69f gtkscrolledwindow: Do not eagerly claim touch press event
Claiming early makes the contents unable to react to the touch press
event. Do this on GtkGestureDrag::update past a threshold, so the
child widget(s) can claim before the scrolledwindow does.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3125
2020-09-25 18:58:44 +02:00
Carlos Garnacho
b1606db839 gtkscrolledwindow: Drop gtk_scrolled_window_set_capture_button_press()
This API is kinda stuck in the GdkEvent days, we now negotiate ownership
of the input sequence via GtkGestures. Remove it as it reflects a way to
work that was not exactly accurate and it will turn plainly wrong soon.
2020-09-25 18:57:40 +02:00
Timm Bäder
1d371db8d8 scrolledwindow: Ignore captured motion events if no child is set
Fixes #3173
2020-09-19 08:44:58 +02:00
Björn Daase
6315cd977c *: Fix spelling mistakes found by codespell 2020-08-21 15:29:34 +02:00
Matthias Clasen
ae7cefd97d Drop style class defines
We document the supported style classes by name,
not by macro name, and these macros don't really
add any value. Drop them for GTK 4.
2020-08-14 07:03:27 -04:00
Matthias Clasen
f561000124 docs: Clean up many dangling links
In many cases, these were references to no longer
existing api, so some rewording was necessary.
2020-08-04 22:11:34 -04:00
Matthias Clasen
7398323b82 scrolledwindow: Fix a11y support code
This error was introduced by me in 971ee2d28a
and causes a crash in the scrolling benchmark in gtk-demo.

Fixes: #3014
2020-08-04 11:00:32 -04:00
Timm Bäder
65b79d2585 Avoid refering to old GtkContainer API in the docs 2020-08-01 15:34:59 +02:00
Matthias Clasen
5fd03f3297 Merge branch 'a11y-work' into 'master'
A11y work

See merge request GNOME/gtk!2312
2020-07-29 11:19:22 +00:00
Carlos Garnacho
cab1dcb696 gdk: Conflate GDK devices
Make GdkEvents hold a single GdkDevice. This device is closer to
the logical device conceptually, although it must be sufficient for
device checks (i.e. GdkInputSource), which makes it similar to the
physical devices.

Make the logical devices have a more accurate GdkInputSource where
needed, and conflate the event devices altogether.
2020-07-29 01:27:51 +02:00
Matthias Clasen
971ee2d28a a11y: Set up controls relations for scrollbars
GtkScrolledWindow knows what its scrollbars control,
so set up the accessible relations for this.
2020-07-28 18:16:37 -04:00
Emmanuele Bassi
c63087a563 Remove ATK
To build a better world sometimes means having to tear the old one down.
        -- Alexander Pierce, "Captain America: The Winter Soldier"

ATK served us well for nearly 20 years, but the world has changed, and
GTK has changed with it. Now ATK is mostly a hindrance towards improving
the accessibility stack:

 - it maps to a very specific implementation, AT-SPI, which is Linux and
   Unix specific
 - it requires implementing the same functionality in three different
   layers of the stack: AT-SPI, ATK, and GTK
 - only GTK uses it; every other Linux and Unix toolkit and application
   talks to AT-SPI directly, including assistive technologies

Sadly, we cannot incrementally port GTK to a new accessibility stack;
since ATK insulates us entirely from the underlying implementation, we
cannot replace it piecemeal. Instead, we're going to remove everything
and then incrementally build on a clean slate:

 - add an "accessible" interface, implemented by GTK objects directly,
   which describe the accessible role and state changes for every UI
   element
 - add an "assistive technology context" to proxy a native accessibility
   API, and assign it to every widget
 - implement the AT context depending on the platform

For more information, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2833
2020-07-26 20:31:14 +01:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Carlos Garnacho
896ebdc9d7 gtkscrolledwindow: Look up correctly target in captured motion events
Check correctly that the captured motion events are emitted towards the
content or one of the scrollbars, in order to have it set the expected
"over" state depending on whether the drag begins from the scrolledwindow
content or one of the scrollbars.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2879
2020-07-09 16:10:55 +02:00
Matthias Clasen
db82eaec0a Merge branch 'wip/carlosg/input-cleanups' into 'master'
Some input cleanups

Closes #2851

See merge request GNOME/gtk!2147
2020-06-24 21:32:30 +00:00
Matthias Clasen
386b63b85d scrolledwindow: Don't take adjustments in new()
In 99.9% of all cases, these are just NULL, NULL.
So just do away with these arguments, people can
use the setters for the rare cases where they want
the scrolled window to use a different adjustment.
2020-06-24 11:25:09 -04:00
Carlos Garnacho
c1d90273ca gdk: Drop GDK_SOURCE_ERASER
All tools come from devices with GDK_SOURCE_PEN.
2020-06-23 23:42:53 +02:00
Benjamin Otte
805fea20cb eventcontrollermotion: Remove mode argument
It's not used and nobody has documented how it's meant to work anyway.
2020-05-30 12:30:23 -04:00
Yuri Chornoivan
01bd4cc4e1 Fix minor typos 2020-05-28 11:00:03 +03:00
Matthias Clasen
10be40a8b1 scrolledwindow: Fix swapping out child
This was not working in the case that the existing child
is not a scrollable. It showed up as crashes of the
scrolling benchmark in gtk4-demo when switching examples.
2020-05-13 17:10:36 -04:00
Matthias Clasen
2a24b8c653 Replace most remaining uses of container api
These are all on GtkBox or enumerating children.
2020-05-11 22:38:21 -04:00
Corentin Noël
076b2f11d2 docs: Fix several missing references in the documentation
This fixes several typos and missing references
2020-05-11 19:26:20 +02:00