mutter:wip/verdre/device-actors-stage

Last commit made on 2020-10-15
Get this branch:
git clone -b wip/verdre/device-actors-stage https://git.launchpad.net/mutter

Branch merges

Branch information

Name:
wip/verdre/device-actors-stage
Repository:
lp:mutter

Recent commits

e38cebc... by =?utf-8?q?Jonas_Dre=C3=9Fler?= <email address hidden>

clutter: Switch to storing device->actor associations in ClutterStage

As planned and prepared with the last commits, now let ClutterStage take
care of tracking inputdevices and their actors and the remove the old
infrastructure from ClutterInputDevice.

387bb20... by =?utf-8?q?Jonas_Dre=C3=9Fler?= <email address hidden>

clutter: Add function to update inputdevice actors to clutter-main

We're moving keeping track of inputdevices and their associated actors
out of ClutterInputDevice, this commit basically adds replacements for
clutter_input_device_update() and clutter_input_device_set_actor() to
clutter-main and shuffles the internals of those functions around a bit
for clarity.

clutter_update_device_actor() is made public because we need to update
the actor of inputdevices not only from ClutterStage (when repicking
after relayout), but also from MetaWaylandPointer.

4f196af... by =?utf-8?q?Jonas_Dre=C3=9Fler?= <email address hidden>

clutter/stage: Add infrastructure to track devices and their actors

For the input thread to get to its full potential we need to move the
tracking of actors associated with input devices out of
ClutterInputDevice. We're going to move it into ClutterStage instead.

So start that by adding the infrastructure to ClutterStage to keep track
of those things. It consists of two hashtables which associate devices
and touch sequences with actors, those hashtables get updated using
clutter_stage_associate_actor_device() and can be queried by calling
clutter_stage_get_device_actor(), which will replace
clutter_input_device_get_actor().

f097e3d... by Carlos Garnacho

backends/native: Add input thread inside MetaSeatImpl

This (now) doesn't change anything in regards to the API that the UI
thread should access from the MetaSeatImpl. The MetaInputDeviceNative,
MetaInputSettings and MetaKeymap objects are now considered owned by
the input thread, as well as all of libinput objects.

The MetaEventSource now dispatches events in a GMainContext that is
the thread default to this thread, and all UI-thread-accessible API
(seat and virtual input device API) will be handled in a serialized
manner by that same input thread.

The MetaSeatImpl itself is still considered to be owned by the caller
thread, and all the signals that this object emits will be emitted in
the GMainContext that is default at the time of calling
meta_seat_impl_new().

The MetaInputSettings configuration changes will likewise be handled
in the input thread, close to libinput devices.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

ffa11b5... by Carlos Garnacho

backends/native: Make MetaVirtualInputDevice vmethods "async"

These are one-way API calls, that now should get executed in the MetaSeatImpl
context. Use the MetaSeatImpl async task plumbing so that's the case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

517573b... by Carlos Garnacho

backends/native: Make some MetaSeatImpl API "async"

This API is the one accessed from different bits of the UI thread,
make it "async" (it's basically one-way setters, so API stays the same
in the surface) and able to run in the MetaSeatImpl main context.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

aef598a... by Carlos Garnacho

backends/native: Shuffle xkb_keymap creation

Push it a little bit down to the MetaSeatNative. As both the UI thread
and the input thread are interested in dealing with the xkb_keymap and
it is not meant to be used in different threads, keep 2 separate copies
around.

The keyboard map will always be set from the UI thread, so the xkb_keymap
owned by the MetaSeatNative (owned by the UI thread) can be considered
canonical.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

c014299... by Carlos Garnacho

backends/native: Seal MetaKeymapNative xkb usage

Don't let the vfuncs (meant to be called from the UI thread) deal with
xkb state itself. Instead store the current state in struct fields, which
is then fetched in vfuncs.

This makes the keymap able to be used from the UI thread, while being
maintained by the input thread. Same caveats apply than
clutter_seat_query_state(), you are asking for the most up-to-date state,
but it still may be changing under your feet.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

0cc4912... by Carlos Garnacho

backends/native: Surround device state queries/updates with RW lock

Wrap all keyboard state updates, and all pointer/stylus/touch cursor
position with a write lock, and ::query_state() (The only entrypoint
to this state from other threads) with a read lock.

The principle is that query_state may be called from different threads
(UI so far, but maybe KMS too in the future), while the input thread
may (or may not) be updating it. This state is fetched "atomically"
(eg. x/y will be consistently old or new, if the input thread were
updating it at the same time).

There's other places deep in backends/native that read this state,
they all will run in the input thread, so they count as "other readers"
to the other thread. Those changes are already mutually exclusive with
updates, so they don't explicitly need the RW lock.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

fd5e2a1... by Carlos Garnacho

backends/native: Protect MetaBarrierManagerNative

While barriers will be added from the main thread, the native barrier
manager will sit close to the MetaSeatImpl in its own thread. Add the
necessary locking so that we can pass MetaBarrierImplNative from the
UI thread to the input thread, and ensure the MetaBarrier signals are
still emitted in the UI thread.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403