Commit Graph

67798 Commits

Author SHA1 Message Date
Jonas Ådahl
fea1b151e6 testsuite/filtermodel: Remove calls to gtk_widget_realize()
They don't do what they used to do.
2020-12-07 22:29:51 +01:00
Christian Hergert
6e0fffa0f8 macos: use CGLSetParameter and CGLEnable
We don't need to go through the NSOpenGLContext for these.
We can just use the C API directly. It's also clearer what is using
CGLEnable() vs CGLSetParameter().
2020-12-07 11:47:51 -08:00
Jonas Ådahl
d2c95a1b13 gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.

It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.

To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 20:37:30 +01:00
Jonas Ådahl
8f8c5040db gtk/headerbar: Remove unused 'state' field 2020-12-07 20:37:30 +01:00
Matthias Clasen
3b69facf0b Mention window sizes in the migration guide 2020-12-07 20:37:30 +01:00
Matthias Clasen
a6bc4c95b1 docs: Add gtk_window_is_fullscreen 2020-12-07 20:37:30 +01:00
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
Christian Hergert
b431e39d4e macos: we only need 24-bit for color 2020-12-07 11:27:11 -08:00
Emmanuele Bassi
606cb51293 Merge branch 'ebassi/activate-signal' into 'master'
Add accessors for GtkWidgetClass.activate_signal

See merge request GNOME/gtk!2925
2020-12-07 15:23:55 +00:00
Jakub Steiner
62e0c0de59 Adwaita: no 3d shadow for pressed sidebar
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3413
2020-12-07 14:19:24 +01:00
Jakub Steiner
30f789650f Revert "Adwaita: avoid clipping menu shadows"
While the workaround hides majority of the issue there are still two big downsides:

  - shadow does eat from the widget dimensions so alignment is broken
  - situations like popover going upwards on screen edge break completely

The appropriate action is to revert these theme duct tape solutions to make room
for a proper fix.

This reverts commit b3dba1dca6.

Issue https://gitlab.gnome.org/GNOME/gtk/-/issues/1987
2020-12-07 10:58:12 +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