3693 Commits

Author SHA1 Message Date
José Expósito
f93e85f69b monitor: Keep track of the for lease status
Add a flag to MetaMonitor indicating if the monitor is available for
lease and store/update it from the monitor configuration.

Also, add unit tests validating that the configuration is applied and
that invalid configurations fail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4112>
2024-11-06 15:36:21 +00:00
José Expósito
406de0d6d7 monitor-manager: Add forlease config to monitors.xml
Allow to configure a list of monitors as available for lease in
monitors.xml.

The monitors available for lease, must be disabled as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4112>
2024-11-06 15:36:21 +00:00
Sebastian Wick
7a4a2ebd36 backend/x11: Make nested and cm subclasses final
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:54:35 +01:00
Sebastian Wick
e47379faad backend: Split dispose into dispose and finalize
Components which do not keep references to other components can be moved
to finalize and be available for longer which can help to shut down the
other components.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:54:35 +01:00
Sebastian Wick
8da99b69e2 backend: Add newlines to break the illusion of grouping
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:53:40 +01:00
Sebastian Wick
007058aac4 backend: Re-order backend component initialization
Move components without dependencies to the top and try to move
components with dependencies close to the component they depend on.

While this is an improvement, we really should start tracking and
documenting the actual dependencies between our components so that the
order here becomes comprehensible.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:52:43 +01:00
Sebastian Wick
2641d28a80 backend: Move stage creation to own function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:51:05 +01:00
Sebastian Wick
01f7ba70e9 backend: Move InputMapper creation and signal connection to function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:51:05 +01:00
Sebastian Wick
acc148ab7c backend: Move cursor tracker creation to function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:51:05 +01:00
Sebastian Wick
ad4f0b74d5 backend: Move constructed to initable_init and init_basic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:51:05 +01:00
Sebastian Wick
d289ef9434 backend: Move subclass initable to specialized init vfuncs
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:51:05 +01:00
Sebastian Wick
ed1bd6c005 backend: Move in_init from object init to initable_init
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:51:05 +01:00
Sebastian Wick
57bceb0759 backend: Split post_init into init_basic, init_render, init_post
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4018>
2024-11-06 13:51:05 +01:00
Bilal Elmoussaoui
a5be92e03d Use _once variant of g_[timeout_idle]
Nice helpers that were added in GLib 2.72, so safe to make use of as we
depend on 2.81.1 already.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4115>
2024-11-04 21:18:37 +00:00
Bilal Elmoussaoui
696dfaa124 clutter/threads: Remove helper functions
See previous commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4077>
2024-10-30 08:32:46 +01:00
José Expósito
a92ecd7373 onscreen/native: Fix fd error check
meta_drm_buffer_dumb_ensure_dmabuf_fd () return -1 on error, not 0.

Fix the error check.

Fixes: 84bde805fe34 ("native: Consolidate DRM buffer management to MetaDrmBuffer types")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4109>
2024-10-29 15:21:03 +00:00
Gert-dev
ceed33b68e onscreen/native: Use EGLSyncs instead of cogl_framebuffer_finish
cogl_framebuffer_finish can result in a CPU-side stall because it waits for
the primary GPU to flush and execute all commands that were queued before
that. By using a GPU-side EGLSync we can let the primary GPU inform us when
it is done with the queued commands instead. We then create another EGLSync
on the secondary GPU using the same fd so the primary GPU effectively
signals the secondary GPU when it is done rendering, causing the latter
to wait for the former before copying part of the frames it needs for
monitors attached to it directly.

This solves the corruption that cogl_framebuffer_finish also solved, but
without needing a CPU-side stall.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4015>
2024-10-22 19:24:27 +00:00
Gert-dev
9cb01597c9 egl: Add helpers to manage and wait for EGLSync objects
This adds meta_egl_create_sync and meta_egl_destroy_sync to be able to
create and dispose EGLSync objects, respectively, as well as
meta_egl_wait_sync to be able to wait for an EGLSync on the GPU.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4015>
2024-10-22 19:24:27 +00:00
Michel Dänzer
01249bd9e4 kms/impl-device: Don't merge KMS updates in process_mode_set_update
Based on the discussion leading to
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3999#note_2220825
this shouldn't be necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4069>
2024-10-19 14:40:45 +00:00
Michel Dänzer
118f294a48 onscreen/native: Don't set sync_fd for KMS update if secondary GPU used
The sync_fd represents only the primary GPU work.

Fixes: c2621eca151d ("onscreen/native: Set latest cogl sync_fd on KMS update")

v2:
* Use g_steal_fd. (Georges Basile Stavracas Neto, Sebastian Wick)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4060>
2024-10-18 14:54:56 +00:00
Michel Dänzer
64ce8b2071 onscreen/native: Rename create_timestamp_query to secondary_gpu_used
This describes the condition it represents, rather than what it's
currently used for.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4060>
2024-10-18 14:54:56 +00:00
Robert Mader
faf4dc21ea meta/stage: Replace \r\n with \n
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4093>
2024-10-18 15:01:46 +02:00
Robert Mader
129a71d0ca cursor-renderer/native: Deduplicate scale and transform code
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4093>
2024-10-18 14:58:03 +02:00
Robert Mader
e32a788179 cursor-renderer: Do pixel alignment a bit later
To avoid multiple identical if statements.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4093>
2024-10-18 14:57:46 +02:00
Robert Mader
72ac8c6987 cursor-sprite: Use early exits when invalidating
To make the code easier to follow. While on it, use `G_APPROX_VALUE`
where appropriate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4093>
2024-10-18 14:54:45 +02:00
Sebastian Wick
245dafe811 color-device: Set the color state to BT2020+PQ when HDR is forced
Sets the color state of all monitors to BT2020+PQ even if the monitor
isn't accpeting such a signal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4035>
2024-10-15 10:37:36 +00:00
Doğukan Korkmaztürk
6a0cc1371c stage-impl: Ensure that a sync object is created in headless mode
During an onscreen swap, the cogl_onscreen_swap_buffers_with_damage()
function ensures that the Cogl renderer creates a sync object every
frame. This sync object is later shared with the Wayland clients that
utilize the explicit sync protocol.

However, in headless mode, the function mentioned above is not called.
As a result, the sync object the Cogl renderer stores seems to be not
created. This causes cogl_context_get_latest_sync_fd() function to
return an invalid sync fd, causing Mutter to not be able to materialize
the sync timeline point that the clients wait for when the explicit sync
protocol is in use.

This change simply adds a call to the cogl_framebuffer_flush() function
to the offscreen swap path to make sure that there is a sync object that
can be shared with the clients, which will be signalled when all the
queued operations before the swap are completed.

Signed-off-by: Doğukan Korkmaztürk <dkorkmazturk@nvidia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4056>
2024-10-15 09:22:42 +00:00
Sebastian Wick
ef58572df7 edid: Use libdisplay-info's high-level API for populating EdidInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3602>
2024-10-15 09:10:21 +00:00
Sebastian Wick
c820a63b87 edid: Make libdisplay-info hard dep
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3602>
2024-10-15 09:10:21 +00:00
Michel Dänzer
3cf3d5d1c6 kms/crtc: Complain and bail if DRM mode info isn't valid
Otherwise meta_calculate_drm_mode_refresh_rate returns 0.0, which
results in non-sense refresh_interval_us.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3982 fixed that
happening before. This is intended to catch if it ever happens again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3980>
2024-10-09 18:51:35 +00:00
Christian Hergert
61c722881d clutter: Classify ClutterStageWindow
Previously ClutterStageWindow was an interface with only one base
implementation (MetaStageImpl) which others inherit from.

This just makes it a class so that we can use _GET_CLASS() API instead of
the costly (by comparison) _GET_IFACE() vtable lookups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4048>
2024-10-07 13:06:26 +00:00
Jason Gerecke
d7d92c68bd backends/x11: Avoid potential crash in pad_switch_mode
The meta_input_device_get_wacom_device function may return NULL, so
we should check it before use. I'm not 100% sure that the code as
currently written could reach here with a NULL wacom_device, but
that could change in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4070>
2024-10-04 20:49:58 +00:00
Kamil Szczęk
57812546b9 udev: Use current tags when looking for preferred primary devices
In some use cases there is a need to dynamically change the preferred
primary GPU, or get rid of the preference altogether. This is currently
not possible due to a change in udev introduced by systemd v247. This
version made the tags "sticky", meaning there is no way to remove them
once attached. When a tag gets removed, only the CURRENT_TAGS property
reflects that change, the removed tag will remain in the TAGS property.

This also bumps libgudev version to 238, since that version introduces
a function, which we need to get the current tags.

Related: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1562
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4055>
2024-10-01 11:18:13 +00:00
Joan Torres
fcbd2e3840 clutter/color-state: Add support for gamma TF
This TF can't be defined as a TransferFunction enum because it needs a
gamma_exp value too.

Add to EOTFType enum a new type: EOTF_TYPE_GAMMA.

With this new type, now EOTFs are unions that can have either
a TransferFunction enum or a gamma_exp.

Set gamma_exp as uniform.

Add the support of it in the color management protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4020>
2024-10-01 10:55:02 +00:00
Joan Torres
3b53f7cb6c clutter/color-state: Drop using default colorspace and default tf
Use the defaults explicitliy, which is SRGB for both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4020>
2024-10-01 10:55:02 +00:00
Joan Torres
eff17bf1b5 clutter/color-state: Encapsulate primaries, tf and luminance
These properties now are tagged unions:
- ClutterColorimetry:
    Can be from colorspace or primaries;
- ClutterEOTF:
    Can be from known tf or custom gamma exp (next commit);
- ClutterLuminance:
    Can be defined explicitly or derived;

Make the color management protocol use them too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4020>
2024-10-01 10:55:02 +00:00
Jonas Ådahl
86c9d602cd drm-buffer: Handle both XR24 and AR24 in legacy path
drmModeAddFB() doesn't take a format, but depth and bits per pixel.
These can be used to determine whether there should be an alpha channel
or not, and is roughly assumed to result in either XR24 or AR24 if one
passes 24 or 32 as depth, with 32 as bpp.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3926>
2024-09-23 22:21:58 +00:00
Jonas Ådahl
fd598e1868 kms: Add some debug logging for added planes/connectors/CRTCs
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3926>
2024-09-23 22:21:58 +00:00
José Expósito
45bf41bf94 wayland/drm-lease: Hold device fd when listing leases
In multi-GPU setups, when one of the GPUs is used to render the desktop
and the other one has all of their devices available for lease,
meta_kms_impl_device_list_lessees() can be called after the device fd
has been unhold.

Make sure to hold and unhold it in this function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4030>
2024-09-23 21:37:26 +00:00
Jonas Ådahl
c2273784ce backend/native: Log more about what pixel formats are attempted
This might help identifying pixel format related issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4016>
2024-09-23 21:27:09 +00:00
Joan Torres
95c9ba514d clutter/color-state: Add ClutterPrimaries
These primaries allow defining different colorspaces apart from the
known ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3948>
2024-09-23 20:33:18 +00:00
José Expósito
3199d4bbb8 wayland/drm-lease: Do not add connector twice on lease disappeared
lease_disappeared() was calling meta_drm_lease_disappeared() and
set_connectors_as_available().

meta_drm_lease_disappeared() emits the "revoked" signal, connected to
on_lease_revoked(), which marks the leased connectors as available by
calling set_connectors_as_available().

Therefore, calling set_connectors_as_available() again from
lease_disappeared() is redundant.

Remove the redundant call to set_connectors_as_available() and drop two
unused functions.

Fixes: fc44437876ee ("wayland/drm-lease: Withdrawn leased connectors")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3675
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4029>
2024-09-23 20:10:02 +00:00
Christian Hergert
1247452d19 gwakeup: Reduce wake-ups to only first item in queue
We only need to wake up the other side of the GAsyncQueue if we transition
from 0 to 1 item in the queue. Otherwise, we can be certain that the other
side has received a wakeup and will eventually flush the queue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4007>
2024-09-17 10:07:07 +00:00
Jonas Ådahl
af250506fb kms/impl-device: Queue result when discarding submitted update
The result will allow adequate state tracking to take place where the
update was posted.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3999>
2024-09-12 14:23:34 +00:00
Michel Dänzer
0d9fd1ead7 kms/impl-device: Destroy submitted update in disarm_all_deadline_timers
And rename it to disarm_all_frame_sources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3999>
2024-09-12 14:23:34 +00:00
Michel Dänzer
42290730e8 kms/impl-device: Merge in submitted update in process_mode_set_update
This has to be done for all CRTCs of the device, not only those with a
modeset, which requires merging in the pending updates for all CRTCs as
well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3999>
2024-09-12 14:23:34 +00:00
Michel Dänzer
b2761819e4 kms/impl-device/atomic: Leave implicit sync enabled for modeset updates
Preparation for next commit, which may merge multiple KMS updates with
sync_fds for modesets. Waiting for all sync_fds to signal before
processing the merged KMS update would be rather involved, for now just
leave implicit sync enabled for it. We're still relying on implicit sync
for modesets in general anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3999>
2024-09-12 14:23:34 +00:00
Peter Hutterer
756992c841 input-settings/native: Use the libinput matrix if we don't have one ourselves
If our calibration matrix (the "area") is the default, use libinput's
default matrix instead. Worst case this is the unity matrix anyway, best
case it uses the matrix set in e.g. the LIBINPUT_CALIBRATION_MATRIX
property.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2939
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3846>
2024-09-11 11:50:08 +00:00
nibon7
148ab84b83 Fix build when libwacom is disabled
Fixes: da828c2fc ("x11/input-device: Stop using deprecated libwacom API")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3996>
2024-09-06 21:37:07 +08:00
José Expósito
cf5508bdeb onscreen/native: Return the correct number of EGL modifiers
g_array_sized_new() creates a new GArray with a preallocated size, but,
after creation, the array length is still zero [1].

Store the modifiers in a EGLuint64KHR array and use g_array_new_take()
to create a new GArray with the correct size.

Because no modifiers were returned, gbm_surface_create() was used
instead gbm_surface_create_with_modifiers() on multi-GPU setups.

[1] https://docs.gtk.org/glib/type_func.Array.sized_new.html

Fixes: aec85281ba ("native/renderer: Retrieve the right modifiers set for each GPU")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3998>
2024-09-03 16:38:09 +00:00