Commit Graph

2333 Commits

Author SHA1 Message Date
Matthias Clasen
18788c2a86 Remove gtk_widget_get/set_has_surface
These serve no purpose anymore - widgets don't
have surfaces, unless they're a GtkNative.
2019-05-28 20:25:15 +00:00
Matthias Clasen
61247a8921 widget: Remove a popover special case
We never run this since GtkPopover has its
own size_allocate, anyway.
2019-05-28 20:25:15 +00:00
Matthias Clasen
f3559fe0f0 widget: Optimize resize propagation
When a GtkNative widget is marked as resize_needed,
we need a current position for its parent and we need
the parent to be allocated (so we can position our
surface), but we don't need the parent to be marked
as resize_needed, since the parent size is entirely
independent of the popup size.
2019-05-28 20:25:15 +00:00
Matthias Clasen
27596c328a widget: Improve warning messages
When we print warnings about a widget, using
gtk_widget_get_name() is slightly better than
G_OBJECT_TYPE_NAME(), since it will give us
the widgets unique name when available.
2019-05-28 20:25:15 +00:00
Matthias Clasen
bab5836e89 Drop gtk_widget_register_surface
This is no longer used.
2019-05-28 20:25:14 +00:00
Matthias Clasen
52c3507ae1 widget: Stop using child surface apis
All our surfaces are toplevels now, and thus all native.
2019-05-28 20:25:13 +00:00
Matthias Clasen
580aa8204f widget: Remove some unneeded popover special-casing 2019-05-28 20:25:13 +00:00
Matthias Clasen
6ab8ab87c8 Reimplement GtkPopover 2019-05-28 20:25:13 +00:00
Matthias Clasen
54662f4ca0 widget: Don't snapshot foreign children
When snapshotting, we walk down the widget tree.
We need to skip children that have a different
surface, since those will do their own snapshot.
2019-05-28 20:25:13 +00:00
Matthias Clasen
5de06f47cf widget: Use GtkNative 2019-05-28 20:24:39 +00:00
Matthias Clasen
9059eee2f0 Review and replace uses of get_toplevel
Now that roots can have parent widgets, we need to
carefully examine all calls of gtk_widget_get_toplevel,
and replace them with gtk_widget_get_root if we want
the nearest root, and not the ultimate end of the parent
chain.
2019-05-28 20:24:39 +00:00
Matthias Clasen
c1d5e82d95 Use GtkNative APIs instead of GtkRoot 2019-05-28 20:24:39 +00:00
Matthias Clasen
7dcb163ee6 Add gtk_widget_get_native
This is a common enough operation to deserve api.
2019-05-28 20:24:39 +00:00
Matthias Clasen
afcf3e66f6 widget: guard popover-specific code paths
This is essentially a special case just for GtkPopover,
which is the last widget with a child surface.
2019-05-28 19:54:32 +00:00
Matthias Clasen
ff1150d87c Export gtk_widget_render privately
We need it in gtkwindow.c and gtkpopover.c.
2019-05-28 19:54:32 +00:00
Timm Bäder
a474beb7b8 widget: Don't always call get_display() when allocating
The GTK_DISPLAY_DEBUG_CHECK macro will cleverly only call the function
if any of the display debug flags are set, so in the common case it
won't even be executed.
2019-05-21 08:17:13 +02:00
Benjamin Otte
fe592cd414 widget: Make gtk_widget_render() static 2019-05-18 17:06:08 +02:00
Matthias Clasen
c6a42e92bb widget: Revert the event translation change
This is a temporary revert to make menus work
in the 3.96 release, until we land the popup
surface work and port menus to it.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1755
2019-05-06 22:20:51 +00:00
Emmanuele Bassi
fe473dbef8 Make get_layout_manager_type() public
The inspector, and other tools introspecting the widget structure like
gtk-builder-tool and Glade, may very well want to access the default
layout manager used by a class, especially if there are layout
properties involved, without having a whitelist of widget/layout manager
associations.
2019-05-06 12:15:21 +01:00
Emmanuele Bassi
c6b2184aa0 Allow specifying the layout manager for a widget type
Some widgets have a well-defined layout manager created alongside their
own instance; if they do, we can handle the layout manager creation at
the GtkWidget instantiation.
2019-05-06 11:57:32 +01:00
Matthias Clasen
af2207bc0b widget: Reset controllers when going numb
Reset event controllers when their
widget is going insensitive. This is
the expected behavior.
2019-05-02 15:53:30 -04:00
Matthias Clasen
bea8025fb5 Drop the GtkWidget::display-changed signal
Display changes now happen exclusively through
the ::root and ::unroot vfuncs. Third parties
can observe display changes by listening
for notify::root.
2019-05-02 01:33:41 +00:00
Matthias Clasen
33a8108f19 window: Implement display change via root/unroot
Export gtk_widget_root/unroot privately,
make them work on roots, and use them in
gtk_window_set_display. This gets us to a
single way to listen for display changes,
the root property.
2019-05-01 23:05:09 +00:00
Matthias Clasen
92e21c3f1c Drop the can-default property
It was added at a time when default buttons
had a very large external border that would disrupt
aligment. Not a problem nowadays.
2019-04-28 23:28:39 +00:00
Matthias Clasen
59d50be737 widget: Drop gtk_widget_grab_default
The default widget is mostly a dialog concept,
and does not really need this generic api.

If you need to mark a widget as default,
use gtk_window_set_default() directly.
2019-04-28 23:23:11 +00:00
Matthias Clasen
6d73443131 widget: Remove special handling for has-default
We used to handle has-default specially in ui
files. It was awkward, so stop doing that. If you
need to influence the default widget in a window,
you can just set the default-widget property.
2019-04-28 23:23:11 +00:00
Matthias Clasen
f4880f5df5 Add gtk_widget_activate_default
This is a convenience wrapper for
activating the "default.activate" action.
2019-04-28 23:20:13 +00:00
Matthias Clasen
65052a5d6c Rename gtk_window_set_default
Call it gtk_window_set_default_widget, to match
the getter, and the property name. Update all
callers.
2019-04-28 23:20:13 +00:00
Matthias Clasen
aa8ada3fed widget: Add a convenience api to activate actions
Since actions are used increasingly, we should
have a convenient way to trigger an action in
the context of a widget.
2019-04-28 23:19:05 +00:00
Matthias Clasen
25f4bb2e17 Avoid critical warnings
These critical warnings break the tests, otherwise.
2019-04-28 22:55:43 +00:00
Matthias Clasen
c92938b378 widget: Remove special handling of has-focus
We used to handle has-focus in ui files specially.
It was awkward, so stop doing that. If you need
to influence the initial focus of a window, you
can just set the focus-widget property.
2019-04-28 22:21:03 +00:00
Matthias Clasen
2bd9b42479 Merge branch 'wip/surface-transform-data' into 'master'
Surface transform listener fixes

See merge request GNOME/gtk!776
2019-04-25 16:42:42 +00:00
Jonas Ådahl
3a1ef7aa2c widget: Move surface relative transform fields into its own struct
The purpose being to reduce the size of GtkWidgetPrivate. What is left
is a pointer to the allocated struct.
2019-04-25 16:02:19 +02:00
Jonas Ådahl
1ad406e15d widget: Remove leftover parent-changed handler removal
It was never added, as the listener was replaced by explicit code in
gtk_widget_(un)root(), but the removal code was left in place in error.
2019-04-25 14:29:19 +02:00
Matthias Clasen
b9770fa752 widget: Drop gtk_widget_set_parent_surface
And the getter, too. Widgets no longer have
extra surfaces that could serve as parent surfaces.
2019-04-24 20:57:09 -04:00
Jonas Ådahl
477ad2505b widget: Add surface relative transform changed callback
Added two new private GtkWidget API:

 * gtk_widget_add_surface_transform_changed_callback()
 * gtk_widget_remove_surface_transform_changed_callback()

The intention is to let the user know when a widget transform relative
to the surface changes. It works by calculating the surface relative
transform during allocation, and notifying the callbacks if it changed
since last time. Each widget adds itself as a listener to its parent
widget, thus will be triggered if a parents surface relative transform
changes.
2019-04-24 14:26:24 +02:00
Matthias Clasen
ef982b7d46 Rename things
Rename the can-pick property to can-target,
and redo the pick flags with more descriptive names.
2019-04-08 08:42:25 -04:00
Matthias Clasen
1b362d1f01 Keep a drawable check in gtk_widget_contains
If the widget is not drawable, it probably doesn't have
an allocation, so asking the question does not make much
sense.
2019-04-07 20:34:12 +00:00
Matthias Clasen
b804235aea Add a flags argument to gtk_widget_pick
This will be used to let the inspector and other users
pick insensitive widgets again. For now, update all
callers to pass no flags, preserving the current
behavior.
2019-04-07 17:19:09 +00:00
Matthias Clasen
6bc32a3d5d widget: Drop the pick vfunc
The way to influence picking is to implement contains,
we no longer use the pick vfunc.
2019-04-07 17:00:51 +00:00
Matthias Clasen
5e24454764 window: Stop implementing pick
Treat popovers as a special-case for now.
2019-04-07 16:11:20 +00:00
Matthias Clasen
676ac380cd widget: Make contains just be about position
Leave out reactiveness considerations here,
pick will handle those.
2019-04-07 15:18:37 +00:00
Matthias Clasen
dce2c58799 widget: Make contains respect rounded borders
We have the api for this now.
2019-04-07 15:18:37 +00:00
Matthias Clasen
bea7ccb41f widget: Propagate display changes to the style context
When a root is set on a widget, the style context may
already exist. We need to make sure that the style context
has the right display set.

This was showing up as "css spillover" in the inspector.

Closes: #https://gitlab.gnome.org/GNOME/gtk/issues/1817
2019-04-06 23:03:25 +00:00
Matthias Clasen
bfb5e6e72f widget: Remove some leftover child-property code 2019-04-05 20:52:29 -04:00
Matthias Clasen
ea7a43beb4 container: Reduce boilerplate
We no longer need to hand-roll the type registration,
since we no longer install our own param spec pool.
2019-04-05 12:01:43 +00:00
Matthias Clasen
70bf6d4b97 Drop child property related apis
We no longer have any child properties in
our containers, so drop the infrastructure for it.
2019-04-05 12:01:43 +00:00
Emmanuele Bassi
208cae2f05 Do not leak unapplied layout properties
If the layout manager does not have a GtkLayoutChild, or if we cannot
apply layout properties, we should free them instead of leaking them.
2019-03-28 17:22:02 +00:00
Emmanuele Bassi
ecba428d52 Add missing handler for <layout> elements in UI files
The layout properties sub-parser needs to handle the parent tag.
2019-03-28 17:21:56 +00:00
Matthias Clasen
e5722367b3 Merge branch 'fixed-layout' into 'master'
Add GtkFixedLayout

See merge request GNOME/gtk!668
2019-03-27 18:51:04 +00:00
Matthias Clasen
03eb455c93 Rename gdk_device_get_position_double
We can drop the double suffix now.
2019-03-26 18:12:55 -04:00
Matthias Clasen
21580309d3 Rename gdk_surface_get_device_position_double
Drop the _double suffix, now that the int version is gone.
2019-03-26 18:12:54 -04:00
Emmanuele Bassi
3389ddf6fc Do not connect to a non-existing signal
The GtkWidget::parent-set signal was removed in ff6cd8f7.

Instead of removing GtkLayoutChild instances associated to a widget
using notifications when the widget's parent changes, we can have
gtk_widget_unparent() call a method on GtkLayoutManager to remove any
eventual GtkLayoutChild instances associated to the widget.
2019-03-26 17:37:49 +00:00
Emmanuele Bassi
65965bed16 Changes after review
- Rename GtkLegacyLayout to GtkCustomLayout
 - Use for() to iterate over children in GtkBinLayout
 - Whitespace fixes for code imported from GtkBox
 - Store the GtkLayoutChild instances inside LayoutManager
 - Simplify the GtkLayoutManager API by dropping unnecessary arguments
 - Fix the ownership model of GtkLayoutManager
2019-03-26 00:11:27 +00:00
Emmanuele Bassi
630442f31c Parse layout properties
If a widget has a LayoutManager instance, then we want to parse layout
properties in UI description files; the grammar is similar to packing
properties in GtkContainer:

    <child>
      <object ...>
        <property name="...">...</property>
        <layout>
          <property name="pname">value</property>
        </layout>
      </object>
    </child>

The properties are applied after a child has been added to its parent,
to the parent's layout manager property should be set.
2019-03-26 00:11:27 +00:00
Emmanuele Bassi
f7856e887e Add GtkWidget:layout-manager
We can use a constructor property for existing container widgets with
a layout policy, and move the layout policy implementation out of the
widget itself and into a LayoutManager subclass.
2019-03-26 00:11:27 +00:00
Emmanuele Bassi
1b8595b5f2 Hook GtkLayoutManager into GtkWidget
We delegate the size request mode, the measuring, and the allocation of
a widget through a GtkLayoutManager instance, if one has been attached
to the widget; otherwise, we fall back to the widget's own implementation.
2019-03-26 00:11:27 +00:00
Timm Bäder
ab7507150b Doc comment fixup 2019-03-25 15:57:31 +01:00
Matthias Clasen
81658105f7 Stop walking parent surfaces for crossing event generation
We basically don't have child surfaces anymore (the last
use in popovers is on the way out). This really needs
to be done in terms of widgets, not surfaces. For now,
just stop walking parent surfaces.
2019-03-22 16:35:20 -04:00
Matthias Clasen
430ea05aea widget: Fix a mission annotation 2019-03-17 01:11:22 -04:00
Matthias Clasen
a3abf0693d Clarify grab_focus docs 2019-03-16 21:24:45 -04:00
Matthias Clasen
7819a5aab9 Drop gtk_widget_send_focus_change
Replace this with gtk_widget_set_has_focus + gtk_widget_event.
2019-03-16 21:24:44 -04:00
Matthias Clasen
15300f839e widget: Add a private setter for has-focus 2019-03-16 21:24:44 -04:00
Matthias Clasen
8c1d852a84 widget: Drop the ::focus signal
The focus vfunc is an implementation detail
of GTK focus handling, and having external
signal handlers interfere with it is not
a good idea.
2019-03-16 21:24:44 -04:00
Matthias Clasen
2738926dcb Simplify the move_focus api
No need to pass the array in from the outside.
2019-03-16 21:24:44 -04:00
Matthias Clasen
029ec38e63 Move a check to gtk_window_set_focus
gtk_widget_grab_focus is just a wrapper for
gtk_window_set_focus. We should do all the enforcement
there.
2019-03-16 21:24:44 -04:00
Matthias Clasen
2bf1561b48 Port widgets to the root focus API 2019-03-16 21:24:44 -04:00
Matthias Clasen
92f1bdcf45 Redo focus handling
GtkWindow has a focus_widget that points to the current input focus.
GtkWidget has a focus_child that points to the child that contains
the input focus. Following the focus_child chain from the toplevel
always leads to the focus_widget. We never unset focus_child, we only
set it. We bubble focus change events.
2019-03-16 21:24:44 -04:00
Matthias Clasen
7ca528b896 widget: Check rootness for invisibility
Make the function that determines initial visibility
look at whether the class implements GtkRoot. That is
the eventual goal for this check. For now, allow
popovers in here as well.
2019-03-16 21:23:28 -04:00
Benjamin Otte
9a1c698070 widget: Make overflow respect rounded corners
Fixes !574
2019-03-08 13:20:17 +01:00
Benjamin Otte
bd113aa85c transform: Redo querying API
Make the API expect a tranform of the proper category instead of
doing the check ourselves and returning TRUE/FALSE.

The benefit is that the mai use case is switch (transform->category)
statements and in those we know the category and don't need to check
TRUE/FALSE.

Using the wrong matrix will now cause a g_warning().
2019-03-04 23:41:51 +01:00
Benjamin Otte
3545abc7a1 transform: Implement gsk_transform_invert()
And use it.

And test it.
2019-03-04 23:41:51 +01:00
Benjamin Otte
b391aea2b3 widget: Make transform a GskTransform
This concludes pushing transforms down into GskTransform.

What's remaining is potentially pushing it further into the renderers.
2019-03-04 23:41:51 +01:00
Benjamin Otte
3cc84d2860 transform: Make category public API
Also rename it from GskMatrixCategory to GskTransformCategory.
2019-03-04 23:15:24 +01:00
Benjamin Otte
0e1a50366a transform: Move to GSK
The renaming of the prefix makes this a large patch.
2019-03-04 23:09:02 +01:00
Benjamin Otte
bed4c68041 widget: Fix gtk_widget_pick() on 3d-transformed widgets
Picking is done by drawing a line along the parent's z axis and picking
at the intersection with the child's z=0 plane.

However, the previous code was casting a ray along the child's z axis.

This patch actually transforms the line to pick into the target's
coordinate system and then computes the corrrect intersection with the
z=0 plane.

Using graphene_point3d_interpolate() to compute the final intersection
point is a bit of abuse of that function, but I found no better way in
Graphene to achieve the same thing.
2019-03-03 19:50:59 +01:00
Matthias Clasen
b0083b33bb widget: Remove the ::grab-focus signal
Nobody is connecting to this signal. And nobody
should.
2019-02-26 08:02:31 -05:00
Matthias Clasen
d3c45cb979 docs: Miscellaneous doc fixes
Additions and correction all over the place,
in GDK and GTK docs.
2019-02-24 16:53:12 -05:00
Matthias Clasen
eb1310effe docs: Remove a mention of Gtkinvisible 2019-02-24 10:40:17 -05:00
Matthias Clasen
edc4f954c6 Revert "inspector: Make picking work again"
This reverts commit 5dbfb18d11.

Inspector picking no longer requries this.
2019-02-24 09:46:46 -05:00
Matthias Clasen
c35554cf68 Drop GtkInvisible
It was already private, and the previous commit removed
the last use.
2019-02-24 09:41:13 -05:00
Matthias Clasen
cc216c9e84 Remove gdk_surface_set_user_data
Change gdk_surface_get/set_user_data to private
API and rename them to get/set_widget.
Also remove an unused associated function.

The last two places where the surface API is used
are in gtkroot.c and gtkwidget.c. Make them
use the private api.
2019-02-23 22:24:50 -05:00
Matthias Clasen
5dbfb18d11 inspector: Make picking work again
This was broken by the change in 01f7f255b5 which
caused the inspector to not get any events anymore.
Revert that part, even though it may be technically
correct.
2019-02-23 18:23:42 -05:00
Matthias Clasen
d633beaccd widget: Connect to GdkSurface::event
This lets us handle input events the same way
we do expose events.
2019-02-23 14:13:57 -05:00
Matthias Clasen
a3901f2563 Drop the anchored field
We can just change priv->root instead.
2019-02-23 09:43:57 -05:00
Matthias Clasen
5dd0863bd7 widget: Drop ::hierarchy-changed
It is no longer used and has been replaced by the
root and unroot vfuncs.
2019-02-23 09:43:57 -05:00
Matthias Clasen
445dca42f5 widget: Remove ::event leftovers
The signal is long gone, no need for this unused
vfunc anymore.
2019-02-22 20:06:06 -05:00
Matthias Clasen
2e5ccce088 Make gtk_widget_set/get_can_pick public
This is a generally useful property to make widgets
'transparent' for input purposes.
2019-02-21 21:53:34 -05:00
Timm Bäder
0ae7c30105 Add & use GTK_CSS_AFFECTS_TRANSFORM
This avoids invalidating the size of all widgets when updating CSS
transforms.

In theory, we don't even have to allocate the widget itself, because we
didn't change its size. But we have no way to track that.
2019-02-21 19:47:28 +01:00
Timm Bäder
fd318a17a4 widget: Apply CSS transform in gtk_widget_allocate() 2019-02-21 19:47:28 +01:00
Benjamin Otte
5965ead5a7 widget: Use new snapshot transforms 2019-02-21 19:47:28 +01:00
Benjamin Otte
f5b44c11c8 widget: Store category of widget transform
And pass that category through to the transform node that we create for
it.
2019-02-21 19:47:28 +01:00
Benjamin Otte
c24f32619f widget: Make gtk_widget_allocate() take a GtkTransform
We can reason about GtkTransform way better - and determine its category or
do equality checks.
2019-02-21 19:47:27 +01:00
Matthias Clasen
b9a41a903b Merge branch 'wip/carlosg/fix-search-entry' into 'master'
Fix search bars

See merge request GNOME/gtk!593
2019-02-20 17:02:15 +00:00
Carlos Garnacho
9ca392b38d gtkwidget: Expose gtk_widget_run_controllers() in private header
Allows for more fine grained access than gtk_widget(_captured)_event
which are meant to work across a hierarchy.
2019-02-20 13:16:07 +01:00
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
Benjamin Otte
514c3679dc widget: Always set out value
Don't leave memory in an unitinialized case when returning FALSE from
gtk_widget_compute_transform().

We both know that people are going to call that function without
checking the return value.
2019-02-20 04:07:34 +01:00
Benjamin Otte
8fbfa955de widget: Fail if matrix not invertible 2019-02-20 04:05:37 +01:00
Benjamin Otte
cfc7dc016e widget: Add optimizations to gtk_widget_compute_transform()
Try to catch 2 common cases with as little work as necessary.
2019-02-20 04:04:29 +01:00
Benjamin Otte
8222631d63 widget: Clean up gtk_widget_compute_transform()
The code was all over the place and being clear here is very useful.
2019-02-20 03:48:41 +01:00
Matthias Clasen
93b47c12d7 Fix gtk_widget_compute_transform
We were collecting all the transforms from widget
up to ancestor, and then trying to collect the
ones from target to ancestor, but failing.
2019-02-19 19:31:16 -05:00
Benjamin Otte
9a8082bab2 widget: Remove gtk_widget_get_allocated_size()
Use gtk_widget_get_allocated_width/height in the only user (GtkStack),
even though that isn't 100% correct.
2019-02-19 19:29:58 +01:00
Benjamin Otte
e223f16aa9 widget: Add gtk_widget_compute_point()
It's the replacement for gtk_widget_translate_coordinates()
2019-02-19 19:22:10 +01:00
Timm Bäder
e922ec1839 widget: Compute child point directly when picking 2019-02-19 19:22:10 +01:00
Timm Bäder
63a23ed0da widget: Remove unused function 2019-02-19 19:22:09 +01:00
Timm Bäder
2ecb4003be widget: Avoid some type checks in pick() and contains()
We've already verified that the given pointer is a proper GtkWidget, so
no need to do it all over again.
2019-02-19 19:22:09 +01:00
Timm Bäder
a953fd762e widget: Add typecheck-less _is_sensitive
It adds up to a whopping 3% in gtk_widget_pick
2019-02-19 19:22:09 +01:00
Timm Bäder
dbf0654e5b widget: Add gtk_widget_compute_transform 2019-02-19 19:22:09 +01:00
Timm Bäder
4529f52c02 widget: Use CSS boxes in gtk_widget_real_contains() 2019-02-19 19:22:09 +01:00
Benjamin Otte
02bb364474 widget: Remove lefover debug code
According to someone involved with those lines, I suck at reviewing
their patches.
2019-02-19 06:50:34 +01:00
Benjamin Otte
d247e5707d widget: Fix gtk_widget_size_allocate()
Compute the matrix for adjusted sizes etc properly.
2019-02-19 05:52:11 +01:00
Timm Bäder
ca2c05cdb3 widget: Push a transform node if we need to
This is the same as the old code since the transformation only contains
teh offset right now, but it will be different later where arbitrary
transformations are possible per widget.
2019-02-16 15:44:46 +01:00
Timm Bäder
10e5856583 widget: Save transform as matrix
The transform matrix is a translation matrix from the parent's origin to
the widget origin. We will later allow more transformations than just
translations.
2019-02-16 15:44:37 +01:00
Benjamin Otte
c44c44ee25 css: Pass boxes to the render functions
Instead of style + rect_of_one_box, pass the new GtkCssBoxes object.
This has the nice side effect that when drawing background + border +
outline, we only compute all the boxes we need once.
2019-02-15 06:53:22 +01:00
Benjamin Otte
285aba6ece widget: Make width, height and transform be widget-relative
Previously, those numbers stored the values relative to the margin box
of the widget. Now they store values relative to the content box,
thereby getting rid of the last remains of weird coordinate systems.
2019-02-15 06:53:22 +01:00
Benjamin Otte
86978d2654 widget: Store the render node in the widget's coordinate system
Also require gtk_widget_snapshot() to be in the widget's coordinate
system.
2019-02-15 06:53:17 +01:00
Benjamin Otte
694d7c378b root: Move the renderer to the root 2019-02-15 06:53:17 +01:00
Benjamin Otte
ddf2a3681d widget: Add a GtkWidget::root property and gtk_widget_get_root()
The property is just for API completeness, the getter is meant to
replace toplevel usage.
2019-02-15 06:53:17 +01:00
Benjamin Otte
4ca1f7e29f widget: Add GtkWidgetClass:root and :unroot functions
They get added whenever a widget gets added into a hierarchy with a root
widget.
2019-02-15 06:53:17 +01:00
Benjamin Otte
aeda099f47 widget: Remove toplevel flag
Instead, rely on GTK_IS_ROOT().

Also implement GtkRoot on GtkWindow and GtkInvisible, the two widgets
that used to set the toplevel flag before.
2019-02-15 06:53:17 +01:00
Benjamin Otte
d65a60e0bd widget: Move compuatation of what changed further up
This way, we can compare with literally the previous allocation and the
size will not be influenced by an adjusted allocation.

But more importantly, we can now use the transform/width/height values
for other stuff.
2019-02-15 06:53:17 +01:00
Benjamin Otte
d3a2218ff4 widget: Split up priv->allocation
It's not priv->transform (to be turned into a graphene matrix),
priv->width and priv->height.

The numbers are still the same.
The only difference is that unallocated widgets will now have x/y set to
0, not to -1.
2019-02-15 06:53:17 +01:00
Matthias Clasen
7cb505a395 Avoid introspection warnings
Unless we keep the parameter names in headers sources and
docs the same, some tools will complain.
2019-02-08 13:49:17 -05:00
Piotr Drąg
cf5f577834 Use Unicode typography in new translatable strings
See https://developer.gnome.org/hig/stable/typography.html
2019-02-08 19:24:53 +01:00
Benjamin Otte
49cbf2a16b widget: Add gtk_widget_set_overflow()
This adds a simple abilities for widget implementations to clip their
content. See future commits for users of this.
2019-02-08 18:26:42 +01:00
Matthias Clasen
a75dcce707 Make the invisible invisible
The change to make widgets visible by default broke GtkInvisibles
special-cased state handling and that in turn caused picking in
the inspector to break with another recent change.

This change makes the inspector pick button work again.
2019-02-05 16:55:07 -05:00
Matthias Clasen
721e598e99 Reduce includes of gtkinvisible.h
We want to get rid of GtkInvisible.
2019-02-05 10:46:33 -05:00
Timm Bäder
4a333f826a Merge branch 'wip/matthiasc/event-signal' into 'master'
Remove vestigial ::event support

See merge request GNOME/gtk!538
2019-01-29 08:33:40 +00:00
Timm Bäder
8c4dc3de4d widget: Also propagate ACTIVE state when unsetting 2019-01-29 07:19:54 +01:00
Timm Bäder
245cebec1d widget: Ignore events on unmapped widgets
There was a special case for GtkSearchBar, so remove that one.
2019-01-29 07:19:54 +01:00
Timm Bäder
61ec2ab5c9 widget: Propagate PRELIGHT state when unsetting it
Without this, disabling a widget that's being hovered and is a child
widget of the widget we're disabling (e.g. the GtkImage child of a
GtkButton) will retain its :hover state even though it should be
insensitive to any sort of input now.
2019-01-29 07:19:54 +01:00
Timm Bäder
611964d915 widget: Avoid some type checks when picking 2019-01-29 05:03:26 +01:00
Matthias Clasen
8a667a5f1d Remove vestigial ::event support
The signal is gone, no need to keep the vfunc around.
2019-01-26 15:36:55 -05:00
Timm Bäder
11f9ae8202 tooltip: Remove gtk_tooltip_trigger_tooltip_query
As stated by the documentation, this should be called when a widget gets
updated, but in that case, one can equally use
gtk_widget_trigger_tooltip_query.
2019-01-18 19:43:51 +01:00
Timm Bäder
0e07912231 tooltips: Remove keyboard mode tooltips
Keyboard mode was only used in gtk_widget_real_show_help before, but now
that's gone and so is any usage of keyboard mode tooltips.
2019-01-18 19:43:50 +01:00
Timm Bäder
cf1526cca6 snapshot: Add gtk_snapshot_from_parent
Most of the time, the GtkSnapshot objects we create while snapshotting
widgets don't end up containing all that many nodes or states in their
respective node or state stack. This undermines the amortized allocation
behavior of the G(Ptr)Array we use for the stacks. So instead, use the
(until now unused) parent_snapshot GtkSnapshot* passed to
gtk_widget_create_render_node and reuse its node and state stack.

We do not avoid allocating a new GtkSnapshot object, but we do avoid
allocating a ton of G(Ptr)Array objects and we also avoid realloc'ing
their storage.
2019-01-16 19:01:40 +01:00
Timm Bäder
904fd5f1fc Remove gtk_widget_intersect
It's been broken for quite a while now and doesn't make sense anymore
these days.
2018-11-29 11:14:26 +01:00
Timm Bäder
c17c18f1ae widget: Remove one translate_coordinates copy
Just use the double version in the integer version.
2018-11-29 07:39:11 +01:00
Timm Bäder
eebb849760 widget: Query CSS values later in size_allocate
Move it below the "this widget only changed its position" check.
2018-11-27 06:00:30 +01:00
Timm Bäder
f92745aacf widget: Save baseline without CSS values applied
Similar to what we do with width/height.
2018-11-27 05:59:47 +01:00
Timm Bäder
b7963a06ab widget: Parent widgets may also consume motions
This is important when the target widget of an event is not the one that
would otherwise receive the gesture. For example, the GtkSwitch
implementation currently attaches a pan gesture to the switch itself,
but the target widget below the pointer might be the switch slider or
label.

See #1465
2018-11-27 05:37:38 +01:00
Timm Bäder
d76a0feef6 widget: gdk_display_get_monitor can return NULL
Fixes #1466
2018-11-20 12:45:18 +01:00
Timm Bäder
c65c6ba11f widget: Fix size-allocate signal docs 2018-11-13 20:54:18 +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
Timm Bäder
481a78eee7 widget: Avoid some more ->priv accesses 2018-11-08 05:13:50 +01:00
Timm Bäder
145659af93 widget: Some whitespace fixes 2018-11-08 05:13:50 +01:00
Carlos Garnacho
55b32c8a8f gtkwidget: Drop obsolete code
This path is not being hit anymore, gtkmain.c does handle those events
itself.
2018-10-15 17:39:04 +02:00
Carlos Garnacho
0f4a6bfbf8 gtkeventcontrollerlegacy: Make public
And move ::event into it, dropping the GtkWidget::event signal.
2018-10-15 17:39:04 +02:00
Timm Bäder
114efa83c6 widget: Stop adding a legacy event controller
The only event signal left is ::event and everything needing that
connects to it directly.
2018-10-11 12:27:56 +02:00
Benjamin Otte
db8474e5b1 inspector: Make controllers page use gtk_list_box_bind_model() 2018-09-16 18:50:17 +02:00
Benjamin Otte
867042f88f widget: Add gtk_widget_observe_controllers()
This mirrors gtk_widget_observe_children() - just that it observes the
controllers, not the children.
2018-09-16 18:50:17 +02:00
Benjamin Otte
dd94129e27 widget: Add gtk_widget_observe_children()
This creates a listmodel that tracks a widget's children. Doing so turns
adding/removing children from O(1) to O(N) though, so use with caution.
2018-09-16 18:50:17 +02:00
Benjamin Otte
63e5b827ed window: Add gtk_window_get_toplevels()
This one returns a list of all toplevel windows.
2018-09-16 18:50:17 +02:00
Timm Bäder
ab30850aad widget: Rename width and height member to {width,height}_request
Because that's much closer to the meaning of those values.
2018-08-05 10:22:11 +02:00
Benjamin Otte
50d5666db0 container: Remove focus chains
They're prectically unused.

Widgets who want to influcence the focus chain behavior should implement
GtkWidgetClass::focus and deal with focus there.
2018-07-31 22:34:27 +02:00
Timm Bäder
480a2c2770 widget: Remove another ->priv usage 2018-07-17 17:33:47 +02:00
Matthias Clasen
7a1073c3ae Revert "gdk: Drop configure events"
This reverts commit a8926c9d87.
2018-07-15 20:23:45 -04:00
Matthias Clasen
7ca6440f4d gdk: Drop map events
We are really inconsistent about generating these,
and they are not actually used in GTK+. Instead,
add a boolean GdkSurface::mapped property.
2018-07-15 15:10:56 -04:00
Matthias Clasen
da3aaf39b9 gdk: Drop expose events
Replace expose events with a GdkSurface::expose signal.
This is part of the move to use events only for input.
2018-07-15 13:13:07 -04:00
Matthias Clasen
a8926c9d87 gdk: Drop configure events
Replace configure events with a GdkSurface::size-changed signal.
This is part of the move to use events only for input.
2018-07-15 11:51:09 -04:00
Benjamin Otte
a7cd1918a8 widgetpaintable: Add a hack to make recursion not infloop
Makes the GUADEC talk not crash that I'm supposed to give in 20 minutes.
2018-07-13 14:56:04 +02:00
Benjamin Otte
bcfd1bbd24 widgetpaintable: Redo implementation
Instead of instantly invalidating, we now cache the old render node and
do the update in an idle handler.
While that gives us a 1 frame delay, it avoids all the tricky things
like queueing resizes while resizing or queueing draws while drawing.

The only remaining issue (and a *big* one at that) is that a nested
widget paintable will now cause the widget to snapshot its previous
render node when creating a new one. And that one will snapshot its
previous render node, and that one will...
And nothing so far breaks this recursion.
2018-07-13 14:56:04 +02:00
Timm Bäder
a6920855ea Implement GtkInspectorLayoutOverlay
To properly replace the old "show layout borders" option.
2018-07-08 11:26:12 +02:00
Matthias Clasen
12464731f1 Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups

See merge request GNOME/gtk!226
2018-07-02 21:19:45 +00:00
Matthias Clasen
7733f646d6 gdk: Rename GdkDragContext to GdkDrag
This is to go along with the newly introduced GdkDrop.

This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.
2018-07-02 14:59:26 +02:00
Benjamin Otte
f3c670ab0c widget: Move opactiy == 0 check
If we check it too early, we will not unset priv->draw_neeeded, which
will then cause queue_draw() calls to not have an effect later. And that
causes changes in opacity to not register.

Closes #1180
2018-06-27 21:50:07 +02:00
Emmanuele Bassi
73d736d800 Do not modify a const GdkEvent in place
When deciding whether or not to emulate a press event, we're translating
the last event coordinates and mutating the given event structure
unconditionally.

We should modify the newly created GdkEvent copy, since it's what we're
going to use when emitting the press event.

This avoids mutating a constant GdkEvent and global state, and also
avoids a compiler warning.
2018-06-26 18:06:23 +01:00
Matthias Clasen
8755d884f3 Remove a lot of Since annotations
4.0 will represent a clean epoch. We don't want to have
lots of noise in the docs about 2.x or 3.x.
2018-06-25 19:55:04 -04:00
Matthias Clasen
87532f0ac3 Merge branch 'wip/carlosg/issue-1159' into 'master'
Fix issue 1159

Closes #1159

See merge request GNOME/gtk!202
2018-06-19 16:40:39 +00:00
Carlos Garnacho
de30a74cdf gtkwidget: Avoid doubly coordinate conversion when emulating press
We are poking again into the event propagation machinery, which
expects events in toplevel coordinates. Since we can't fetch the
original event back at this point, translate the coordinates
back to the toplevel so the emulated press ends up in the right
place.

https://gitlab.gnome.org/GNOME/gtk/issues/1159

Closes: #1159
2018-06-19 13:47:26 +02:00
Benjamin Otte
9a91d3739d widget: Remove time argument from drag_data_get() vfunc 2018-06-18 23:49:53 +02:00
Benjamin Otte
b00609c21c dnd: Make drag-motion and drag-drop signals use GdkDrop 2018-06-18 23:49:52 +02:00
Benjamin Otte
6d7cb2b781 dnd: Make drag-data-received use a GdkDrop 2018-06-18 23:49:52 +02:00
Benjamin Otte
314eaf7d10 widget: Make GtkWidgetClass::drag_leave() take a GdkDrop
Drag Contexts are on their way out!
2018-06-18 23:49:20 +02:00
Benjamin Otte
5b0a6a52c1 dnd: Get rid of gtk_drag_finish()
It's just a wrapper around gdk_drag_finish(), so use that one instead.
2018-06-18 23:49:20 +02:00
Timm Bäder
218b39fe01 GtkStyleContext: Remove the frame clock
It's unused within GtkStyleContext.
2018-06-18 17:35:03 +02:00
Timm Bäder
cfbba2c710 widget: Use priv pointer less
Instead declare a priv local. We should do this even if we don't remove
the priv pointer from GtkWidget entirely, just to stay consistent with
new code we introduce.
2018-06-09 21:25:15 +02:00
Timm Bäder
758137b5d9 widget: Add docs for {get,set}_focus_child
With get_ being still private.
2018-06-04 21:58:44 +02:00
Mohammed Sadiq
f4c1a40446 widget: Fix example code in doc 2018-05-31 16:24:00 +05:30
Matthias Clasen
8746322d53 Drop the ::key-press/release-event signals
These are the last event-type specific signals,
we are just relying on the generic ::event signal now.
2018-05-21 20:20:55 -04:00
Matthias Clasen
287c900bdb Remove key-press-event from more docs
This signal will be going away, so stop mentioning it so much.
2018-05-19 23:36:01 -04:00
Timm Bäder
3edd24fb01 widget: Properly remove event controllers in finalize
We were mutating the list while iterating over it. This was not a
problem before since remove_controller just set the controller pointer
to NULL instead of actually removing it from the list of controllers.
2018-05-19 23:03:32 +02:00
Timm Bäder
0aad5da1b3 widget: Remove controller sequence-state-changed signal connection
We can avoid a signal connection per event controller (and the
EventControllerData struct) since every event controller knows the
widget it's attached to.
2018-05-19 10:18:50 +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
Timm Bäder
f13cccd042 widget: Fix measure docs
Fix a typo and don't ever pass NULL to a ::measure() implementation.
2018-05-19 10:18:50 +02:00
Mohammed Sadiq
33bacb4150 widget: Avoid an unnecessary check
The preceding loop terminates when either the widget is NULL,
or if their type matches. There is no reason to check that again
2018-05-11 16:09:38 +05:30
Timm Bäder
d1cdb9b5cf widget: Clarify add_tick_callback docs
You don't pass the callback to remove_tick_callback, but the id returned
from add_tick_callback.
2018-05-05 07:39:55 +02:00
Timm Bäder
af27199102 widget: Directly access priv pointer in even controller API
Spares us a few lines.
2018-05-05 07:25:10 +02:00
Timm Bäder
e0205eb27c widget: add shortcut to gtk_widget_set_child_visible
So we don't do unnecessary work when just setting priv->child_visible to
the same value again.
2018-05-01 15:13:11 +02:00
Timm Bäder
a54e5844b6 widget: Don't mention gtk_widget_snapshot() in the docs
It's not public so people can't know about it.
2018-05-01 15:13:11 +02:00
Benjamin Otte
ba7849960e eventcontroller: Make widget no longer a construct-only property
The new API model is now complete. To set a widget on a controller, it
is now necessary to call gtk_widget_add_controller().
2018-04-26 17:59:42 +02:00
Benjamin Otte
6fb92a0ab9 legacycontroller: Port to new API model
We no longer set the widget on construction, but instead require an
explicit call to gtk_widget_add_controller().

This way, the reference handling becomes explicit and bindable.

Because gtk_widget_add_controller() is (transfer: full), we don't
even need to unref the controller after adding it.
And we don't need to keep track of it, because controllers get cleaned
up by GtkWidget.
2018-04-26 17:59:41 +02:00
Benjamin Otte
9c0acf62b4 widget: Allow adding event controllers in ui files 2018-04-26 17:59:41 +02:00
Benjamin Otte
9af03fa602 widget: Expose gtk_widget_add_controller()
.. and gtk_widget_remove_controller().
2018-04-26 17:59:41 +02:00
Benjamin Otte
e01e9ce092 eventcontroller: Add vfuncs to (un)set widget
This is the first step towards refactoring how widgets deal with event
controllers.

In the future, the widget will treat controllers the same way it treats
child widgets:
1. The controllers will be created without a widget.
2. There will be gtk_widget_add/remove_controller() functions to add
   or remove controllers.
3. The widget will hold a reference to all its controllers.

This way we will ultimately be able to automate controllers with ui
files.
2018-04-26 17:59:41 +02:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Daniel Boles
e6deaa3a85 Widget: Add missing space in new warning 2018-04-22 23:12:18 +01:00
Daniel Boles
f36c8c219c Widget: Show widget name/addrs if fail to reparent
so we can more easily get an idea of where the problematic code is

https://gitlab.gnome.org/GNOME/gtk/issues/200
2018-04-22 21:49:41 +01:00
Daniel Boles
ae14fa4efd Widget: Trivially fix arg name in non-doc comment 2018-04-22 21:40:20 +01:00
Benjamin Otte
7a09cd4cda widget: Position changes don't require a redraw
Well, they don't require a redraw of the widget, because the widget
itself didn't change.
They require a redraw of the parent, because that now displays the
widget in a different position.

And this means we can keep the cache of the widget's render node.

My fishbowl numbers are through the roof^W water surface. Vulkan gets
4000 now.
2018-04-22 02:57:47 +02:00
Timm Bäder
1313234ae0 Use inlined gtk_widget_get_display version in a few places
We can safely do this whenever we already made sure that the given
pointer is a valid GtkWidget.
2018-04-21 19:06:21 +02:00
Timm Bäder
c3e02b2b22 widget: Add static inline version of gtk_widget_display()
Due to the few type checks in gtk_widget_get_display(), it was the
slowest part of a call to gtk_widget_query_size_for_orientation if the
in case of a cache hit.
2018-04-21 18:48:15 +02:00
Timm Bäder
ac268b1c5d widget: Use get_instance_private more often
To be more consistent with newer code. We can also save a few lines here
and there by pulling the priv initialization before the precondition
checks.
2018-04-21 10:06:57 +02:00
Benjamin Otte
2db43edbd6 snapshot: Don't handle clip anymore
If widgets want to clip things, they now need to do it themselves.

By not taking care of clip, we avoid the need to track clip. And by not
tracking clip, we can avoid all unnecessary cache invalidations that we
were doing for render nodes whenever the clip changed.

And when you are scrolling, the clip changes *a lot*.
2018-04-17 23:21:37 +02:00
Timm Bäder
4b02982e1c widget: Use _set_has_tooltip everywhere
real_set_has_tooltip sounds like it's a vfunc implementation, but it
wasn't. The force parameter was also useless so just remove that.
2018-04-15 17:12:01 +02:00
Timm Bäder
914656b8b6 widget: Use priv pointer directly 2018-04-15 17:12:01 +02:00
Timm Bäder
5f02caf09b widget: Update docs to mention ::draw less 2018-04-15 17:12:01 +02:00
Timm Bäder
3a995b41d7 widget: Avoid a dead assignment 2018-04-14 11:47:02 +02:00
Benjamin Otte
2dd37e9624 widget: Not all toplevels are containers
Guard against GtkInvisible.
2018-04-11 04:04:37 +02:00
Benjamin Otte
b79c138100 widget: Only start/stop idle sizers for toplevels
They are the only widgets that have idle sizers.
2018-04-11 03:16:34 +02:00
Benjamin Otte
2abf082231 widget: Move frame clock handling to vfunc
Instead of connecting to / disconnecting from the frame clock, do it
inside the vfuncs next to changing the priv->realized boolean.

This removes a race between those 2 cases that could cause child
widgets' unrealize handlers to reconnect this widget to the frame clock
because it was still marked as realize when the widget had already
disconnected from the frame clock.

Fixes #168
2018-04-11 03:16:34 +02:00
Benjamin Otte
7ef8cb652b widget: Remove gtk_widget_set_realized()
Everybody chains up now.
2018-04-11 03:16:34 +02:00
Benjamin Otte
5c51a302a4 widget: Make gtk_widget_real_realize() stricter
But in turn, also allow it to work on widgets with their own surface.

This way, we can chain up from everywhere and won't have to export
gtk_widget_set_realized().
2018-04-11 03:16:34 +02:00
Benjamin Otte
0af5316f00 widget: Assert unrealizing
Instead of just setting the flag, assert that it was set.
2018-04-11 03:16:34 +02:00
Benjamin Otte
2862ee7682 widget: Remove unused member 2018-04-11 03:16:34 +02:00
Benjamin Otte
3ee2aa1b22 container: Remove gtk_container_maybe_start_idle_sizer()
Fold it into gtk_container_start_idle_sizer()
2018-04-11 03:16:34 +02:00
Benjamin Otte
21f15094fb container: Remove gtk_container_queue_resize_handler()
It's the same as gtk_container_maybe_start_idle_sizer()
2018-04-11 03:16:34 +02:00
Benjamin Otte
b591d7bc20 widget: Don't queue resize handler twice
We already queue it when we set_alloc_needed(), so there's no need to do
it again.
2018-04-11 03:16:34 +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
Timm Bäder
3a5b2f54ea widget: Remove gtk_widget_get_own_allocation
Use compute_bounds everywhere.
2018-04-10 09:43:47 +02:00
Timm Bäder
5d1f93796e widget: Remove get_own_allocation usages 2018-04-10 09:43:47 +02:00
Timm Bäder
44390c16b2 widget: Fix typo in compute_bounds docs 2018-04-10 09:43:47 +02:00
Benjamin Otte
0afdd84a2a css: Clipping changes don't need a queue_allocate() anymore
Now that queue_draw() isn't restricted to clip anymore, we don't need to
care about clip in the CSS engine either.

We do keep GTK_CSS_AFFECTS_CLIP around though because GtkWindow does
care for the window's size.
2018-04-09 20:20:55 +02:00
Benjamin Otte
e8fef1147f widget: Don't do a 0-size check before snapshotting
Even widgets with an empty allocation may still want to draw stuff.
Examples include shadows or child widgets with negative margins.

Fixes GtkEntry's progressbar not showing up anymore.
2018-04-09 01:00:31 +02:00
Carlos Garnacho
6892b5c5ba gtkwidget: Activate key bindings through run_controllers()
Deferring a bit further making those a standalone controller, make
binding activation happen on run_controllers(), so it happens by
default on widgets (unless the key event was consumed earlier)
without the need of a legacy event controller.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
d74ecfb02e gtkwidget: Break early if non-gesture controllers handle the event
Non gesture controllers have no means to collaborate with other
controllers, thus should be considered standalone entities. It makes
no sense to propagate any further if scroll/key controllers handled
the event.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
f0c8e9de4f gtk: Add GtkGestureStylus
This is a GtkGesture done to deal with stylus events from drawing tablets.
Those have a special number of characteristics that extend a regular
pointer, so it makes sense to wrap that.
2018-04-05 19:26:53 +02:00
Benjamin Otte
ebea84474d widget: Fix variable names
Stop docs build from complaining
2018-04-05 17:09:52 +02:00
Benjamin Otte
2699c15a99 widget: Remove draw signal
The only remaining user is the text handle, but the text handle doesn't
draw anything anyway currently, so whoever fixes it can make it use
snapshots.
2018-04-05 14:57:10 +02:00
Benjamin Otte
cbf26fbd02 widget: Add gtk_widget_compute_bounds()
The first in a set of functions intended to query widget coordinates
from another widget's coordinate system.
2018-04-05 14:57:10 +02:00
Benjamin Otte
6c55096933 inspector: Change semantics of inspector render node notify
Instead of just notifying the inspector of what is going to be rendered,
allow the inspector to modify it.

This way, the inspector can overlay information it deems relevant over
the render node while still having access to what the actual widget
(without the inspector) would paint.
2018-04-05 14:57:10 +02:00
Benjamin Otte
56e018b91c widget: Remove GtkWidget.draw vfunc
Widgets are exclusively snapshot now.

The draw signal still exists.
2018-04-05 14:57:10 +02:00
Benjamin Otte
c06a790694 widget: Remove gtk_widget_draw()
If you want to draw a widget to cairo today, you create a widget
paintable, snapshot it to a render node and then draw the render node to
cairo.

And yes, this is that complicated on purpose. Don't draw widgets to
Cairo.
2018-04-05 14:56:39 +02:00
Benjamin Otte
12fedca726 widgetpaintable: Protect against too many signals
This is actually not just a mechnaism to protect against too many
signals, but it's also a method to getting those signals at the wrong
time.

For every size/content change, a widget needs to invalidate twice:
Once when it queues a resize/redraw (going valid => invalid) and once
when the new size/content is actually assigned (going invalid => valid).

However, one of those invalidations might be inconvenient for the
listener. GtkImage for example does not like receiving
invalidate-contents signals when new contents are assigned, but is fine
with them when the old ones go invalid. And it will not try to draw the
paintable in between anyway.

So by bypassing the 2nd emission if nothing was changed, we can make
GtkImage happy.
2018-04-05 14:56:39 +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
fc6de135fe widget: Don't keep track of clip anymore.
It's not used anywhere, so why would we need it?
2018-04-05 14:56:38 +02:00
Benjamin Otte
a36b0f8bae widget: Don't clip widgets anymore when snapshotting
This is the first step in removing clips.

It's seperate to allow bisecting to this commit when analyzing
performance problems.
2018-04-05 14:56:38 +02:00
Benjamin Otte
4bf90633ea widget: Cache clip from creating render node
When the clip changes that is passed to a snapshot function, we need to
create eventual cached render nodes because they might not have drawn
their whole area before.

Fixes issues with redrawing when scrolling.
2018-04-05 14:56:38 +02:00
Benjamin Otte
278ab3c4de snapshot: Track clip as a rect only 2018-04-05 14:56:38 +02:00
Benjamin Otte
e3a717363b snapshot: Remove clip argument from gtk_snapshot_new()
It's not used anymore. And anybody who wants to have a clip on a
newly created snapshot can achieve that using gtk_snapshot_push_clip().
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
Benjamin Otte
a468714849 widget: Stop tracking invalidations
Instead of calling gdk_surface_invalidate_region(), just
gdk_surface_queue_expose() and rely on the renderer computing the diff
from the previous rendering.
2018-04-05 14:56:38 +02:00
Benjamin Otte
7e078cd940 gtk: Remove debug updates
With the soon-to-arrive automatic updates (aka computing invalid region
from render nodes), this will no longer be necessary.
2018-04-05 14:56:38 +02:00
Benjamin Otte
d0873c7dec gsk: Fold gsk_renderer_begin_draw_frame() into renderer
It doesn't need to be exported anymore.

As a side effect, the inspector no longer has any information about the
render region, so remove the code that was taking care of that.
2018-04-05 14:56:38 +02:00
Benjamin Otte
b19d7630ae widget: Reorder gtk_widget_render()
Now that we don't clip the created render nodes anymore, we don't have
to compute the clip region beforehand.

So snapshot the render nodes before initializing the renderer.
2018-04-05 14:56:38 +02:00
Benjamin Otte
2d10c2568c gtk: Add GtkWidgetPaintable
A GtkWidgetPaintable is a paintable that observes a given GtkWidget and
renders that widget into a paintable.
2018-04-05 14:56:38 +02:00
Benjamin Otte
29111a16d4 widget: Cache the render node
This requires a bunch of refactorings:

1. Don't pass the current clip region to gtk_widget_snapshot()
   so we don't create full widget contents
3. Have a widget->priv->draw_needed that we invalidate on every
   queue_draw() call and set on every snapshot()
2. In queue_draw(), walk the widget chain to invalidate the
   render nodes of all parents
2018-04-05 14:56:38 +02:00
Timm Bäder
66d5a4f752 widget: Fix snapshot condition
Of course, we only need to snapshot if both width and height > 0,
otherwise the result is invisible.
2018-03-30 23:15:04 +02:00
Tomasz Miąsko
494f75b4cf Widget: Fix doc of default ::keynav-failed handler
https://bugzilla.gnome.org/show_bug.cgi?id=793089
2018-03-29 19:18:28 +01:00
Benjamin Otte
1cfa88ed91 snapshot: Remove renderer
Now that there's no longer a need to keep the renderer around for Cairo
rendering, don't do that then.
2018-03-24 21:57:20 +01:00