Commit Graph

81 Commits

Author SHA1 Message Date
Carlos Garnacho
2b703b61cf gtk: Add private gtk_widget_reset_controllers()
This is a one-shot call that can be called on the places we
know we're taking input away.
2016-01-19 14:17:35 +01:00
Benjamin Otte
580ea227a6 widget: Redo drawing code
Previously, we had a special cae to draw subwindows of widgets.

This is not necessary as conformant widgets should be able to properly
render themselves when all windows need to be painted.
From now on assume that is the case.

We therefore paint nonnative GDK windows "inline" by just returning TRUE
for gtk_cairo_should_draw_window() for those windows.

This speeds up hilighting different rows in the listbox gtk-demo example
tremendously (by a factor of 10 or more) as the previous code was
O(<number of non-window subwidgets> *
<number of subwindows>) which in the listbox example were ~15,000 and
~2,000 respectively.
2016-01-19 03:45:27 +01:00
Timm Bäder
e8aa9b0440 Add a way to highlight resizing widgets
https://bugzilla.gnome.org/show_bug.cgi?id=759586
2015-12-18 16:20:19 +01:00
Matthias Clasen
cbde3ee01f css: Add a :dnd pseudoclass
This will be used for drag highlighting.
2015-12-02 23:23:36 -05:00
Florian Müllner
ebdf5f581d widget: Add :focus-on-click property
There are currently three widget that implement such a property, and
there are other widgets for which the behavior can make sense. It
seems like a good time to add the property to GtkWidget itself so
subclasses can choose to respect it without adding their own property.

https://bugzilla.gnome.org/show_bug.cgi?id=757269
2015-11-03 07:44:17 -05:00
Benjamin Otte
cd20ae8fe1 container: Don't keep our own variable trying to track need for resize
Insteaad, introduce gtk_widget_needs_allocate() and use that.
2015-10-28 19:44:29 +01:00
Benjamin Otte
6866d1c06e widget: Make gtk_widget_queue_allocate() not resize
This commit toggles the big switch. We now don't run size_allocate()
from the toplevel up anymore in cases where we don't need to.

Things might be broken in subtle ways as a result of this commit. We'll
have to find them and fix them.
2015-10-28 19:44:28 +01:00
Benjamin Otte
299600a7d4 widget: Track if a child needs an allocation
This is not used so far.
2015-10-28 19:44:28 +01:00
Benjamin Otte
3e3f17576e widget: Warn if size-unqueried widgets get allocated
Widgets should have gtk_widget_get_preferred_width/height() called
on them before gtk_widget_size_allocate() gets called.
Add a check for this.
2015-10-28 19:44:28 +01:00
Benjamin Otte
6cc2615b63 widget: Add a resize_needed flag
... and API to set and unset it.

It is set when gtk_widget_queue_resize() is called.
It is unset when gtk_widget_get_preferred_width/height() is called.

So far it is not used.
2015-10-28 19:44:28 +01:00
Benjamin Otte
3ff894c201 widget: Add a function that does actual resize
It's just shuffling code around.
2015-10-28 19:44:28 +01:00
Benjamin Otte
d3d9f52365 API: widget: Add gtk_widget_get_allocated_size()
See docs for what this is.
2015-10-28 19:44:27 +01:00
Benjamin Otte
5dd2087d19 widget: Remove _gtk_widget_override_size_request()
The function was only used by the geometry widget.
2015-10-28 19:44:27 +01:00
Matthias Clasen
ac198a3ce6 Add a few more inlined getters 2015-09-28 06:29:50 -04:00
Matthias Clasen
c7c1f9ff61 widget: Add a few more inlined getters 2015-09-23 07:01:16 -04:00
Matthias Clasen
8a540ea0d0 Drop GtkWidgetAuxInfo
Merge it into GtkWidgetPrivate. In my measurements, about half
of all widgets have a non-default auxinfo struct, and we use this
information in size allocation, so it is nice to avoid the gdata
overhead.
2015-09-13 00:12:04 -04:00
Matthias Clasen
b355b07c10 Move font map to qdata
This is very rarely used, lets not reserve space for it
in every widget.
2015-09-12 21:11:54 -04:00
Matthias Clasen
70a2281959 Move font options to gdata
This is very rarely used, lets not reserve space for it in
every widget.
2015-09-12 21:11:54 -04:00
Matthias Clasen
b166582835 Move action muxer to gdata
Most widgets don't have their own, and we don't access them
very frequently.
2015-09-12 21:11:54 -04:00
Matthias Clasen
e4de412fd3 Move widget paths to gdata
We only use widget paths for a few widgets nowadays (notebook,
treeview, pathbar, combobox), so we can save some space by
not having this field in GtkWidgetPrivate.
2015-09-12 21:11:54 -04:00
Matthias Clasen
75439cafb6 Move template support to qdata
The hash table is only accessed at creation and destruction time,
and many widgets don't use templates at all, so no need to have
this permanently occupying space.
2015-09-12 19:22:17 -04:00
Matthias Clasen
d8e1f1edf5 Pack GtkWidgetPrivate a bit better
This makes it shrink from 240 to 232 bytes.
2015-09-12 18:54:51 -04:00
Matthias Clasen
f1414a125f Move GtkWidgetAuxInfo struct to private headers
There's no API returning such a struct, it is entirely internal.
Therefore, don't expose it in public headers.
2015-09-12 18:36:32 -04:00
Matthias Clasen
09e4f753fd widget: Move _gtk_widget_peek_request_cache to private.h 2015-09-12 12:50:38 -04:00
Matthias Clasen
6f2fcce494 Use a getter for widget direction 2015-09-09 06:32:46 -04:00
Matthias Clasen
15b9feda22 widget: Add more inline getters
Add a getter for state flags, and use it where appropriate.
2015-09-07 12:23:09 -04:00
Matthias Clasen
0f92a43e10 Move GtkWidgetPrivate to gtkwidgetprivate.h
This lets us use inlined getters for members in there,
avoiding the type checks in the public getters.
2015-09-07 02:40:22 -04:00
Christoph Reiter
5d17b0af54 GtkWindow: don't increase the preferred size for empty windows if there is a size request set.
This fixes a reftest broken by commit 84e99b20ac

https://bugzilla.gnome.org/show_bug.cgi?id=751341
2015-07-01 09:32:19 -07:00
Benjamin Otte
fdc620cd56 cssnode: Clear widget path more aggressively
When recomputing CSS, we need a correct widget path in the fallback mode
where we're still using widget paths.
So we need to invalidate it everytime it actually changes, and not just
when emitting the style-updated signal.

Fixes css-match-regions reftest.
2015-03-24 04:23:07 +01:00
Benjamin Otte
7395dddd47 csswidgetnode: Avoid creating a stylecontext
If the widget doesn't have a style context, don't create one. Instead,
call functions on the widget directly.
2015-03-18 15:23:33 +01:00
Benjamin Otte
b92fe2fa85 widget: Add gtk_widget_get_css_node()
and replace gtk_style_context_get_root() with it.
2015-03-18 15:23:31 +01:00
Carlos Garnacho
08494f86a0 widget: Improve hack to ignore drags from widgets using motion events
Postpone until the last moment whether the target widget still
potentially uses updates from this sequence, or window dragging
actually applies because all gestures on the target went to denied
state.

This fixes window dragging on empty space in a headerbar that is
contained in a paned (as in e.g. gedit).

https://bugzilla.gnome.org/show_bug.cgi?id=745562
2015-03-04 21:20:29 -05:00
Carlos Garnacho
13e22e2030 gtkwindow: Move window dragging to a standalone drag gesture
The gesture is hooked to the capture phase, so it works for buttons in
header bars and whatnot. In order to be friendly to the widget it is
capturing events from, an ugly hack is in place to avoid capturing
events when the target widget has a gesture that would consume motion
events.
2015-03-02 12:03:39 +01:00
Christian Hergert
661da5558c widget: add helpers to resolve GActionGroups available to GtkWidget
These functions, while added for use by the GTK inspector, are generally
useful to applications that need to resolve what action groups are
available to a particular GtkWidget.

https://bugzilla.gnome.org/show_bug.cgi?id=741386
2014-12-11 15:25:41 -08:00
Carlos Soriano
235837ad49 gtkwindow: Use actions from focused widget to activate accel
Currently we only take into account the window GActionGroup for
activating the accels.

However, the application could have some custom GActionGroup in the
chain of focused widgets that could want to activate some action if
some accel is activated while that widget is focused.

To allow applications to set accels on widgets that use custom
GActionGroups, simply use the muxer of the focused widget, which
already contains the actions of the parents.

https://bugzilla.gnome.org/show_bug.cgi?id=740682
2014-12-08 20:19:33 -08:00
Matthias Clasen
778865f316 Fix toplevel input shape for csd windows
We need to maintain the application-set and the the csd
input shape separately, and intersect them to pass them
down.
2014-10-28 20:23:47 -04:00
Matthias Clasen
a55000613a Add private API to query tick callbacks
This information can be useful for debugging purposes.
2014-10-24 08:34:13 -04:00
Benjamin Otte
b5a8b7ef3b widget: Make _gtk_set_simple_clip() take an optional content clip 2014-08-21 00:54:07 +02:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Benjamin Otte
0cd63faee2 widget: Add _gtk_widget_set_css_clip()
... and use it in GtkBox and GtkGrid.
2014-05-24 16:12:21 +02:00
Benjamin Otte
4f89eb05cf API: widget: Add gtk_widget_set_clip() API
And handle the fact that drawing bounds are now handled by this API and
the corresponding gtk_widget_get_clip().

Also add _gtk_widget_supports_clip() function to check if a widget has
been ported to the new world.
2014-05-24 16:12:20 +02:00
Matthias Clasen
4928d5e401 Drop an unneeded include
There's no GtkGesture in gtkwidget.h anymore. We do need an include
in gtkwidgetprivate.h though.
2014-05-23 20:09:50 -04:00
Matthias Clasen
a727c41e4a Add back a private api to list controllers
This will let us show them in the inspector.
2014-05-23 19:54:32 +02:00
Carlos Garnacho
5369c77029 gesture: Simplify gesture/widget interaction public API
The propagation phase property/methods in GtkEventController are gone,
This is now set directly on the GtkWidget add/remove controller API,
which has been made private.

The only public bit now are the new functions gtk_gesture_attach() and
gtk_gesture_detach() that will use the private API underneath.

All callers have been updated.
2014-05-23 19:54:29 +02:00
Matthias Clasen
3f224a7165 Add private GtkWidget api for action groups
Similar to the just-added action muxer api for enumerating
action prefixes and for getting the action group for a
prefix.

https://bugzilla.gnome.org/show_bug.cgi?id=730095
2014-05-14 21:28:53 -04:00
Alexander Larsson
6bf32999b1 widget: Track when the window scale factor changes and notify
The scale-factor property on the widgets will be notified, and the
scale will change on the style property, causing us to pick up
new css assets.
2013-07-03 14:34:13 +02:00
Ryan Lortie
6c49cd0ea6 action stuff: stop abusing GLib's namespace
Rename our internal GActionMuxer, GActionObserver and GActionObservable
classes and interfaces to have names in our own namespace.

These classes were originally intended for GIO but turned out to be too
special-purpose to be useful there, so we never made them public API but
have just been copying them around (without bothering to properly rename
them).  Now that other people will be copying them out of Gtk, it's even
more important to prevent this namespace abuse from spreading further.
2013-05-13 16:33:42 -04:00
Benjamin Otte
689905c1b4 widget: make gtk_widget_compute_size_for_orientation() static
It's not used anywhere outside of gtksizerequest.c anymore.
2013-05-11 15:11:53 +02:00
Benjamin Otte
bd4d00918e API: Don't export gtk_widget_preferred_size_and_baseline()
gtk_widget_preferred_size() is only useful if you want to quickly port a
widget from GTK2 sizing code to GTK3 but does not properly work with
height-for-width as used in GTK. So we don't want to encourage people to
use it. In particular we want people to convert to height-for-width
before adding baseline support to their widgets.
2013-05-11 14:48:01 +02:00
Alexander Larsson
d22fd7223c Only handle exposes on native window, propagate to children via draw()
We now consider non-native windows non-opaque, which means any invalid
area in a subwindow will also be invalid all the way up to the nearest
native windows. We take advantage of this by ignoring all expose events
on non-native windows (which typically means just the toplevel) and instead
propagating down the draw() calls to children directly via
gtk_container_propagate_draw.

This is nice as it means we always draw widgets the same way, and it
will let us do some interesting ways in the future.

We also clean up the GtkWidget opacity handling as we can now always
rely on the draing happening via cairo.

We can't really just draw by walking down the widget hierarchy, as
this doesn't get the clipping right (so e.g. widgets doing cairo_paint
may draw outside the expected gdkwindow subarea) nor does it let
us paint window backgrounds.

So, we now do multiple draws for each widget, once for each GdkWindow,
although we still do it on the same base cairo_t that we get for the
toplevel native window. The difference is only the clipping, the rendering
order, and which other widgets we propagate into.

We also collect all the windows of a widget so we can expose them inside
the same opacity group if needed.

NOTE: This change neuters gtk_widget_set_double_buffered for
widgets without native windows. Its impossible to disable
the double buffering in this model.
2013-05-07 16:33:01 +02:00