Commit Graph

2163 Commits

Author SHA1 Message Date
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