Commit Graph

529 Commits

Author SHA1 Message Date
Benjamin Otte
01f7f255b5 gtk: Check return value of compute_bounds()
Half of these calls will completely break if anybody ever uses CSS
transforms with them, but hey...
2019-02-20 05:26:31 +01:00
Timm Bäder
131e8d8905 Remove some unnecessary gtkwindow.h includes 2019-02-05 08:11:43 -05:00
Emmanuele Bassi
25fd230327 gtk: Drop the "plus"
Source names should use "[gtk]" without the plus.
2019-02-05 11:26:20 +01:00
Timm Bäder
f3c51cdf5f scrolledwindow: Don't NULL the indicator widget in unmap
We still have the widget, so just keep the pointer to it.
2019-01-29 05:03:26 +01:00
Timm Bäder
3ca688a6dd scrolledwindow: Reset indicators in unmap()
This is unrelated to any windowing resources these days, so no need for
an unrealize handler.
2019-01-18 19:43:49 +01:00
Timm Bäder
dbc8d253c3 scrolledwindow: Fix a event widget/event target mixup 2019-01-18 19:43:47 +01:00
Timm Bäder
0f6e15cfa2 scrolledwindow: remove unused struct 2019-01-18 19:43:46 +01:00
Timm Bäder
83f8056992 scrolledwindow: Remove unused drag_device member 2019-01-16 19:01:40 +01:00
Timm Bäder
ade171a2ed widget: Don't pass a position to ->size_allocate
The values have been 0/0 for a long time now, so just drop the
GtkAllocation argument and replace it with width and height.
2018-11-13 16:28:54 +01:00
Ernestas Kulik
edc4b2f7d0 eventcontrollerscroll: Conditionally propagate ::scroll
Currently, gtk_event_controller_scroll_handle_event() always returns
TRUE if it is handled, which stops the propagation of the event. If
there’s a single GtkEventControllerScroll in the widget hierarchy, that
means that no others will run, depending on the propagation phase. In
Nautilus, this can be observed when adding a scroll controller to the
GtkScrolledWindow (ctrl-scrolling controls the zoom level) - either the
scrolling or the zooming breaks.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/45
2018-11-12 10:35:37 +01:00
Timm Bäder
c44728282c scrolledwindow: Remove some useless code
This is all being done already be the add_class/remove_class calls
before.
2018-11-09 19:37:55 +01:00
Sebastian Keller
14b21d78db gtkscrolledwindow: Consider shift key presses when decelerating
Otherwise horizontal scrolling using the shift key would decelerate
vertically.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/770
2018-08-04 16:24:33 +02:00
Carlos Garnacho
71762d3b28 gtkscrolledwindow: Use controller for motion capturing
Perform scrollbar visibility checks through a motion controller,
always based on GtkScrolledView-relative coordinates. The captured
event handler remains though, for a tiny bit of GDK_SCROLL event
handling.
2018-07-30 13:14:12 +02:00
Ernestas Kulik
6adaf7c33d Remove GDestroyNotify casts in g_clear_pointer() uses
GLib master propagates argument types in g_clear_pointer(), which causes
the usual function pointer casts to GDestroyNotify to trip compiler
warnings. Additionally, this commit changes some cleanup functions where
appropriate (wl_data_source_destroy ->
gtk_primary_selection_source_destroy for struct
gtk_primary_selection_source).
2018-07-25 10:05:39 +03:00
Timm Bäder
af8fe182c8 Fix a few documentation warnings 2018-07-08 09:41:15 +02:00
Daniel Boles
51981d562b ScrolledWindow: a couple of spelling/grammar fixes
(A) Put a space in "scrolled window" like the other doc comments
(B) Say "i.e." rather than "ie."
(C) Fix grammar from "makes [...] exactly reaches" to "exactly reach"
2018-07-02 20:14:41 +01:00
Daniel Boles
51b77a425a ScrolledWindow: Fix/improve doc of key bindings
Saying 'key + modifiers' is really weird, so reverse that, and explain
why there are 2 cited and what the difference between them is.
2018-07-02 20:14:41 +01:00
Daniel Boles
ae3163b5e0 ScrolledWindow: Add missing apostrophes 2018-07-02 20:14:41 +01:00
Timm Bäder
e079fad1d5 scrolledwindow: Avoid a queue_resize path in size-allocate 2018-06-21 20:54:47 +02:00
Timm Bäder
798944cb26 scrolledwindow: Remove priv pointer 2018-06-18 17:35:02 +02:00
Timm Bäder
5ff4ef14e6 widget: Directly notify gestures of grab
Since each widget has a list of event controllers now, we don't need to
connect to ::grab-notify of the widget for every controller.
2018-05-19 10:18:50 +02:00
Benjamin Otte
4f3058f195 eventcontrollermotion: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
74dbb057ed eventcontrollerscroll: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
1e6eb1f8b9 draggesture: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
bf82149271 longpressgesture: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
71991270b0 pangesture: Port to new API model 2018-04-26 17:59:41 +02:00
Benjamin Otte
66223aaa08 swipegesture: Port to new API model 2018-04-26 17:59:41 +02:00
Timm Bäder
0965812e37 scrolledwindow: Fix indicator revealing
We need to increase the scrollbar bounds size.
2018-04-11 19:14:55 +02:00
Timm Bäder
3ce6355bf4 widget: Remove _get_own_allocation
Replace all usages of it with _compute_bounds
2018-04-10 09:43:47 +02:00
Benjamin Otte
169203951b widget: Remove clip from size-allocate vfunc
As the clip is no longer needed, get rid of it.
2018-04-05 14:56:38 +02:00
Benjamin Otte
73650c6da2 gtk: Remove gtk_widget_queue_draw_region()
... and gtk_widget_queue_draw_area().

They don't doi anything anymore.
2018-04-05 14:56:38 +02:00
Timm Bäder
e6d104bfa0 Rename gtkkineticscrolling.h to gtkkineticscrollingprivate.h
To match the naming scheme we use for all private header files.
2018-03-28 16:47:54 +02:00
Alexander Larsson
63e060a21d GtkWidget: Start renaming widget->window
This is an automated change doing these command:

git sed -f g gtk_widget_set_has_window gtk_widget_set_has_surface
git sed -f g gtk_widget_get_has_window gtk_widget_get_has_surface
git sed -f g gtk_widget_set_parent_window gtk_widget_set_parent_surface
git sed -f g gtk_widget_get_parent_window gtk_widget_get_parent_surface
git sed -f g gtk_widget_set_window gtk_widget_set_surface
git sed -f g gtk_widget_get_window gtk_widget_get_surface
git sed -f g gtk_widget_register_window gtk_widget_register_surface
git sed -f g gtk_widget_unregister_window gtk_widget_unregister_surface

git checkout NEWS*
2018-03-20 15:21:12 +01:00
Benjamin Otte
3bb95a09bb a11y: Remove gtk.h include from container accessible 2018-02-09 00:42:38 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Emmanuele Bassi
c655759cef Replace gdk_threads_add_timeout* with g_timeout_add()
The main GDK thread lock is not portable and deprecated.

The only reason why gdk_threads_add_timeout() and
gdk_threads_add_timeout_full() exist is to allow invoking a callback
with the GDK lock held, in case 3rd party libraries still use the
deprecated gdk_threads_enter()/gdk_threads_leave() API.

Since we're removing the GDK lock, and we're releasing a new major API,
such code cannot exist any more; this means we can use the GLib API for
installing timeout callbacks.

https://bugzilla.gnome.org/show_bug.cgi?id=793124
2018-02-03 12:06:58 +01:00
Matthias Clasen
4b613c2f6a docs: Stop referring to legacy event signals
These are going away.
2018-01-16 14:14:10 -05:00
Matthias Clasen
ab4f4fb045 scrolled window: Use a motion event controller
This lets use replace one of the last uses of ::leave-notify-event.
2018-01-16 14:14:10 -05:00
Timm Bäder
185525a58d scrolledwindow: Remove workarounds
Instead of making sure here that the scrollbars are the last children,
just add the bin child as first one and keep the scrollbars last.
2018-01-10 16:36:59 +01:00
Daniel Boles
b89bf98731 ScrolledWindow: add() before remove() in snippet
We can't remove() a child widget that wasn't already add()ed, of course.
2018-01-07 16:47:24 +00:00
Timm Bäder
4a999cbd1f scrolledwindow: Fix code sample compilation 2018-01-03 17:11:32 +01:00
Timm Bäder
93df23d962 Remove some more gtk_widget_get_content_size uses 2017-12-04 12:42:52 +01:00
Matthias Clasen
ffd6baec42 gtk: Intern css names
This avoids a bunch of strdups at startup.
2017-11-17 22:49:57 -05:00
Benjamin Otte
a409320cda gtk: Use gtk_widget_set_cursor()
... and gtk_widget_set_cursor_from_name() instead of setting cursors on
GdkWindows.
2017-11-04 01:37:03 +01:00
Benjamin Otte
9323d098a6 gdk: Cursors no longer have a display
Change constructors to reflect that.

While doing so, also add a fallback argument to the cursor constructors,
so it is now possible to create cursors with fallback.
2017-11-04 00:07:13 +01:00
Matthias Clasen
e49615184a Drop the env var for scrolling control
This was never meant to be an official api, but rather
a transition help. Time to drop it for GTK+ 4.
2017-10-07 18:27:51 -04:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Timm Bäder
786d89cd9d scrolledwindow: Make sure gtk_get_current_event_state returned a state
Technically correct and pleases Coverity.
2017-10-05 10:21:54 +02:00
Timm Bäder
29a4f0ce1f Plug some memory leaks
Make sure the scroll controllers in GtkComboBox and GtkScrolledWindow
get destroyed.
2017-09-28 20:01:01 +02:00
Carlos Garnacho
cf6ecc9095 gtkscrolledwindow: Use scroll event controller
All kinetic scrolling initial velocity calculations are now
taken from the scroll controller. The handling of timeouts
to snap back when overshooting has been also made to just
apply on devices that can't emit ::scroll-begin/end.
2017-09-19 18:40:50 +02:00
Matthias Clasen
c7225bc8c1 scrolled window: Use GdkEvent API 2017-09-19 18:39:03 +02:00
Carlos Garnacho
0a55573ca3 scrolledwindow: Update to using GdkEvent API 2017-09-19 18:39:02 +02:00
Daniel Boles
021e0d5e3d ScrolledWindow: Dodge possible surplus disconnects
In case the outgoing Adjustment for whatever reason has other handlers
referring to this SW, be sure to avoid disconnecting any but our own.
2017-09-01 16:28:57 +01:00
Daniel Boles
ceb09e4c8d ScrolledWindow: Fix non-disconnection of handlers
• Use disconnect_by_data() to catch both _adjustment_changed() and now
  _adjustment_value_changed(), as the latter had been missed until now.

• Also disconnect from indicator_value_changed(), which was not done in
  destroy() due to indicator_reset() and remove_indicator() disagreeing.

https://bugzilla.gnome.org/show_bug.cgi?id=775074
2017-08-31 23:18:46 +01:00
Daniel Boles
ad5c4d09b3 ScrolledWindow: Bin unreachable ternary branches
We already checked that the child is not NULL above.

Coverity CID 1454191
2017-08-15 20:33:49 +01:00
Timm Bäder
5f859a1f24 widget: Remove gtk_widget_get_content_allocation
Replace it where we still need something similar, e.g. in
gtk_widget_translate_coordinates
2017-08-14 12:22:39 +02:00
Matthias Clasen
b52c1cb8dc scrolled window: Don't leak timeout sources
We must only create a new source if there isn't one already,
otherwise we override the ID and leak the previous one.
2017-08-13 09:24:50 -04:00
Matthias Clasen
98089778df Add names to more sources
This makes debugging mainloop-related issues more pleasant.
2017-08-13 09:03:40 -04:00
Timm Bäder
36ab70ddf5 widget: Add baseline and out_clip parameters to size-allocate
Since setting a clip is mandatory for almost all widgets, we can as well
change the size-allocate signature to include a out_clip parameter, just
like GtkCssGadget did. And since we now always propagate baselines, we
might as well pass that one on to size-allocate.

This way we can also make sure to transform the clip returned from
size-allocate to parent-coordinates, i.e. the same coordinate space
priv->allocation is in.
2017-07-19 21:27:16 -04:00
Timm Bäder
3dc6d240b3 Fix a few allocation coordinates & sizes 2017-07-19 21:27:15 -04:00
Timm Bäder
3077198de0 scrolledwindow: Fix indicator hiding
Only hiding the indicator if the widget is not mapped won't work.
2017-07-19 21:27:14 -04:00
Timm Bäder
9e43d267bd scrolledwindow: Fix scrollbar allocations
Use the content size everywhere. Fixes scrollbar positions with padding
and/or css borders applied to the scrolledwindow.
2017-07-19 21:27:14 -04:00
Timm Bäder
3a20bc5e9a scrolledwindow: Fix on_scrollbar check
The event widget is always the toplevel window, so use the event target
and check the GtkScrollbar ancestor.
2017-07-19 21:27:14 -04:00
Timm Bäder
e3bd1e10e8 scrolledwindow: fix scrollbar allocation 2017-07-19 21:27:13 -04:00
Timm Bäder
58320c02ea scrolledwindow: Properly remove scrollbars
Instead of keeping an extra ref, then unparent+destroy+unref, don't keep
an extra ref and just unparent the scrollbar when appropriate.
2017-07-19 21:27:13 -04:00
Timm Bäder
753e915f87 scrollbar: Add accessor for wheel delta
Make the one in gtkrange.c static since it was only ever used from
GtkScrolledWindow.
2017-07-19 21:27:12 -04:00
Timm Bäder
86a2156d17 scrolledwindow: Use scrollbar API on scrollbars 2017-07-19 21:27:12 -04:00
Timm Bäder
8bf3b2d5e4 scrolledwindow: Remove useless function call
We never use the result.
2017-07-19 21:27:12 -04:00
Timm Bäder
5b51936676 scrolledwindow: Fix child widget positioning
Instead of relying on get_relative_allocation, just use the
scrolledwindow's content allocation we get passed to size-allocate.
2017-07-19 21:27:12 -04:00
Timm Bäder
cfd67eb4ec scrolledwindow: Remove last argument from allocate_child
We never use that when calling gtk_scrolled_window_allocate_child.
2017-07-19 21:27:12 -04:00
Timm Bäder
2e3211b0cb scrolledwindow: Remove gadget 2017-07-19 21:27:11 -04:00
Timm Bäder
52f8fd8242 scrolledwindow: Remove css box drawing 2017-07-19 21:27:11 -04:00
Timm Bäder
030b96cb49 scrolledwindow: Avoid critical when removing source
Make sure indicator->conceil_timer is actually set before trying to
remove it.
2017-05-25 16:25:59 +02:00
Timm Bäder
e54d8a6114 scrolledwindow: Calculate indicator coords relative to scrolledwindow
The event coordinates we get are relative to the scrolledwindow
coordinates.
2017-05-25 16:25:59 +02:00
Timm Bäder
782477188a scrolledwindow: Stop checking event->detail in leave-notify
This is obsolete and resulted in sometimes stuck .hovering style classes
on scrollbars.
2017-05-25 16:25:59 +02:00
Carlos Garnacho
87c7ca910c gtkscrolledwindows: Remove child windows
Both for the view (compensated by widget clip) and the scrollbar
indicators (just not needed anymore).
2017-05-25 16:25:59 +02:00
Carlos Garnacho
a72404dd5a gtk: Mass delete all GtkWidget event mask API
We now rely on toplevels receiving and forwarding all the events
the windowing should be able to handle. Event masks are no longer a
way to determine whether an event is deliverable ot a widget.

Events will always be delivered in the three captured/target/bubbled
phases, widgets can now just attach GtkEventControllers and let those
handle the events.
2017-05-25 16:25:58 +02:00
Daniel Boles
a96c586450 ScrolledWindow: Don’t req size for autohidden bars
POLICY_AUTOMATIC means scrollbars are only shown when needed, i.e. when
the size of the window is not large enough to show the entire child. So
when measuring the preferred size, such scrollbars should be ignored.

But measure() added size for *any* non-overlay scrollbar of the opposite
orientation, e.g. for horizontal size, it added the width of vscrollbar.
So we requested for child + bar, & having enough for child meant that the
policy hid the bar, leaving extra space empty below/right of the child.

Fix this by only adding size for such bars if they use POLICY_ALWAYS.

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-05-10 22:29:01 +01:00
Daniel Boles
1a95c259d7 ScrolledWindow: Optimise and clean up measure()
• Only calculate the specified dimension – rather than measuring both &
   discarding the other (which will often be recalculated right after)
 • Only measure a given child scrollbar if it may be visible, not always
 • Move variables into narrowest scopes & otherwise improve readability

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-05-10 22:29:01 +01:00
Timm Bäder
f053a63d74 container: Remove include_internals parameter from forall
with include_internals=TRUE, this is the same as the (still private)
gtk_widget_forall, or just using the children/sibling accessors in a
loop.
2017-04-25 20:30:37 +02:00
Timm Bäder
43cdeee3c4 widget: Save pointer to focus child
Do the same thing GtkContainer does.
2017-03-31 09:50:39 +02:00
Daniel Boles
5c2f642ddd ScrolledWindow: Don’t check if child is Scrollable
If the child added is not a Scrollable, it gets wrapped in a ViewPort –
which is. So it is impossible to end up with a non-Scrollable child.

Just check we have /any/ child where needed, which is semantically nicer

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-03-20 23:25:23 +00:00
Daniel Boles
52547054a5 ScrolledWindow: Streamline/clarify the intro docs
• intro: Clarify that external policy and/or adjustments can be used.
 • add(): Don’t waffle on about having to add a ViewPort since we handle
          that transparently for the user, so they can add() any widget.
 • Adjustment stuff: most of this was repeating the docs for Scrollbar,
                     so just refer the user to that. Also, mention how
                     policies NEVER and EXTERNAL interact with all this.

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-03-20 23:25:23 +00:00
Daniel Boles
10e49a2861 Revert "ScrolledWindow—Don’t req size for auto-hidden bars"
This reverts commit 901e5ff3a3.

This causes criticals in e.g. the Text View: Multiple Buffers demo.
More work is required to get a fix for Bug 778853 that does not cause
anything else to regress.

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-02-22 19:31:38 +00:00
Daniel Boles
901e5ff3a3 ScrolledWindow—Don’t req size for auto-hidden bars
POLICY_AUTOMATIC means scrollbars are only shown when needed, i.e. when
the size of the window is not large enough to show the entire child. So
when measuring the preferred size, such scrollbars should be ignored.

But measure() was adding size for bars for which policy_may_be_visible()
was TRUE, which it returns for POLICY_ALWAYS (good) & _AUTOMATIC (bad).
So we reserved space for child plus scrollbars, & because we have enough
space for the child, POLICY_AUTOMATIC hides the scrollbar, leaving the
extra reserved space empty at the right/bottom sides of the child. This
is very noticeable/inconvenient for non-overlay, automatic scrollbars.

Fix this by only requesting size for scrollbars that use POLICY_ALWAYS,
rather than basing the decision on policy_may_be_visible().

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-02-19 17:03:44 +00:00
Timm Bäder
85aaf13c03 scrolledwindow: Remove unused define 2017-02-18 19:11:22 +01:00
Timm Bäder
ed245b42cb scrolledwindow: Avoid usage of uninitialized local
the scrollbar passed in better be either priv->hscrollbar or
priv->vscrollbar. Ensure that by using a simple else instead of an
else-if and a g_assert.
2017-02-18 19:01:28 +01:00
Timm Bäder
56a58655fe Remove unnecessary gtk_widget_show calls 2017-01-22 14:38:21 +01:00
Alexander Larsson
7bee22bcb6 Avoid some more type checks for internal calls 2017-01-11 15:27:51 +01:00
Daniel Boles
0259312142 scrolledwindow: Fix func summary being cut off in bindings using doxygen
...which treats the first '.' in doc comments as the end of the summary.
So, e.g., in gtkmm, get_kinetic_scrolling() is currently summarised as
"Changes the behaviour of @scrolled_window wrt." Not very informative!

No need for a period there & anyway, the phrase "wrt to" is superfluous,
and we have space to actually say "with regard to", so just do that now.
2016-12-31 13:27:15 +00:00
Benjamin Otte
0dbdf0c428 gadget: Remove gtk_css_gadget_draw()
And with it, remove the draw func from custom gadgets, that has been
NULL everywhere.

All gadgets are snapshot now.
2016-12-20 18:01:12 +01:00
Benjamin Otte
2090219abb scrolledwindow: Implement snapshot() 2016-12-19 05:36:06 +01:00
Benjamin Otte
e09fd1eb8a scrolledwindow: Fix rendering
We used to allocate the gadget relative to the view window. We allocate
relative to widget->window now.
2016-12-19 05:36:06 +01:00
Timm Bäder
5ee590fbc8 scrolledwindow: measure child widgets using gtk_widget_measure 2016-12-04 12:00:46 +01:00
Benjamin Otte
4850271ae8 API: Remove gtk_cairo_should_draw_window()
The answer is: Yes.
2016-11-23 18:48:38 +01:00
Benjamin Otte
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Matthias Clasen
5e19e06dcc Fix a copy-paste error
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=774185#c3
2016-11-10 15:07:08 -05:00
Benjamin Otte
e0600346e2 scrolledwindow: Turn into no-window widget 2016-11-06 15:50:26 +01:00
Benjamin Otte
2ca641edc9 scrolledwindow: Use gtk_widget_queue_draw() 2016-10-27 05:07:23 +02:00
Sébastien Wilmet
83dc4c8b39 docs: fix copy/paste errors in the docs of GtkScrolledWindow
Trivial commit.
2016-10-26 15:20:25 +02:00