Commit Graph

1801 Commits

Author SHA1 Message Date
Benjamin Otte
765e78f72b window: Add a titlebar property
It just turns get/set_titlebar into a property.
2021-09-21 02:52:30 +00:00
Benjamin Otte
32871f997e window: Make priv->titlebar the titlebar
It was priv->title_box before - unless priv->titlebar wasn't NULL, then
it was NULL.

Confusing? Yeah, that's why I changed it.
2021-09-21 02:52:30 +00:00
Benjamin Otte
9fb729ccc0 window: Improve set_titlebar() function
Get rid of a goto and check if the titlebar is already set.
2021-09-21 02:52:30 +00:00
Matthias Clasen
0b4817a1c6 window: Drop some dead code
The gtk_window_set_buildable_property implementation
was only used to set the unused builder_visible flag.
Remove both the flag and the vfunc.

This means we no longer have any set_buildable_property
implementations and could eventually drop that vfunc and
the support for it in GtkBuilder.
2021-09-20 00:01:24 -04:00
Timm Bäder
c2ab1f172d window: Fix mnemonics-visible getter+setter annotations 2021-09-18 08:29:18 +02:00
Florian Müllner
3fa26861cd window: Prefer menu bars when handling F10
Focusing the first widget in the titlebar is a good fallback,
but a "real" menubar or :primary menu button should take
precedence.
2021-08-28 00:19:23 +02:00
Matthias Clasen
f5b6488eb2 window: Make resizeability changes work
We were forgetting to update the toplevel
properties here.
2021-08-19 16:03:58 -04:00
Matthias Clasen
19b534f7de Avoid copying static debug strings
The g_source_set_name calls were showing up as a
major source of strdups in our profiles. Avoid that
by using new GLib api when available.
2021-07-28 22:42:46 -04:00
Matthias Clasen
64af90111e window: Propagate accel changes
When the global accels change, tell the
shortcut controller to re-inject them into
the action muxer hierarchy.
2021-06-17 08:50:26 -04:00
Christian Hergert
a4c5d1d94d window: clear move_focus when focus is already set
This can get set in other places, so we need to ensure it is cleared so
that an after-paint handler does not move the focus to a new widget.
2021-06-10 14:01:41 -07:00
Matthias Clasen
e8852c9a25 Merge branch 'primary-menu-button' into 'master'
menubutton: Enable F10 for primary menus

See merge request GNOME/gtk!3580
2021-06-03 19:37:23 +00:00
Emmanuele Bassi
a88b4f517e docs: Fix link to the interactive debugging section
It's in the "running" document.
2021-06-03 09:31:13 +01:00
Matthias Clasen
a74420bc1a menubutton: Enable F10 for primary menus
Add a ::primary property to GtkMenuButton, which can
be set to make the menu activatable with F10, like
menubars.
2021-05-24 17:27:40 -04:00
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