Commit Graph

1788 Commits

Author SHA1 Message Date
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
4a0d3d7acc docs: Reduce redundancy
Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.

This adds a few missing nullable annotations too.
2021-05-20 20:45:06 -04:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Carlos Garnacho
6b7b232114 gtkwindow: Fix "shadowed" checks for GTK grabs
We iterate here from the target widget up the toplevel checking
for the previous and new grab, there's however 2 bugs here:
- The check for is_shadowed was different to the check for was_shadowed
- The loop started with the assumption that the widgets did not hold
  a grab, just to change it if the grab widget was found. (or maybe
  it's the other way around? it's unclear with the differing checks
  for past/present state).

Make these checks consistent, and ensure we start with the right
assumption for the past/present grabbing state, and accounting that
new/old grab widgets may or may not be part of the pick stack.
2021-05-18 00:16:55 +02:00
Carlos Garnacho
0a5d21ca9e gtkwindow: Rename function
With gtk_grab_notify_foreach() just taking care of emitting crossing
notifications due to the GTK grab change, rename it to a more apt
gtk_synthesize_grab_crossing().
2021-05-18 00:16:48 +02:00
Carlos Garnacho
f003a4c6cc gtkwindow: Simplify GTK grab notification
The _gtk_widget_grab_notify() function just (maybe) did a) reset
controllers and b) hide toplevels. The second part was a testing
remnant introduced in commit 024d832d94, not part of the original
fix.

Do the former more concisely, called from the place where we figure
out whether a widget's ability to receive events changed due to
GTK grabs. It's across those changes that we are interested in
resetting the controllers.

With the gestures being reset both ways, GtkWindowHandle (and
probably other) gestures are now able to reset after a GTK grab
takes input away (e.g. GtkMenuButton). This could be seen as
a sudden jump the next time they'd be dragged with the mouse,
as the gesture would "resume" the previous interaction.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3942
2021-05-18 00:16:48 +02:00
Matthias Clasen
aa569acaa1 window: Don't let solid-csd linger
Just from reading the code, it seems that we
should unset .csd and .solid-csd at the same
time, since the are mutually exclusive and
we unset them here so realize() can set one
of them again.
2021-04-24 11:29:19 -04:00
Matthias Clasen
1c1c030b8e Simplify shadow conditions
The code in gtkwindow.c for dealing with the various
combinations of client-side decorations and client-side
shadows is entirely too complicated.

This commit does not really clean it up, but simplifies
one of the shadow conditions far enough to make some
sense.

With this change, I get the expected decorations in
all the cases I can easily reproduce locally.
2021-04-24 11:07:20 -04:00
Matthias Clasen
628d5406d7 x11: Fix shadows
Commit a2cd21cab6 changed a condition and inadvertedly
broke client-side shadows on X11. Change this back.

Fixes: #3896
2021-04-24 09:19:18 -04:00
Matthias Clasen
be927d9ce6 Merge branch 'resize-borders' into 'master'
window: Fix up resize borders

Closes #3856

See merge request GNOME/gtk!3467
2021-04-22 11:13:20 +00:00
Matthias Clasen
01d81ffc17 window: Make resize border size independent
Deriving the resize border size from the shadows
carries the risk that we might end up with uneven
resize borders (or none at all, on some sides).

So, justs enforce that we have a big enough shadow
width on all sides.
2021-04-22 06:45:28 -04:00
Matthias Clasen
a2cd21cab6 window: Tweak resize borders
Make windows resizable in the padding and border
area of the css box as well. This naturally makes
solid-csd borders work again.
2021-04-21 21:09:09 -04:00
Matthias Clasen
760e60fa04 window: Fix up resize borders
The invisible resize borders have been wider than they
should, for a while. Go back to a size close to what
we have in GTK3.

To summarize: resize borders will be at most 12 pixels
on each size, but never wider than the windows shadow.
The resize corners have 'legs' of 24 pixels where you
still get a corner resize cursor.

Fixes: #3856
2021-04-21 20:09:38 -04:00
Matthias Clasen
9e8187bdc4 a11y: Track window states more closely
Orca ignores events unless the object is inside an object
with role window and states ACTIVE and SHOWING. To arrange
for this, introduce a new ACTIVE platform state, and set it
for windows when they are active.

This gets orca to be a lot more talkative.
2021-04-19 19:22:20 +01:00
Matthias Clasen
4d19de4e03 window: Fix deferred focus unsetting
In commit 4a76abffd4, we deferred unsetting focus
and default until after the next draw, overlooking the
case where the focus is set to another widget before we
ever get to the unsetting.

Fixes: #3413
2021-04-16 07:35:26 -04:00
Matthias Clasen
4a76abffd4 window: Defer focus setting until after paint
Commit 3dbf5038fa tried to defer focus changes
until after rendering is done. But it failed to do so, since
the toplevel ::render handler is still before rendering of
popups that are attached to that toplevel. To do this
properly, we need to do it in the AFTER_PAINT frame clock
phase.

Fixes: #3725
2021-04-09 19:44:10 -04:00
Matthias Clasen
b79eb55b34 window: Actually enable the inspector by default
427d216081 changed the default in the schema,
but didn't handle cases where the schema isn't found.
2021-04-05 11:54:37 -04:00
Matthias Clasen
cfc91b62b0 window: Add a way to disable F10 shortcut
This is needed for terminal emulators.

Fixes: #3727
2021-03-14 19:47:06 -04:00
Matthias Clasen
292643890b window: Use markdown for css tree 2021-03-11 16:37:35 +00:00
Matthias Clasen
7afc1291a8 window: Convert docs
Convert link format, add an example image, add
property annotations. General cleanup.
2021-03-11 16:37:33 +00:00
Matthias Clasen
52a2891933 window: Add some more details to css docs
Mention more of the supported style classes.
2021-02-14 11:22:44 -05:00
Matthias Clasen
3dbf5038fa Fix unsetting focus
Make _gtk_window_unset_focus_and_default queue the changes
for after the next draw. This achieves two things: first,
it avoids invalidating css at the wrong time (e.g. when
setting child-visible during size-allocation), and second,
it defers the focus change until after the widget is
hidden, so that moving the focus has the desired effect
of picking a different, visible widget.

Fixes: #3623
2021-01-29 21:41:16 -05:00
Matthias Clasen
10d5705b70 Reduce use of GtkStyleContext
Remove some unnecessary uses of GtkStyleContext where
we can directly go to the GtkCssStyle, and and drop
unnnecessary includes.
2021-01-28 12:27:07 -05:00
Matthias Clasen
6c54abeca7 wayland: Explicitly announce ssd for kwin
Without this, kwin correctly assumes that we are
using client-side decorations. This is a port
of 32ae97f1 from GTK 3.24.

Fixes: #3609
2021-01-21 22:45:47 -05:00
Emmanuele Bassi
95ceb49770 a11y: Make GtkATContext realization lazier
We only realize the ATContext on the top level, which will create an
GtkAtSpiRoot object and the corresponding GtkAtSpiCache object. Whenever
an AT connects to the accessibility bus, and asks for the various
objects, all the ATContext will be realized on demand.
2021-01-21 16:40:57 +00:00
David Lechner
4fb70c5e4d gtk/window: remove GtkWindowGeometryInfo from public header file
GtkWindowGeometryInfo is only used by static methods in gtkwindow.c
so it doesn't need to be in the public header file.
2020-12-30 01:32:27 -06:00
Matthias Clasen
5cd2ee927a window: Release application in destroy
We used to do this; it was lost in some life-cycle
reshuffling.
2020-12-22 20:34:13 -05:00
Jonas Ådahl
142f7862ed gdk/toplevellayout: Change API to be about intent, not full state
When being fullscreen, and wanting to unfullscreen but not caring about
whether to go unmaximized or maximized (as this information is lost), if
the GdkToplevelLayout represents the full intended state, we won't be
able to do the right thing.

To avoid this issue, make the GdkToplevelLayout API intend based, where
if one e.g. doesn't call gdk_toplevel_set_maximized() with anything, the
backend will not attempt to change the maximized state.

This means we can also remove the old 'initially_maximized' and
'initially_fullscreen' fields from the private GtkWindow struct, as we
only deal with intents now.
2020-12-16 14:16:08 +01:00
Jonas Ådahl
b6412adc32 gtk/window: Check widget mappdness and not surface mappedness
When deciding whether to call gdk_toplevel_present(), check the
mappedness of GtkWidget instead of the mapped-ness of GdkSurface, as the
latter is mapped asynchronously, while the former is direct state of the
GtkWindow itself.

This fixes an issue where calling e.g. gtk_window_maximize() shortly
after showing it didn't take effect, as hadn't been mapped yet. While
maximizing after showing is racy, and will likely glitch from time to
time, the correct thing to do is still to maximize and handle whatever
state the compositor configured the window to be in.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3466
2020-12-16 11:56:41 +01:00
Carlos Garnacho
612d3bca7d gtk/window: Bring back L-shaped resize corners
These ended up square in the various refactors. Make them again L-shaped
by extending these along the edge being checked. This means we have to
check for corner positions in all edges, though.
2020-12-12 01:42:42 +01:00
Matthias Clasen
324683993e docs: Update references to GtkWindow:fullscreened
The property got renamed from fullscreen to fullscreened.
Update all references.
2020-12-10 09:10:21 -05:00
Emmanuele Bassi
c4b768a4ec Rename GtkWindow:fullscreen to :fullscreened
Having a property with the same name of a method makes some languages
which put properties and method names in the same flat namespace not
really happy about our choices. To avoid collisions, let's put the the
"fullscreen" property into the past, alongside the "maximized" property.
2020-12-09 00:11:49 +00:00
Emmanuele Bassi
6d1be832d9 Fix the documentation for GtkWindow state properties
Drop the "don't write code that crashes" folksy bit; don't start
sentences with conjunctions; remove copy-pasted references to
"iconified" states; point to the corresponding property notification in
a consistent manner.
2020-12-08 23:49:45 +00:00
Matthias Clasen
08ca8a361e docs: Remove a mention of gtk_window_get_size
That function has been removed.
2020-12-08 10:44:33 -05: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
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
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
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
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
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
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