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
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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
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.
GtkShortcutsWindow is among the 'cheating' containers that iterate
over indirect children in forall, and this is now triggering
an assertion in gtk_container_propagate_draw.
For now, just exclude the cheating containers from the assertion.
Eventually, this needs a better solution.
gdk_rectangle_union will happily add all the worlds pixels
to the union if the initial rectangle is initialized to all
zeros. Therefore, explicitly check for an empty rectangle
before calling it.
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.