Instead of bending GtkGizmo to the breaking point,
split off a GtkPopoverContent class that just does
what is needed here. Its simpler, and lets us keep
GtkGizmo simpler too.
Use gdk_popup_layout_set_shadow_width to take shadows into
account when positioning popovers, and set the input region
to exclude the shadow, since we aren't doing interactive
resizing and the like.
When the popover has a beak, we make the surface size be
content size + shadow + tail, and then position the content
according to the final position inside this slightly too large
surface. The surface being too large doesn't matter, since we
set up an input region.
When the natural size of the popover exceeds
the monitor width, clamp it to fit on screen.
This gives the Emoji chooser a chance to
work on phone screens.
Fixes: #3307
This changes allocation of the widget trees to happen as a side effect
to the GdkSurface::layout signal, which first passes the GtkNative
instance where it is then forwarded to the implementations of the
GtkNative interface.
The implementations of GtkNative are the ones doing the actual
gtk_widget_allocate(), and they do so in their GtkNativeClass::layout
function.
By moving popup layout emission to the layout phase, the current
GdkPopup::poup-layout-changed signal has no value on its own as it'd be
ignored by GtkPopover.
Make the Wayland backend communicate the popup layout changes via the
common signal; but leave the rest intact until other backends catch up.
And honor it in gtk_popover_popdown(). By default, a GtkPopover
pops down automatically if a child popover was closed, if this
property is FALSE, the popover will remain opened.
Currently there is no way to alter the offset of the popup when positioning
with GdkPopupLayout. This makes using the popup difficult for scenarios
like completion windows where you may need to offset the window by a given
amount for aligning text.
gtk_popover_set_offset() allows setting these values and are analagous to
the function of the same name for GdkPopupLayout.
Add private gtk_tooltip_maybe_allocate() function
and use it from GtkWindow and GtkPopover.
This will let us stop using the ::size-allocate signal,
without having to redo all the tooltip management first.
That will happen later.
When we find out that we've been flipped, set
final_position and final_rect before allocating
the popover. This prevents 'smashed-in beak' disease.
Fixes: #2671
If the popover fails to be shown, it would internally undo visible
and mapped state. If we just proceed as normal, the widget enters
in inconsistent state, and a grab remains issued on the invisible
widget, preventing further input from the input device.
These popovers handle clicks outside the widget, and expect input
to be routed through it when it is shown. This pretty much matches
the characteristics of GTK grabs, and setting one up will ensure
the cancellation of event controllers that were active at the time
of showing the popover.
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2446