1
0
Fork 0
Commit graph

12939 commits

Author SHA1 Message Date
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
Jason Gerecke
d46352b23f display: Do not crash attempting to display OSD for unknown Wacom device
The gnome-control-center has recently allowed unknown tablets to appear
in its UI. The UI provides a "Map Buttons" button that tries to open the
OSD, but if a device is not known there may be no Wacom object to actually
act on.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3722
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4059>
2024-10-04 20:38:55 +00:00
Joan Torres
0ed0367d74 wayland/color-management: Add support for bt.709 TF
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4062>
2024-10-03 11:41:25 +02:00
Joan Torres
f671fea7b9 wayland/color-management: Add support for NTSC primaries
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4062>
2024-10-03 11:41:24 +02:00
Joan Torres
1d4061f21e wayland/color-management: When sending colorspace info send primaries too
clutter_primaries_to_wayland made sense when there only existed
ClutterColorspace. Now that ClutterPrimaries also exist, it makes more
sense to change that func to clutter_colorspace_to_wayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4062>
2024-10-03 11:40:51 +02:00
Sebastian Wick
077eb80a8d gir: Correct usage of the closure annotation
Quoting Ebassi https://www.bassi.io/articles/2023/02/20/bindable-api-2023/:

    Whenever you’re describing a function that takes a callback, you
    should always annotate the callback argument with the argument that
    contains the user data using the (closure argument) annotation

    You should not annotate the data argument with a unary (closure).

    The unary (closure) is meant to be used when annotating the callback
    type

Recently gobject-introspection became a bit more strict with this and
that generated some warnings:

    Warning: Cogl: invalid "closure" annotation: only valid on callback
    parameters

This commit fix all the closure annotations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4058>
2024-10-01 15:39:18 +02:00
Sebastian Wick
b218fc5b7f tests/wayland-drm-lease: Let the test be skipped if not on a tty
By passing META_TEST_RUN_FLAG_CAN_SKIP instead of
META_TEST_RUN_FLAG_NONE.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4049>
2024-10-01 11:38:51 +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
2636ff7430 tests/wayland: Add color-management test
Right now multiple image_descriptions are created with different
parameters and are set to a surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4020>
2024-10-01 10:55:02 +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
Christian Hergert
2666aabde2 tests: Avoid g_assert() use in unit tests
This is aimed towards allowing g_assert() to be compiled out of
release builds by ensuring they do not affect the testsuite.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4011>
2024-09-24 14:51:43 +02:00
Jonas Ådahl
bce2790f7f Revert "window/wayland: Use scale for configured rect in configuration"
This caused https://gitlab.gnome.org/GNOME/mutter/-/issues/2616.

This reverts commit 2a62e690a2.


(cherry picked from commit 2ea002c0df)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4041>
2024-09-23 22:53:01 +00:00
José Expósito
562beb9314 tests/wayland: Add lease without connectors error test
Add a test that:
- Creates a client
- Creates and submits a lease without connectors
- Check that the compositor returns the correct error

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
973454dbdd tests/wayland: Add duplicated connector lease error test
Add a test that:
- Creates a client
- Creates a lease with a duplicated connector
- Check that the compositor returns the correct error

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
c804222e40 tests/wayland: Add connector lease with leased connector test
Add a test that:
- Creates 2 clients
- Leases a connector using the first client
- Tries to lease the same connector using the second client
- Checks that the first lease succeeded
- Checks that the second lease failed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
e6178fae6d tests/wayland: Add connector lease test
Add a test that:
- Creates 2 clients
- Leases a connector using the first client
- Checks that the first client receives a lease_fd event
- Checks that both clients receive a connector withdrawn event
- Finishes the lease
- Check that both clients have access to the connector

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
c366e32da6 tests/wayland: Add DRM lease device release test
Add a test that:
- Creates 2 clients
- Releases a device for each client
- Checks that releasing a device for one client doesn't affect the other
- Checks that an error is raised if a released client is used

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
59c4054c91 tests/wayland: Add event queue
Add an event queue to the DRM lease client that allows to check that the
compositor sent the expected events in the expected order.

For the moment, the event queue is used to check that the initial
connection to the compositor works as expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
97e50a7285 tests/wayland: Add DRM lease client basic test
Add the most basic possible test that checks that:
- The DRM lease protocol is available
- At least one device is advertised
- At least one connector is available for lease

Organize the code in a way that it is possible to created multiple DRM
lease clients at the same time as future tests will need this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
b4aba293b0 tests/wayland-test-utils: Add helper to start a client with args
Add a helper function similar to meta_wayland_test_client_new() that
allows to pass command line arguments to the test clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
bc8a376b81 tests/wayland: Add DRM lease test scaffolding
Add the required files to run DRM lease using the KVM/tty backends.

DRM lease tests need at least one connector available for lease. Instead
of adding the test to "wayland-unit-tests.c", add it to its own file and
set the environment variable MUTTER_DEBUG_LEASE_CONNECTORS=Virtual-1 to
make the only connector created by VKMS by default available for lease.

This commit doesn't add any tests, just the required files to start
adding them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +00:00
José Expósito
9c536939a1 wayland/drm-lease: Fix reference count cycle
MetaWaylandDrmLeaseDevice and MetaWaylandDrmLeaseConnector hold a
reference to each other.

In both cases, the reference count was increased. Do not increase the
reference count when lease_connector->lease_device is stored to break
the reference count cycle.

Fixes: fb08a597e1 ("wayland/drm-lease: Advertize initial connectors")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
2024-09-23 22:38:10 +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
cd65670f7a wayland/color-management: Support arbitrary primaries
The colorspace could be defined only with known colorspace names.
Now it can be defined with arbitrary primaries too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3948>
2024-09-23 20:33:18 +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
Joan Torres
c05e3e74ac wayland/single-pixel-buffer: Use higher precision pixel formats
The single pixel buffer allows setting colors with 32 bpc.

Attempt to use pixel formats that allow higher precision than BGRA_8888.

First attempt to use half float format, fallback to ABGR_2101010 and
finally fallback to BGRA_8888.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3913>
2024-09-23 20:21:38 +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: fc44437876 ("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
Jonas Ådahl
3bc3740a9e wayland/tablet-tool: Fix grabbing tablet devices
The NULL check was inverted, meaning we'd grab with no leader device.
That meant updates coming from the what-should-have-been leader device
getting lost because incorrectly being classified as non-leader of
the grab.

Fix this by only allowing to grab if we have a device, and always mark
the current tool device as the grab leader.

Fixes: e4004a7c4f ("wayland: Use the tool's current_tablet device instead of caching it")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4033>
2024-09-19 07:26:54 +00:00
Joan Torres
e8a9d3a68e wayland/color-management: Fix SIGSEGV on dispose
meta_wayland_color_management_dispose func is only called when the compositor
is shutting down, in that case the wl_globals are already automatically removed.

meta_wayland_color_management_dispose calls wl_global_remove again,
this makes a SIGSEGV when color_management is enabled and mutter is being
shut down.

Stop calling wl_global_remove to fix it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4032>
2024-09-17 11:46:56 +00:00
Christian Hergert
971bf15f26 x11: Reduce chances XPending does recvmsg() syscall
XPending() will do a recvmsg() syscall if there are no items in the queue.
In most cases, this is unnecessary because we know that there is data to be
read of the connection or there are items already read which simply need
to be processed.

Discovering both of those conditions can be done without recvmsg() in the
hot paths.

Before this path, every iteration of the main loop had the potential to
submit a recvmsg() syscall. This reduces that overhead drastically.

XFlush() on the other-hand knows if it needs to write data or not and will
do no IO in the case the buffer is empty.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3653
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4006>
2024-09-17 11:12:41 +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
Michel Dänzer
18eb1be491 window/x11: Use g_autoslist (MetaStrut) in meta_window_x11_update_struts
The wrong type resulted in a crash when returning from the function,
because g_slist_free was called instead of g_free for the old_struts
list data pointers.

Fixes: e005d035c0 ("boxes: Define cleanup function for MetaStrut and use auto-pointers")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4028>
2024-09-16 15:11:55 +02:00
Jonas Ådahl
e69e4fa6db Revert "wayland: Check focus surface to set a pointer cursor"
This reverts commit b35129db61.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3541
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4026>
2024-09-14 20:21:32 +00:00
Carlos Garnacho
69b6e7ead6 wayland: Save session state in the background in a delayed manner
Track toplevels being saved, and save state some time after. This
will make session state somewhat remembered on shell crashes, as
long as there was time to snapshot the data in disk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
8b9bf6b051 core: Add async save method to MetaSessionManager
Allow saving the session gvdb file in the background, with as little
overhead in the main thread as possible. We still need to serialize
all created/deserialized MetaSessionState to a GVDB hashtable there,
in order to avoid these being poked from the async task thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Jonas Ådahl
8468888508 tests: Add some basic tests for XDG session management
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
6c3c17daa6 tests: Make test context able to create a session manager
And create an empty one when asked for it. This session data is not
saved on disk, except for the purpose of creating an empty file FD.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Jonas Ådahl
74ce36f323 wayland: Implement the XDG session management protocol
The xdg_session_manager_v1 global interface is the generator
of xdg_session_v1 objects for clients. These will notify of an
unique ID that can be used for future instantiations.

Once a xdg_session_v1 object is obtained, toplevels can be added
to be managed by it, and clients may get a hint about whether the
toplevel was restored to a saved state.

Changes by Carlos Garnacho: Integrate with MetaSessionManager core
object. Flesh out event emission of xdg_session_v1 and
xdg_toplevel_session_v1 objects, handle sessions being
replaced/deleted.

Changes by Sebastian Wick:
* make lifetimes of xdg_sessions entirely determined by the wayland and
  handle its destruction via the signal
* fix session destruction vs deletion
* do not drop refcount of replaced session state temporarily to make
  sure the replacing session keeps the state
* disconnect signals of destroyed and replaced sessions
* disconnect window-unmanaging signal handler for
  MetaWaylandXdgToplevelSession
* call wl_resource_destroy in xdg_toplevel_session_remove to make it a
  destructor
* handle session being destroyed before topevel-sessions
* handle the toplevel going away before the topevel-sessions

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
2074e4e146 core: Add debug control setting for session management
We will at the moment want it guarded behind a setting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
5c30483739 wayland: Add XDG Shell glue to cater for already restored windows
Make the restored state prevail, instead of letting the client still
pick an initial size.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Jonas Ådahl
4a3eb2f992 build: Include a private copy if the session management protocol
This is still being discussed upstream, so will be included as a private
protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Jonas Ådahl
6fa3a91325 wayland: Add MetaWaylandXdgSessionState
This object is a windowing-specific implementation of MetaSessionState,
allowing to save window state for toplevel surfaces of a Wayland client
using the xdg_session_management_v1 protocol.

This object is detached from windowing logic itself, and will be
integrated in later commits.

Changes from Carlos Garnacho: Integrate state serialization with
MetaSessionState and MetaSessionManager.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
920de400f5 core: Make MetaContext manage the MetaSessionManager singleton
Make this core object own the MetaSessionManager, for the window management
code to access.

At this level, we will be able to integrate with systemd notification
system, and use systemd fdstore to keep the mapped memory warm for
us for the case of soft reboot. This is at the moment not implemented
here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
fa9c70a1d4 core: Add MetaSessionManager
This core object will be the manager of "client sessions", allowing
the windowing-specific paths to generate MetaSessionState objects to
track their clients.

This object is unused at the moment, and will be integrated in later
commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
c6acf3aef5 core: Add MetaSessionState
This is an abstract base class to implement a "client session",
carrying the accounting of the windows, and allowing to serialize/read
their state into a Gvdb table.

Since different windowing backends may require slightly different
data to be saved for each window, this is meant to have windowing-specific
implementations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00