1
0
Fork 0
Commit graph

2016 commits

Author SHA1 Message Date
Jonas Ådahl
487ea0dd95 kms: Add symbolic page flips and cogl frame infos
This makes it possible to post a symbolic page flip and frame callback,
meant to be used by immediate symbolic page flip reply when emulating
cursor plane changes using legacy drmMode* functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
fea8ebcca9 cursor-renderer/native: Store struct in CRTC private
In this struct, for now only the buffer is stored, but it'll be used for
more state in later commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
447c51e68e renderer-native: Always post device wide updates during mode set
Don't mode set each CRTC in separate KMS updates, as reconfiguring one
CRTC might cause other CRTCs to be implicitly reset thus as well,
causing KMS return EBUSY if using atomic modesetting.

Prepare for this by compositing each CRTC first including adding steps
to the KMS update, but wait until all views has rendered at least once
before posting the initial update. After this each CRTC is posted
separately.

Using EGLStreams instead of normal page flipping seems to fail when
doing this though, so handle that the old way for the EGLStream case,
i.e. eglSwapBuffers() -> mode set with dumb buffer -> eglStream
"acquire" (resulting in page flip under the hood).

For this we also introduce a new error code so that we don't use client
buffers when doing mode sets, which could accidentally configure the
CRTC in a way that is incompatible with the primary plane buffers.

Do the same also when we're in power save mode, to only have one special
case path for this scenario in the regular swap-buffer path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
92d4cb5184 clutter/frame: Make rendering backends set the frame result
Instead of setting the frame result in the most generic layer, have the
backends do it themselves. This is necessary to communicate that a
swap-buffer call didn't really succeed completely to present the swapped
buffer, e.g. errors from KMS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6bda72e3eb kms/plane: Make get_primary_plane() actually get the primary plane
The plane was not type checked, so it retrieved whatever plane happened
to come first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
249512b068 cogl/onscreen: Add opaque user_data pointer to onscreen present calls
This argument is intended to be used by clutter to be able to
communicate with the onscreen backend, that happens to be the native
backend. It will be used to pass a ClutterFrame pointer, where the
result of page flips, mode sets etc can be communicated whenever it is
available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
72b35e07c0 clutter: Introduce ClutterFrame
ClutterFrame aims to carry information valid during dispatching a frame.
A frame may or may not include redrawing, but will always end with a
result.

A asynchronous page flip, for example, will result in a
CLUTTER_FRAME_RESULT_PENDING_PRESENTED, while a frame that only
dispatched events etc will result in CLUTTER_FRAME_RESULT_IDLE. Instead
of this being implicit, make the ClutterStageWindow implementation
handle this itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
722f7ae2c3 clutter/stage-window: Pass 'view' to finish_frame() too
Not used yet, just done separately to decrease future diffs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
3bd0037fa1 tests/monitor: Check that the CRTC "layout" is correct
The layout should be the region of the stage the CRTC represents; check
that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7215b0d88c output: Tie the output to the monitor it's part of
Outputs correspond to active connectors, that we translate into
monitors. Make this association more real by adding a pointer back to
the monitor from the output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5edc118d62 monitor-manager: Connect assigned CRTCs to their outputs both ways
We had a pointer from the output to the assigned CRTC, but had no way to
get the outputs an CRTC was assigned to. Add that connection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
b7441514fe kms: Add some basic debug logging
Enabled using MUTTER_DEBUG=kms or via
Meta.add_verbose_topic(Meta.DebugTopic.KMS) in looking glass.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
c0e9a6fe15 kms/impl-device: Make the actual implementation handle the drm event
The way drm events are handled depends on whether we're using atomic or
not. Lets move the handling to the implementation, so that later the
atomic backend can handle the event they it need to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
b693e58c53 kms/update: If reassigning a plane handle the fb changed flag
If we reassign e.g. a cursor plane twice before it's updated, we need to
make sure the 'fb-unchanged' flag is correctly handled, so that if we
changed the fb first, then updated the assignment again only changing
the position, the new assignment should not be flagged with
fb-unchanged.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
3bad37482d kms: Add way to preserve failed update
When we e.g. try to post an direct client buffer scanout update, it
might arbitrarily fail; when this happen we still will want to post the
rest of the update when we try again after having composited the primary
plane. To do this, add a way to preserve the metadata of an update if it
failed, only dropping the failed plane assignments. This involves
unlocking a previously locked MetaKmsUpdate, so that e.g. a new primary
plane can be assigned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
8876b217af kms/update: Change 'seal' to 'lock'
Sealing is a one way operation, but in the next commit, the "seal" will
be broken, so to avoid missusing the "seal" terminology, rename related
methods and variables to use the term "lock" instead. E.g.
meta_update_is_sealed() is now meta_update_is_locked().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
4f89f159ca cursor-renderer/native: Postpone cursor update if modeset is pending
If a modeset is pending, it's likely that the cursor update will not
work; thus, wait with updating the cursor so that it's applied together
with the mode set update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
afd0a272cd kms/update: Add way to receive result from later posted update
Something might want to affect the next update that is going to be
posted, but without posting it immediately. For example, changing the
cursor might need to wait for mode setting. Make it possible to get
feedback from posting the update, in order to gracefully handle any
errors.

Note, the API for notifiying about results take out the result listener
from the update, and notifies them in an open coded for loop. The reason
for this is that in the next commit we'll sometimes reuse updates, and
we only want notify about the results once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5c7e2bfe22 kms/update: Make explicit page flip just listeners
Page flipping shouldn't necessarily be an actively requested action, but
happen implicitly depending on the given state. Thus, change the "page
flip" update into adding listeners for page flip feedback instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
0acae7f3c1 kms/feedback: Make getter take consts
This will be necessary later, as places that wants to use them will only
have the const variants of the feedback pointers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
411ec5fd18 kms: Allow update passing with failed plane assignments
This will later make it possible to pass cursor plane assignments,
together with a complete update including the primary plane, but not
failing the whole update if just processing the cursor plane failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a2b8668544 kms/impl: Dont discard page flips in callback when failed up front
If posting an update resulted in an immediate error, don't communicate
this failure using the page flip feedback callbacks, but directly as a
return value.

This makes it possible for the direct client buffer scanout path not to
pass around flags triggering this behavior, meaning we can handle such
direct scanouts better.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
2df6327367 kms: Post pending updates per device
Instead of a "post all pending updates", pass an update specific to a
single device. This gets rid of the awkward "combine feedback" function,
and makes it possible to queue updates to a multiple devices without
always posting them together.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5ba2d79076 kms/update: Make custom page flip be per update
Custom page flips are meant to allow using e.g. EGLStream API to
indirectly trigger page flip queueing, when the KMS API cannot be used
directly. This is really something that is specific to a device, so
instead of making part of the page flip API, make it a configuration of
the update itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
94ab6d8736 crtc/kms: Remove page flip helper
The only thing it did was shuffle around arguments and calling a getter.
lets just do that ourself in the call site.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
f07d6d1f43 kms/crtc: Keep track of ACTIVE property value
When atomic modesetting isn't enabled, this property may not exist, so
emulate by assuming ACTIVE is set to true if a mode is set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
28facbfa3a kms/update: Assign planes with MetaDrmBuffer instead of fb ids
This will eventually allow better lifetime control.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7842517519 kms/impl-device: Keep a path string around
This is useful for e.g. logging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
deb8f07c65 kms/device: Get driver details before constructing impl device
Eventually the type of impl device will depend on the driver details, so
get that information before constructing the impl device. This commit
doesn't introduce any new usage of the details, it just prepares for
the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
84bde805fe native: Consolidate DRM buffer management to MetaDrmBuffer types
This commit consolidates DRM buffer management to the MetaDrmBuffer
types, where the base type handles the common functionality (such as
managing the framebuffer id using drmModeAdd*/RMFb()), and the sub types
their corresponding type specific behavior.

This means that drmModeAdd*/RmFB() handling is moved from meta-gpu-kms.c
to meta-drm-buffer.c; dumb buffer allocation/management from
meta-renderer-native.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
40e5633fab cursor-renderer/native: Change guint to unsigned int
No need to use GLib types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
17712f7905 kms/update: Make dst_rect a int rectangle
It's never used as a 16.16 fixed point rectangle so no reason it should
be passed around as one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7f60d8bd66 kms/update: Fix a couple of style issues
Include macro order was incorrect, and a line was incorrectly indented.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7137bd4b10 kms: Move impl backend inherit MetaKmsImplDevice instead of MetaKmsImpl
This allows different types of backends to coexist, would e.g. one
device support atomic but another not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
37fe30c515 kms/update: Make each MetaKmsUpdate update a single device
For now feedbacks from an update are combined, meaning we might lose
error information. The feedback API may have to be reconsidered and
redesigned when planes gets a more front seat position.

This means we need to avoid trying to post updates if we're in power
save mode, as it may be empty.

Note that this is an intermediate state during refactoring that aims to
introduce atomic mode setting support, and we'll stop combining
feedbacks completely in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a7a1391de7 renderer/native: Fix 'notify-frame-complete' function name
It had the word "queue" in it, which was incorrect, as it invoked the
listeners directly without queueing anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a8d724d058 kms/impl: Manage a list of impl devices
Accessing the device list directly from MetaKms might not be safe if we
introduce threads, so keep a list completely within the impl context.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
eb78b62515 kms/crtc: Find GAMMA_LUT property
To be used by the atomic backend to implement setting gamma ramps.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
8808d518cc kms/impl-device: Construct using GInitable
Instead of a constructor method, use the type directly and handle error
reporting using GInitable.

The DRM capability setting is done before construction, as later it'll
determine what type of impl device should be constructed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d3c630f637 kms/connector: Look up CRTC_ID property
To be used by the atomic backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
1959a872b8 kms/impl-device: Make type derivable
This means moving things from the private struct _MetaKmsImplDevice into
a instance private struct. No other changes made.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
837501ab25 native: Remove left-over flip waiting functionality
With the frame clocks split up, we never wait for page flip callbacks
anymore, so remove the functions that implement that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
9d7be40502 monitor-manager-kms: Set gamma on MetaKmsUpdate directly
The meta_kms_crtc_* helper didn't do anything more than call another
function with the exact same arguments.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
ec7667fc31 kms/connector: Set DPMS and underscanning directly on the update
Instead of telling MetaKmsConnector fill a MetaKmsUpdate with connector
property changes, make the update itself aware of the changes, making
the impl side translate that to property changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
c1ce36f08e kms/update: Make plane assignment take rotation instead of property list
Instead of having MetaKmsPlaneAssignment carry a low level property
list, set the actual state change, and then have the implementation
translate that into the necessary property changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
2b7b4576fb kms/plane: Parse IN_FORMATS via prop table parse vfunc
With the aim at always using the property table to fetch and parse
property metadata, move IN_FORMATS handling to the property table, using
the newly introduced parse vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
1b3e8b4a27 kms/impl-device: Make property ID lookup also handle parsing
Values may need to be processed and parsed in custom ways; make this
possible via the property table infrastructure using a callback.
Will be used for e.g. parsing rotation and formats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a9ae202327 kms/plane: Find property IDs to be used for atomic modesetting
Currently undiscovered, as we haven't enabled the atomic modesetting
capability, but lets get the infrastructure to get the property IDs in
place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
11966dc6cb kms/crtc: Find MODE_ID and ACTIVE property IDs
Will be used by the atomic KMS backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
df89e8ce4b kms/connector: Make property ID fetching more declarative
Instead of relatively verbosely going through the DRM properties finding
the properties we care about and saving their ID's, add a more
declarative way to fetch property metadata. This'll allow for fetching
more property IDs with relatively less code, which will be useful for
the atomic backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
309651df6b kms/update: Make change updates to take MetaKmsMode
This will be needed for state keeping connected to turning mode infos
into blobs later used by the atomic modesetting implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
abac217617 crtc-mode-kms: Wrap MetaKmsMode instead of drmModeModeInfo
We'll need to use the MetaKmsMode later on for state keeping.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
e15bb68d8f gpu-kms: Fix mode ID type
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d3abaf46a1 output-kms: Hand over fallback mode management to MetaKms
Eventually we need MetaKmsMode for more than carrying the
drmModeModeInfo, so prepare for that by having the KMS layer create
MetaKmsMode for those as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
0fa0eeef57 kms/mode: Add getter for name
Gets the name directly from the DRM mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
2c4a3c5959 kms/mode: Add mode flags
Will be used to add flags modes specific to MetaKmsMode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
eb66449ab7 kms/mode: Add API to create blob IDs for modes on demand
Will be used by the atomic KMS backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
f0d3201dab kms: Add MetaKmsMode abstraction
This contains a copy of a drmModeModeInfo, describing a mode. It also
has an unused pointer to the impl device it is associated with. It'll
later be used to get a blob ID for the mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Carlos Garnacho
d43f95703d backends/native: Update keymap state on latched modifier updates
The input thread refactors missed to update the MetaKeymapNative state when
the keys that trigger the latched modifiers are being pressed. Let that happen
here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1679>
2021-01-21 15:35:06 +01:00
Jonas Ådahl
1c6dd7f30a backend/native: Destroy logind helper after seat
Otherwise we don't actually close input devices using it, since that
would happen after meta_launcher_free() was called.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 22:54:32 +01:00
Jonas Ådahl
db6bf9d14e backend: Tear down in dispose() instead of finalize()
This means backend implementations can have more control of the order of
how things are destroyed. To be precise, this will, in the next commit,
allow us to destroy the logind integration after the clutter backend
thus the libinput owning seat, that uses the logind integration to
release input devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 22:54:32 +01:00
Jonas Ådahl
05765daabf seat/native: Explicitly destroy MetaSeatImpl
We can't post tasks to the input thread when cleaning up the
MetaSeatImpl, as that will make the GTask complain about adding
references to a to be purged object. Avoid this by adding an explicit
meta_seat_impl_destroy() function that handles the destruction of the
MetaSeatImpl properly.

This also does more of the cleanup in the input thread, as that is where
it was managed. Will likely not make a difference as before this
happened after tearing down the thread, but lets tear down things in the
thread they were managed for good measure.

This fixes the last log spew I see right now when terminating mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 22:54:32 +01:00
Olivier Fourdan
cde0cd5d23 xwayland: Enable Xwayland on demand by default
Make "Xwayland on demand" the default policy when Xwayland supports
"initfd" and remove the corresponding experimental feature.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1673>
2021-01-19 09:33:33 +01:00
Olivier Fourdan
3fc603edd3 xwayland: Make autoclose-xwayland an exp. feature
Closing automatically Xwayland once all relevant X11 clients are gone is
inherently racy, if a new client comes along right at the time we're
killing Xwayland.

Fixing the possible race conditions between mutter, Xwayland and the X11
clients may take some time.

Meanwhile, make that an experimental feature "autoclose-xwayland".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1673>
2021-01-19 09:33:33 +01:00
Carlos Garnacho
6011562aa9 backends: Update pointer drag-threshold/double-click settings location
Following recent gsettings-desktop-schemas changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1416>
2021-01-14 13:58:16 +00:00
Jonas Ådahl
237cdeef4c seat-impl: Destroy libinput objects on input thread on tear down
We didn't tear down the libinput objects in the right thread when
exiting, but did so after the input thread exited.

We also tried to destroy the libinput devices after the libinput context
was destroyed, which isn't allowed.

Fix these two issues by tearing down the libinput objects in a input
thread task that when done exits the input thread. This effectively
"flushes" the input thread tasks while destroying the libinput objects
just before the thread exits.

While it might fine to tear down libinput objects in an arbitrary (main
in this case) thread while making sure nothing pokes at it in parallel
(e.g. the input thread is gone), libinput is by definition single
threaded, and could theoretically make assumptions about this, and we
shouldn't cause any possible surprises here, so make sure to destroy it
all in the right thread.

This fixes an abort() on exit caused by an assert about invalid object
destruction in libinput.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1663>
2021-01-11 17:17:39 +00:00
Jonas Ådahl
3bf1af07ed seat-impl: Fix some variable names
The "seat" usually refers to the ClutterSeat (MetaSeatNative) object,
and "seat_impl" to the MetaSeatImpl object, but there were still a few
places where this wasn't adhered to so fix those.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1663>
2021-01-11 17:17:39 +00:00
Aaron Plattner
e88467f9d7 x11: Support the CTM (color transform matrix) RandR property
When supported, this property allows the window system to apply a 3x3 color
correction matrix in order to transform colors from the window system's native
color space to the measured color space of a display device.

Query for this property and set the 'supports-color-transform' property in the
GetResource reply. Add support for the SetOutputCTM DBus method and plumb that
through to the server's CTM property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1048>
2021-01-11 13:44:54 +00:00
Pascal Nowack
f363476229 remote-desktop: Allow using custom scroll source for NotifyPointerAxis
Currently, the NotifyPointerAxis method always assumes that the scroll
source is CLUTTER_SCROLL_SOURCE_FINGER.
This is however not always true and in some cases a remote desktop
client needs to submit a PointerAxis event with a custom axis step.
This is for example the case with high resolution mouse wheels, where
the NotifyPointerAxisDiscrete method is unsuitable.
In such cases NotifyPointerAxis needs to be called, but with the
intention that the scroll source is still a mouse wheel.

To solve this situation, don't assume the scroll source always to be
CLUTTER_SCROLL_SOURCE_FINGER.
Instead, add further flag options to NotifyPointerAxis, which allow a
remote desktop client to choose the scroll source.
This way a remote desktop client can choose what scroll source is the
most suitable one for the current scroll event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1636>
2021-01-11 10:12:53 +01:00
Carlos Garnacho
96820a9979 backends: Disconnect MetaInputMapper signal connection on device dispose
This signal may be left dangling when disconnecting a device, and be executed
later on if the device is connected again, and mapped to other output. Make it
sure the signal handler is disconnected when unplugging the device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1657>
2020-12-28 19:11:26 +01:00
Olivier Fourdan
904d7fa798 backends/native: Protect against NULL pointer constraints
To clear a pointer constraint, the Wayland backend passes a NULL
constraint to the native input backend.

The new async API however tries to reference/un-reference the given
object to use it while running in a separate task, which leads to a
warning from GLib trying to g_object_ref()/g_object_unref() a non
GObject pointer.

To avoid that issue, simply set the data only if the given constraints
pointer is not NULL.

Suggested-by: Carlos Garnacho <carlosg@gnome.org>
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1587
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1652>
2020-12-22 14:45:00 +01:00
Kai-Heng Feng
ed87937faf monitor-manager-xrandr: Disable CRTCs if there is no monitor
After last monitor gets unplugged from the system, hotplug detection may
no longer work on Intel GFX.

This is because we didn't trigger a modeset to disable CRTCs, and i915
requires it to make hotplug detection continue to work [1].

There's no guarantee that DPMS off in DDX also disables CRTCs, so
explicitly disable CRTCs to solve the issue.

[1] https://www.kernel.org/doc/html/latest/gpu/i915.html#hotplug

https://gitlab.freedesktop.org/drm/intel/-/issues/2602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1561>
2020-12-22 17:03:53 +08:00
Kai-Heng Feng
e5b07138f0 monitor-manager-kms: Disable CRTCs if there is no monitor
After last monitor gets unplugged from the system, hotplug detection may
no longer work on Intel GFX.

This is because we didn't trigger a modeset to disable CRTCs, and i915
requires it to make hotplug detection continue to work [1].

Ensure disabled CRTCs are unset and post a modeset to disable them.

[1] https://www.kernel.org/doc/html/latest/gpu/i915.html#hotplug

https://gitlab.freedesktop.org/drm/intel/-/issues/2602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1561>
2020-12-22 17:03:53 +08:00
Kai-Heng Feng
45a9c386bb renderer/native: Refactor modeset boilerplate into new helpers
Extract some boilerplate into new functions for next patch.

No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1561>
2020-12-22 17:03:53 +08:00
Carlos Garnacho
446839c0d0 backend/native: Check libinput_device in async call
Power saving changes in laptop panels enable/disable the attached
touchscreen input device, this is an asynchronous operation that
may be happening while the device is disappearing.

In fact, closing the lid is such perfect storm where both things
happen around the same time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1644>
2020-12-16 19:14:54 +01:00
Carlos Garnacho
b2b3d000d2 backends/native: Dispose the libinput device in the input thread
Currently, the MetaInputDeviceNative owns the libinput_device, with the
small catch that it is eventually finished in the main thread (as the
CLUTTER_DEVICE_REMOVED event keeps the last reference to it).

Make it sure that the libinput_device is destroyed in the input thread,
before giving away the last extra input device references.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1639>
2020-12-16 17:09:58 +01:00
Carlos Garnacho
67f0704340 backends/native: Make device grouping libinput independent
Keep device groups as opaque pointers, and just compare those
afterwards.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1639>
2020-12-16 17:09:58 +01:00
Carlos Garnacho
96070e820c backends/native: Make group modes checks libinput device independent
Remove the dependence on the underlying libinput device here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1639>
2020-12-16 17:09:58 +01:00
Carlos Garnacho
505f65e8d6 backends/native: Make mode switch checks libinput independent
Add this info to the PadFeatures array, and pull it from there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1639>
2020-12-16 17:09:58 +01:00
Jonas Ådahl
95e0bf34e9 renderer/native: Remove left over comment
There was an attempt to remove an unnecessary inclusion of a header
file, but only got so far as compile testing after having commented out,
but didn't remove the comment before creating a commit. This commit
fixes that mistake.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1640>
2020-12-16 09:17:20 +01:00
Jonas Ådahl
d5cbbb2733 backends/native: Destruct udev after kms
MetaKms is a user of MetaUdev, so destroy MetaUdev later than MetaKms,
to avoid use-after-free.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1640>
2020-12-16 09:17:20 +01:00
Carlos Garnacho
e21929be82 clutter: Do not poke backend code for motion compression
We now have all info available in ClutterEvent, use it and stop poking
backend internals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
0842ac936f clutter: Drop infrastructure to copy/free platform event data
This is now unused, all information belongs to ClutterEvents.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
64d5e8a9bd backends/native: Drop MetaEventNative
This doesn't really hold anything now, so we can stop trying to
copy these across events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
b88790554b clutter: Move relative motion information to ClutterEvent
Instead of using native backend platform data specifically, store
this info in ClutterMotionEvent. This includes time in usec since
it's just used for motion events, in the future it could make sense
to make these general to all events again, but it could make sense
to make ClutterEvent structs private before.

In order to express that a motion event has relative motion info,
the CLUTTER_EVENT_FLAG_RELATIVE_MOTION event flag has been added
for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
eaa04ecee5 backends: Unify touch sequence to slot conversion
We had code in both backends that sort of independently associated
sequences to slots. Make both transform slots to sequences the same
way, so they may share the implementation convert those back to slots.

This helper now lives in Clutter API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
9f5c453fc7 clutter: Move evdev evcode data to Clutter button/key events
We have this as platform-dependent data in the native backend, and
a bunch of fallback code done in place in the evcode users. Stop
making this platform-dependent data, and move it to the relevant
ClutterEvents.

The fallback code for the X11 backend case is about the same, but
now it is done directly by the X11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
09b956997c backends/x11: Drop platform-specific event data
This is largely unused, for long probably. We want to avoid adding
platform data to events, so that's convenient.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
4a0c56f928 clutter: Simplify stage state management
Making this an event is overly convoluted, accounting that we
emit the event, then convert it to a ClutterStage signal, then
its only consumer (a11y) sets the active ATK state.

Take the event out of the equation, unify activation/deactivation
of the stage in MetaStage, and use it from the X11 backend too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
96e320ba5a clutter: Drop CLUTTER_DESTROY_NOTIFY event
Stop propagating this as a Clutter event. DestroyNotify is only
relevant on nested X11 sessions, so handle it specifically in place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
20ac791f4b backends/native: Avoid -Wmaybe-uninitialized warning
Ensure that color_ptr gets set, and avoid color_char usage too in
that case. Fixes:

  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c: In function ‘meta_monitor_manager_kms_set_crtc_gamma’:
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:370:7: warning: ‘color_char’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    370 |       g_string_append_printf (string, " %c: ", color_char);
        |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:351:12: note: ‘color_char’ was declared here
    351 |       char color_char;
        |            ^~~~~~~~~~
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:391:36: warning: ‘color_ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    391 |                                   (*color_ptr)[i]);
        |                                   ~^~~~~~~~~~~
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:350:24: note: ‘color_ptr’ was declared here
    350 |       unsigned short **color_ptr;
        |                        ^~~~~~~~~

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1624>
2020-12-08 13:35:50 +00:00
Carlos Garnacho
fc6446f326 backends/x11: Iterate button modifiers all the way
This is misuse of XIMaskLen (on a mask len! not the right mask!).
Have this iterate all possible values stored in the button state.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1559
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1617>
2020-11-30 19:05:36 +01:00
Carlos Garnacho
6aafdbebd9 backends/x11: Use XkbBuildCoreState the right way around
Pass parameters in the correct order, and don't let it clamp button
modifiers away (Since this macro does "state & 0xff").

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1559
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1617>
2020-11-30 19:05:21 +01:00
Piotr Drąg
407e8c0f37 backends/x11: Stop translating a property ID
These are not visible to users.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1593>
2020-11-28 13:36:40 +01:00
Carlos Garnacho
13202f4e45 backends/native: Pass xkb_state directly when updating MetaKeymapNative
Figuring out the MetaSeatImpl this much indirectly is fairly awkward when
the keymap is only updated from the MetaSeatImpl, pass instead the seat
impl's xkb_state, as we have it handy in all the places this is called.

This will not break on NULL seats during initialization, should the numlock
state be restored from previous sessions.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1556
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1612>
2020-11-27 17:34:55 +00:00
Jonas Ådahl
f5949af0bb barrier: Complain loudly if bogus barriers are created
The API allows for invalid barriers to be created; in an X11 session,
this could result in involutary early exit, so guard against those with
soft asserts. These will be logged in the journal as warnings, but will
avoid the crash unless compiled out.

Note that this doesn't fix the bug, it just makes it more detectable.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1901610
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1611>
2020-11-27 17:47:35 +01:00
Carlos Garnacho
8b6ea12fac backends/native: Add distinct meta-input-thread.h header
Make it impossible to add individual includes of input thread objects.
This must go through meta-input-thread.h now, which should be enough
to make anyone think it twice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
c03be03cd3 backends/native: Add a bunch of "_in_impl" suffixes to functions
They're a dime a dozen. If it gets called exclusively from the
input thread, it got one. Hopefully these breadcrumbs will be
enough so people don't lose their way here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
820262e537 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
321b971a96 backends/native: Add missing seat finalization paths
On finalize we leak the clutter backend, which leaks the stage and seat.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
2ff5bb4299 backends/native: Update keyboard a11y status in seat impl
Instead of going through the event queue, stage handling code, and
back to the input device via a vmethod call, do this directly in the
MetaSeatImpl. This is not too different from X11, where everything
happens inside the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
f117a157dc clutter: Add vmethod to find out group for pad features
Do it so the wayland bits don't have to access native input devices
internals. The data is still readonly, idempotent, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
18fdcfc95a backends/native: Make MetaInputSettingsNative vmethods "async"
Those that are exposed via MetaInputSettings API that's still accessible
in other parts of the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
ceefa72ade backends/native: Shuffle keyboard a11y signal connection into MetaSeatImpl
This signal gets emitted in the input thread, and does things that
belong to it. Make it clear by moving to the MetaSeatImpl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
7547891a76 backends: Straighten MetaInputSettings creation
We have "create" and "get" methods, and a "create" vmethod. Make it all
"get" so the backend implementations can keep their own reference without
completely lying.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
e0444a3d35 clutter: Move ClutterInputDevice fields to private struct
All that is left in the "public" struct is all state that ClutterStage
delegates on ClutterInputDevice. That should move somewhere else, but
not here, not now.

All private fields belong to construct-only properties, with only getter
API, and idempotent vmethods (except keyboard a11y, atm). This should
be enough to make ClutterInputDevice obviously thread safe, outside the
backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
71b4c0ee02 clutter: Drop keycode_to_evdev vmethod
This is just used in the native backend, move it to an utility
function there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
c7f989c1e2 clutter: Drop ClutterInputDevice private tool maintenance API
This is just used in the native backend (with the X11 going its own
way). Just keep a HT of tools there, and drop this API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
06d577fdf3 clutter: Move scroll valuator accounting to backends/x11
This is just used there. Another X11 detail that got open coded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
d7d92b0ddc clutter: Drop ClutterInputDevice axis API
Most of this comes from X11 peculiarities that were open coded in
the Clutter ABI. We don't need this except in X11, so move this axis
handling there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
5689a843c7 clutter: Drop internal update_from_tool() vmethod
This is kinda pointless now, and will be made completely unneeded
by dropping device axes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
168ceb9905 backends: Forward event axes as array of ClutterInputAxes elements
Instead of encoding arrays in ways that we need the ClutterInputDevice
to decode them, use ClutterInputAxes as the array index.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e772f62ea7 clutter: Make axes part of the device tool
This info can be construct-only there, as opposed to devices.
Move this info to tools, so we can drop it from devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
be9c531ab9 clutter: Drop clutter_input_device_get_associated_device()
And the private setter. One may ask the seat for the pointer/keyboard
instead of asking the device for its counterpart.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c4fa5ef88a clutter: Drop clutter_input_device_get_physical_devices() API
This is unused, we have the seat for this kind of stuff.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
699da157c7 clutter: Drop clutter_input_device_get_key()/n_keys API
And the corresponding setters. This is completely unused, and
unrecommended. In xkb we trust.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c6849a66e8 clutter: Drop clutter_input_device_get_coords() method
This is not device state anymore. It uses ClutterSeat API underneath,
so let callers do that instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
efc1592d4d backends: Make pointer cursor invisible until the stage is shown
We are able to show the cursor before that, it doesn't mean we should.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
fb2440a1cf 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
fd90e41e12 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
f7fbd6ea6f backends: Handle numlock saving/restoring directly in backends
Simplify the handling of numlock state, so it can be entirely handled
within the input thread. Since the saving/restoring is triggered inside
each backend code, there's no need anymore for meta_backend_set_numlock().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
23f95348fd 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
40665b0fb1 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
cf45050cba 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e76a7f43e0 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
1609d1459e backends/native: Move MetaInputSettings ownership to MetaSeatImpl
Together with keymaps and devices, MetaInputSettings will live in the
ninth circle of hell with MetaSeatImpl, forever tied to it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
4e56352bcc backends: Do not use clutter_seat_list_devices() in MetaInputSettings
Make it keep its own list of devices, it's not that far off.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
2c1558ddbd backends: Make device tracking at MetaInputSettings ad-hoc API
Depending on the backend, we want to integrate this object at different
levels. It will sit close to the MetaBackendX11/MetaSeatX11 in X11, but
it will be put deep down with MetaSeatImpl in the native backend, in a
separate thread.

Since we can't depend on a single object type, nor are able to track
ClutterSeat signals neatly, make this API something to be called
explicitly by backends.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
fe9092da19 backends: Simplify function arguments
We just pass a device in order to check it with the seat pointer, we
can do without this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c601a824e9 clutter: Update device for the current tool in backends
This should happen deeper in backends, not here in clutter-main.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
89a140d618 backends/native: Proxy modifier state changes via MetaSeatImpl
This changes within the MetaSeatImpl realm, so use a signal to forward
this to the MetaSeatNative/MetaKeymapNative one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
be1ffc86ca backends/native: Proxy bell notifications from within the MetaSeatImpl
As with other changes from within the MetaSeatImpl realm, proxy that
through a MetaSeatImpl signal, instead of poking directly on the ClutterSeat.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
facc963213 backends/native: Proxy touch-mode via MetaSeatImpl
Handle this via a MetaSeatImpl signal, as the heuristics that apply
here are based on libinput events. The MetaSeatNative just forwards
the touch-mode changes now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
31439d7841 backends/native: Forward keyboard a11y changes via the MetaSeatImpl
These changes will happen in the input event management code, so let them
be emitted via the MetaSeatImpl, as that's what we'll have neat access to.
The ClutterSeat signals are now emitted from there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
39f4acac3d backend/native: Let cursor renderer/tracker be updated by events after warp
We will generate a motion event, which will end up with the same result, at
a time we can ensure it did happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
59059e1730 backends/native: Spin MetaSeatImpl off MetaSeatNative
Move most of the functional bits (those meant to run on a standalone
thread) to a MetaSeatImpl object. This object is managed by the MetaSeatImpl
and not exposed outside the friend MetaSeatNative/MetaInputDeviceNative/
MetaInputSettings classes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
2ceac4a296 clutter: Make ClutterSeat::handle_device_event vfunc more generic
Make it able to handle not just device added/removed events, but perform
any kind of post-processing that needed to be done on ClutterEvents at
the seat level.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c3acaeb251 backends: Move keyboard a11y into backends
And out of Clutter API. This is mainly set via settings, or the windowing
itself, so we don't need to leak these details up our own backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
4013bed6e4 backends: Make MetaInputMapper take over MetaInputSettings public API
Banish MetaInputSettings from MetaBackend "public" API, it's now meant to
spend the rest of its days in the backend dungeons, maybe hanging
off a thread.

MetaInputMapper replaces all external uses.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
9a21482fef backends: Move all output management to MetaInputMapper
Delegate on the MetaInputMapper all matching of inputs and outputs,
including configuration. Other secondary aspects, like output
aspect ratio for tablet letterbox mode, or toggling attached devices
with power saving changes, are also moved here.

This makes MetaInputSettings independent of MetaMonitorManager,
all interaction with it happens indirectly via public API entrypoints.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
b56d31ef48 backends: Simplify MetaInputSettings vfunc
Rename the set_tablet_keep_aspect() vfunc into a set_tablet_aspect_ratio()
one that takes an aspect ratio double, instead of leaking monitor info
into subclasses to let them all figure out this number themselves.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
1dc534ea9e backends/native: Drop meta_seat_native_[gs]et_stage()
This is now unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
0cb0dd3538 backends: Assign stage to events in MetaBackend
Don't do this in the MetaSeatNative, this should be detached from
the stage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
05edf4815b backends/native: Drop early processing of ClutterEvents
We have 2 sources (this one in MetaSeatNative, and the one in
MetaBackend) dispatching ClutterEvents to the stage. Make the
MetaSeatNative one exclusively about dispatching the libinput
queue, and leave ClutterEvents to the other.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c362bc4b51 backends/native: Use viewport info to find out stage extents
This information is equivalent to the stage extents, this just
leaves meta_seat_native_get_stage() used for setting event->any.stage,
which is a tiny lame excuse.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
1377c2a97e backends: Add method to get extents from viewport info
This way we know the stage extents without poking the stage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
165b7369c8 backends: Use also a native cursor renderer for tablets
This will resort to SW rendering if this cursor renderer does not
own the MetaKmsCursorRenderer, so it's pretty much equivalent thus
far, except we may now implement logic to flip the kms cursor renderer
around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
727e64dddf backends: Use MetaViewportInfo to keep MetaSeatNative informed of layout
Use this for the calculations to keep absolute motion properly constrained,
and relative motion properly scaled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
0c1d48bd08 backends: Add simple object to delegate logical monitor layout queries
This object can be passed to random places, and be trusted to remain unchanged
till replaced. Makes it an ideal replacement for MetaMonitorManager across
threads.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
b1d12a994d clutter: Drop ClutterInputDevice::enabled and setter/getter
This is unused now, and not something we generally allow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00