Commit Graph

2457 Commits

Author SHA1 Message Date
Emmanuele Bassi
82664003c0 a11y: Allow setting the role post-construction
Some widgets have different roles after they are constructed, so we need
to allow changing the role defined by the class. We should still avoid
setting a role after the GtkATContext has been created.
2020-07-26 21:27:03 +01:00
Emmanuele Bassi
a9e0cf77a0 a11y: Update labelled-by when setting mnemonic labels
The ARIA labelled-by attribute behaves the same way as the mnemonic
labels in GTK.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
572861be27 Allow setting the accessible role at construction
Some widgets have different accessible roles depending on some
parameter, so we cannot set the role at class init time. For those
widgets, we add an "accessible-role" property to GtkAccessible, and we
allow setting it (only) at construction time.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
3ea069a8d3 Update the accessible state on widget visibility changes
The GTK_ACCESSIBLE_STATE_HIDDEN has the opposite meaning of the
GtkWidget:visible property.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
25f6da5e89 Have GtkWidget implement GtkAccessible
Each widget type has an accessible role associated to its class, as
roles cannot change during the life time of a widget instance.

Each widget is also responsible for creating an ATContext, to proxy
state changes to the underlying accessibility infrastructure.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
14faec3ce2 Introduce GtkAccessible
GtkAccessible is an interface for accessible UI elements.

Currently, it doesn't do much except exist as a type; in the future, it
will be the entry point for all accessible state in GTK.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
c63087a563 Remove ATK
To build a better world sometimes means having to tear the old one down.
        -- Alexander Pierce, "Captain America: The Winter Soldier"

ATK served us well for nearly 20 years, but the world has changed, and
GTK has changed with it. Now ATK is mostly a hindrance towards improving
the accessibility stack:

 - it maps to a very specific implementation, AT-SPI, which is Linux and
   Unix specific
 - it requires implementing the same functionality in three different
   layers of the stack: AT-SPI, ATK, and GTK
 - only GTK uses it; every other Linux and Unix toolkit and application
   talks to AT-SPI directly, including assistive technologies

Sadly, we cannot incrementally port GTK to a new accessibility stack;
since ATK insulates us entirely from the underlying implementation, we
cannot replace it piecemeal. Instead, we're going to remove everything
and then incrementally build on a clean slate:

 - add an "accessible" interface, implemented by GTK objects directly,
   which describe the accessible role and state changes for every UI
   element
 - add an "assistive technology context" to proxy a native accessibility
   API, and assign it to every widget
 - implement the AT context depending on the platform

For more information, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2833
2020-07-26 20:31:14 +01:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Matthias Clasen
4786a16696 actionmuxer: Port internal users
Port all internal users of the action muxer
from the GActionGroup interface to the new
action muxer apis.
2020-07-20 08:24:52 -04:00
Timm Bäder
14589c2a59 widget: Save a gtk_css_node_get_style call 2020-07-17 05:49:12 +02:00
Timm Bäder
f678b3804d widget: Remove useless if statement
filter_value is never NULL anyway.
2020-07-17 05:49:12 +02:00
Timm Bäder
f721d2de15 debug: Remove resize highlighting
This has been broken ever since the debug highlighting moved to
inspector overlays.
2020-07-17 05:49:12 +02:00
Matthias Clasen
43b9fc6981 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2162
2020-07-01 01:35:56 +00:00
Matthias Clasen
5229069101 widget: Avoid uninitialized access
Initialize all field in the GtkCrossingData struct
when synthesizing crossing events.

Fixes: #2743
2020-06-28 13:42:02 -04:00
Timm Bäder
83543423e2 widget: Don't get the frame clock if we don't use it 2020-06-27 11:47:42 +02:00
Matthias Clasen
913cd91df0 widget: Fix an oversight
g_message comes with a builtin newline, don't add one
to the message.
2020-06-26 22:12:14 -04:00
Matthias Clasen
a26865e741 widget: Add a debug message for consumed key events
Run the application with GTK_DEBUG=keybindings to
get some hints where key events get lost.
2020-06-26 14:08:14 -04:00
Carlos Garnacho
8e549d73a0 gtkwidget: Drop _gtk_widget_[gs]et_shadowed()
This API is meaningless now, with grab-notify being handled internally.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
102d2a36f3 gtkwidget: Avoid use of shadowed flag
This is going away, look up whether there is a grab, and whether
the widget is within it, instead.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
f046e27bb4 gtkwidget: Drop gtk_widget_device_is_shadowed()
A widget no longer needs updating on GTK grabs on itself, drop
this miscellaneous and no longer used API.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
1c5cf17f1c gtkwidget: Drop internal checks in grab-notify
There's no need to check if the widget is already shadowed, we
implicitly have that from the signal argument.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
994f32704b gtkwidget: Drop ::grab-notify signal and vfunc
We don't expect widgets to react directly to these anymore.
Internally we still reset the controllers.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
f401b05e7b gtkwidget: Avoid poking surfaces and events in gtk_widget_list_devices()
This got stuck in ancient times when widgets were windowed, so the devices
in a window to know the devices in that widget would pan out. We do only
want here the devices that are inside the widget, not spread over the
surface, so rewrite this helper function to poke the toplevel foci, and
look they are contained inside the widget.
2020-06-24 11:14:52 +02:00
Carlos Garnacho
42ed8a2748 gtkwidget: Drop _gtk_widget_get_device_surface()
A widget cannot have multiple surfaces anymore, nor needs to
fetch the last event surface as it ought to handle its own.
2020-06-24 10:47:15 +02:00
Carlos Garnacho
29d054c421 gtkwidget: Remove dead code
This variable got unused over time.
2020-06-24 10:47:15 +02:00
Carlos Garnacho
59a8106373 gdk: Drop supports_multidevice API
Crossing events are now detached from widget state, all tricky consequences
from getting multiple crossing events are now somewhat moot. Resort to sending
all generated crossing events, and drop this barely (ever?) used API.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
4fe608e423 gtkwidget: Cancel all gestures in other groups
When a gesture (group) claims a sequence, all other gesture groups
in the same widget should get cancelled. Not just previously claimed
ones, that shouldn't happen actually.
2020-06-23 23:42:53 +02:00
Matthias Clasen
692cc42e10 Add gtk_widget_prepend_controller
Add a variant of gtk_widget_add_controller that
inserts the controller at the beginning, instead
of the end. This will be used in entry completion
to make sure the entry completion key event handling
supersedes the entry one while the popup is open.

Keep this private for now, until we determine if
it needs to be public api.
2020-06-22 12:47:27 -04:00
Matthias Clasen
9faaa5e8be Fix change notification for event controllers
We were adding event controllers at the end, but
announcing a change at the beginning, in
gtk_widget_add_controller. Fix that by emitting
::items-changed for the position where we actually
inserted the controller.
2020-06-22 12:46:12 -04:00
Timm Bäder
424e46849a widget: Don't leak css transform 2020-06-19 05:26:25 +02:00
Timm Bäder
0b13e68bca Avoid calling g_list_model_get_n_items() all the time
These are used in hot paths, e.g. widget construction.
2020-06-19 05:26:25 +02:00
Timm Bäder
1e4dc90d62 widget: don't queue a redraw on css transform changes 2020-06-19 05:26:24 +02:00
Timm Bäder
203bb42cc1 widget: Re-shuffle preconditions in snapshot_child()
The GtkNative type check is more expensive than the mapped one, so avoid
the former for unmapped widgets
2020-06-19 05:26:24 +02:00
Timm Bäder
461497e8d4 widget: Avoid doing GtkSnapshot work just to append one node
We already know that a widget will have literally 1 node, not more.
Avoid doing the GtkSnapshot state stack dance and just append a new
transform node instead.

Seems to give me around 400 more icons in the fishbowl
2020-06-19 05:26:24 +02:00
Emmanuele Bassi
1c856a208f Rename master and slave device
We already use the "logical/virtual" and "physical" names in the
documentation, there's no reason to use loaded terms just because X11
uses them.
2020-06-18 19:22:20 +01:00
Matthias Clasen
37633985bd Drop gtknativeprivate.h
No need to ship empty headers.
2020-06-07 08:52:45 -04:00
Matthias Clasen
3412f0554f gtk: Documentation fixups
Document missing symbols, and other cleanups.
2020-06-05 22:50:30 -04:00
Emmanuele Bassi
51fc382582 Notify accessibility state changes from GtkWidget
Piggybacking on blanket GObject::notify is not very efficient.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
6e52ef96a4 Move orientable style classes into GtkWidget
It feels slightly wrong to have GtkOrientable operate on widgets, but at
least what happens when an orientable widget changes orientation should
be part of GtkWidget.

This will allow to add more state changes without accessing widget state
from the outside of gtkwidget.c.
2020-06-05 20:35:09 +01:00
Emmanuele Bassi
9606c1eee9 Notify mapped state to the accessible object directly
Do not use signal connections: if we have an accessible object, notify
it directly when getting mapped and unmapped.
2020-06-05 20:32:27 +01:00
Emmanuele Bassi
959c101400 Drop unused AtkRegistry path
We expect widgets to use their own derived GtkWidgetAccessible type,
these days, and given that we hard code the default accessible type of a
GtkWidget to GtkWidgetAccessible, and that we enforce the dependency of
the type passed to gtk_widget_class_set_accessible_type(), the registry
code path is clearly unused.
2020-06-05 20:32:27 +01:00
Emmanuele Bassi
6b096e5c5b Make tooltip properties idiomatic
The tooltip handling in GtkWidget is "special":

 - the string is stored inside the qdata instead of the private
   instance data
 - the accessors call g_object_set() and g_object_get(), and the
   logic is all inside the property implementation, instead of
   being the other way around
 - the getters return a copy of the string
 - the setters don't really notify all the involved properties

The GtkWidgetAccessible uses the (escaped) tooltip text as a source for
the accessible object description, which means it has to store the
tooltip inside the object qdata, and update its copy at construction and
property notification time.

We can simplify this whole circus by making the tooltip properties (text
and markup) more idiomatic:

 - notify all side-effect properties
 - return a constant string from the getter
 - if tooltip-text is set:
   - store the text as is
   - escape the markup and store it separately for the markup getter
 - if tooltip-markup is set:
   - store the markup as is
   - parse the markup and store it separately for the text getter

The part of the testtooltips interactive test that checks that the
getters are doing the right thing is now part of the gtk testsuite, so
we ensure we don't regress in behaviour.
2020-06-05 20:32:26 +01:00
Alexander Larsson
d3e0a1f68c Avoid quadratic slowdown in gtk_widget_add()
If you add a widget to a parent, this will invalidate the css nodes
for parent/siblings. Afterwards, if the parent is mapped, we will
realize the new child. This calls gtk_widget_update_alpha() which
needs the css opacity, so it revalidates the css.

Thus, for each widget_add (while visible) will trigger a full
revalidation of each sibling. If you add N children to a parent that
leads to O(N^2) revalidations.

To demo this I changed gtk-demo to always double the count
(independent of the fps) and print the time it took. Here is the
results (after a bit):

Setting fishbowl count=256 took 3,4 msec
Setting fishbowl count=512 took 10,1 msec
Setting fishbowl count=1024 took 34,1 msec
Setting fishbowl count=2048 took 126,3 msec
Setting fishbowl count=4096 took 480,3 msec
Setting fishbowl count=8192 took 1892,7 msec
Setting fishbowl count=16384 took 7751,0 msec
Setting fishbowl count=32768 took 38097,7 msec
Setting fishbowl count=65536 took 191987,7 msec

To fix this we drop gtk_widget_update_alpha() and just
calculate it when needed (which is only in a single place).
It was really only necessary because we previously set
the alpha on the surface.

With this fix the above becomes:

Setting fishbowl count=256 took 1,0 msec
Setting fishbowl count=512 took 1,9 msec
Setting fishbowl count=1024 took 3,7 msec
Setting fishbowl count=2048 took 7,4 msec
Setting fishbowl count=4096 took 18,1 msec
Setting fishbowl count=8192 took 31,0 msec
Setting fishbowl count=16384 took 66,3 msec
Setting fishbowl count=32768 took 126,7 msec
Setting fishbowl count=65536 took 244,6 msec
Setting fishbowl count=131072 took 492,2 msec
Setting fishbowl count=262144 took 984,3 msec
2020-06-04 16:42:59 +02:00
Matthias Clasen
6652e14662 Update action muxer hierarchy propertly
When a new muxer appears, we must not only make it
inherit from the parent, we also have to update all
children to inherit from it.
2020-06-01 13:52:42 -04:00
Christoph Reiter
2d5cf2b4c4 Drop fallback-c89.c
We require a C compiler supporting C99 now. The main purpose of
these fallbacks was for MSVC. From what I can see this is now all supported
by MSVC 2015+ anyway.

The only other change this includes is to replace isnanf() with the
(type infering) C99 isnan() macro, because MSVC doesn't provide isnanf().
2020-05-31 17:09:23 +02:00
Benjamin Otte
34c6ef5332 widget: Add a hook for resizes
It's private, no APIs, we don't talk about it. But we will start using
it very soon, so we can do size request caching in columns and avoid
sizegroups...
2020-05-30 19:26:46 -04:00
Benjamin Otte
db3e225f09 builder: Make gtk_builder_extend_with_template() work with objects
This will be relevant later when we introduce GtkListItem which is not a
GtkWidget.
2020-05-30 19:26:46 -04:00
Benjamin Otte
7831980c1d listlistmodel: Add gtk_list_list_model_item_moved()
Use it to fix a case that just said g_warning ("oops").

Apparently I had forgotten the case where a container moved a child
in the widget tree.
2020-05-30 19:26:45 -04:00