3693 Commits

Author SHA1 Message Date
Jonas Ådahl
c11c654f0d screen-cast: Check whether modifier is implicit via helper
This avoids another native backend macro check.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3315
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
6dcc5e9a6b screen-cast: Query format modifiers via CoglRenderer
This moves some backend specific code to the actual backend.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/3315
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
2205181da8 cogl/renderer: Add API to get the implicit modifier
This allows avoiding having to depend on libdrm in places that are
otherwise independent of the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
01dcec31b0 cogl/renderer: Add way to filter modifiers by external-only
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
4bf04585d2 render-device/gdm: Make query format modifier filter loop more generic
This will allow adding more filters more easily.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
157c4af11e screen-cast/stream-src: Put type definition higher up
Type definition (G_TYPE_DEFINE..()) should be above all other code; only
type definitions etc should be above.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
e3f743facc cogl/renderer: Add API to query DRM format modifiers
Will be used to do explicit modifier buffer allocation via the Cogl API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
8509b74532 Make DMA buffer allocation format and modifier aware
This makes DMA buffer allocation in all layers take an array of possible
modifiers to allocate using, or zero modifiers if implicit modifiers
should be used.

The format hard coding previously used is moved to the screen cast code,
or in case of the (unused by default) shadow buffer buffers use the same
format as the the CoglOnscreen.

This also means the CoglDmaBufHandle and MetaDrmBuffer got taught how to
distinguish between planes. It's mostly unused in practice, so rather
untested.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
a4ddba44e9 onscreen/native: Move DRM modifier querying to MetaRenderDevice
It's only implemented by the GBM render device backend, and uses EGL,
thus does not distinguish scanout capable modifiers.

A filter enum is added to Cogl, since it'll be used via the Cogl API,
but the actual Cogl API isn't added yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Michel Dänzer
a8fe1fd625 crtc-kms: Use clutter_stage_view_schedule_update in _kms_set_gamma_lut
Instead of clutter_stage_schedule_update. There's no need to schedule
updates for stage views other than of the CRTC passed in.

As a bonus, this avoids a crash when a virtual monitor is removed.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3719
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4148>
2024-12-05 09:36:07 +00:00
Jocelyn Falempe
e44620c86e renderer/native: Add BGRX8888 format to the default list
On big endian machine, the native 32bits format is
DRM_FORMAT_BGRX8888, so add this format to the list.

Tested on a s390x VM, using virtio-gpu driver.

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4088>
2024-11-22 14:21:31 +00:00
Michel Dänzer
a516090014 backend/native: Handle NULL priv->startup_render_devices
In add_drm_device, calling g_hash_table_insert with NULL for the hash
table (which happens for any device added after mutter finished starting
up) would presumably just drop the key/value pointers on the floor,
leaking the string & MetaRenderDevice object referenced by them. Fixing
this should help for the referenced issue.

In meta_backend_native_take_render_device, g_hash_table_steal_extended
would presumably return FALSE (and log a warning), so the behaviour would
be "correct" by chance.

Issue: https://gitlab.gnome.org/GNOME/mutter/-/issues/3785
Fixes: 58c3734d78e9 ("backend/native: Prepare render devices earlier than KMS")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4136>
2024-11-20 19:38:58 +00:00
José Expósito
479bb6921d monitor-manager: Configure for lease monitors in ApplyMonitorsConfig
Add a new property to the ApplyMonitorsConfig D-Bus API allowing to set
a list of monitors for lease.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4121>
2024-11-15 14:58:32 +00:00
José Expósito
80a19134ff monitor-manager: Allow to check if config has a visible monitor
Add a new function, similar to meta_logical_monitor_configs_have_monitor()
that, in addition, checks if the monitor is visible.

Refactor, no functional change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4121>
2024-11-15 14:58:32 +00:00
José Expósito
c93e06696f monitor-manager: Return for lease status in GetCurrentState
Add a new property to the list of monitors returned by the
GetCurrentState D-Bus API indicating whether the monitor is available
for lease or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4121>
2024-11-15 14:58:32 +00:00
Sebastian Wick
8103301115 renderdoc: Integrate renderdoc into mutter
This allows to capture the next update of all stage views using
meta_backend_renderdoc_capture. Finer control over what stage view is
captured when can be added in the future.

Currently, renderdoc does not support the GL_OES_EGL_image extension
that we depend on for importing dma-bufs. This means that dma-buf
support is broken when mutter in launched with renderdoc.

One can hack up renderdoc to pretend to support GL_OES_EGL_image and
specifically EGLImageTargetTexture2DOES to restore the full mutter
functionality but renderdoc captures replay with a black rectangle where
those dma-buf buffers are being painted.

See:
https://registry.khronos.org/OpenGL/extensions/OES/OES_EGL_image.txt
https://registry.khronos.org/OpenGL/extensions/OES/OES_EGL_image_external.txt

It looks like the renderdoc maintainer does not want to merge support
for the extension: https://github.com/baldurk/renderdoc/pull/2845

We would only need support for dma-buf EGLImages which so it might be
possible to convince the maintainer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4061>
2024-11-15 14:04:35 +00:00
Sebastian Wick
f467a31d56 onscreen: Get device and window handle for onscreens
This adds a new method which returns the device and window handle for
onscreen framebuffers. Renderdoc uses those handles to target what it
is going to capture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4061>
2024-11-15 14:04:35 +00:00
Jonas Ådahl
aea9afa6ec kms: Default to high priority KMS thread scheduling
As mentioned in the previous commit, this will give us more or less the
same benefits as realtime scheduling, according to tests, without the
risk of SIGKILL. It's still possible to use realtime scheduling via an
env var, for experimentation.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3065
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3151
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3225
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3358
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3450
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3479
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3751
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7967
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4124>
2024-11-15 12:39:24 +00:00
Jonas Ådahl
3e024ae2d3 thread: Add support for requesting high priority scheduling
In contrast to realtime scheduling, this doesn't risk us getting
SIGKILL:ed when the kernel is doing busy looping in
drmModeAtomicCommit() for some reason, but will according to testing,
right now, give us more or less the same benefit when it comes to
dispatch lateness and commit lateness.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4124>
2024-11-15 12:39:24 +00:00
Jonas Ådahl
1a6c0ea3d0 thread: Make thread priority preference more generic
Either prefer "normal" or "realtime", via an enum, instead of a boolean.
Also make it configurable with an env var
`MUTTER_DEBUG_KMS_SCHEDULING_PRIORITY`, which can be set to either
`normal` or `realtime`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4124>
2024-11-15 12:39:24 +00:00
Jonas Ådahl
52aa84b3c3 stage: Make some cursor overlay function names more obvious
Overlays are always cursors, and "redraw overlay" doesn't communicate
that. Add "cursor" or "cursor overlay" to some functions to make it a
bit more obvious in a couple of places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4066>
2024-11-15 12:24:24 +00:00
Jonas Ådahl
67995f2730 screen-cast-stream-src/virtual: Remove redundant frame scheduling
We're posting damage; that'll mean a frame clock already being
scheduled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4066>
2024-11-15 12:24:24 +00:00
Jonas Ådahl
ca47be6ee9 screen-cast-stream-src/virtual: Reorganize hooking things up
There were things hooked up (connecting signals, adding stage watches),
but it was a bit disorganized, with "adding watches" doing more, and
"init callbacks" being a bit vague. Split things up to

 * setup view - hook up things that need to listen on a stage view
 * setup cursor tracking - track cursor positions, sprite changes
 * the rest - monitor changes etc

This also properly handles a race condition when we'll enable before the
idle callback creating the view from the virtual monitors is run.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4066>
2024-11-15 12:24:24 +00:00
Jonas Ådahl
7ff5334a3b screen-cast-stream-src/virtual: Stop inhibiting hw cursor
The hardware cursor support in the cursor renderer now acts on a per
stage view basis, so no need to inhibit the hardware cursor, it isn't
going to try to put a hardware cursor on a virtual CRTC anyway.

Instead use overlay inhibitation to decide whether an cursor overlay
should be painted or not. Inhibit the overlay when hidden/metadata, but
not when embedded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4066>
2024-11-15 12:24:24 +00:00
Jonas Ådahl
13e0b72026 stage: Don't queue overlay damage on views with overlays inhibited
This saves some unnecessary redraws with virtual monitors with
metadata/hidden cursor modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4066>
2024-11-15 12:24:24 +00:00
Mario Limonciello
ecbe4a5dad Prefer GPUs with built-in panels connected when selecting a primary GPU
Some laptops don't have the integrated GPU come earlier in the PCI topology
which means that when mutter enumerates the GPUs it may select the dGPU
as the primary.

In a laptop context, this is unlikely to work because the eDP panel can
only be actively connected to a single GPU at a time.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3746
Suggested-by: Jonas Ådahl
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4114>
2024-11-12 11:28:59 +00:00
Mario Limonciello
a280280cff backend/native: Refactor choose_primary_gpu_unchecked() to meet style
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4114>
2024-11-12 11:28:59 +00:00
Bilal Elmoussaoui
45296416df cogl: Move blit_framebuffer to it correct namespace
As it belongs into CoglFramebuffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4127>
2024-11-12 10:01:29 +00:00
Jonas Ådahl
4345ff6be4 input-capture/session: Start emulating new devices if already active
The client may not wait for devices to be created before enabling,
meaning we might activate the input capture session before the device
emulation is started. This would result in events silently being
dropped.

This helps with the flaky input-capture test case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4128>
2024-11-11 20:34:02 +00:00
Jonas Ådahl
91f1d3dab3 screen-cast-stream-src: Improve state change debug log entry
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4065>
2024-11-11 14:53:53 +00:00
Jonas Ådahl
ee41825f03 screne-cast-stream-src: Fix argument alignment
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4065>
2024-11-11 14:53:53 +00:00
Jonas Ådahl
bf758f349b screen-cast-stream-src: Track buffer sequence number
Use the 'seq' field in the spa_meta_header struct to track buffer
sequence numbers. This can be useful for predictable buffer tracking in
consumers, or for debugging purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4065>
2024-11-11 14:53:53 +00:00
Jonas Ådahl
cb702a7d21 screen-cast-stream-src: Use obj_props array for properties
As is convention.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4065>
2024-11-11 14:53:53 +00:00
Jonas Ådahl
bc9cc0135b screen-cast-stream-src: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4065>
2024-11-11 14:53:53 +00:00
Jonas Ådahl
2e068dd124 stage-view: Bump fake swap ready notify callback priority
This will become important when dispatching happens from a frame clock
driver, where the driver itself triggers from a GSource. If the driver
source has a higher priority, we'll risk dispatching before the frame
clock has returned to a state expecting to be dispatched.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4065>
2024-11-11 14:53:53 +00:00
Robert Obkircher
dbf1edefdf output-xrandr: Ignore duplicate modes reported by xrandr
This fixes an issue where xrandr reports the preferred mode of an
internal laptop display twice. This triggered an assertion that
crashed GDM, because meta_monitor_normal_generate_modes assumes
that the list of display nodes doesn't contain duplicate pointers
to the preferred one.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/2945>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3176>
2024-11-09 12:01:23 +00:00
Jonas Ådahl
efddf28925 eis-client: Remove brackets from a couple of if then branches
They were done this way to make capability configurations similarly
indented, but lets interpret the coding style strictly instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:09:52 +01:00
Jonas Ådahl
f63a2ce420 eis-client: Log received events
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:09:52 +01:00
Jonas Ådahl
c46db0a020 eis/client: Add touch support
Touch devices are handled very similarly to how absolute pointer
devices, by creating either shared or standalone devices depending on
what kind of monitor it's associated with.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:09:52 +01:00
Jonas Ådahl
6a1e1d74e5 eis-client: Handle unbinding device types
A EIS client might want to unbind a device capability; doing so should
effectively remove the device, which we didn't. Instead we always
created devices that a seat bind event had capabilities set for.

Fix this by explicitly keeping track of what is our "keyboard", our
"pointer", and whether we have a set of abs pointers, and don't create
duplicates if we already have devices created. For absolute pointer
devices, just keep track if we should have them, because we might have
many, or none, if we happen to be headless at the time being.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:09:17 +01:00
Jonas Ådahl
d2325f1507 eis-client: Configure shared and standalone abs pointer the same way
We don't need two separate configuration helpers, they do the same
thing. This will simplify making the viewport dependent device creation
more generic and reusable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:08:21 +01:00
Jonas Ådahl
ef3870e6aa virtual-input-device/native: Move away from _evdev suffix
For some reason the variable for the *Native subclass of
MetaVirtualInputDevice was suffixed with _evdev. Long long ago the input
backend in clutter was called "evdev", so might be because of that.
Anyway, lets rename to something more closely related, i.e. _native.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:08:21 +01:00
Jonas Ådahl
f76b59322a virtual-input/native: Properly forward 'finish' scroll event flags
This makes kinetic scrolling in e.g. GTK work.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:08:21 +01:00
Jonas Ådahl
59f40fe16c kms/update: Use mtk_region_get_box() instead of reconstructing the boxes
The underlying data structure of MtkRegion is pixman_region32, which
gives us boxes, not rectangles. Use the new get_box() API to bypass
going via rectangles to get the boxes directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4103>
2024-11-07 11:53:22 +00:00
Jonas Ådahl
c8fc1edea6 cogl/onscreen: Pass regions instead
Go one step further and pass regions. Sometimes the rectangles were
already a region, e.g. the swap-buffer case, and sometimes it still
potentially needs to pass through a rectangle array, e.g. damage with a
view transform.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4103>
2024-11-07 11:53:22 +00:00
Jonas Ådahl
3548faed03 cogl/onscreen: Pass rectangle arrays as MtkRectangle arrays
Only before passing to EGL does it need to become a int tuple array.
It's used in non-EGL places which now become more easy to read. While at
it, make use of the new (and tweaked) helper function for flipping
rectangles from "cogl space" to "GL space".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4103>
2024-11-07 11:53:22 +00:00
Jonas Ådahl
5deef6accb cogl/onscreen: Pass damage regions unflipped
The other similar API all operate with the assumptions that (0,0) is at
the top left, so lets make damage regions behave this way too. Add a
helper to flip the rectangles, to make it a bit more convenient. It'll
be used in more places in a follow up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4103>
2024-11-07 11:53:22 +00:00
José Expósito
55910e467f native/drm-lease: Handle monitors configured for lease
Follow the configuration stored in MetaMonitor and make connectors
configured as for lease available to Wayland clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4112>
2024-11-06 15:36:21 +00:00
José Expósito
63b7d958f2 kms/connector: Rename meta_kms_connector_is_for_lease()
Now that connectors can be configured as for lease, rename the function
to meta_kms_connector_is_non_desktop() to make clear that it returns
the hardware configuration rather than the user configuration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4112>
2024-11-06 15:36:21 +00:00
José Expósito
863b31cae9 output/kms: Add meta_output_kms_from_kms_connector()
Add a function that returns a MetaOutputKms (if any) from a
MetaKmsConnector.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4112>
2024-11-06 15:36:21 +00:00