Commit Graph

420 Commits

Author SHA1 Message Date
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
7481affb82 container: Drop priv pointer 2017-09-03 09:17:35 +02:00
Timm Bäder
f879750759 container: Fix scrolling adjustment coordinates 2017-08-21 12:30:47 +02:00
Timm Bäder
b24535ea75 container: Remove gtk_container_propagate_draw
It's superseded by gtk_widget_snapshot_child now.
2017-08-21 12:30:42 +02:00
Daniel Boles
23b6699ec3 Container: Don’t scroll to unset focus child coord
In gtk_container_real_set_focus_child(), we try to scroll to the
position of the new :focus-child if we have h or v adjustments.

gtk_widget_translate_coordinates() returns FALSE if neither widget is
realized or in other situations that cause output parameters x and y not
to be set. Thus, if the caller did not initialise x/y and uses them even
if the function returned FALSE, they are using uninitialised variables.

In gtk_container_real_set_focus_child(), we did not check the return
value but merrily went ahead and used x and y regardless. This is UB, as
revealed by Valgrind, as well as being pointless.

The trivial fix is to exit early if (!gtk_widget_translate_coordinates).

https://bugzilla.gnome.org/show_bug.cgi?id=776909
2017-08-07 19:21:09 +01:00
Daniel Boles
c4865bed43 Container: Fix scrolled coord in set_focus_child()
Commit 885bcd9fe4 trampled the bit here
that is meant to translate between the nominated focus child and the
actual innermost one that is used for updating the h/v adjustments.

So, we need to save the passed focus child before diving into its
children, then translate and get allocations between them both. This
makes GTK+ 4 behave like GTK+ 3 again: instead of priv->focus_child and
focus_child, we now have focus_child and child, serving the roles of the
nominated focus child and its innermost focus child respectively.

This also ditches the unnecessary call to Widget:get_focus_child(), as
Container::set_focus_child() gets that same new child as an argument.
2017-08-07 18:42:15 +01: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
f9f6f3027d container: Remove get_children_clip
Unused.
2017-07-19 21:27:14 -04:00
Timm Bäder
bccaeb0e2d widget: Make allocations parent-content-allocation relative 2017-07-19 21:27:13 -04:00
Timm Bäder
f1c1e52eea container: GtkActionBar is not a special container anymore 2017-07-19 21:27:13 -04:00
Timm Bäder
07cbbc6fa9 container: Propagate child properties if parent != container
This can happen when e.g. GtkNotebook adds the child page widgets not
directly inside the notebook, but inside the inner GtkStack.
2017-07-19 21:27:12 -04:00
Timm Bäder
ef0ab1fb00 container: Remove snapshot and draw implementations 2017-07-19 21:27:11 -04:00
Timm Bäder
0938183ae6 container: Use gtk_container_forall less
Just iterate over the child widgets directly and produce a much nicer
stack trace when debugging.
2017-04-25 20:30:37 +02: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
885bcd9fe4 container: Remove focus_child pointer
Use GtkWidget's instead.
2017-03-31 09:50:39 +02:00
Timm Bäder
0d480a3eb0 Remove gtk_container_get_focus_child 2017-03-31 09:50:39 +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
Timm Bäder
47d4ad71fb Remove gtk_container_snapshot_child
Replace it with the already existing gtk_widget_snapshot_child.
2017-01-07 17:19:30 +01:00
Timm Bäder
8ef73660e4 widget: Implement map/unmap with child widgets
Once again, do what GtkContainer did before.
2017-01-07 16:44:01 +01:00
Timm Bäder
b15b9e028f widget: Implement show_all
Do what gtk_container_forall did: show_all all children, then the widget
itself.
2017-01-07 16:44:01 +01:00
Benjamin Otte
c4065b9ee0 API: Export gtk_container_snapshot_child()
It's equivalent to gtk_container_propagate_draw() and then one is
public, too.
2016-12-20 19:26:40 +01:00
Benjamin Otte
cb8483b0a6 gtk: Remove unneeded gtk_snapshot_push()/pop() calls 2016-12-09 21:39:43 +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
f728f33382 container: ensure we only append a single node
The snapshot vfuncs must only append at most a single node,
otherwise things are going to break if the widget is the root node.

Unfortunately there is no code that can check this in a generic fashion,
so we'll have to debug this on a case-by-case basis.
2016-11-15 22:39:26 +01:00
Benjamin Otte
e2fb970889 container: Remove get_render_node() support API
It's unused now.
2016-11-15 17:49:19 +01:00
Benjamin Otte
ae2477b1bc container: Add snapshot() implementation
Note that this implementation does not respect GDK windows at all. If
your widget requires respecting them, you should write your own
snapshot implementation and not chain up.
2016-11-15 17:48:45 +01:00
Benjamin Otte
d1fec79c00 snapshot: Completely reengineer API
We now try to emulate cairo_t:

We keep a stack of nodes via push/pop and a transform matrix.

So whenever a new node is added to the snapshot, we transform it
by the current transform matrix and append it to the current node.
2016-11-15 17:48:45 +01:00
Benjamin Otte
bb9626dc29 window: Implement snapshot() 2016-11-15 17:48:45 +01:00
Timm Bäder
846cf681e8 Remove gtk_widget_set_mapped
Let all the remaining callers chain up.
2016-11-05 11:56:36 +01:00
Matthias Clasen
68cc1412e5 container: Add a private api for render node propagation
Add a function that propagates a render node for a single
child. This will be used in the box gadget to handle widgets.
2016-11-01 14:29:25 -04:00
Timm Bäder
0f6235752e container: Remove composite_name 2016-10-20 20:12:05 +02:00
Timm Bäder
de65f87816 container: Remove reallocate_redraws 2016-10-20 20:12:05 +02:00
Timm Bäder
e772c2b622 container: Don't queue resize on non-toplevel widgets 2016-10-20 17:09:06 +02:00
Matthias Clasen
58b38d59c5 container: Prepare to prune render nodes
Add a should_propagate function for render nodes. Eventually,
this is meant to avoid creating render nodes for child widgets
that are outside the parents clip area. Since we don't have
that information available right now, just filter out nondrawable
children for now.
2016-10-18 11:49:15 +01:00
Matthias Clasen
f74dd416d6 Make outer shadows work again
Change get_render_node to return nodes that are sized to the clip
area and expect to be placed at the clip position; change
gtk_container_propagate_render_node to place child render nodes
accordingly, and change gtk_css_gadget_get_render_node to return
nodes that are sized accordingly as well.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
23a009a408 gtk: Sort children by window depth when rendering
This makes popovers pop over instead of under.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
bfad9fe4ee gtk: Update the coordinates when propagating render nodes
Just like gtk_container_propagate_draw() does for the immediate mode
rendering.
2016-10-18 11:49:10 +01:00
Emmanuele Bassi
cd0de3f87c gtk: Add GtkContainer API to gather render nodes
We cannot implement GtkWidgetClass.get_render_node() in GtkContainer
without breaking the fallback path that renders a widget to a single
render node rasterization. For GtkContainer subclasses we should provide
a simple API, similar to gtk_container_propagate_draw(), that gathers
all the render nodes for each child.
2016-10-18 11:49:09 +01:00
Emmanuele Bassi
9557364216 gtk: Mark internal functions as static
These functions are only used within their compilation unit.
2016-10-17 11:44:10 +01:00
Benjamin Otte
1d4f23da8e API: container: Remove GtkContainer::child property 2016-10-16 18:18:58 +02:00
Benjamin Otte
d4d3374729 container: Remove gtk_container_set_resize_mode() 2016-10-16 18:18:58 +02:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Timm Bäder
fb3d9022ad Remove GtkHBox 2016-10-16 18:17:21 +02:00
Arnaud Bonatti
3c3a11591b Fix typos.
https://bugzilla.gnome.org/show_bug.cgi?id=770624
2016-09-01 07:14:30 +02:00
Benjamin Otte
e1a03ead7a Use NULL for generic marshallers in g_signal_new()
glib will use the correct marshaller automatically. And as a side
effect, we also get all glib optimizations, like a va marshaller.
2016-08-29 16:20:54 +02:00
Cosimo Cecchi
d61c2b4cce window: stop stomping on resize-mode set by external API
commit c3dc0d80f1 fixed the behavior of
GtkContainer widgets requesting an IMMEDIATE resize-mode.

However, GtkWindow has been stomping on resize-mode during realize()
since commit addcc64b9c. The combination
of factors that led to this not being a visible problem during all this
while is uncertain, but this now causes the Shell to continuously try to
relayout its ShellEmbeddedWindow (a GtkWindow subclass).

This commit separates the resize-mode as set internally by GtkWindow
from the one set with the external API, so that GtkWindow only changes
it when it had not been set before by the subclass.

https://bugzilla.gnome.org/show_bug.cgi?id=763650
2016-03-14 16:10:15 -07:00
Benjamin Otte
a380533336 container: Remove check
The check is not working for many containers anymore as they are not the
direct parents of their children. We want to allow this behavior in more
places.
2016-03-02 13:54:39 +01:00
Benjamin Otte
c3dc0d80f1 container: Request layout again depending on layout mode
Containers with RESIZE_MODE_PARENT should never request layout and those
with RESIZE_MODE_IMMEDIATE should only request it for updating CSS.

Fixes clutter embeds (like the tray icon embed in gnome-shell)
continuously requesting relayout when all they want to do is relegate
relayout to Clutter.

https://bugzilla.gnome.org/show_bug.cgi?id=758893
2016-02-23 04:22:19 +01:00
Matthias Clasen
8ba996a6db container: Clarify the forall/foreach documentation
Try to make the difference between these two functions
clearer.
2016-01-23 18:16:51 -05:00
Benjamin Otte
d4f853dc64 container: Turn assert into return_if_fail()
There's no reason to insta-crash when something goes wrong. Just don't
do anything stupid.

Also, remove the SPCIAL_CONTAINER() exception. Every case where special
containers needed this, it is wrong and made containers draw children
multiple times.
2016-01-22 14:17:28 +01:00