1
0
Fork 0
Commit graph

1942 commits

Author SHA1 Message Date
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
Carlos Garnacho
c2940efe8b backends: Move away from clutter_input_device_set_enabled()
We actually have a set_send_events() vfunc that can enable or disable
devices at the libinput and X11 input driver level, so use that. A
positive side effect is that those layers will leave the device at
a consistent idle state (as opposed to going mute maybe amid user
input).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
5f30d1b8ac backends: Split pad action mapping to a separate object
This now lives in the core, and will get updated from events 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
d6f720497a backends: Move HW cursor inhibitors to MetaBackend
We are aiming for a split of HW and SW cursor rendering management.
Given the HW plane is a limited resource and the amount of cursor
renderers may be >1 (due to tablets, even though we currently use an
always-software cursor renderer there), it would ideally be able to
switch between renderers.

Being MetaCursorRenderer not really a singleton, having cursor
inhibitor accounting here doesn't pan out. Make it MetaBackend API
so all cursor renderers get the same picture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e218b00747 backends: Make MetaHwCursorInhibitor less about sprites
Remove the sprite argument from the vfunc, it's used in no implementations
and conceptually gets a bit in the middle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
00cbcb7ba1 core: Centralize cursor renderer and tracker updates
These use now more of a "pull" model, where they receive update
notifications and the relevant input position is queried, instead
of the coordinates being passed along.

This allows to treat cursor renderers all the same independently
of the device they track. This notifying of position changes should
ideally be more backend-y than core-y, a better location will be
figured out in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
a8e2935225 backends: Drop meta_cursor_renderer_get_position()
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
3ade57e4e9 backends: Add ::device property to MetaCursorRenderer
A cursor renderer is made to invariably follow a pointer device, make
it a construct-time property, and update all creators of cursor renderers
to specify it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
247613d26d backends: Move away from meta_cursor_renderer_get_position()
We are moving onto relying fully on the seat cursor position. As
this focuses (thus far?) on mouse pointers only, use the cursor
tracker as a convenient shortcut.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
cd02286b87 backends/native: Manage tablet cursors in backend
Instead of letting the wayland bits maintain an always-software
cursor renderer, let the cursor renderer be managed by the backend,
and only hook to it (as we do for pointer cursor) in the wayland
bits.

ATM, make the cursor renderer still always-software, although
ideally we should allow moving the HW cursor management between
renderers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
35abb8ab53 backends: Add meta_backend_get_cursor_renderer_for_device()
Different devices may get standalone cursor renderers, add this API
to adapt slowly to this. The meta_backend_get_cursor_renderer() call
still exists, but shortcuts to the mouse pointer's renderer (as it
actually did before).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e721fde259 backends: Add argument for best scale on MetaCursorSprite::prepare-at
Instead of letting implementations poke backend internals from various
places, give that information right away.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
7a2a2445c3 backends: Remove x/y arguments from MetaCursorTracker::cursor-moved
Make this signal a hint, the actual coordinates should be queried to the
cursor tracker, the device, the seat... There's enough options.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
8a8d47725c backends: Delegate pointer confinements to an impl object
Split pointer confinements in 2 objects, one set from the upper layers
containing its definition, and another managed by the backend that
applies it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
efd065259d backends: Drop GDK device querying code from MetaCursorTracker
Clutter behavior is now equivalent to GDK's on X11, avoid poking to
GDK here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
932a5cab09 clutter: Drop clutter_input_device_set_state()
Nothing uses it anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
7d78768809 backends/native: Move away from ClutterInputDevice coords
Use a new set in MetaInputDeviceNative, this coexists with
ClutterInputDevice coords for the time being. This API will
eventually be only accessed from the input thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
9d195b3fa4 backends/native: Implement ClutterSeat::query_state() vmethod
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
384b97792d backends/x11: Implement ClutterSeat::query_state() vmethod
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Jonas Ådahl
f6db6cd203 monitor-config-manager: Handle multiple builtin panels gracefully
While multiple built-in panels isn't actually supported in any
meaningful manner, if we would ever end up with such a situation, e.g.
due to kernel bugs[0], we shouldn't crash when trying to set an
'external only' without any external monitors.

While we could handle this with more degraded functionality (e.g. don't
support the 'switch' method of monitor configuration at all), handle it
by simply not trying to switch to external-only when there are no,
according to the kernel, external monitors available. This would e.g.
still allow betwene 'mirror-all', and 'linear' switches.

The crash itself was disguised as an arbitrary X11 BadValue error, due
to mutter trying to resize the root window to 0x0, as the monitor
configuration that was applied consisted of zero logical monitors, thus
was effectively empty.

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1896904

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1899260
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1607>
2020-11-27 09:11:43 +01:00
Simon McVittie
60f647df8e backends/native: Don't crash if keymap is misconfigured
xkb recently gained support for user-specified keymaps, which means we
can no longer assume that the configuration data is necessarily fully
complete or correct; and the configuration language is quite a labyrinth,
so it's easy to get wrong. If setting the keymap fails, leave it in
whatever state it previously had, since that seems preferable to crashing
with a NULL pointer dereference.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/1555
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1605>
2020-11-26 12:11:33 +00:00
Florian Zwoch
efb577efb0 screen-cast: Fix segfault when drawing cursor
Add a sanity check if the cursor is on screen and cursor texture data
is available. This prevents a potential segfault when trying to access
non-existing texture data.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1446
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1604>
2020-11-26 09:59:44 +01:00
Carlos Garnacho
23ae8b4519 clutter: Drop clutter_input_device_get_device_id()
Move the GObject property to MetaInputDeviceX11, and throw away the
rest. This is no longer public API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Carlos Garnacho
20e6464087 backends/native: Don't fake device IDs
Stop making them up, they go nowhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Carlos Garnacho
7738ce2a64 backends/x11: Move to backend-specific meta_input_device_x11_get_device_id()
Make this info part of the MetaInputDeviceX11, as it's actually just
relevant to that backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Jonas Ådahl
d622960429 renderer/native: Add udev rule to select primary GPU
Sometimes the automatically selected primary GPU isn't suitable with no
way to make an well educated guess to do it better. To make it possible
for the user to override the automatically calculated default, make it
possible to override it using a udev rule.

E.g. to select /dev/dri/card1 as the primary GPU, add a file e.g.
/usr/lib/udev/rules.d/61-mutter-primary-gpu.rules (path my vary
depending on distribution) containing the fellowing line:

ENV{DEVNAME}=="/dev/dri/card1", TAG+="mutter-device-preferred-primary"

Reboot or manual triggering of udev rules to make it take effect may be
required.

Related: https://gitlab.gnome.org/GNOME/mutter/merge_requests/1057

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1562>
2020-11-16 16:00:33 +00:00
Jonas Ådahl
83360a4aed cursor-sprite/xcursor: Fall back to gray square if missing theme
Instead of aborting with an error, display a half transparent gray
square instead of cursors and log a warning in the journal, allowing the
user to fix their system withotu having to rely on switching to a TTY.

It will be immediately obvious the cursor is silly looking, which will
be a better hint than just aborting.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1428
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1563>
2020-11-16 13:49:05 +00:00
Carlos Garnacho
b6211bb684 backends/x11: Emit CLUTTER_DEVICE_ADDED events for initial devices
This is similar to commit b9e5a2d6e2, but for the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1553
2020-11-07 10:13:00 +01:00
Jonas Ådahl
4ecc80fd80 x11/output: Fix init tile info guard
Monitor tile info is possible to fetch when RANDR version 15 is exposed
by the X11 server. We had inverted the check meaning that only if older
versions were advertised would we attempt to init the tile information.
Fix this guard, thus fix monitor tiling on X11.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1524
2020-11-05 08:49:29 +01:00
Olivier Fourdan
9b88172982 backend: Update cursor visibility on device added
Not calling libinput dispatch in the backend constructor defeats the
logic in post init as the device added events have not been processed
yet.

So instead of trying to guess the cursor initial visibility, simply
update it along when devices get added.

Additional benefit, we do not need to walk the all device list looking
for touchscreens anymore, we just need to check the device being added
since the current logic is to hide the cursor as soon as a touchscreen
is found.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1534
2020-10-30 15:50:23 +01:00
Olivier Fourdan
c618b8a0eb clutter/backend: Don't dispatch libinput events too early
At startup, libinput dispatch is called from the MetaSeatNative
constructed callback.

That means that we may get libinput events even before the default seat
is set.

In turn, processing those events may trigger the use the default seat
while it's still not set yet, and cause a crash of gnome-shell/mutter
at startup.

A simple reproducer for this is to start gnome-shell/mutter with a
tablet connected and the stylus in proximity, the proximity event will
cause gnome-shell/mutter to crash at startup.

To avoid that issue, avoid dispatching libinput events early from the
MetaSeatNative constructed callback, those events will eventually get
processed when the seat and the backend are all setup.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1501
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1534
2020-10-30 15:50:23 +01:00
Daniel van Vugt
514b2ff424 cursor-tracker: Get the GDK (X11) pointer position in floats, not ints
This makes X11 consistent with Wayland which already uses floats.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1519
2020-10-28 15:40:56 +00:00
Daniel van Vugt
aff14eab86 cursor-tracker: Check for NULL coordinates before retrieving them
This makes Wayland consistent with X11 in not emitting warnings when
unwanted parameters are NULL.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1519
2020-10-28 15:40:56 +00:00
Daniel van Vugt
ebe8cd3704 cursor-tracker: Check if coordinates are NULL
To avoid a SEGV on X11. Passing NULL coordinates is perfectly valid if
you are only seeking to get the `mods`.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1484

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1519
2020-10-28 15:40:56 +00:00
Georges Basile Stavracas Neto
a77e1f200b drm-buffer-gbm: Clear framebuffer with g_clear_object
Another fallout of eb14da3874

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1531
2020-10-27 14:32:45 +00:00
Olivier Fourdan
8711d8d591 backend: Keep a refcount on backend's current_device
Otherwise we might run into a use-after-free and crash on (virtual)
device removal:

 Invalid read of size 8
   at clutter_input_device_get_device_type (clutter-input-device.c:811)
   by update_last_device (meta-backend.c:1282)
   by g_main_dispatch (gmain.c:3325)
   by g_main_context_dispatch (gmain.c:4016)
   by g_main_context_iterate.constprop.0 (gmain.c:4092)
   by g_main_loop_run (gmain.c:4290)
   by meta_run_main_loop (main.c:708)
   by meta_run (main.c:723)
   by main (main.c:550)
 Address is 32 bytes inside a block of size 504 free'd
   at free (vg_replace_malloc.c:538)
   by g_type_free_instance (gtype.c:1939)
   by clutter_event_free (clutter-event.c:1420)
   by _clutter_stage_process_queued_events (clutter-stage.c:830)
   by handle_frame_clock_before_frame (clutter-stage-view.c:1064)
   by clutter_frame_clock_dispatch (clutter-frame-clock.c:405)
   by frame_clock_source_dispatch (clutter-frame-clock.c:456)
   by g_main_dispatch (gmain.c:3325)
   by g_main_context_dispatch (gmain.c:4016)
   by g_main_context_iterate.constprop.0 (gmain.c:4092)
   by g_main_loop_run (gmain.c:4290)
   by meta_run_main_loop (main.c:708)
   by meta_run (main.c:723)
 Block was alloc'd at
   at malloc (vg_replace_malloc.c:307)
   by g_malloc (gmem.c:106)
   by g_slice_alloc (gslice.c:1025)
   by g_slice_alloc0 (gslice.c:1051)
   by g_type_create_instance (gtype.c:1839)
   by g_object_new_internal (gobject.c:1939)
   by g_object_new_valist (gobject.c:2264)
   by g_object_new (gobject.c:1782)
   by meta_input_device_native_new_virtual (meta-input-device-native.c:1365)
   by meta_virtual_input_device_native_constructed (meta-virtual-input-device-native.c:705)
   by g_object_new_internal (gobject.c:1979)
   by g_object_new_valist (gobject.c:2264)

Suggested-by: Carlos Garnacho <carlosg@gnome.org>
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1529
2020-10-26 18:19:31 +00:00
Carlos Garnacho
6e49ad436d clutter: Drop clutter_input_device_set_stage()
Also drop the stage argument from clutter_input_device_set_coords()
in consequence. No one uses this already.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
ce2b3728a2 backends/x11: Drop users of clutter_input_device_set_stage()
There is no getter, so this information is useless.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
942b3c63df backends/native: Drop users of clutter_input_device_set_stage()
There is no getter, so doing this is now pointless.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
e3644acbbf backends/x11: Drop all users of clutter_input_device_get_stage()
And clutter_input_device_get_pointer_stage().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
9598eedd04 backends/native: Drop all uses of clutter_input_device_get_stage()
Rely on the seat stage, or other ways to fetch it. Also rely that
there is actually a single stage, so that we assign the right stage
to all events going out of the seat, in a single place.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
3c8376ad91 backends/native: Move relative motion filter to MetaSeatNative altogether
And drop the relative motion filter API. The seat will handle relative motion
across outputs with different scales. This accesses the MetaMonitorManager
ATM.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
90df3c6fa3 backends/native: Make seat constrain pointer to monitors out of the box
It does access the MetaMonitorManager directly ATM.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
27ef073432 backend/native: Move barrier manager to MetaSeatNative
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
6cb1557d99 backends: Move absolute/relative device mapping to native backend
This is a bit scattered around, with the setter/getter in Clutter, and
it only being only directly honored in Wayland (it goes straight through
device properties in X11).

Make this private native API, and out of public ClutterInputDevice API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
82c6c3f303 backends: Move device mapping check into backend
Make the upper parts agnostic about the device being relative in
order to apply the display mapping. Just make the low level bits
resort to the identity matrix for those.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
c4d11f7550 backends: Fold device mapping check into backend
Make the upper part agnostic about the device being relative in order
to avoid applying keep-aspect. The X11 bits already are, so make it
sure it's also the case for the native backend.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
e28007edb9 backends: Drop extra layer of touch info handling
We have a hashtable in the device that does not add much on top
to the seat handling. Make all the places rely on the seat accounting
instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
c9a405ff9e backends/native: Use libinput seat slot API
Instead of creating a seat-wide touch slot ID ourselves, rely on libinput
API doing this for us.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
439e9a5567 backends/native: Assign unique ranges of slots to virtual devices
We are moving to seat-wide touch slot accounting, so move these virtual
devices to using their own range each. The theoretical case of
overflow/rollover is also handled.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
bd4062a196 clutter: Limit number of touch slots available to a virtual touch device
It's not worth letting these devices have an "unlimited" range of touch
slots. Limiting it to 32 is more than enough to map it with real touch
devices nowadays.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
7698fc4aaf backends: Drop the filter for libinput events
This is now unused, and it's arguably any useful to stay.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
dd60fa2bc6 backends: Use slot from cancel events
As it does seem from a read to libinput code, TOUCH_CANCEL events
actually do contain slot information, and are emitted per-slot.
This means we can avoid iterating over the slots ourselves, they
are still expected to be sent altogether.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Christian Rauch
7e0d80be39 backend/dummy: Do not enforce minimum screen size
https://gitlab.gnome.org/GNOME/mutter/-/issues/1481
2020-10-23 12:12:15 +01:00
Christian Rauch
4862e4cb39 backend/dummy: Warn about missing dummy mode specs
When malformed modes are provided and no valid mode spec is found, mutter
will eventually try to access the last element of an empty list. Warn about
this and exit properly.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1481
2020-10-23 12:12:08 +01:00
Uday Kiran Pichika
9d0bac0754 output: Move edid parse function to the right file
Move the edid parsing function from MetaMonitorManager to MetaOutput
to read the monitor manufacturer,serial,vendor,etc.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1516/
2020-10-21 17:04:44 +05:30
Hans de Goede
ec18a559c6 monitor-manager: Ignore tablet-mode-switch on initial config of native portrait mode panels
Many tablets have a native portrait mode panel, yet come with a keyboard dock,
where the device gets docked in landscape mode. To avoid the display being
on its side when mutter starts while the tablet is docked, we need to take
the accelerometer reported orientation into account even if there is a
tablet-mode-switch which indicates that the device is NOT in tablet-mode
(because it is docked).

Add special handling for the first time the "orientation-changed"
signal gets signalled by the orientation-manager, which happens after it
has successfully claimed the accelerometer with iio-sensor-proxy.

The added special handling of the initial "orientation-changed" signal
does a number of checks:

1. panel_orientation_managed is false because of the tablet-mode-switch and not
   because of other reasons.

2. The device has a native portrait mode panel (and thus likely needs rotation
   to display the image the right way up when docked).

If all these checks succeed then it continues with creating a new
monitors-config based on the orientation ignoring the panel_orientation_managed
value (for the initial/first "orientation-changed" signal only).

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:10 +00:00
Hans de Goede
1b13f50582 monitor-manager: Update orientation based config when panel_orientation_managed changes
The orientation reported by the orientation_manager may have changed while
panel_orientation_managed was false. So when panel_orientation_managed
changes to true we should re-check the orientation.

This fixes the orientation not being correct when e.g. taking a 360 degree
hinges 2-in-1 in clamshell mode (so landscape orientation) and then folding
it into tablet mode while holding it in portrait orientation.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:09 +00:00
Hans de Goede
4c12208363 monitor-manager: Add a handle_orientation_change helper function
Move the bulk of orientation_changed to a new handle_orientation_change
helper function. This is a preparation patch for further orientation
handling related changes.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:09 +00:00
Hans de Goede
21c714a0f2 seat-native: Add support for tablet-mode-switch being hot-unplugged
Add support for the (mostly theoretical) case of an input-device
offering tablet-mode-switch functionality being unplugged.

This makes the has_tablet_switch handling identical to the has_touchscreen
handling, leading to more consistent code.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:09 +00:00
Hans de Goede
88cabf8039 seat-native: Check for tablet-switch devices from meta_seat_native_constructed
Detect if a tablet-mode-switch device is already present when mutter
starts by checking for this from meta_seat_native_constructed. This
mirrors how we also set has_touchscreen from meta_seat_native_constructed.

This fixes tablet-mode-switches only being recognized when they are added
at runtime.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:09 +00:00
Hans de Goede
6c240dc83b seat-native: Fix has_touchscreen becoming FALSE when a non touchscreen device gets added
Unconditionally setting has_touchscreen to check_touch_mode
when a new device gets added leads to has_touchscreen becoming
false when during runtime e.g. an USB keyboard gets plugged in.

Fix this by setting has_touchscreen to TRUE when check_touch_mode
is TRUE and leaving it alone otherwise.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:09 +00:00
Hans de Goede
b5d21f00f8 backend: Use new clutter_seat_has_touchscreen helper
Replace the meta-backend.c private check_has_physical_touchscreen
function with a call to the new clutter_seat_has_touchscreen helper.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:08 +00:00
Robert Mader
b2f2050b95 renderer-native: Fix GObjectify oversight
This was forgotten in eb14da3874, triggering crashes.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1510
2020-10-18 11:25:27 +02:00
Jonas Ådahl
eb14da3874 cogl: Turn CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects
A first step towards abandoning the CoglObject type system: convert
CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects.
CoglFramebuffer is turned into an abstract GObject, while the two others
are currently final. The "winsys" and "platform" are still sprinkled
'void *' in the the non-abstract type instances however.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
aa99e505ad cogl/framebuffer: Move public struct fields to private struct
This will limit accidental manipulation of the framebuffer struct
fields, while also paving the way to change to GObject type hierarchy.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Daniel van Vugt
df76d3deec renderer-native: Get the GBM buffer format from EGL to match the framebuffer
This eliminates two locations where the format was hardcoded.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1491
2020-10-15 07:45:06 +00:00
Daniel van Vugt
df65f05e27 cogl: Remove unused swap-related COGL_FEATURE_ID_ flags
What we actually use is `COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT`, which
is also set in the same locations.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1297
2020-10-14 16:27:23 +00:00
Peter Hutterer
e078a007d6 backends: add support for scroll button locking
Where enabled, the first click of the scroll button sets the button logically
down, the second click sets the button logically up.

This is an accessibility feature, it doesn't require users to keep holding the
button down while scrolling which is hard or impossible for some users.

gsettings-desktop-schemas merge request:
https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/-/merge_requests/39

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1432
2020-10-14 16:02:29 +00:00
Jonas Ådahl
2c95e08998 Remove misplaced line break in g_* logging functions
They resulted in empty lines in the log.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1466
2020-10-08 16:38:41 +02:00
Jonas Ådahl
313e3e771c Make meta_* logging utilities not require line break
Unlike g_* logging utilities, the meta_* counterparts behave like odd
printf() functions. Lets change that so they fit better into how logging
is done everywhere else.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1466
2020-10-08 16:38:41 +02:00
Carlos Garnacho
bbc4116f10 backends: Use graphene_point_t on meta_cursor_tracker_get_pointer()
It's nicer to propagate along.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1475
2020-10-06 21:33:10 +02:00
Carlos Garnacho
e0944b6097 backend: Don't pull generated headers (indirectly)
Use a typedef for MetaRemoteDesktop, so tests poking MetaBackend don't
indirectly depend upon generated headers. This is arguably a code fix
for a build system bug.

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

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1449
(or something...)
2020-10-06 16:16:21 +00:00
Olivier Fourdan
6db7d8f830 backend: Add a backend release function
Mutter still relies heavily on singletons such as its MetaBackend.

For that, the backend implementation has a meta_init_backend() function
which is called at startup from meta_init(), which creates the desired
backend and sets the singleton which is returned by meta_get_backend().

Unfortunately, that means that the backend is never actually freed, and
all the code from the backend finalize function never actually get
called.

Add a meta_release_backend() to free the backend singleton.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1438
2020-10-06 15:45:42 +00:00
Olivier Fourdan
c956193d09 input-settings: Disconnect device signals on dispose
The input settings constructor installs callback functions on device
added/remove and tool-changed.

However, on dispose, those signals are not disconnected, meaning that on
teardown, once the devices get removed eventually, the callback will
still fire and call the callback with freed data, causing a crash.

Make sure we clear the signals on devices on dispose, to avoid the crash
on teardown.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1438
2020-10-06 15:45:42 +00:00