Commit Graph

2405 Commits

Author SHA1 Message Date
Timm Bäder
5b77d3fde3 widget: Remove GtkWindow special case in create_render_node() 2020-05-20 17:06:54 +02:00
Matthias Clasen
75d9310986 Change coordinate translation apis to take doubles
Change gtk_widget_translate_coordinates and
gtk_native_get_surface_transform to operate
on doubles. Update all callers.
2020-05-17 17:17:31 -04:00
Benjamin Otte
b353221185 Merge branch 'wip/otte/monitors' into 'master'
various GDK cleanups

See merge request GNOME/gtk!1920
2020-05-17 16:57:52 +00:00
Matthias Clasen
d70feb9165 Apply surface transform in more places
With these fixes, GtkSwitch now works in the presence
of surface transforms.
2020-05-17 02:23:23 -04:00
Matthias Clasen
c90078fd4a widget: Fix gtk_widget_get_surface_allocation
As the name implies, this should be surface-relative
coordinates, so it needs to take the surface transform
into account.
2020-05-17 02:04:22 -04:00
Benjamin Otte
4c7914dc49 display: Remove unneeded getters
Applications can use the listmodel instead.
2020-05-17 07:32:37 +02:00
Benjamin Otte
0c6266fd1a surface: Remove gdk_surface_is_viewable()
It returns the same value as gdk_surface_get_mapped(), so use that
instead.
2020-05-17 00:41:44 +02:00
Matthias Clasen
8912a6eb75 gtk: Handle seatless displays
If you run weston with the headless backend, you get a Wayland
display with no seat, which is just fine by the protocol.

gdk_display_get_default_seat() returns NULL in this case. Various
widgets assume that we always have a seat with a keyboard and a
pointer, since that is what X guarantees. Make things survive
without that, so we can run the testsuite under a headless
Wayland compositor.
2020-05-15 14:11:53 -04:00
Corentin Noël
80473ccd69 widget: Add array annotation to set_css_classes
It expects a NULL-terminated array so annotate it.
2020-05-15 12:01:56 +02:00
Timm Bäder
8a7fb4b133 widget: Make 1 if out of 2 ifs 2020-05-13 11:52:07 +02:00
Timm Bäder
167c6119eb widget: Move adjusted size calculation below early-out goto 2020-05-13 08:07:55 +02:00
Timm Bäder
ef2af521b1 widget: Remove size allocate signal enum member 2020-05-13 08:07:55 +02:00
Matthias Clasen
2a24b8c653 Replace most remaining uses of container api
These are all on GtkBox or enumerating children.
2020-05-11 22:38:21 -04:00
Matthias Clasen
cc28a7b0ef Merge branch 'wip/tintou/doc-fixes' into 'master'
docs: Fix several missing references in the documentation

See merge request GNOME/gtk!1874
2020-05-11 18:40:34 +00:00
Corentin Noël
076b2f11d2 docs: Fix several missing references in the documentation
This fixes several typos and missing references
2020-05-11 19:26:20 +02:00
Matthias Clasen
6d969d1026 Update the docs
Remove various references to gtk_widget_destroy in the docs.
2020-05-11 12:20:59 -04:00
Matthias Clasen
0f10b170f4 widget: Drop gtk_widget_destroy 2020-05-11 12:20:59 -04:00
Matthias Clasen
573b20a8f8 Drop gtk_widget_destroyed
Use g_object_add_weak_pointer or a weak reference instead.
2020-05-11 12:19:39 -04:00
Matthias Clasen
329994291a Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!1867
2020-05-11 14:24:45 +00:00
Matthias Clasen
6372a33838 Clarify docs around focus. 2020-05-11 00:29:41 -04:00
Matthias Clasen
b93631164f Remove lots of focus vfuncs
In many cases, the default widget vfuncs work just fine,
combined with setting focusable.
2020-05-11 00:11:37 -04:00
Matthias Clasen
46bad5d513 widget: Fix gtk_widget_focus_all for !focusable
This was a case that wasn't handle properly when
the focus is entering from the outside, in forward
direction.
2020-05-11 00:11:04 -04:00
Matthias Clasen
edc31a264c widget: Add a :focusable property
Add back a property that determines whether an individual
widget will accept focus or not. :can-focus prevents the
focus from ever entering the entire widget hierarchy
below a widget, and :focusable just determines if grabbing
the focus to the widget itself will succeed.

See #2686
2020-05-10 23:24:48 -04:00
Matthias Clasen
eae4a194b8 Merge branch 'wip/exalm/headerbar-dragging' into 'master'
Extract GtkWindow dragging and titlebar actions

Closes #2689

See merge request GNOME/gtk!1814
2020-05-10 18:15:57 +00:00
Timm Bäder
2455978c78 widget: Move {dis,}connect_frame_clock into their only caller
Makes sense to have these only in (un)realize.
2020-05-10 08:44:20 +02:00
Matthias Clasen
0cd0ef2d26 widget: Don't leak a reference when reordering
When reordering a widget that is alrady under the
same parent, we must not take another reference.
2020-05-09 19:27:56 -04:00
Alexander Mikhaylenko
6c636642df widget: Pass parent to gtk_widget_consumes_motion()
Right now it assumes that the parent is a GtkWindow. This will break when
window dragging is handled by another widget.
2020-05-07 09:44:15 +05:00
Matthias Clasen
57d3719583 Fix an inspector crash
Fix the listmodel semantics of the controller model,
by making get_item return a reference.
This was broken in 4b9e5304cc.
2020-05-06 22:25:51 -04:00
Matthias Clasen
56e590bd31 widget: Drop the ::size-allocate signal
This signal is mainly used for bad things, and we
don't want to emit signals during layout if we can
avoid it.

If you are subclassing, you should either use a
layout manager or override the size_allocate vfunc.

If you are using a GtkDrawingArea or GtkGLArea,
use their ::resize signals to learn about size
changes.

Fixes: #2705
2020-05-06 14:27:45 -04:00
Emmanuele Bassi
cb94c7d69e Explicitly update widget a11y bounds when allocating
The a11y machinery is using signal subscription to get notified of size
changes and notify listeners in turn. This is suboptimal for a couple of
reasons:

 - if something connects to the GtkWidget::size-allocate signal we need
   to emit it; currently, we have an optimization in place that will
   skip the signal emission if there are no handlers, and it would be
   nice to go through the fast path
 - the accessibility implementation is part of GTK, and should not go
   through additional hoops like any out-of-tree API consumer
2020-05-06 14:27:45 -04:00
Matthias Clasen
b96509c030 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!1828
2020-05-06 03:55:55 +00:00
Matthias Clasen
a4cfbec5c2 widget: Drop the destroy vfunc
We still emit the ::destroy signal, but if you
want a vfunc, use dispose.
2020-05-05 18:25:29 -04:00
Timm Bäder
75e202f02b widget: Use an unchecked cast in _get_native()
This is either no chagne because we know for a fact that the returned
value is a GtkNative - after all thats's the type we pass to
gtk_widget_get_ancestor().

Or it is a bug fix since casting NULL to a GtkNative using GTK_NATIVE()
is not going to work, but the API contract of gtk_widget_get_native()
explicitly allows a NULL return value.
2020-05-05 08:20:10 +02:00
Timm Bäder
4b9e5304cc widget: Save controllers list in a GPtrArray 2020-05-05 08:20:09 +02:00
Timm Bäder
ef623aaabc widget: Only do a IS_ROOT type check if the parent is unset
So we do less type checks
2020-05-05 08:20:09 +02:00
Timm Bäder
61195df7a3 widget: Use early-out style in gtk_widget_realize()
This is much more common in the current code base and reduces the
indentation level by one.
2020-05-05 08:20:09 +02:00
Matthias Clasen
b968ced567 Reshuffle action muxer initialization
We were having a problem where property actions were
not getting state updates because prop_actions_connect
was triggered from some instance_init function while
the widget class is not in place yet.

Delay that call until the widget is fully constructed,
so we can guarantee that we are dealing with the
correct class private struct, and see all class actions.
2020-04-28 18:37:43 -04:00
Emmanuele Bassi
65c56ea812 Merge branch 'drop-realize-invariant' into 'master'
Drop parent->realized => child->realized invariant

See merge request GNOME/gtk!1783
2020-04-28 14:11:55 +00:00
Alexander Larsson
c6104fe7fd Drop parent->realized => child->realized invariant
We already dropped this invariant in gtk_widget_verify_invariants()
because it was not true in all cases. Also, it is not really useful
these days as we extended what it means to be a "child" to also
include widgets in different toplevels.

For example, a popup in a popup button need not be realized just
because the button is in a realized window. The main invariants
we want are:

 * Parent is realized before child
 * Widget is realized before it is mapped

This sounds like its not a huge deal, but in fact it is a massive win
for things like menus, because when we go between menus in a menubar
each switch between two open menus involves a lot of intermingled
crossing events to different surfaces and for each of these the
tooltip window of the toplevel gets assigned to the new surface.  This
shouldn't be a huge deal, as the tooltip window is not even visible,
but due to the realized invariant it get re-realized each time it gets
re-assigned.
2020-04-28 14:32:57 +02:00
Emmanuele Bassi
555230ec9c Annotate more functions returning GListModel
Now that we can have an element-type annotation, we should use it where
needed.
2020-04-28 13:31:59 +01:00
Matthias Clasen
637890517b Move the idle sizer to the gtkroot.c
This is needed since we already have a second GtkRoot
implementation with GtkDragIcon, and DND is causing
critical warnings due to this.
2020-04-25 21:03:57 -04:00
Matthias Clasen
b2deab6adf Drop gtk_widget_has_grab
This was just a leftover in our public api.
All other grab-related apis are gone.
2020-04-23 14:10:44 -04:00
Matthias Clasen
94906d076a Drop gtk_widget_reset_style
There was a single call left that should not be necessary.
Also drop no longer used attached-window functionality.
2020-04-22 19:30:48 -04:00
Matthias Clasen
7b4378bc46 widget: Update when font settings change
Update the pango context when font-related settings
change, using the new GtkSystemSetting mechanism.
2020-04-22 19:30:48 -04:00
Matthias Clasen
723d57eeb5 widget: Add a system_setting_changed vfunc
This gives us a hook to walk the widget tree whenever a global
setting changes and do per-widget invalidations. This will
replace gtk_style_context_reset_widgets().
2020-04-22 19:29:15 -04:00
Florian Müllner
8e2ffb3b46 widget: Add missing callback annotation
GI can only figure out the correct scope if there's a GDestroyNotify
or GAsyncReadyCallback parameter.
2020-04-21 16:35:07 +02:00
Matthias Clasen
b55195fa2e Move the idle sizer to GtkWindow
This was only living in gtkcontainer.c for historic
reasons. Move it closer to where it belongs, and
rename it from 'idle' to 'layout', since it is
really about the layout phase of the frame clock,
nowadays.
2020-04-20 16:30:45 -04:00
Matthias Clasen
d756c6e282 Move set_focus_child to GtkWidget
Move the set_focus_child vfunc from GtkContainer
to GtkWidget. This removes the last focus functionality
from GtkContainer.

Update the two users.
2020-04-20 16:30:43 -04:00
Matthias Clasen
b4c79bad34 Assorted documentation fixes 2020-04-20 00:38:58 -04:00
Timm Bäder
ca47e96d35 widget: Return an array from list_devices
To forther reduce the GList usage in the code base.
2020-04-17 15:21:00 +02:00