Commit Graph

67673 Commits

Author SHA1 Message Date
Matthias Clasen
59fd171515 popup: Documentation tweaks
Use proper syntax for referring to signals.
2020-12-07 20:37:30 +01:00
Matthias Clasen
3db0d06901 Properly remove gtk_window_get_size
It was still in the headers and the docs, but did
not have an implementation anymore.
2020-12-07 20:37:30 +01:00
Jonas Ådahl
d7d738d745 tests/animated-resizing: Use gtk_window_default_size() instead
This will actually make it resize on-demand, as the default size is the
size used when computing the window size when the size is not fixed.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
ac17217c69 wayland/toplevel: Don't alwyas skip changing xdg_toplevel state
We only called xdg_toplevel.(un)set_maximize() if the toplevel layout
changed, but this misses the case when the compositor had changed the
maximized state. Change it to call the xdg_toplevel request if either
the local layout changed, or if the layout differs from the current
state.

This fixes an issue where one couldn't unmaximize a window by double
clicking the titlebar that, had previously been maximized e.g. using a
keyboard binding.

Do the same for fullscreen.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
2e5eeb6b92 gtk/window: Add 'fullscreen' prop and gtk_window_is_fullscreen()
This makes it possible to set 'fullscreen' to 'true' in a .ui file to
start an application in fullscreen mode.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
eb0eac0f03 gtk/window: Make R/O is-maximized R/W maximized prop
This makes it possible to set 'maximized' to true in .ui files, and the
window will show up maximized.

gtk_window_is_maximized() will return the intended maximized state until
actually mapped, it will then show the actual maximized state. The same
applies to reading the property.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
27077d5be8 gtk/window: Make 'default-size' adapt to configured size
This commit changes the behavior of window size computation and the
default size properties to:

 * The default-width and default-height properties are updated to the
   current window size unless the size is fixed by e.g. being maxmized,
   tiled etc.
 * The compute-size semantics are to just pick the default size, or if
   not adequate, use the measured size, and consequently update the
   default size, unless unresizable.
 * gtk_window_get_size() is removed, what's more likely relevant is the
   gtk_window_get_default_size() which will now contain more sensible
   values.

Various places that used gtk_window_get_size() were updated to use
gtk_window_get_default_size() to remember and restore previous sizes.

This also changes the default value of 'default-width' and
'default-height' from -1 to 0. The gtk builder simplify tool is taught
how to omit when the default size is set to both -1 and 0.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
fd01723470 x11/surface: Avoid resizing if computed size didn't change
This fixes an issue where we'd resize to the previous window size during
interactive resize.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
994aa41ccc x11/surface: Move the scattered compute-size calls to helper
This simplifies things, and fixes issue where we'd resize the wrong
time, and miss resizing other times.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
c791185c20 x11/surface: Remember the toplevel layout 2020-12-07 20:37:29 +01:00
Jonas Ådahl
e7ddaf5ed1 x11/surface: Compute size after update too
This will sometimes mean a frame is skipped if a resize was requested
during the update phase of the frame dispatch. Not doing so can cause
trying to allocate a window smaller than the minimum size of the widget.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
2217cf8ea2 x11/surface: Remember when there is a pending ConfigureNotify
This will be used to decide whether to try to resize windows when .
2020-12-07 20:37:29 +01:00
Jonas Ådahl
3bbeb891c4 gdk/surface: Allow inhibit layout from backend
If compute_size() returns TRUE, the layout will not be propagated to
GTK. This will be used by the X11 backend to queue asynchronous resizes
that shouldn't yet allocate in GTK.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
ff23a2a582 x11: Use resize counting for freezing updates too
It's already keep strack of when we're waiting for configure events, so
lets reuse it. This fixes an issue where reshown dialogs wouldn't
reappear.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
8396bdb759 wayland/surface: Reset last sent min/max size when hiding
As with the window geometry, the last sent min/max values must be reset
so they are sent again next time the surface is shown.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
351d88f7ae wayland/surface: Clear shadow width when hiding
Not doing this means the next time the same surface is shown, if the
shadow size wasn't changed, it wouldn't be sent to the compositor, which
then would result in compositor deriving its own window geometry which
would include the shadow margin.

This fixes an issue where the file chooser dialog would grow each time
it opened.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
dfb7ab3352 x11/surface: Compute toplevel size outside of frame dispatch
We can't compute and resize a toplevel size during dispatch, as resizing
on X11 is an asynhronous operation, requiring a configuration event.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
8e3ee58e3f tests/animated-resizing: Don't try to resize during frame dispatch
This will not work on X11 because it's too late to resize, due to
resizing being asynchronous i.e. it won't be complete before we need to
draw.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
40a9baa2db gtk/native: Remove gtk_native_check_resize()
This is now handle by the corresponding implemenatations using per
non-gobject-type API.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
4b2aae9950 gtk/dragicon: Use private gtk_drag_icon_present() instead of GtkNative
It didn't even use GtkNative, just the vfunc it set to the interface
sturct.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
9d3f497a21 gtk/tooltipwindow: Use gtk_tooltip_window_present() instead of GtkNative 2020-12-07 20:37:29 +01:00
Jonas Ådahl
517bc0db84 gtk/texthandle: Use gtk_text_handle_present() instead of GtkNative 2020-12-07 20:37:29 +01:00
Jonas Ådahl
369b03a3d8 gtk/window: Don't go via GtkNative when presenting
It'll only call directly back into GtkWindow's toplevel present handling
code.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
2cddec7798 gtk/popover: Use gtk_popover_present() instead of going via GtkNative
This makes it more explicit that managers of popovers make it "present".
2020-12-07 20:37:29 +01:00
Jonas Ådahl
f7fceab40b gtk/entry: Remove emoji chooser field
It wasn't ever set.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
3b66f63523 gtk/popover: Request fake motion events for popovers too
As with GtkWindow, we need to request fake motion events if allocation
changes, to emulate motion events given the new layout.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
96450ed9cc gdk/surface: Emit layout event while frozen
The allocation of popups are part dependent of the allocation of the
root, which means the root must still be allocated when updates are
frozen, otherwise we'll try to allocate non-laid out popups.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
5eee1dfcd1 gdk/popup: Remove the popup-layout-changed signal
It was replaced with GdkSurface::layout.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
19d2a4ab94 gtk/window: Only fake motion events on windows with pending allocations
This fixes an issue where the focus of the window continuously received
fake motion events even when a popover was open, making input events end
up behind the popover.

It also adds a comment describing why motion events are requested. Note
that popovers won't work with this, and it's possible both in the past
and now that sporadic missplaced motion events will appear, e.g. when a
window changes allocation but a popover is open.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
6ee7535af0 gdk/toplevelsize: Rename 'margin' to 'shadow' and 'shadow_width'
This makes it more consistent with everywhere else.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
b738054344 gdk: Remove GdkSurface::size-changed
It's not emitted, and everyone should use the GdkSurface::layout signal
from now on.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
b8fa892b70 gtk/window: Minor cleanup 2020-12-07 20:37:29 +01:00
Jonas Ådahl
ca65ee8d50 gtk/window: Remove out-dated comment 2020-12-07 20:37:29 +01:00
Jonas Ådahl
5eca548acc gtk/window: Use default size if non-resizable if set 2020-12-07 20:37:29 +01:00
Jonas Ådahl
42679f2903 gdk: Replace all GDK_CONFIGURE usage with GdkSurface::layout
This removes the GDK_CONFIGURE event and all related functions and data
types; it includes untested changes to the MacOSX, Win32 and Broadway
backends.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
3f96d4b6da gdk: Always get shadow width via GdkToplevelSize
This removes the gdk_surface_set_shadow_width() function and related
vfuncs. The point here is that the shadow width and surface size can now
be communicated to GDK atomically, meaning it's possible to avoid
intermediate stages where the surface size includes the shadow, but
without the shadow width set, or the other way around.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
0dcd4a5bdb wayland: Stop emitting size-changed
It's dealt with by GdkSurface::layout now.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
8a599b2582 gtk: Allocate everything from GtkNativeClass::layout
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.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
a798edc360 gtk/window: Only deal with shadow when (ex|in)cluding csd size
The size should correspond what gtk_widget_measure() does, and it
measures what's within the window excluding the shadow; so make this
helper function correspond to this.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
e51c32b9c1 gdk/wayland: Always compute-size if GTK asked fer layout 2020-12-07 09:46:39 +01:00
Jonas Ådahl
048a0172a0 gdk/wayland: Always configured size when resizing
GTK4 doesn't support arbitrary constraints when resizing a window (e.g.
steps, or aspect ratio), so we don't need to care about the result from
compute-size when doing interactive resizing.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
64f6118af4 gdk/toplevelsize: Don't complain if only shadow extends out of bounds 2020-12-07 09:46:39 +01:00
Jonas Ådahl
14b5a5a4c7 gtk/window: Remove gtk_window_resize()
Use gtk_window_set_default_size() or change the size of the widget
inside the window to get the same effect.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
4083f7e47f testsuite: Remove test for gtk_window_resize()
And use gtk_window_set_default_size() in the other place.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
2854d0339c tests/testgtk: Remove 'Resize' button
The gtk_window_resize() API is going away, so remove this test.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
98fffe6f23 tests/animated-resizing: Resize widget instead of window
This means the window needs to be marked as non-resizable, otherwise it
won't shrink.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
f083849ebb tests: Use gtk_window_set_default_size() when appropriate
Replace the usage of gtk_window_resize() with
gtk_window_set_default_size() where possible.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
deb58339b9 gtk/expander: Remove manual call to gtk_window_resize()
It happens implicitly for a non-resizeable window.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
65ad9d6d96 gdk/x11: Flush layout changes to the frame clack dispatch
This follows the trail of the Wayland backend in that GdkSurface changes
happen during the layout phase, and that a GDK_CONFIGURE no longer being
used to communicate the size changes of a surface; this now also uses
the layout signal on the GdkSurface.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
e0f13ecae7 gdk/surface: Try to reschedule pending phase until dispatched
If a surface scheduled a relayout, got frozen, and a layout phase
happened, then got unfrozen, it wouldn't see it's layout being
requested; avoid this race by remembering the pending phases until they
actually happened.
2020-12-07 09:46:39 +01:00