1
0
Fork 0
Commit graph

2552 commits

Author SHA1 Message Date
Olivier Fourdan
56939abd2f cursor-renderer/native: Add a means to disable HW cursors
When dealing with a faulty hardware or bugs in the driver, it might be
interesting to force the use of software cursors for debugging purposes.

Add a debug environment variable MUTTER_DEBUG_DISABLE_HW_CURSORS to
disable hardware cursors and force using software cursors.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2046
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2150>
2021-12-20 10:41:28 +00:00
Hans de Goede
cc9bb7c516 monitor-manager: Fix orientation changes on devices with 90° mounted panels
Commit 2289f56112 ("monitor-manager: Don't apply unneeded orientation
changes") added an early return to handle_orientation_change () in case
the transform is unchanged.

But this did not take the correction of the transform for devices
with 90° mounted panels into account causing a desired orientation
change to get skipped if the new orientation matches the corrected
logical orientation from the previous transform setting.

Fix this by calling meta_monitor_crtc_to_logical_transform () on the
transform before comparing it, matching the
meta_monitor_crtc_to_logical_transform () call in
create_for_builtin_display_rotation ().

Related: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2090>
2021-12-20 10:08:13 +00:00
Jonas Ådahl
3602762a18 tests/wayland-unit-tests: Add test case for remapping popup with subsurface
This test reproduces the crash in
https://gitlab.gnome.org/GNOME/mutter/-/issues/1828. It does not
reproduce with 'window-actor/wayland: Remove subsurface actors on
dispose' (dd416dd3e2). applied. This test case differs slightly
from the one that came with the dd416dd3e2 as in that it uses
withdrawn popup surfaces instead of explicitly client managed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
José Expósito
2e8aef6f8a backends/native: Refactor LIBINPUT_EVENT_POINTER_AXIS handling
Move the logic to handle LIBINPUT_EVENT_POINTER_AXIS events to its own
function (handle_pointer_scroll).

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
Jonas Ådahl
d43cc776ef renderer/native: Allow forcing EGLStream backend
The GBM support in the NVIDIA driver is fairly new, and to make it
easier to identify whether a problem encountered is related to using GBM
instead of EGLStreams, add a debug environment variable to force using
EGLStream instead of GBM.

To force using EGLStream instead of GBM, use

    MUTTER_DEBUG_FORCE_EGL_STREAM=1

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2045
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2132>
2021-12-08 15:47:35 +00:00
Carlos Garnacho
eda7588190 backends: Replace MetaCursorSprite::prepare-at with in-place function
Since this signal is in a hot path during input handling, it makes sense
not to have this be a signal at all, currently most of the time spent in
it is in GLib signal machinery itself.

Replace it with a function/user data pair that are set on the sprite
itself. Only the places that create an sprite are interested in hooking
one ::prepare-at behavior per sprite, so we can do with a single pair.

This makes meta_cursor_sprite_prepare_at() inexpensive enough.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
8310766845 backends: Upload xcursor texture only after invalidations and theme changes
Make realize_texture() return FALSE for the situations that we do not need
to push again the cursor texture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
508c08fa09 backends: Only reload sprite cursor on changes
Let the meta_cursor_sprite_realize() function return a boolean value
telling whether there was an actual change in the sprite cursor. E.g.
the surface/icon for it changed in between.

This is used in the native backend to avoid converting/uploading again
the cursor surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
49045b2ab9 backends: Remove superfluous intermediate variable
Having this intermediate variable is not of much use anymore, remove
it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
35b8346a33 backends/x11: Use clutter_do_event() for event delivery
It'll do some things that will be no longer optional here. So don't
avoid this step towards event emission.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Jonas Ådahl
70c6d28fca ScreenCast: Allow recording new streams on active sessions
This is useful if you have a session, and want to "hot-plug" new sources
over time; there is no point in having to create separate sessions for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2131>
2021-12-07 19:23:52 +00:00
Jonas Ådahl
764c75d2fb screen-cast-session: Add is-active tracking
Will be used to determine one can start a new recording or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2131>
2021-12-07 19:23:52 +00:00
Joan Torres
754c834590 Add method to show if in headless mode
MetaBackend can now show whether it is in headless mode or not
using a vfunc is_headless.

Fallback of is_headless returns FALSE.

MetaBackendNative implements is_headless returning its
is_headless property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2130>
2021-12-07 16:03:10 +00:00
Carlos Garnacho
67a27a82d9 backends: Do not exclude devices from an output based on capability
This is a strange thing to do since MetaInputMapper also does take care of
devices with an output configured through settings, since we might have
devices that were configure through settings exclude other devices that
belong together with an output (e.g. a display-integrated tablet).

This was essentially here as a last resort to avoid matching two very
similar looking tablets to one of two very similar looking outputs. There
was a 50% chance already that the choice was wrong, and now these devices
can all be configured specifically through settings, so this shouldn't
be missed either.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2107>
2021-12-07 14:59:57 +00:00
Carlos Garnacho
e3702c8b9a backends: Only default to builtin panel on touchscreen devices
Non-display-attached tablets (e.g. Intuos) may find no match, which
should mean "use the span of all monitors", not "pick one for me".
Reserve this fallback to touchscreen devices, since these might
still benefit from it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2107>
2021-12-07 14:59:57 +00:00
Carlos Garnacho
04eda556e7 backends: Do not emit pointless signals remapping pad devices
The matrix and aspect ratio of the tablet is irrelevant on pads, and
it actually triggers warnings when trying change that on those devices:

gnome-shell:42536): mutter-CRITICAL **: 17:22:41.994: meta_input_device_native_get_mapping_mode_in_impl: assertion 'device_type == CLUTTER_TABLET_DEVICE || device_type == CLUTTER_PEN_DEVICE || device_type == CLUTTER_ERASER_DEVICE' failed

This is unnecessary to do on pad devices, these just need to be moved
together with their respective stylus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2107>
2021-12-07 14:59:57 +00:00
Pascal Nowack
d5f2ec6f1e backends/native: Stop freeing slow keys list twice
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1225
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2138>
2021-12-07 09:35:26 +01:00
Jonas Ådahl
65d8164833 backend: Expose get_monitor_manager() publicly
So that it can eventually replace the standalone singleton getter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2128>
2021-12-03 15:43:40 +00:00
Jonas Ådahl
5afe51b143 monitor-manager: Add 'has-builtin-panel' property
Will be TRUE if there are any built in panels. Can for example be used
to determine whether a machine is a laptop or a desktop computer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2128>
2021-12-03 15:43:40 +00:00
JoseExposito
d4ba16252b backends/native/meta-seat: Capture hold events
Receive hold gesture events from libinput and enqueue them as Clutter
events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
Jonas Ådahl
5ca43e7017 renderer/native: Set EGLContext when creating secondary GPU data
When changing to using MetaRenderDevice, setting the EGLContext was
mistakenly dropped. Add it back. Fixes hybrid graphics setups.

Fixes: d4e8cfa17a
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2032
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2111>
2021-11-26 15:04:39 +00:00
Jonas Ådahl
00c329a2e5 cursor-renderer/native: Use MetaCrtcNative API to check capabilities
The cursor renderer shouldn't assume all the CRTCs of a logical are KMS
CRTC's, as we'll end up checking hardware capabilities for CRTC's of
virtual monitors as well, when they were created to not embed the cursor
image directly in the framebuffer.

Instead, use the newly introduced API for checking CRTC cursor
capabilities. This fixes a crash with the following backtrace:

 0) get_plane_with_type_for at ../src/backends/native/meta-kms-device.c:150
 1) meta_kms_device_get_cursor_plane_for at ../src/backends/native/meta-kms-device.c:173
 2) has_cursor_plane at ../src/backends/native/meta-cursor-renderer-native.c:678
 3) foreach_crtc at ../src/backends/meta-logical-monitor.c:247
 4) meta_monitor_mode_foreach_crtc at ../src/backends/meta-monitor.c:1920
 5) meta_logical_monitor_foreach_crtc at ../src/backends/meta-logical-monitor.c:274
 6) crtcs_has_cursor_planes at ../src/backends/native/meta-cursor-renderer-native.c:718
 7) should_have_hw_cursor at ../src/backends/native/meta-cursor-renderer-native.c:881
 8) meta_cursor_renderer_native_update_cursor at ../src/backends/native/meta-cursor-renderer-native.c:1085
 9) meta_cursor_renderer_update_cursor at ../src/backends/meta-cursor-renderer.c:411

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2000183
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
2021-11-26 14:30:27 +00:00
Jonas Ådahl
e82685d049 crtc/native: Add API to check whether the CRTC supports hardware cursors
On a KMS backed CRTC, hardware cursor are supported when there are
cursor planes to assign them to. Note that when using legacy mode
setting, fake cursor planes are added when adequate.

On virtual CRTCs, used with virtual monitors, the equivalent of hardware
cursor are always supported, as they are sent using embedded PipeWire
stream metadata.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
2021-11-26 14:30:27 +00:00
Daniel van Vugt
acadf5b3f7 onscreen/native: Increase buffer ref count in copy_shared_framebuffer_cpu
It was dropping to zero after the first frame because it hadn't been
incremented high enough. So the second frame would crash with:
```
  #0 g_type_check_instance_cast
  #1 META_DRM_BUFFER
  #2 copy_shared_framebuffer_cpu
```
That's the CPU-copy path (fallback-fallback) that probably no one is using
but it does work after this fix. Exactly the same issue as was fixed
in `copy_shared_framebuffer_primary_gpu` by 36352f44f9.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2104>
2021-11-24 15:15:24 +00:00
Jonas Ådahl
cbdd62c197 kms/impl-device: Report 'full' change if we removed connectors
If some connectors disappeared, but the rest didn't change, we missed
actually removing the ones that disappeared, as we incorrectly assumed
nothing changed. Fix this by only assuming nothing changed if 1) we
didn't add any connector, and 2) we have the same amount of connectors
as before the hotplug event. The connector comparison checking makes
sure we report changes if anything of the still available connectors
changed.

Fixes: a8d11161b6
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2007
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:55:22 +01:00
Jonas Ådahl
c765730af7 kms/crtc: Always log whether we updated CRTC state
Change a few early-outs to handle the state changes without returning.
This means we'll get to log the result in all cases, which might help
debugging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:55:22 +01:00
Jonas Ådahl
8546ca31ff kms/connector: Fix updating the state when drmConnector is NULL
When a docking station is disconnected, a few previously existing DRM
connectors may now be gone. When this happens, getting them via the
libdrm API results in NULL pointers returning, and we need to handle
this gracefully by making sure the connector state is properly updated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:15:57 +01:00
Piotr Łopatka
33529426a9 backend: Copy damage rectangles to secondary GPU when available
Systems with AMD GPUs do not take advantage of Mutter's zero-copy path
when driving DisplayLink screens. This is due to a very slow CPU access
to the zero-copy texture. Instead they fall back on primary GPU doing a
copy of the texture for fast CPU access. This commit accelerates texture
copy by working through damage regions only.

Tests on a 4K screen with windowed applications show significant
reduction of GPU utilisation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2033>
2021-11-17 08:24:15 +00:00
Ray Strode
6060b6a240 backends/x11: Fix key repeat of on-screen keyboard for second level keysyms
Certains keys (such as ~ and |) are in the keyboard map behind the
second shift level. This means in order for them to be input, the
shift key needs to be held down by the user.

The GNOME Shell on-screen keyboard presents these keys separately on
a page of keys that has no shift key. Instead, it relies on mutter
to set a shift latch before the key event is emitted. A shift latch
is a virtual press of the shift key that automatically gets released
after the next key press (in our case the ~ or | key).

The problem is using a shift latch doesn't work very well in the face
of key repeat. The latch is automatically released after the first
press, and subsequent repeats of that press no longer have shift
latched to them.

This commit fixes the problem by using a shift lock instead of a shift
latch. A shift lock is never implicitly released, so it remains
in place for the duration of key repeat.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2045>
2021-11-04 13:15:25 +00:00
Jason Gerecke
64ff1f20f8 input-mapper: Reverse sort order of display score comparator
The `guess_candidates()` function scores each display that an input
device could be mapped to and then uses the `sort_by_score()` comparator
to find the best option. The function expects the list to be sorted from
best to worst, but the comparator currently sorts them in the opposite
order. This causes the function to end up returning the _worst_ match
rather than the the best. This commit reverses the sort order of the
comparator so that the best display can be returned as intended.

Closes: #1889
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1934>
2021-11-02 17:17:21 +00:00
Erico Nunes
577c4711e1 backends: Enable partial update on clipped redraws
Mutter already calculates and tracks the damage rectangles to redraw
only areas of the screen that change since the last time a buffer was
used.
This patch extends this by using the EGL_KHR_partial_update extension to
inform the GPU in advance that only those areas will be changed, which
may allow for further optimization.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2023>
2021-10-26 16:56:39 +00:00
Carlos Garnacho
b3046cca2d backends/x11: Fix off by one in debug output
We are looking the atom name based on the wrong index, as the
axis is incremented to cater for the extra CLUTTER_INPUT_AXIS_IGNORE
value.

CID: #1418330
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
820aa18126 backends/native: Use rtkit to get realtime priority
Instead of using sched_setscheduler directly (and relying that we
somehow got CAP_SYS_NICE), use rtkit to do this for us.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2284
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2060>
2021-10-22 08:35:15 +00:00
Jonas Ådahl
ac907119ae wayland: Only init EGLStream controller if we didn't end up with gbm
When we use gbm together with the NVIDIA driver, we want the EGL/Vulkan
clients to do the same, instead of using the EGLStream paths. To achieve
that, make sure to only initialize the EGLStream controller when we
didn't end up using gbm as the renderer backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2052>
2021-10-20 13:08:06 +00:00
Jonas Ådahl
8fc1325e8e renderer/native: Try the gbm renderer before the EGLDevice renderer
This switches the order of what renderer mode is tried first, so that
the gbm renderer mode is preferred on an NVIDIA driver where it is
supported.

We fall back to still try the EGLDevice renderer mode if the created gbm
renderer is not hardware accelerated.

The last fallback is still to use the gbm renderer, even if it is not
hardware accelerated, as this is needed when hardware acceleration isn't
available at all. The original reason for the old order was due to the
fact that a gbm renderer without hardware acceleration would succeed
even on NVIDIA driver that didn't support gbm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2051>
2021-10-19 17:43:13 +02:00
Jonas Ådahl
e8249a572d renderer/native: Log render mode per device
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2051>
2021-10-19 17:43:12 +02:00
Jonas Ådahl
d4e8cfa17a renderer/native: Use MetaRenderDevice
This replaces functionality that MetaRenderDevice and friends has
learned, e.g. buffer allocation, EGLDisplay creation, with the usage of
those helper objects. The main objective is to shrink
meta-renderer-native.c and by extension meta-onscreen-native.c, moving
its functionality into more isolated objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:36:18 +02:00
Jonas Ådahl
8662f33b9e render-device: Add API to allocate dumb buffers
All render devices that have a device file backing them might be able to
allocate dumb buffers, so add a helper for doing that. Will indirectly
result in an error up front on a surfaceless render device due to lack
of a device file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:36:17 +02:00
Jonas Ådahl
986588ade2 render-device: Add API to import other buffers
This more or less is a helper for creating MetaDrmBufferImport objects
with a bit more friendly API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:35:26 +02:00
Jonas Ådahl
802e7eb56f render-device: Add API to allocate DMA buffers
Only possible with the gbm implementation; aims to make it easier for
users of render devices to allocate DMA buffers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:34:31 +02:00
Jonas Ådahl
9292eba035 render-device/gbm: Add getter for gbm_device
Will be needed, at least during a transition period, to e.g. deal with
gbm_surface's et. al. without having MetaRenderDevice learning about
render surfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
b3dffb43b3 drm-buffer: Don't always generate fb_id on construction
It might not be needed by the user of the buffer, so don't always
require it up front. Instead make sure that any user that needs it first
calls "meta_drm_buffer_ensure_fb_id()" to create the ID.

Only the plain gbm implementation creates the ID lazilly, the other
still does it on construction due to the objects used to create them
only existing during construction.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
a1266e19f4 drm-buffer: Add API to export buffer file descriptor
Practically ends up in gbm_bo_get_fd(). For dumb buffer, an
'unsupported' error is returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
6ba86366b3 drm-buffer: Replace 'use-modifier' boolean with flags
This lets us add more customization to the buffer instance without
adding more boolean arguments.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
99f51d2866 drm-buffer: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
e078718180 drm-buffer: Add getters for more metadata
Mostly calls into gbm_bo_* API, or something somewhat similar when on
dumb buffers. Added API are:

 * get offset for plane
 * get bpp (bits per pixel)
 * get modifier

This will allow users of MetaDrmBuffer to avoid having to "extract" the
gbm_bo to get these metadata.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
bece36b4ad renderer/native: Get bpp from gbm_bo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
2047d2d4e9 Introduce MetaRenderDevice{Gbm,EglStream,Surfaceless}
The purpose of MetaRenderDevice is to contain the logics related to a
render device; i.e. e.g. a gbm_device, or an EGLDevice. It's meant to
help abstract away unrelated details from where it's eventually used,
which will be by MetaRendererNative and the MetaOnscreenNative
instances.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:32 +02:00
Jonas Ådahl
7058013660 clutter/stage: Remove 'minimum window size' logic
It was a feature relevant for when Clutter was an application toolkit
that wanted the application window to communicate a minimum size to the
windowing system.

Now, clutter is part of the windowing system component, so this feature
doesn't make any sense, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
259a906b8c cogl/winsys: Remove 'multiple-onscreen' feature
It was always set, and is no longer used; remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
85de82bb4e clutter: Remove 'stage cursor' feature
It was unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
8008f0b7b0 Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.

The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().

During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.

This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.

This function now explicitly creates the backend, without having to go
via the previously set global vfunc.

This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.

The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.

This also removed the unused option parsing that existed in clutter.

In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.

The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
92b95b0b4b clutter/backend/x11: Make filter add/remove take a clutter backend
This avoids some global fetching, which is problematic if it happens
during init.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
6ae9bc9045 clutter/backend/x11: Keep a pointer to the actual backend
As with the native backend, eliminate going via some globals when
getting the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
1fbdfa8ca7 clutter/backend/native: Keep a pointer to the actual backend
This eliminates going via a global variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
cf1715ac43 backend: Get the default seat directly
In various places we retrieved the default seat from the ClutterBackend.
All the clutter backends implement this by calling
meta_backend_get_default_seat() which will then return
MetaBackendPrivate::default_seat.

Lets avoid this by fetching the default seat directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
c23c07716f clutter/backend/x11: Remove screen dimension fields
They were not used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
c6530551de clutter/backend/x11: Don't keep track of a Screen pointer
It was used during init, and nowhere else.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
08c34c887f clutter/backend/x11: Clean up ClutterBackend variable naming
Just as with MetaClutterBackendX11, lets avoid confusing it with
MetaBackend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
bbf2f6e064 clutter/backend/x11: Clean up variable naming
Rename all instances of `MetaClutterBackendX11` so they are called
`clutter_backend_x11`. This is because `MetaBackendX11` will start to be
used for some things, and having both be named `backend_x11` would be
confusing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
528ae91385 clutter: Remove option parsing support
For a long time we always passed NULL, lets take it one step further and
just remove all the options parsing stuff.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
a545fecad3 clutter/x11: Remove X11 display name field
It was unused, and we don't even let clutter open the display itself.
Lets clean that up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
fbb586283f clutter: Remove left-over xinput debug code
The only thing that happened was a static boolean getting set but never
read.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Ray Strode
c1f5e57f2b keymap-x11: Don't update key types when adding key to keymap
meta_keymap_x11_replace_keycode currently reports to the X server
that the key types data is changed when adding a key to the keymap.

It's not changed. The number of key types is the same, and none of
them are modified.

This has two bad side effects:

1) It sends all of the key types data into the request
2) It hits a bug in the X server leading to the request getting
rejected entirely.  See:

https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/761

Furthmore, the changed structure used to report to the X server
that the key types data is changed doesn't actually need to modified
at all in the function.  It's already prepped by libX11 with the
correct state for the changes mutter is doing when
XkbChangeTypesOfKey is called.

This commit addresses the above two problems by just removing the
lines causing the issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2039>
2021-10-06 14:16:39 +00:00
Sebastian Keller
2740f1d2d2 keymap/x11: Stop searching through reserved keycodes explicitly
Keys in the reserved keycode list are always added for the first group.
Before the previous commit such keycodes were not found unless that was
the current group. But now that we can also find matching keycodes that
are not directly in the current group, this is not necessary anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Sebastian Keller
795418a5db keymap/x11: Consider the out of range group action
Some keys, such as enter or backspace are only bound to a single group,
even if multiple groups are configured. Because the code was previously
only looking for keysyms in the same group as the current one, no
matching keycodes for these would be found if the current group is not
the first group. This was causing those keys to not work on the X11 OSK.

To fix this use the correct action to convert an out of range group for
that key according to its group_info field.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Sebastian Keller
bb24e4ac9e keymap/x11: Check for the group earlier when finding keycode from keyval
This effectively changes meta_keymap_x11_get_entries_for_keyval() to
meta_keymap_x11_get_entry_for_keyval() and moves the check if the
keycode maps to the keyval in the current group there. This simplifies
the code a bit and will allow a followup fix.

As a side effect this now also causes the reserved kecodes to be
searched, if no keycodes were found, rather than just when only ones
matching the wrong groups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Jonas Ådahl
9179d4a4b1 kms/impl-device/atomic: Add virtio_gpu to deny list
virtio_gpu is used in virtual machine environments, meaning they need
accurate cursor hotspots, which currently needs non-atomic mode setting.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2009304
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2040>
2021-10-05 13:55:06 +00:00
Bastien Nocera
c789b6be38 backend: Reset idletime when unplugging the power cable
Avoid having laptops suspend or lock as soon as the power cable is
unplugged as the timeout for those actions when on battery are smaller
than the timeouts when on AC.

- laptop is plugged in, and hasn't been used for X minutes
- laptop is unplugged
- the gnome-settings-daemon power plugin sets up its timeouts for
  inactivity for the "on battery" case
- those X minutes of inactivity are still counting, and are above
  the level of one of the timeouts (say, suspend or lock screen),
  mutter fires the timeouts
- gsd-power activates the action associated with the timeout

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1953
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
2021-09-30 17:45:39 +02:00
Bastien Nocera
14b6c8780d backend: Refactor "lid-is-closed" handling code
We'll need to handle another property in the same place, so refactor the
code to allow falling-through to handle another property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
2021-09-30 17:45:22 +02:00
José Expósito
36b5719a3b backends/x11: Fix middle button emulation settings
Update the name of the property used to toggle middle click emulation to
"libinput Middle Emulation Enabled".

Fix: <#1881>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2000>
2021-09-20 17:39:15 +00:00
Marco Trevisan (Treviño)
ef0f708404 monitor-manager: Use connect_object to connect to settings signals
We were disconnecting from the wrong object, so instead of adjusting it
we can simply use "new" utility functions instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
16e335eb24 backends/native: Remove unused includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d689989ea kms/connector: Use utility function to get the property ID
We already have one for this, so use it instead of repeating the same

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
cbfb59b828 backends/native: Ignore udev events while we're paused
When the native backend is paused we still process the udev events
even though this isn't needed and may just cause unneeded events to be
triggered afterwards.

Since we'll resume with full changes on such event, we can just block
the signal hander when paused and restore it afterwards.

As per this we can cleanup also a bit the device adding signal handling
given that now we don't have to disconnect/reconnect it again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9cb35e2c80 backends/kms: Always perform full changes on KMS resume
Resume happens after we may have received various events that we've
ignored, so at this point we need to just emit an hotplug event like if
everything changed so that user settings may be re-applied.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
dd0ad3bfb1 kms/impl-device: Only update crtc/connector whose ID has changed
On hotplug events we may get informations about what CRTC or connector
changed a property (and the property itself), so in such case let's just
ignore the changes to the non-affected CRTCs/connectors, and let's read
only the affected one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
91ed95ab6f kms: Only update a device state if it contains the changed crtc/connector
On hotplug events we may receive a "CRTC" or "CONNECTOR" property that
indicates which crtc/connector property ID has changed.

In such case, instead of update data for all the devices, only update the
device containing the relative connector.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d3668a389 kms/device: Add functions to find connector and crtc in devices
Hotplug events may contain CRTC or CONNECTOR ids to notify a property
change to just one owner, so we need to find its parent device.

Also we may want to update properties directly without having to go through
all the devices, so expose a simple way to find them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
ea00c96044 udev: Pass the device as parameter on hotplug events
This will allow to find the related MetaKmsDevice that is emitting the
hotplug event

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
49501c28f2 kms: Return a more specific change if there are no devices
In case we have no devices, after a KMS update (both because they've
all have been removed or because there were none), we may need to behave
differently compared to the case in which nothing changed, so add a more
specific KMS update change type

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9ce3abad28 monitor-manager-native: Do not reload all the monitors on gamma-only change
If only gamma changed on drm CRTC's we don't have to rebuild the whole
monitors, nor to inform the backed about, the only consumer could be the
DBus API, and so we still emit a signal, but nothing else is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
a8d11161b6 kms: Only emit resources-changed signal if we recorded a change
Since we cache already all the KMS parameters we care about let's check at
each device update if anything has really changed and only in such case
emit a resources-changed signal.

In this way we can also filter out the DRM parameters that when changed
don't require a full monitors rebuild.

Examples are the gamma settings or the privacy screen parameters, that
emits an udev "hotplug" event when changed, but we want to register those
only when we handle the changed property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Michel Dänzer
3059d3ffc8 cursor-renderer: Remove meta_cursor_renderer_is_overlay_visible
Not used anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Michel Dänzer
6c818cd8d5 screen-cast/monitor-src: Use clutter_stage_paint_to_buffer
It works correctly with scanouts, in contrast to
clutter_stage_capture_into. Inspired by
meta_screen_cast_area_stream_src_record_to_buffer.

maybe_paint_cursor_sprite is now unused and thus removed.

v2:
* clutter_stage_paint_to_buffer requires switching to recording from an
  idle callback as well. (Jonas Ådahl)
v3:
* Set human readable name for idle source. (Ivan Molodetskikh)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1940
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Michel Dänzer
10d1de2bdf screen-cast/monitor-src: Always set before-paint watch
We weren't setting it for META_SCREEN_CAST_CURSOR_MODE_EMBEDDED, so
that case didn't work correctly with scanouts.

Suggested by Georges Basile Stavracas Neto.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Marco Trevisan (Treviño)
b3c5ca12a5 monitor-manager: Remove persistent_timeout on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
4fe7569567 orientation-manager: Use an idle to apply monitor orientation changes
In X11 when we switch to another tty all the the signals are blocked (as
the display fd is not replying back to polling, causing the main loop to
stop), and they are all handled once we switch back to the tty.

This is not a problem for most of external events, but in case of
accelerometer changes, once we reactivate a mutter session we'll get
them all together, causing lots of monitor reconfigurations leading to
black screen for some seconds and most of the times to a wrong
configuration being applied.

To avoid this, batch all these events using an idle to only apply the
last one we got in a loop.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1217
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
d5f397977e monitor-unit-tests: Add tests with dynamic orientation changes
Verify monitors disposition when we have rotation changes coming from
MetaOrientationManager, using our mock dbus implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
d0a9dfefc8 monitor-transform: Add function to compute from orientation
We have two places in the code where we compute the monitor
transformation from the device orientation, avoid duplicating this
code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
bf54a16f92 tests: Add MetaOrientationManager tests via SensorsProxy mock
Create a test system bus and use it to run all the tests, add a mock
SensorsProxy (via dbusmock template) server that implements the
net.hadess.SensorProxy interface.

To make testing easier, the service is created on request of a proxy for
it, whose lifetime controls the mock service lifetime as well.
This is done using a further mock service that is used to manage the
others, using python-dbusmock to simplify the handling.

Add basic tests for the orientation manager.

As per the usage dbusmock, we're now launching all the tests under such
wrapper, so that local dbus environment won't ever considered, and
there's no risk that it may affect the tests results both locally and in
CI.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:00 +02:00
Marco Trevisan (Treviño)
f1228c4a51 orientation-manager: Expose the number of valid orientations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
617e1b30e2 monitor-config-manager: Rename builtin monitor lookup utility function
It's only meant to find the builtin monitor configuration, for any
rotation, so no need to specify that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
c326313370 monitor-config-manager: Find builtin configuration even when inactive
When creating the configuration for the builtin monitor we try to get
the panel configuration for the builtin panel, but we don't proceed if
that monitor is currently inactive.

This is fine when adjusting an active configuration to the current
device rotation, but it isn't correct when we want to create a new
configuration based on another where the monitor is configured but not
yet enabled.

So, only find the panel configuration without looking the current state
but ensuring that the passed configuration will enable it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
f803c0ee0a monitor-manager: Add config relationships and use it for orientation events
When we get an orientation event we don't care about keeping track of the
configuration changes, but actually we can consider the new configuration
just a variant of the previous one, adapted to floating device hardware
events, so we only want to apply it if possible, but we don't want to keep
a record of it for reverting capabilities.

Doing that would in fact, break the ability of reverting back to an actual
temporary or persistent configuration.
For example when device orientation events happen while we're waiting for
an user resolution change confirmation, we would save our new rotated
configuration in the history, making then impossible to revert back to
the original persistent one.

So in such case, don't keep track of those configurations in the history,
but only keep track of the last one as current, checking whether the
new current is child or sibling of the previously one.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1221
Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/646

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
d773aaf7a9 monitor-manager: Apply built-in monitor orientation to previous configurations
When we reuse a monitor configuration (from the storage or previously
used), we need to make sure that the built-in monitor rotation matches
with the current sensors status.

So, instead of trying to apply a previously used or stored configuration
with a wrong orientation and fix it later, if orientation is managed by
sensor, try to create another configuration based on the previous one that
uses the current built-in monitor orientation and use it.

Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/646

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/592
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/646
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/954
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
dbf5e38f03 monitor-config-manager: Ignore orientation if it is not managed
When creating a configuration taking orientation into account we're using
the sensors orientation even if this is currently not used (for example
when an accelerator is available, but there's no touch screen).

This would cause to have a different behavior when configuration is
created and when we're loading a known configuration on startup.

So always honor whether the monitor's orientation is managed or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
2289f56112 monitor-manager: Don't apply unneeded orientation changes
There's no need to ensure monitor orientation changes if the wanted
orientation is matching the current one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
e976137d97 monitor-manager: Only manage orientation if we have a built in panel
All the auto-rotation code is expecting to have a built-in panel, but we
still monitor accelerometer changes if we don't have one (uncommon, but
possible).

Thus manage the panel orientation in such case and update it on monitors
changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
f78e21c45a monitor-manager: Remove some trailing spaces in orientation code
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Piotr Lopatka
b328c8cc8b onscreen/native: Pass damage rectangles when page flipping
This commit passes damage rectangles metadata to the (KMS) primary
plane.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:37:56 +01:00
Piotr Lopatka
af0460d0ce kms: Allow passing framebuffer damage metadata
This commit adds support to atomic KMS backend for optional plane property
prop_fb_damage_clips. Some drivers (e.g. EVDI) take advantage of this
property and process only updated regions of the screen instead of
processing the full frame. This can save system resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:10:35 +01:00
Ray Strode
2cb617e9e0 backend: Clean up renderer after clutter backend
commit c4a73e7950 added
code to cleanup the renderer when the meta backend is
disposed. Unfortunately, this introduced a crash when
the window manager is replaced.

This is because cleaning up the renderer involves talking
to the X server over a display connection that's closed
two lines higher as part of the clutter_backend_destroy
call.

This commit fixes the crash by swapping their order.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1965>
2021-08-31 16:41:11 +00:00
Daniel van Vugt
cd355b5d74 onscreen/native: Remove a tab character
To resolve CI warnings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1972>
2021-08-24 16:44:44 +08:00
Jonas Ådahl
4615da2122 monitor: Add hash function
Will be used to keep a monitor spec as a hash table key.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Ivan Molodetskikh
f6bf1ceb92 cursor-tracker: Add meta_cursor_tracker_get_scale ()
Used in the screenshot UI (and arguably should be used in the existing
gnome-shell screenshot drawing code).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1967>
2021-08-22 15:02:38 +00:00
Marco Trevisan (Treviño)
37e154c832 monitor-config-manager: Use match rule to check laptop panel visibility
Use the MONITOR_MATCH_VISIBLE match rule instead of doing the same check when
initializing the list of disabled monitor specs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
e59da5ad83 monitor-conifig-manager: Generate primary monitor config with others
Primary monitor is just the same of the other monitors, but it has a
primary monitor flag. Since the computation of the scaling isn't
dependent anymore on the computed configuration we can now generate the
primary monitor config together with the others.

However, we've to ensure that the primary monitor is the first of the
configs list in order to properly compute the positioning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
e8b84441a4 monitor-config-manager: Computer monitor scale in caller
Compute the monitor scaling in a separated function using the primary
monitor (not its config) and pass it to the creation function instead.

This will allow removing the special logic for the primary monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
aeea2882e5 monitor-config-manager: Use monitor match filters to create config
Factorize the creation of a configuration inside one function that looks for
the primary monitor and the other monitors using the matching rules and
dispose them according to the chosen policy (checking if the result is valid
when using the suggested positioning).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
3dbec4d709 monitor-config-manager: Define cleanup functions for structs
Monitor configuration structures can be used inside containers such as GList
and in order to have smart cleanups we need to define the relative free function

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
4574f2d9af monitor-config-manager: Use single filter function to build configs
Add a find_monitors function that allows to search for monitors that match
the MonitorMatchRule filter and use this to look for the primary monitor and
the other monitors that need to match the requested filter in order to be
configured.

Having just one function doing this kind of checks reduces the possibility
of unexpected results.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
32d7c5fbfb monitor: Only assign suggested positions to valid pointers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
be9e6dcc4f monitor-config-manager: Reject a suggested config with gaps
It could happen that monitors suggest to use coordinates that don't take
in consideration the scaling applied to one monitor, and such the
generated configuration is not valid because not all the monitors are
adjacent.

So enforce this check before accepting a suggested configuration as it
is.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Pascal Nowack
20db6af4e6 remote-desktop: Check pipe fd before assuming existing read() operation
Currently, if g-r-d closes the read end of the pipe for a
SelectionRead() operation, due to realizing that the application, that
should provide the mime type content, does not provide any content,
mutter won't notice that and still assumes that the read() operation
on the pipe in g-r-d is still happening, as mutter never writes to the
pipe in that situation and therefore cannot realize that the pipe is
already closed.
The effect of this is, that if g-r-d aborts a read() operation and
requests a new read() operation via SelectionRead(), mutter will deny
the request since it assumes that the previous read() operation is
still ongoing.

Fix this behaviour by also checking the pipe fd in mutter before
denying a SelectionRead() request.

https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/issues/60

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1874>
2021-07-28 15:26:04 +00:00
Marco Trevisan (Treviño)
3e1e2cb91f monitor: Do not overlap when checking for applicable scaling values
With some resolutions (such as 4096x2160) we may compute duplicated
scale factors because we used a too wide threshold to check for an
applicable value.

In fact, while when we're at the first and last values it's fine to
search applicable values up to SCALE_FACTORS_STEP, on intermediate ones
we should stop in the middle of it, or we're end up overlapping the
previous scaling value domain.

In the said example in fact we were returning 2.666667 both when
looking to a scaling value close to 2.75 and 3.00 as the upper bound of
2.75 (3.0) was overlapping with the lower bound of 3.0 (2.75).
With the current code, the lower and upper bounds will be instead 2.875.

Adapt test to this, and this allows to also ensure that we're always
returning a sorted and unique list of scales (which is useful as also
g-c-c can ensure that this is true).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:19:15 +02:00
Marco Trevisan (Treviño)
98f3f96978 monitor: Never return fractional scale values when NO_FRAC is used
We introduced META_MONITOR_SCALES_CONSTRAINT_NO_FRAC to get global scale
values however, this didn't work properly for some resolutions.

In fact it may happen that for some resolutions (such as 3200x1800) that
we did not compute some odd scaling levels (such as 3.0) but instead
its closest fractional value that allowed to get an integer resolution
(2.98507452 in this case).

Now this is something relevant when using fractional scaling because we
want to ensure that the returned value, when multiplied to the scaled
sizes, will produce an integer resolution, but it's not in global scale
mode where we don't use a scaled framebuffer.

So, take a short path when using no fractional mode and just return all
the applicable values without waste iterations on fractional values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:06:08 +02:00
Marco Trevisan (Treviño)
f6e2059a65 monitor: Replace some useless goto with clearer returns
There was no point to use goto in place of normal returns here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 15:54:03 +02:00
Marco Trevisan (Treviño)
4ca5a97ea8 monitor-manager: Only derive global scales supported by all monitors
When deriving the global scale from current monitor, we were just checking the
supported value by the primary monitor, without considering weather the current
scale was supported by other monitors.

Resolve this by checking if the picked global scale is valid for all active
monitors, and if it's not the case, use a fallback strategy by just picking the
maximum scale level supported by every head.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
1ab79c79a5 monitor-manager: Derive configured global scale using common value
When deriving the global scale from config, we need to ensure that the value
is matching all the monitor configurations.

If not, we should fallback to the normal scale value.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
7c87c1c24f monitor-manager: Check if all monitor scales are matching in global mode
When global scaling is set we need to ensure that all the requested scale
configurations are matching, otherwise we'd end up in a mixed setup that
we don't support in this scenario.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
1ac63fcd77 monitor-manager-xrandr: Use monitor to calculate scaling
In Xrandr we were caching the available scaling modes that were computed just
for the current mode, for each monitor, while we can actually reuse the
default implementation, by just passing the proper scaling constraint.

In monitor we need then to properly filter these values, by only accepting
integer scaling factors that would allow to have a minimal logical monitor
size.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:02 +02:00
Marco Trevisan (Treviño)
67eb60c19a monitor-manager: Pass the Logical mode when computing the monitor scale
In order to compute proper default scaling value we need to know if the
fractional scaling is enabled or not and thus if we're using a logical
mode or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 13:14:01 +02:00
Carlos Garnacho
414302fa82 backends: Promote g_debug() MetaStageImpl message to meta_topic()
We now have a META_DEBUG_BACKEND topic that can suit this bag of
assorted debug messages. Assign it to these, instead of plain
G_MESSAGES_DEBUG=mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:12:01 +02:00
Carlos Garnacho
dc6d3cead2 backends: Shuffle ClutterBackendX11 code into MetaClutterBackendX11
We have a Clutter implementation of the X11, just to subclass it in
our backends. Move the implementation entirely to src/backends/x11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
e77e88894b backends: Excise MetaStageView to its own file
It was implemented together with MetaStageImpl, move it to a separate
file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
d5c3c80dfe backends: Rename ClutterStage[View]Cogl API and types
Rename to MetaStageImpl and MetaStageView, so they are in line with
the rest of the backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
8f839b2f9c clutter: Move ClutterStageCogl[View] code to src/backends
This is now MetaStageImpl in backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
5785d8cde0 backends/native: Remove unused array definition
This array is a relic from the input code belonging to Clutter,
and is nowadays unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Jonas Ådahl
a2937a47bb onscreen/native: Change some g_debug() meta_topic()
g_debug() is inconvenient to use; change to meta_topic() with the 'kms'
topic. This makes it possible to enable valuable debug output at
runtime.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
d057762cdb device-pool: Add debug logging
Enabled by enabling the 'backend' debug topic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
b65555a958 renderer/native: Include error message in log entries
We had a GError handed to us, where we logged a warning, but didn't log
the message from the error. Do that so it becomes easier to find out
what might have failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:10:56 +02:00
Jonas Ådahl
58f053d437 drm-buffer/dumb: Return TRUE when init succeeded
Returning FALSE means it failed, but we returned FALSE even when it
succeeded, meaning it would never succeed.

Fixes: 10c4bc6e3f
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1880
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1888
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1932>
2021-07-16 17:18:55 +02:00
Jonas Ådahl
ff0afb186a context: Move 'replace-current-wm' tracking to the context
This move yet another scattered global static variable into the
context's control.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
0330ce1f15 context: Make the context own MetaWaylandCompositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
4be9bc9db4 stage/x11: Terminate using MetaContext instead of meta_quit()
Done for the nested backend when clicking the close button.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
7d116bee0f main: Move MetaX11DisplayPolicy to a new meta-private-enums.h
As with the compositor type enum, also have the X11 display policy enum,
as it's also effectively part of the context configuration. But as with
the compositor type, move it to a header file for enums only, and since
this is a private one, create a private variant meta-enums.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:36 +02:00
Jonas Ådahl
b1c643eeaa context: Make the context owner of the backend
There is still the `_backend` singleton still, as there are still the
`meta_get_backend()` that needs to work for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
23b79f33fa launcher: Remove open/close restricted file API
It has since some time been replaced with MetaDevicePool, and isn't used
by anything anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1929>
2021-07-13 12:19:14 +00:00
Ivan Molodetskikh
1116b14f38 backends/native: Get rendering and swap timings during scanout
Scanout doesn't go through the usual path of compositing and doing
eglSwapBuffers, therefore it doesn't hit the timestamp query placed in
that path. Instead, get the timings by binding the scanout buffer to an
FBO and doing a timestamp query on the FBO.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
5a0d3ed4dd backends/native: Remove unneeded NULL check
There seems to be no way to construct this type with an invalid bo.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
8c258d1de1 cogl: Add CPU swap time and GPU rendering query to CoglFrameInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
d10567ea3e clutter: Add vblank duration to ClutterStageView
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
2d939754b1 crtc-mode-info: Add vblank duration field
Only populated for KMS backed modes, as that's where it's relevant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
e40ff9d8b7 backends/native: Add meta_calculate_drm_mode_vblank_duration_us()
Computes the vblank duration from mode timings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Daniel van Vugt
9f492a0ee0 kms: Add fixed point formatting to MUTTER_DEBUG=kms printing
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:29:14 +08:00
Daniel van Vugt
b59c5386b9 kms: Add a trivial meta_fixed_16_to_double conversion function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:26:43 +08:00
Daniel van Vugt
ea75ea0b73 kms: Add an internal MetaKmsPropType to distinguish fixed point values
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:26:43 +08:00
Daniel van Vugt
d996319cf9 kms: Add a missing g_set_error on error
So the GError is not left NULL and then dereferenced.

Fix provided by Jonas Ådahl <jadahl@gmail.com>

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1878
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1925>
2021-07-09 16:26:11 +08:00
Jonas Ådahl
ce5a5789bb native: Release output device files that are unused
In order to make it possible to e.g. unload an unused DRM device, we
need to make sure that we don't keep the file descriptor open if we
don't need it; otherwise we block anyone from unloading the
corresponding module.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:10:30 +02:00
Jonas Ådahl
3c47661b78 egl: Add eglBindAPI helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
173d895d53 kms: Remove now unused API to get file descriptor
The last user switched to using MetaDeviceFile, so time to clean up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
10c4bc6e3f drm-buffer: Create from MetaDeviceFile instead of MetaKmsDevice
The DRM buffers aren't really tied to mode setting, so they shouldn't
need to have an associated mode setting device. Now that we have a
device file level object that can fill this role, port over
MetaDrmBuffer and friends away from MetaKmsDevice to MetaDeviceFile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
6613463f58 renderer/native: Decouple device file from MetaKmsDevice
Keep a private MetaDeviceFile instance for the GPU's managed by the
renderer. This is a step towards decoupling rendering from mode setting,
as well as on-demand holding of device file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
e567cb972d renderer/native: Get 'uses-monotonic' state from MetaKmsDevice
It's better suited to be handled by the MetaKmsDevice abstraction.

This eliminates the last caller of drmGetCaps() from outside
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
86c4369f41 renderer/native: Look up prefers-shadow cap via MetaKmsDevice
This eliminates the second last user of drmGetCap() from outside of
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
93f9c99cc5 kms/impl-device: Set universal plane client cap when opening file
This means it will be set again if the file is reopened.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
5502f956f5 device-file: Add tags
Tags are meant to make it possible for a device file opener to tag a
file if it has affected the state the file descriptor is in; e.g. if it
has enabled a DRM capability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
ceff2a93ca renderer/native: Create dummy offscreens if onscreens fail to allocate
This is less dramatic than aborting, and could in theory be a temporary
issue, so handle it by rendering into an offscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
db1d35c53d kms/mode: Recreate blob id each mode set
This simplifies the blob management and isn't that less efficient that
it matters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3c9ab768ec launcher: Remove now unused file management API
The open/close helpers for (maybe) restricted files has been replaced
with MetaDevicePool, so lets remove that functionality from here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
7ce266628e seat-impl: Open/close files via device pool
This replaces going through MetaLauncher to open/close restricted files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f6f9c093ba clutter/seat: Remove backend pointer
It was unused, and having a pointer to the MetaBackend in subtypes is
more useful, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
b4cf839e87 device-pool: Add way to open files read-only
Will be used by libinput's tablet device led device files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
a845a07a92 device-pool: Handle interrupted open()
Handle open() failing due to being interrupted by trying again until it
either succeeds, or fails due to some other error. This was an error
handling path taken when opening sysfs files; do the same here to not
potentially regress once we open sysfs files with the device pool.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3d882b6410 device-pool: Only fetch major/minor for taken devices
It's only when we take/release from/to logind we need these two
integers, so only retrieve them when that's done. Making this change
makes it possible to open devices that don't have these parameters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
e6421dc5da kms: Have the device impl open device files themself
This changes the way the KMS backends load; if we're headless, we always
use the dummy one and fail otherwise; in other cases, we first try the
atomic backend, and if that fails, fall back on the simple one.

The aim for this is to have the impl device open and close the device
when needed, using the device pool directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f3457b678c kms/device: Use device pool to open/close dri devices
This replaces the usage of MetaLauncher.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
ee8c252a8c native: Add device pool for tracking device file descriptors
This practically does the same thing as part of MetaLauncher, except
with added thread safety and caching. For example, opening the same file
a second time will return the same MetaDeviceFile, and only once all
acquired MetaDeviceFile's are released, will the file descriptor be
closed and control of the device released.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Carlos Garnacho
841ee0a227 backends/native: Fix logic error
ClutterInputDevice's get_group_n_modes() vfunc is meant to return
-1 for groups that are out of the known range, not within. Fix the
early return condition, and let the native backend return correctly
the number of modes for the given group.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1920>
2021-07-07 18:37:54 +02:00
Jonas Ådahl
8ca087fee9 kms/impl-device/simple: Pass the NULL to discard_page_flip() on shut-down
The second argument is an optional GError, not an impl device pointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1911>
2021-07-07 14:51:46 +00:00
Michel Dänzer
8de0771aad screen-cast/area-src: Add before-paint watch to catch scanouts
Scanouts are taken away after painting. However, when we're
streaming, what we actually want is to capture whatever is
going to end up on screen - and that includes the scanout
if there's any.

Add a before-paint watch that only records new frames if a
scanout is set.

Inspired by (and commit log mostly copied from) e6a13e5d57
("monitor-stream-src: Add before-paint watch to catch scanouts").

v2:
* Do not call stage_painted from before_stage_painted (Georges Basile
  Stavracas Neto)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1707
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1902>
2021-07-05 15:57:20 +00:00
Michel Dänzer
7bcbf6d5c7 screen-cast/area-src: Drop phase parameter from add_view_painted_watches
It was always META_STAGE_WATCH_AFTER_ACTOR_PAINT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1902>
2021-07-05 15:57:20 +00:00
Jonas Ådahl
1d7920872d kms: Gracefully handle page flipping direct scanouts failing
When drmModePageFlip() or drmModeAtomicCommit() unexpectedly failed (e.g.
ENOSPC, which has been seen in the wild), this failure was not handled
very gracefully. The page flip listener for the scanout was left in the
MetaKmsUpdate, meaning when the primary plane composition was later page
flipped, two page flip listeners were added, one for the primary plane,
and one for the scanout. This caused the 'page-flipped' event to be
handled twice, the second time being fatal.

Handle this by making 'no-discard' listener flag be somewhat reversed,
and say 'drop-on-error', and then drop all 'drop-on-error' listeners
when a MetaKmsUpdate failed to be processed.

Also for a "preserve" flagged update, don't ever trigger "discard"
callbacks just yet, as preserved updates are used again for the primary
plane composition, in order to not miss e.g. CRTC gamma updates, or
cursor plane updates, which were added separately.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1809
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1910>
2021-07-02 13:29:54 +00:00
Christoph Trassl
4b0fd9ab76 input-mapper: Fix (libwacom) tablet mapping to monitor
Remove early return when using libwacom, so guess_candidates returns
monitor candidates for those devices, too.

Additionally, changing the output of an input requires removing the
input from its current output first.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1712
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1887>
2021-07-01 06:36:33 +02:00
Jonas Ådahl
a0343b0abd renderer/native: Clear pending update list before repopulating
Before we did a simple copy, meaning the old list was overriden. Copy
was too eager, as it meant views without modes to set was waited for,
resulting in a dead lock. Instead only the relevant views were added to
the list for view which had pending updates needed. What was missed was
that the list was never cleared, meaning we just appended the new list
on top of the old, causing issues.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1846
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1843
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1844
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1895>
2021-06-12 21:09:55 +02:00
Jonas Ådahl
c0758c63b5 native: Properly ignore devices on init too
There is an udev rule marking whether a device should be ignored by
mutter or not, but it was only respected on hotplug events not on init,
partly defeating its purpose. Fix this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1892>
2021-06-09 19:21:44 +00:00
Jonas Ådahl
8478db96f9 renderer-native: Don't attempt to queue mode sets on non-onscreen views
A view is only a 'CoglOnscreen' if it ends up on a CRTC, thus needs a
mode. Other views are for virtual monitors, and require no mode setting,
so exclude them from the pending mode set list.

This avoids a dead lock when we'll be waiting indefinitely for mode
setting on a virtual monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>
2021-06-09 17:40:34 +00:00
Jonas Ådahl
2a81c6d393 screen-cast: Clean up sessions on 'prepare-shutdown'
However, leave the remote desktop screen cast sessions to the remote
desktop manager to close.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>
2021-06-09 17:40:34 +00:00
Jonas Ådahl
5c77b640d4 egl: Add helper for eglBindWaylandDisplayWL
Lets us untangle awkward Cogl setup dependencies.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
ebfeb106bc egl: Fly-by indentation fix
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
18d670e69f backends: Introduce MetaIdleManager
This object takes over the functionality of meta-idle-monitor-dbus.c,
meta-idle-monitor.c and meta-backend.c, all related to higher level
management of idle watches etc.

The idle D-Bus API is changed to be initialized by the backend instead
of MetaDisplay, as it's more of a backend functionality than what
MetaDisplay usually deals with.

It also takes over the work of implementing "core" idle monitors. The
singleton API is replaced with thin wrapper functions on the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1859>
2021-05-18 13:19:36 +00:00
Jonas Ådahl
389432de46 backend/x11-cm: Add missing chain-up to finalize()
Reported by @muktupavels.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1869>
2021-05-17 19:22:25 +02:00
Jonas Ådahl
b0a73f04b7 main: Move rect related macro to util-private.h
No reason that it should be in main-private.h, lets place it in
util-private.h. This also mean we can remove main-private.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
3bb6865912 stage/x11: Fix clutter backend variable naming
Being in backends/, `backend` tends to refer to a `MetaBackend`, so
avoid that naming convention for things that are not, e.g. clutter
backends.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
6558d43cd5 main: Let the X11 CM backend deal with selecting the display
It's specific to that backend, so do it there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
c9992a2953 main: Initialize Wayland just before MetaDisplay
Wayland support is not really a "backend" thing, it just lacked a better
place to store its instance pointer. Eventually we'll have a better
place, but prepare for that by initializing it together with the more
similar subsystems.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Pascal Nowack
25e2839339 screencast: Fix transform_position(), when using fractional scaling
Commit 64c9c9c5b0 fixed monitor
screencasting, when fractional screencasting is enabled.
For the remote desktop usage, NotifyPointerMotionAbsolute() submits
the new mouse pointer position in addition to the stream, where the
mouse pointer was moved.
When not using fractional scaling, the mouse pointer position is
correct.
With the usage of fractional scaling, the mouse pointer position is
wrong, as the scale of the position is applied two times.

Fix this behaviour, by reverting the second scale by dividing by the
logical monitor scale, when fractional scaling is used.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1808
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1867>
2021-05-17 16:11:47 +02:00
Jonas Ådahl
4a057535e7 remote-desktop: Close sessions on prepare-shutdown
When finalizing, the MetaDisplay instance will already be gone, so to be
able to gracefully tear down the clipboard integration, make sure to
close sessions before the display is closed, i.e. on prepare-shutdown.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1853>
2021-05-11 16:18:13 +00:00
kirbykevinson
64c9c9c5b0 clutter: Make stage capture support fractional scaling
This commit adds scaling support to clutter_stage_capture_into, which
is currently used when screencasting monitors. This is supposed to
fix graphical issues that arise when using fractional scaling.

Fixes #1131

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1855>
2021-05-08 22:27:52 +07:00
Jonas Ådahl
a49dc78396 remote-desktop-session: Don't recreate virtual device over and over
In 'remote-desktop-session: Create virtual input devices on demand' the
intention was to create input devices on-demand, but during a
refactorization of the code, instead the virtual input device was
recreated over and over. Lets fix that.

Fixes: a0af52caf0
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1799
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1858>
2021-05-07 13:16:27 +00:00
Jonas Ådahl
c4a73e7950 backend: Cleanup renderer on shutdown
This removes left-over views, and related resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
abf2f17387 renderer: Cleanup views in dispose
The views needs to be cleaned up before things cleaned up on finalize
that they depend on existing, so do so in dispose().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
558cb4fac3 backend: Cleanup cursor tracker on shutdown
It keeps references to cursors, and cursors keep references to DRM
buffers. In order to be able to clean up on exit, explicitly destroy the
cursor tracker on shutdown.

We can't rely on GObject reference counting, as gjs might hold onto a
reference until it's garbage collected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
f1a120ca36 backend: Clean up GPU instances last
Various things, e.g, the renderer, the stage, either directly or
indirectly depends on GPU objects being alive during tear-down. Make it
so, by moving GPU cleanup after the other cleaning. This will allow
tearing down a couple of more objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
22417b8a94 backend/native: Split up KMS shutdown in two phases
The first phase happens early, which discards pending page flips,
meaning the references held by those page flip closures are released.

The second phase happens late, after other units depending on the KMS
abstraction, have been cleaned up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
1af874fca6 kms/impl-device/atomic: Discard pending page flip datas on finalize
This is so page flip listeners can clean up any references attached to a
page flip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
7c924a562f kms/impl-simple: Clean up pending page flip datas on finalize
They might be holding on to references, so lets keep track of them and
clean up on finalize.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
2ed4e8c906 kms-impl/simple: Discard pending flips when finalizing
Removing the reference isn't enough, the callbacks needs to be invoked
so the buffer state machinery gets notified about the page flips being
discarded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4dec1f5ddf kms/impl-simple: Add helper for dispatching page flip datas
Instead of a invoke helper, and a clear helper, use a single dispatch
helper that does both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
c29f8c8b73 onscreen/native: Complete buffer swap also if we discarded
We already swapped the front buffer, and even if it didn't get
presented, we should still swap our representation of the state, to not
get into a confused buffer tracking state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4cb6033a27 onscreen/native: Simplyify notify_view_crtc_presented()
We don't really need to fetch the rendering mode, as we'd only ever call
a function that is effectively a no-op if render modes it isn't relevant
to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
b731eb29b5 kms: Remove idle flush callback when flushing
We might flush in other places than the idle callback; in this case, we
don't need the idle callback anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
023dd13d6c onscreen/native: Get backend pointer from GPU
If we clean things up during destruction, the singleton pointer to the
backend is already gone; get it from a better place instead, to not
crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
d077baadbb renderer/native: Destory EGL context on GPU data tear down
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Carlos Garnacho
63d969537f backends: Drop MetaInputSettings::seat property
This is now entirely unused, and it's dubious it should ever
be again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1849>
2021-05-05 19:07:26 +00:00
Carlos Garnacho
7ba1448e5b clutter: Move pointer a11y settings management from MetaInputSettings
All pointer a11y is a fabrication of Clutter backend-independent
code, with the help of a ClutterVirtualInputDevice and with some
UI on top.

On the other hand, MetaInputSettings is a backend implementation
detail, this has 2 gotchas:
- In the native backend, the MetaInputSettings (and pointer a11y
  with it) are initialized early, before the ClutterSeat core
  pointer is set up.
- Doing this from the MetaInputSettings also means another dubious
  access from the input thread into main thread territory.

Move the pointer a11y into ClutterSettings, making this effectively
backend-independent business, invariably done from the main thread
and ensured to happen after seat initialization.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1765
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1849>
2021-05-05 19:07:26 +00:00
Florian Müllner
d4a042b88d native: Fix compiler warning
cogl_context is only used when building with EGLDevice support,
resulting in an "unused variable" warning otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1852>
2021-05-05 10:32:28 +02:00
Jonas Ådahl
8989c42d40 backend/native: Add udev rule to ignore vkms devices
Virtual Kernel Mode Setting (vkms) is a virtual /dev/dri/card* device
not backed by any actual hardware. It's intended for testing purposes,
e.g. to run tests suites with a reproducable setup, or in continuous
integration pipelines.

Currently mutter don't have any tests that can run on top of vkms, but
will eventually get that. To prepare for the ability to do that, and
having said kernel module loaded without causing wierd issues with any
active session, add an udev rule that tells mutter to ignore any vkms
device.

Otherwise, when vkms is loaded, mutter would detect it, assume it's a
regular monitor, configure it as such, thus add a region of the stage
that ends up nowhere, which isn't very helpful. It might also conflict
with running actual tests that need to interact with vkms if the active
session has taken control of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
4af0f05603 udev: Move device tag detection into helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
eaf75f0706 udev: Don't only check 'platform' device for KMS modifier tag
Only checking the 'platform' device missed the tags added for i915 and
others, meaning the multi head configurations yet again started to fail
due to default modifier behavior is incompatible with multi many head
configurations.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1769
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1774
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1843>
2021-04-29 18:48:24 +00:00
Jonas Ådahl
c5e4d7db45 native: Invalidate CRTC gamma when resuming or leaving power save
With atomic mode setting, commits don't work when CRTCs aren't enabled,
which they aren't when we're power saving. This means the gamma state
fails to being update. To fix night light and for whatever other reason
gamma ramps was changed during power saving by marking the CRTC gamma
state as invalid when leaving power saving, as well as when resuming.
This means that the next frame will append the CRTC gamma state to the
KMS commit.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1755
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1835>
2021-04-29 18:04:04 +00:00
Jonas Ådahl
a0af52caf0 remote-desktop-session: Create virtual input devices on demand
This avoids triggering heuristics based on available input device types;
e.g. hiding the cursor when connecting a touchscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1800>
2021-04-29 17:24:08 +00:00
Jonas Ådahl
efd9af1183 output/kms: Add back common modes on non-single mode outputs
But this time, filter out modes that exceed a roughly calculated maximum
bandwidth. This should avoid e.g. setting a 60 Hz 4K mode, when 4K is
limited to 30 Hz, but lower resolutions supporting 60 Hz.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4155
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1834>
2021-04-27 16:12:18 +00:00
Carlos Garnacho
b4a7f35146 backends/native: Unref/unset key repeat GSource when cleared
This GSource is not being properly unref nor the variable holding it
cleared. This on one hand leaks the GSource memory, on the other hand
may trigger warnings in keyboard_repeat() as the source may be
(reentrantly) cleared, yet we don't exit early as
seat_impl->repeat_source is never NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1839>
2021-04-27 08:37:38 +00:00
Aaron Plattner
cf8efb5827 x11: Skip sending redundant CTM change requests
The X server generates a property change notification whenever it processes a
property change request, even if the value of the property is not changing. This
triggers libgdk to probe all display outputs, which can be slow depending on
which display driver and hardware are in use.

 #0  0x00007f8e4d5e91a0 in XRRUpdateConfiguration () at /usr/lib/libXrandr.so.2
 #1  0x00007f8e505208da in _gdk_x11_screen_size_changed (screen=0x5566e4b7e080, event=0x7ffe0e44bd60) at ../gdk/x11/gdkscreen-x11.c:1199
 #2  0x00007f8e505066d1 in gdk_x11_display_translate_event (translator=0x5566e4b5b110, display=0x5566e4b5b110, event=0x7f8dec001b20, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkdisplay-x11.c:1201
 #3  0x00007f8e505135a0 in _gdk_x11_event_translator_translate (translator=0x5566e4b5b110, display=0x5566e4b5b110, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkeventtranslator.c:51
 #4  0x00007f8e50512c97 in gdk_event_source_translate_event (event_source=0x5566e4b764a0, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkeventsource.c:243
 #5  0x00007f8e50512f57 in _gdk_x11_display_queue_events (display=0x5566e4b5b110) at ../gdk/x11/gdkeventsource.c:341
 #6  0x00007f8e50497644 in gdk_display_get_event (display=0x5566e4b5b110) at ../gdk/gdkdisplay.c:442
 #7  0x00007f8e5051301f in gdk_event_source_dispatch (source=0x5566e4b764a0, callback=0x0, user_data=0x0) at ../gdk/x11/gdkeventsource.c:363
 #8  0x00007f8e516ecf9c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
 #9  0x00007f8e51740a49 in  () at /usr/lib/libglib-2.0.so.0
 #10 0x00007f8e516ec503 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
 #11 0x00007f8e508ef5fd in meta_run_main_loop () at ../src/core/main.c:928
 #12 0x00007f8e508ef60e in meta_run () at ../src/core/main.c:943
 #13 0x00005566e450842a in  ()
 #14 0x00007f8e50649b25 in __libc_start_main () at /usr/lib/libc.so.6

When GNOME is animating a display fade when the night light feature is toggled
on or off, it sends a lot of change requests for the CTM property in the
process, which triggers a lot of display probes from gdk. In the case of the
night light feature, the CTM itself is not actually changing, so these requests
are redundant. Fix this by caching the CTM value in the MetaOutputXrandr and
skipping the server requests if it's not being changed.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3978
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1816>
2021-04-14 18:03:35 -07:00
Aaron Plattner
aa498dc27a x11: Rename atom to ctm_atom
This makes it clearer exactly what atom this is referring to.

Feedback from https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1816#note_1081588

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1816>
2021-04-14 18:02:00 -07:00
Jonas Ådahl
90eab42867 input-settings/native: Check mapping mode in input thread
When we set the matrix, we checked the device mapping mode in the main
thread, then passed along the calculated matrix to the input thread for
application. This could however be racy, as the mapping mode is managed
in the input thread. Fix this by sending the unaltered matrix, having
the input thread checking the mapping mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1806>
2021-04-14 19:16:22 +00:00
Jonas Ådahl
efde781747 input-settings: Make set_matrix() vfunc take const float array pointer
It shouldn't alter it, or take ownership, so clarify that by making it
constant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1806>
2021-04-14 19:16:22 +00:00
Jonas Ådahl
e956078052 kms/connector: Properly predict connectors turning off
The connector state wasn't properly predicted, as it earlied out if
the connector wasn't part of a mode set connector list.

Instead use the old CRTC to check whether it was used in any mode set,
and whether the connector was part of any new mode set, to predict
whether the connector is inactive or active.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1821>
2021-04-14 18:44:57 +00:00
Jonas Ådahl
4b78c8d84f renderer/native: Fix disabling monitors on otherwise unchanged device
When a device only had mode sets which turned off monitors, not enabling
anything, there would be no KMS update created and posted, and the
active monitors would remain on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1821>
2021-04-14 18:44:57 +00:00
Jonas Ådahl
14f6869381 onscreen/native: Make sure to reset the EGL context after dGPU blit
On hybrid graphics system, the primary path used to transfer the stage
framebuffer onto the dedicated GPU's video memory preparing for scanout,
is using the dedicated GPU to glBlitFramebuffer() the content from the
iGPU texture onto the scanout buffer.

After we have done this, we reset the current EGL context back to the
one managed by cogl. What we failed to do, however, was to reset the
current EGL context when we inhibited the actual page flip due to having
entered power save mode.

When we later started to paint again, Cogl thought the current EGL
context was still the correct one, but in fact it was the one used for
the iGPU -> dGPU blit, causing various EGL surface errors, and as a side
effect, eventually hitting an assert.

Fix this by making sure we reset to the Cogl managed EGL context also
for this case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
60a998bdbc onscreen/native: Release buffer before destroying EGLSurface
Destroying the EGLSurface frees the underlying container structs. When
we call gbm_surface_release_buffer() with a gbm_surface the EGLSurface
was created from, doing that after the EGLSurface was destroyed results
in attempts to access freed memory. Fix this by releasing any buffer
first, followed by destroying the EGLSurface, and lastly, the
gbm_surface.

This was not a problem prior to CoglOnscreen turning into a GObject, as
in that case, the dispose-chain was not setup correctly, and the
EGLSurface destruction was done in the native backend implementation.

This also changes a g_return_if_fail() to a g_warn_if_fail(), as if we
hit the unexpected case, we still need to call up to the parent dispose
vfunc to not cause critical issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
abbbe8f755 onscreen/native: Remove redundant EGLSurface cleanup
It's handled by CoglOnscreenEgl's dispose() implementation. It was
failed to be invoked in the past because the old non-GObject web of
vtables were not setup correctly, meaning the old generic EGL layer of
the CoglOnscreen de-init was never invoked.

When the type inheritence was cleaned up, this mistake was not cleaned
up, so do that now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
91117bb052 monitor-manager: Don't include generated code in header file
Meson doesn't seem to handle depending on generated headers, at least
when those headers are pulled in indirectly via another header file.

Luckily, we don't actually need to include the generated D-Bus boiler
plate in meta-monitor-manager-private.h, since the MetaMonitorManager
type no longer is based on the D-Bus service skeleton.

So, by moving the inclusion of the generated D-Bus header file into
meta-monitor-manager.c, we should hopefully get rid of the sporadic
build issues.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1682
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1819>
2021-04-14 16:22:24 +00:00
Jonas Ådahl
4c7a846dc8 output/kms: Only add common modes for single mode connectors
If there was only a single mode, add the common modes to provide options
to select other resolutions than the built in default. This avoids
issues where the connector listed multiple supported modes, but where
the common modes added would exceed the possible bandwidth. We could
probably make an attempt to filter out more modes from the common mode
list to avoid these issues, but it's likely that the driver already
lists suitable modes, meaning there is no point in adding the common
modes.

The common modes were initially added[0] to add modes to connectors with
a single bundled mode, so we shouldn't regress the original bug fix.

[0] https://bugzilla.gnome.org/show_bug.cgi?id=744544

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1232
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1824>
2021-04-14 15:15:52 +00:00
Jonas Ådahl
1f3c5bd316 kms/impl-device-atomic: Remove useless warning
No much use having a "g_return_if_fail (expr);" when we "if (expr)
return;" just above.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
dc35514fb4 renderer: Switch open coded list clearing to g_clear_list()
The same for MetaRendererNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
1a7f4d49f3 renderer/native: Remove unused function parameter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
a40b040cd6 seat-native: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
c822c799e4 kms/impl-device: Fix some argument naming mistakes
It was left-overs from when the MetaKmsImpl was not per device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
8867b11e19 launcher: Use gnome.gdbusgen and add prefix to generated API
This is more in line with how generated D-Bus boilerplate work, lets
stay consistent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
da3baba980 backend/native: Only disable KMS modifiers for i915
The intel DRM driver is known for not being able to handle multi head
setups when KMS modifiers are enabled, due to the implicitly selected
modifiers, while being more suitable for single head setups, cause
bandwidth issues when a certain number of monitor times resolution and
refresh rate is configured.

We don't yet support automatically finding a combination of modifiers
that work, and have because of this disabled KMS modifiers unless the
driver actually needs it.

Lets flip this configuration the other way around, changing the current
udev rule to decide wen to *disable* KMS modifier support, as it so that
only the Intel driver has this problem, while on the other hand, there
several drivers that requires modifiers to function at all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1792>
2021-04-14 07:14:24 +00:00
Carlos Garnacho
f92232ae4f backends/native: Check whether views are scaled via MetaViewportInfo
The input thread is in deep water doing the meta_is_*() check itself,
as that pokes the MetaMonitorManager managed by the main thread. Use
the getter from the MetaViewportInfo instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1793>
2021-04-13 10:32:14 +00:00
Carlos Garnacho
24dbfbfcf2 backends: Store whether views are scaled in MetaViewportInfo
We need to pass this info from the main thread, as that pokes the
MetaMonitorManager underneath. Store it in the MetaViewportInfo
so that the input thread can use this information.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1793>
2021-04-13 10:32:14 +00:00
Carlos Garnacho
1b1f852086 backends/x11: Add traps around XIPointerWarp call
This is left up to higher level code, which is not too nice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1807>
2021-03-29 13:52:31 +02:00
Jonas Ådahl
c3aa32987a backend: Destroy stage when destroying backend
Otherwise we leak it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
c5f699b8b3 backend: Destroy backend explicitly
This now ensures that calling meta_release_backend() destroys the
backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
c1810d6947 backend: Destroy clutter backend explicitly
Instead of relying on reference counting, destroy it with a destroy
function that calls run_dispose() on before removing a reference.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
ab600cafd2 backend: Destroy seat explicitly
Don't let any dangling pointer keeping it alive.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
6ecd911dd0 backend: Take over seat ownership from the clutter backend
Having the clutter backend owning and managing creates complication for
implementing graceful shutdown, so move it to the real backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
16b63451a3 input-settings: Don't eat up seat reference
MetaInputSettings unref:ed the seat on destruction, but it never ref:ed
it on construction, meaning it "stole" the reference from the rightful
owner. Make MetaInputSettings less of a thief.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
353cdf5273 clutter/backend/x11: Fix some variable naming convention
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
5aa43ec6c4 clutter/backend/native: Don't double manage stage implementation
The stage owns the "stage window", so don't double manage it in
MetaClutterBackendNative, as that means it'd be double-destroyed if the
stage would be destroyed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Olivier Fourdan
c016437857 backends/native: Sync LEDs when adding new device
Adding new input devices resets the LED state, make sure to restore it
to keep the LED and XKB state consistent.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1594
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1662>
2021-03-13 18:34:22 +00:00
Sebastian Keller
e77e454d34 backends/x11: Don't leak XRRGetPanning result
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1728>
2021-03-13 15:34:55 +00:00
Sebastian Keller
0e396ee7bb backends/x11: Unref keymap on finalize
Despite keymaps being relatively large, this does not really have much
of an impact, because there is only ever one and it's only leaked on
shutdown.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1728>
2021-03-13 15:34:55 +00:00
Sebastian Keller
7dd4ae339c backends/x11: Free button state mask allocated by XIQueryPointer
XIQueryPointer allocates the button state mask that we were leaking in
some places. We need to manually free this, because there is no XI
function that would do this for us.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1728>
2021-03-13 15:34:55 +00:00
Sebastian Keller
335a85ab84 backends/x11: Don't try to read more button states than there are
This was causing an (inconsequential) invalid read.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1728>
2021-03-13 15:34:55 +00:00
Sebastian Keller
330609e887 backends/input-settings: Don't bind mouse GSettings to ClutterSettings
On Wayland MetaInputSettings is part of the input thread. Connecting
a GSettings binding to the default ClutterSettings could result in the
change notification being emitted on the input thread. This then could
end up triggering the same handler from two different threads at the
same time. In the case of the ClutterText layout cache it was attempting
to unref the same layout twice, leading to a crash.

This can be avoided by simply removing the GSettings bind. This does not
cause changes to this setting to be missed by ClutterSettings because it
itself already sets up a bind.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1776>
2021-03-12 17:06:12 +00:00
Jonas Ådahl
634c948fc6 native: Add headless mode using surfaceless EGL context
This eliminates the need for any render node or device nodes, thus can
be used without any graphics hardware available at all, or with a
graphics driver without any render node available.

The surfaceless mode currently requires EGL_KHR_no_config_context to
configure the initial EGL display.

This also means we can enable the native backend tests in CI, as it
should work without any additional privileges.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
74ab2120fa screen-cast/session: Introduce RecordVirtual D-Bus API
The new RecordVirtual API creates a virtual monitor, i.e. a region of
the stage that isn't backed by real monitor hardware. It's intended to
be used by e.g. network screens on active sessions, virtual remote
desktop screens when running headless, and scenarios like that.

A major difference between the current Record* API's is that
RecordVirtual relies on PipeWire itself to negotiate the refresh rate
and size, as it can't rely on any existing monitor, for those details.

This also means that the virtual monitor is not created until the stream
negotiation has finished and a virtual monitor resolution has been
determined.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
2fbde28720 screen-cast/src: Allow for source with adaptive stream size
The area source, window source, and monitor source, currently set up the
stream size up front, given the area, maximum allowed window size or
monitor resolution, but for to be introduced sources, the size will be
negotiated using PipeWire, instead of specified via the D-Bus API. This
commit changes the internal source API to allow for this. There are
currently no users of this new behaviour.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
cf5836a6ec screen-cast/src: Add helper to close stream after dispatch
This is needed to close the stream from non-abstract sources during
PipeWire dispatch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
688280f82d remote-desktop/session: Handle unable to transform coordinate gracefully
There may be a race between the ability to turn stream relative input
coordinates and turning them into screen coordinates, due to the future
scenario where the entity backing a stream is created and managed ad-hoc
depending on PipeWire stream negotiations.

When an input event is sent during this time, drop it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
51ff51c854 tests: Add virtual monitor tests
The testing currently done is:

 * Creating a virtual monitor succeeds and gets the right configuration
 * Painting a few times results in the expected output
 * Changing the content of the stage also changes the painted content
   accordingly
 * Destroying the virtual monitor works as expected

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
d7ce6a47f8 tests: Add reference test framework
This adds a test framework that makes it possible to compare the result
of painting a view against a reference image. Test reference as PNG
images are stored in src/tests/ref-tests/.

Reference images needs to be created for testing to be able to succeed.
Adding a test reference image is done using the
`MUTTER_REF_TEST_UPDATE` environment variable. See meta-ref-test.c for
details.

The image comparison code is largely based on the reference image test
framework in weston; see meta-ref-test.c for details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
1818d21da5 Introduce virtual monitors
Virtual monitors are monitors that isn't backed by any monitor like
hardware. It would typically be backed by e.g. a remote desktop service,
or a network display.

It is currently only supported by the native backend, and whether the
X11 backend will ever see virtual monitors is an open question. This
rest of this commit message describes how it works under the native
backend.

Each virutal monitor consists of virtualized mode setting components:

 * A virtual CRTC mode (MetaCrtcModeVirtual)
 * A virtual CRTC (MetaCrtcVirtual)
 * A virtual connector (MetaOutputVirtual)

In difference to the corresponding mode setting objects that represents
KMS objects, the virtual ones isn't directly tied to a MetaGpu, other
than the CoglFramebuffer being part of the GPU context of the primary
GPU, which is the case for all monitors no matter what GPU they are
connected to. Part of the reason for this is that a MetaGpu in practice
represents a mode setting device, and its CRTCs and outputs, are all
backed by real mode setting objects, while a virtual monitor is only
backed by a framebuffer that is tied to the primary GPU. Maybe this will
be reevaluated in the future, but since a virtual monitor is not tied to
any GPU currently, so is the case for the virtual mode setting objects.

The native rendering backend, including the cursor renderer, is adapted
to handle the situation where a CRTC does not have a GPU associated with
it; this in practice means that it e.g. will not try to upload HW cursor
buffers when the cursor is only on a virtual monitor. The same applies
to the native renderer, which is made to avoid creating
MetaOnscreenNative for views that are backed by virtual CRTCs, as well
as to avoid trying to mode set on such views.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
e7ae1978f8 kms/connector: Don't use MetaConnectorType for connector type
Use uint32_t as that is what it is in the drm layer. MetaConnectorType
will be less suitable, as it will grow custom connector types that can't
be mapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
c8089f07a3 backend: Only show cursor when showing stage if pointer is present
This avoids showing the cursor when initially there is no pointer
device, nor touchscreen device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
b31a639378 backend: Add 'prepare-shutdown' signal
This will be used to avoid doing various work when we're shutting down,
e.g. react to changes triggering monitor reconfigurations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
47a6725207 monitor: Unset output monitor when disposing
When rebuilding the monitors (e.g. during hotplug), make sure to detach
the disposed monitors from any outputs before creating the new monitors.
While this isn't currently needed, as outputs are too being recreated,
with the to be introduced virtual outputs that are created for virtual
monitors, this is not always the case anymore, as these virtual outputs
are not regenerated each time anything changes.

Prepare for this by making sure that cleaning up disposed monitors
detach themself properly from the outputs, so new ones can attach
themself to outputs without running into conflicts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
b91740df0e crtc/kms: Make the 'transform-handled' API pass through MetaCrtcNative
In preparation for creating another non-KMS backend virtual CRTC.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
6aef4b3970 monitor: Attach to backend instead of GPU
Prepare for the future when a monitor isn't necessarily attached to a
mode setting device, which is practically what MetaGpu represents.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
19c4667d6a renderer/native: Downgrade warning to message about no hw-accel dGPU path
Warnings should be for errors, not non-optimal system configurations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
78ba1429c8 tests: Add headless native backend test
It doesn't do anything more than construct and tear down, but it's a
start.

Don't run the test as part of CI yet, as doesn't have the DRM devices
needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
1e2ef9023d backend/native: Hook up 'headless' mode to input and KMS subsystems
With this commit, it's possible to run mutter without being DRM master.
It's not yet possible to add virtual monitors, but one can for example
already add virtual input devices.

This currently doesn't try to hook up to any logind session, thus will
not have a real seat assigned. Currently it's hard coded to "seat0".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
ee4e78b100 kms: Add way to run without mode setting
Currently our only entry point for DRM devices is MetaKms*, but in order
to run without being DRM master, we cannot use /dev/dri/card*, nor can
we be either of the existing MetaKmsImplDevice implementation (legacy
KMS, and atomic KMS), as they both depend on being DRM master.

Thus to handle running without being DRM master (i.e. headless), add a
"dummy" MetaKmsImplDevice implementation, that doesn't do any mode
setting at all, and that switches to operate on the render node, instead
of the card node itself.

This means we still use the same GBM code paths as the regular native
backend paths, except we never make use of any CRTC backed onscreen
framebuffers.

Eventually, this "dummy" MetaKmsImplDevice will be replaced separating
"KMS" device objects from "render" device objects, but that will require
more significant changes. It will, however, be necessary for e.g. going
from being headless, only having access to a render node, to turning
into a real session, with a seat, being DRM master, and having access to
a card node.

This is currently not hooked up, but will be in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
739283d396 backend/native: Add getter for is-headless state
Will be used to determine how to run subsystems.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
0786f44b0b seat/impl: Make it possible to run without libinput
Add a flag to MetaSeatNative and MetaSeatImpl that tells it not to
attempt to create a libinput context. This is intended to be used when
mutter is to run headless, as in without any input devices other than
virtual ones.

Currently not hooked up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
59a10cd188 monitor-manager/native: Allow starting without outputs when headless
This will allow starting, then adding virtual outputs when needed e.g.
via the screen cast API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
34b0f9c124 kms/device: Move universal plane cap check to mode set init
This leaves only the atomic mode setting cap check before creating the
impl device, aiming to make it possible to create a non-mode-setting
MetaKmsImplDevice implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
7c25953c65 kms/impl-device: Make non-abstract types explicitly init mode setting
This is a step towards making it possible to add a MetaKmsImplDevice
that doesn't actually do any mode setting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
c4a422bc24 crtc/kms: Add an abstract MetaCrtcNative that sits under MetaCrtcKms
There is going to me another non-abstract MetaCrtcNative type, just as
there will be for MetaOutputNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
074d4f3418 output/kms: Make EDID be read via MetaOutputNative object
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
fd4ea67b27 native: Add abstract MetaOutputNative object
MetaOutputKms is made to inherit from this, but it doesn't do anything
special yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
3091cd89dc native: Rename MetaMonitorManagerKms to MetaMonitorManagerNative
We'll sooner or later start managing not only KMS backend monitors, but
virtual / remote ones too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
42d614f6fa backend-native: Add non-functional 'headless' mode
Make it possible to pass --headless as a command line argument in order
to turn the native backend "headless". This currently doesn't do
anything, but the intention is that it should not use logind nor KMS,
and work completely headless with only virtual outputs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Marco Trevisan (Treviño)
244e881912 backends/input-settings: Do not disconnect seat signals
This was added with commit c956193d, when we did connect to the seat
signals in input settings, but this is not the case anymore since commit
2c1558dd, so we can safely remove this call now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1763>
2021-03-10 16:18:25 +00:00
Marco Trevisan (Treviño)
8d008112b6 backends/x11: Pass the seat to the input settings
Input settings requires a valid seat in order to initialize the a11y
settings (since commit 1609d145), however in X11 we never set it and
even if we create the input settings early (as per commit 7547891a) we
never initialize the seat for it.

This leads to startup critical errors on X11:
 clutter_seat_get_pointer_a11y_settings: assertion
   'CLUTTER_IS_SEAT (seat)' failed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1763>
2021-03-10 16:18:24 +00:00
Suryashankar Das
b353b97512 backends/x11: Fix device hierarchy event handling for x11 backend
This commit adds the events created in the function
`meta_seat_x11_notify_devices` to the clutter events queue, which
are currently only added to the stage queue making the events not
being picked up by the `clutter_seat_handle_event_post` function.
This results in devices not getting added to the device-list of
`MetaInputSettings`.

Fixes the bug in which mouse and touchpad settings are not working in
the settings app during x11 session.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1767>
2021-03-10 15:44:46 +01:00
Marco Trevisan (Treviño)
012c0a18ef clutter: Ensure we always call handle_event_post for processed events
Since commit 2ceac4a device-related X11 events aren't processed anymore,
causing the input settings not to handle the devices.
This is due to the fact that we may never call clutter_seat_handle_event_post()
for such events.

While this is always happening for the native backend, it doesn't happen in
X11 because the events are removed from the queue as part of
meta_x11_handle_event(), and thus no event was queued to the stage by the
backend events source.

This also makes sure that the event post handler is called after the
event is actually processed, and not before an event is queued.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1564
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1769>
2021-03-10 13:56:54 +00:00
Marco Trevisan (Treviño)
ccbdf91776 backends/x11: Add dummy input-settings implementation
The nested backend may need to have an input setting implementation,
while we don't want to change the host settings (re-using an X11 input
settings) we can add a dummy implementation, until something more
complex is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1769>
2021-03-10 13:56:54 +00:00
Jonas Dreßler
3263084bcf backends/native: Translate right coords when creating motion events
With commit 7d78768809 we switched to
storing pointer coordinates in MetaInputDeviceNative instead of
ClutterInputDevice, and while we had set the coordinates of the
ClutterInputDevice in ClutterStage when queueing an event, we now set
the MetaInputDeviceNative coordinates in new_absolute_motion_event().

Here a small mistake snuck in: new_absolute_motion_event() only
translates the coordinates of the event, but we call
meta_input_device_native_set_coords() using the x and y variables
(which remain untranslated), so now the input device coordinates are no
longer translated.

Fix that by translating the coordinates of the x and y variables in case
we're we handling a tablet/stylus event instead of only translating the
event coordinates.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1760>
2021-03-08 15:33:36 +00:00
Jonas Ådahl
b962822f26 onscreen/native: Fix cast from CoglOnscreenEgl
It used the defunct platform pointer, meaning if this path would have
hit, it'd end up with a segmentation fault due to the platform pointer
being NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1759>
2021-03-08 15:02:30 +00:00
Jonas Dreßler
301198a9b8 Revert "backends: Use also a native cursor renderer for tablets"
With commit c985753442 the support for
multiple hardware cursors broke, but those were never properly supported
anyway as we usually assume there's only one hardware cursor around.

With the introduction of the KMS thread in the future, we'll only have
one KMS cursor that gets updated directly from the input thread. So
apart from the fact that it never really makes sense to have two cursors
visible, in this new model having multiple cursors won't work anyway.

So make the cursor we show for stylii a software cursor again.
Eventually the plan is to make the input device that's driving the KMS
cursor interchangeable, so that we can always use hardware cursors.

This reverts commit 165b7369c8.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1758>
2021-03-08 13:13:22 +00:00
Ivan Molodetskikh
cd9ae13465 backend: Pass stage view to cursor-painted signal
Will be used for presentation-time handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
f02f17808a onscreen/native: Send a symbolic flip on discard
Now that symbolic flips were introduced, it makes more sense to use them
instead of emitting a fake page flip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
47183a94eb cogl/frame-info: Add VSYNC flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
c96fb181ab cogl/frame-info: Add sequence
It will be used for the presentation-time Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4ba2df0bd2 cogl: Remove cogl_get_clock_time()
It's no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4810164885 cogl: Make presentation time always MONOTONIC
This concerns only the cases when the presentation timestamp is received
directly from the device (from KMS or from GLX). In the majority of
cases this timestamp is already MONOTONIC. When it isn't, after this
commit, the current value of the MONOTONIC clock is sampled instead.

The alternative is to store the clock id alongside the timestamp, with
possible values of MONOTONIC, REALTIME (from KMS) and GETTIMEOFDAY (from
GLX; this might be the same as REALTIME, I'm not sure), and then
"convert" the timestamp to MONOTONIC when needed. An example of such a
conversion was done in compositor.c (removed in this commit). It would
also be needed for the presentation-time Wayland protocol. However, it
seems that the vast majority of up-to-date systems are using MONOTONIC
anyway, making this effort not justified.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
d8606829c4 cogl: Report presentation time in microseconds
KMS and GLX device timestamps have microsecond precision, and whenever
we sample the time ourselves it's not the real presentation time anyway,
so nanosecond precision for that case is unnecessary.

The presentation timestamp in ClutterFrameInfo is in microseconds, too,
so this commit makes them have the same precision.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Ivan Molodetskikh
9d54ef3994 cogl/frame-info: Add HW_CLOCK flag
A flag indicating whether the presentation timestamp was provided by the
display hardware (rather than sampled in user space).

It will be used for the presentation-time Wayland protocol.

This is definitely the case for page_flip_handler(), and I'm assuming
this is also the case for the two instances in the GLX code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Akihiko Odaki
a6df6796dd backend/native: Add tests for refresh rate calculation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1737>
2021-03-05 14:37:48 +00:00
Akihiko Odaki
a41c30338f backend/native: Calculate refresh rate in double-precision
The old calculation was introduced to improve the precision
with commit c16a5ec1cf.

Here, I call the calculation as "revision 2", and the
calculation even older as "revision 1", and the new
calculation introduced with this commit as "reivion 3".

Revision 2 has two problems:
1. The calculation is mixed with fixed-point numbers and
   floating-point numbers.

To overcome the precision loss of fixed-point numbers division,
it first "calculates refresh rate in milliHz first for extra
precision", but this requires converting the value back to Hz.
An extra calculation has performance and precision costs.
It is also hard to understand for programmers.

2. The calculation has a bias.

In the process, it does:
refresh += (drm_mode->vtotal / 2);
It prevents the value from being rounded to a smaller value in
a fixed-point integer arithmetics, but it only adds a small
bias (0.0005) and consumes some fraction bits for
floating point arithmetic.

Revision 3, introduced with this commit always uses
double-precision floating-point values for true precision and
to ease understanding of this code. It also removes the bias.

Another change is that it now has two internal values, numerator
and denominator. Revision 1 also calculated those two values
first, and later performed a division with them, which minimizes
the precision loss caused by divisions. This method has risks of
overflowing the two values and revision 1 caused problems due to
that, but revision 3 won't thanks to double-precision. Therefore,
revision 3 will theoretically have the result identical with
the calculation with infinite-precision.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1737>
2021-03-05 14:37:48 +00:00
Jonas Ådahl
67acf99314 remote-desktop/session: Add CapsLockState and NumLockState properties
Will be used by remote desktop services that want to try to affect the
end result of these. We cannot let it set these directly, as these needs
to be done using virtual key events to not cause issues in all the XKB
state tracking, so remote desktop services try to deal with this
themself if they need to.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1342
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00
Jonas Ådahl
ce3fa3938a clutter/keymap: Make caps and num lock state properties
This removes the responsibility of tracking these from the backend to
the base object. The backends are instead responsible for calling the
function to update the values.

For the native backend, it's important that this happens on the correct
thread, so each time either of these states may change, post a idle
callback on the main thread that sets the, at the time of queuing said
callback, up to date state. This means that things on the main thread
will always be able to get a "new enough but not too new" state when
listening on the 'notify::' signals and getting the property value
after.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00
Jonas Ådahl
26912523fa native/seat-impl: Add helper for queuing main thread idle callbacks
Make the emit main thread signal use it. Will be used for calling code
on the main thread from the input thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00
Jonas Ådahl
adc6537917 remote-desktop: Add backend getter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00