1
0
Fork 0
Commit graph

12652 commits

Author SHA1 Message Date
Jonas Ådahl
a72ee3be0d cursor-renderer/native: Transform cursor sprite into output color state
This avoids making the cursor too bright when HDR is enabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:59:25 +02:00
Jonas Ådahl
b0e4d7c6ad cursor-sprite: Tag each cursor sprite with a color state
So far, always set a default color state. For Wayland cursors, it will
probably be more dynamic in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:59:07 +02:00
Jonas Ådahl
0bbb78f29e cursor-renderer/native: Pre-process cursor sprite with Cogl
Instead of using cairo for scaling and rotating cursors before putting
them on a plane, use Cogl. For now still download them back to the CPU
so we can place them on a dumb buffer, but can explore rendering to a
DMA buffer directly as a future improvement.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
20c7653d49 compositor-view/native: Don't scan out surface with color state mismatch
If the color state of a surface doesn't match the output, don't try to
scan it out, as it needs to pass through color state transformations to
look correct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
aaba08e5aa Set names of various Cogl pipelines
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
b7291cfe48 shaped-texture: Use color aware rendering
This looks at the color state it got from the actor on construction, and
the target color state from the paint context and generates (and caches)
color aware pipelines used for painting. One of the purposes here is for
mixing SDR and HDR content and painting to a HDR monitor. If HDR (or
optical blending) isn't activated, the produced shaders will be
equivalent to what we had before.

Also add some names to the piplines, as this helps identifying what
pipeline source is associated with what pipeline.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
6836a511db shaped-texture: Pass around paint context instead of Cogl context
In some of the places we need more context than just the CoglContext, so
prepare for that by passing around the paint context, which carries
this, everywhere instead. It won't be needed everywhere, but lets stay
consistent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:06 +02:00
Jonas Ådahl
d49bfbc6ec background-content: Fix annotation
The annotations were missing a #MetaDisplay argument.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:06 +02:00
Jonas Ådahl
4238512764 clutter: Introduce color transform aware pipeline cache
Color aware rendering needs shaders / pipelines that adapt to what
output they render to. For example if we want to render to a linear
BT.2020 intermediate framebuffer on one monitor, and a non-linear sRGB
direct target buffer on another, the shader for the same paint node or
content will depend on where they are going to be presented.

In order to help keeping track of what shader should target what
monitor, without having to regenerate them each time, introduce a
pipeline cache that knows how to handle differentiating between
transforming between different color state.

The cache is meant to handle caches for multiple pipeline users, where
each user might potentially want to keep track of multiple pipelines
itself. Lookup should be O(1), and in order to achieve this, separate
the cache into 3 levels.

The first level is the "pipeline group", where e.g. a ClutterContent
type allocates a group where it can store its pipelines. Each group has
a fixed number of "slots" where it can store a pipeline. Each slot has a
hash table where the key is derived from a color state transform, and
where the value is a CoglPipeline where the thame color state
transformation is expected to be handled.

A content will when painting know about its own color state, and the
target state it should render into, retrieve a cached pipeline for the
correct transform, or if the cache didn't have it, generate it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:06 +02:00
Jonas Ådahl
0c2fa8e9a8 clutter/stage-view: Add linear intermediate color space buffer
Allow compositing in a linear color space and do so either when forcing
it via the debug controls D-Bus API, or when the experimental HDR mode
is enabled.

This relies on paint nodes etc to actually transform everything into the
linear target color space, which isn't done yet, so enabling it right
now will cause a broken result. Yet, introduce this now, so that
painting can be fixed piece by piece.

Linear blending is automatically enabled on monitors where HDR is
enabled, as this makes it possible to use an linear color space when
blending content from different color spaces with different transfer
functions.

Linear blending requires extra precision, i.e. 16 bit per channel
in the intermediate buffer due how the values are distributed,
so only enable the experimental HDR mode if the Cogl context supports
half float formats.

By default, no intermadiate linear offscreen framebuffer is used.

To test, do e.g.

  ./tools/debug-control.py --toggle ForceLinearBlending

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:55:54 +02:00
Jonas Ådahl
beb3415d7e renderer/native: Use format from onscreen when creating offscreen
This means we'll get the same bit depth etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:51:30 +02:00
Jonas Ådahl
b275af95b7 clutter/paint-context: Add content and target color state tracking
The initial target color state is the color state of the stage view
being painted to. If we're painting to an arbitrary framebuffer, it's
currently hard coded to sRGB/electrical.

The content color state is not set on construction, but when starting to
paint, it's set to the color state of the stage itself. Whenever an
actor is painted, it'll set the color state to the color state of
itself. The intention is that offscreen rendering pushes a target color
state that causes painting to it to not necessarily be in the stage view
color state.

Pass color state with offscreen framebuffer, as this avoids hard coding
sRGB in the lower level bits of paint contexts. It's still practically
hard coded, only that it's derived from somewhere else (e.g. the stage
or window actor).

Nothing is actually using this yet, but will eventually.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:51:30 +02:00
Jonas Ådahl
d7bbc9712f clutter/color-state: Pass the ClutterContext when constructing
This will be used to cache pipeline snippets shared by multiple color
states.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00
Jonas Ådahl
8b425f4e85 clutter/actor: Make unsetting color state an explicit function
It makes things easier and more straight forward to handle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00
Jonas Ådahl
b538f4b999 shaped-texture: Take a ClutterContext when constructing
This will be used to fetch the corresponding pipeline cache.

This also means some minor reshuffling in MetaSurfaceActor to create it
after constructing the object.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00
Jonas Ådahl
6c34055cae tests/clutter: Add getter for context and backend
Add a getter for getting a ClutterContext, and another for getting a
ClutterBackend, so that these can be easily retrieved from test cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00
Jonas Ådahl
c4dc0bd755 backend: Add getter for ClutterContext
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00
Jonas Ådahl
af71749e75 clutter/color-state: Add transfer function
Another enum, defining SRGB gamma transfer function, and the PQ transfer
function. As with color spaces, add a 'default' that for now is treated
as if it was sRGB.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00
Jonas Ådahl
563fff9c9c colorspace: Rename 'unknown' to 'default'
An unknown color space isn't very useful to have, as there is not very
actionable what to do with it. Rename it to 'default'. Later it'll be
used to an implicit color space, which in practice will be treated as
sRGB.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00
Florian Müllner
906920cb33 compositor: Handle skipped transition in visual bell
Implicit transitions may be skipped, for example when the actor
isn't currently mapped.

Failing to check for that case not only results in a couple of
warnings, it also means that the "flash" actor is never destroyed,
and the window remains darkened.

Close: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7760
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3872>
2024-07-09 13:22:38 +00:00
Pascal Nowack
8e9d13aa3b remote-desktop-session: Always check fd index of g_unix_fd_list_append
g_unix_fd_list_append() duplicates the provided fd. If that fails, it
returns -1 as fd index and sets - if provided - the passed GError
accordingly.
However, currently, mutter does not check the return value (the fd index
of the appended fd) and thus passes an invalid fd list via dbus to the
remote desktop session user.

Fix this error by also checking the fd index. If the fd index is invalid
(< 0), simply pass the error message of the g_unix_fd_list_append() call
to the caller.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3871>
2024-07-04 13:29:52 +02:00
Sebastian Wick
6bbb04bbf4 Revert "backend/native: Let get_seat_id() handle all modes"
This reverts commit a3082b8eb3.

We don't find the VKMS device with this commit because it is on seat0
and not on META_BACKEND_TEST_INPUT_SEAT.

The other way around, i.e. returning seat0 in all cases also doesn't
work because *something* hangs if the default seat referrs to the real
seat0 instead of the nonesense META_BACKEND_TEST_INPUT_SEAT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3869>
2024-07-04 08:17:20 +00:00
Sebastian Wick
f767ccd7a8 tests/kvm: Create the status tempfile in the build dir
mktemp can create a tempfile relative to a directory passed in via -p.
It also uses the $TMPDIR variable for the same purpose. When the
template is specified via -t, $TMPDIR takes precedence over -p. When the
template is specified via a positional argument, -p takes precedence.

Since fec38819ac $TMPDIR is set via the
dbus runner which took precedence.

virtme-ng doesn't seem to share /tmp with the host system which results
in the exit status from the test in the VM not propagating back to the
test harness.

Fix that by making sure we always create the tempfile for the result in
the build directory.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3867>
2024-07-04 07:42:58 +00:00
Michel Dänzer
041a404ba0 wayland/actor-surface: Don't bail for Xwayland surfaces
Thawing Xwayland surfaces don't hit meta_window_actor_wayland_set_frozen,
so we need to sync actor state for them here.

v2:
* Guard META_IS_XWAYLAND_SURFACE by HAVE_XWAYLAND, fixes Wayland-only
  build.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3557
Fixes: ec5444f541 ("wayland/actor-surface: Don't sync actor state for frozen actors")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3862>
2024-07-02 19:39:27 +02:00
Michel Dänzer
92d60dbb08 backend/native: Define struct drm_plane_size_hint only if libdrm doesn't
Fixes error building against libdrm >= 2.4.122:

../src/backends/native/meta-kms-plane.c:67:8: error: redefinition of ‘struct drm_plane_size_hint’
   67 | struct drm_plane_size_hint {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/libdrm/drm.h:1025,
                 from /usr/local/include/xf86drm.h:40,
                 from ../src/backends/native/meta-kms-plane-private.h:20,
                 from ../src/backends/native/meta-kms-plane.c:21:
/usr/local/include/libdrm/drm_mode.h:866:8: note: originally defined here
  866 | struct drm_plane_size_hint {
      |        ^~~~~~~~~~~~~~~~~~~

Suggested by Jonas Ådahl.

v2:
* Use has_type. (Sebastian Wick)

v3: (jadahl)
* Bump meson requirement to 1.3.0 for compiler.has_type()

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3556
Fixes: 0ca933baec ("backend/native: Adds support for SIZE_HINTS Cursor Plane Property")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3848>
2024-07-02 14:09:21 +00:00
Carlos Garnacho
a1191c405d wayland: Remove dead code
This code is called from handlers connected to signals of a
MetaWindow. It cannot happen that the window will end up NULL
in these, so exchange with a g_assert() as we in fact expect
it to be non-NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3860>
2024-07-02 13:26:01 +02:00
Carlos Garnacho
949eb8b638 wayland: Use separate signal handlers to track pending activations
We cannot use a function with the same signature for signals with different
arguments, if we want to rely on the user data parameter. Separate into
two signal handlers calling the same function inside.

Fixes: b9ba34ac6f ("wayland/activation: Fix signal callback signature")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3860>
2024-07-02 13:26:01 +02:00
Bilal Elmoussaoui
bfd7f9d549 build: Split X11 server & client dependencies
Allows xwayland=true x11=false to be built with less dependencies
Also removes some unused x11 dependencies on the frame client & cogl

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3853>
2024-06-30 15:09:00 +02:00
Bilal Elmoussaoui
decf43d3b4 tests: Add missing wayland-client dependency
It was pulled indirectly from clutter, see next commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3853>
2024-06-30 15:09:00 +02:00
Bilal Elmoussaoui
820a7ad813 build: Allow building xwayland without x11
Co-authored-by: Jonas Ådahl <jadahl@gmail.com>
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/3553

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3853>
2024-06-30 15:08:55 +02:00
Corentin Noël
4134d12789 meta/plugin: Annotate dialog creation virtuals as return full
The two dialog creation virtual functions returned by these functions have to
be unreferenced by the caller (and are actually unreferenced in other places in
the code).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3790>
2024-06-29 12:04:31 +00:00
Carlos Garnacho
01444e803f clutter: Specify that input-only grabs are started inactive in API
Add the _inactive suffix, so that the state of these objects is clear.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3747>
2024-06-28 22:49:45 +00:00
Carlos Garnacho
8e5f3a1f83 clutter: Add API to create inactive ClutterGrabs, and activate them explicitly
This gives greater control to the callers on the place where a grab is being
activated, this may make a difference in the handling of crossing events
triggered through it, e.g. by having callers rely on having already obtained
a ClutterGrab prior to handling the resulting effects.

The "input only" grab has also been turned inactive by default, in order to
to have the ClutterGrab pointer available for checks at the MetaWaylandEventHandler
focus changing methods triggered through grab activation.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3463
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3747>
2024-06-28 22:49:45 +00:00
Jeffrey Knockel
5ba364a947 constraints: Allow resize of windows moved above screen
If the titlebar of a window has been moved above the screen by a user
via an unconstrained move, then any constrained user resize following
this move will cause the window to jump below the top of the screen or
cause other glitchy behavior.

This commit removes the constraint that the titlebar of a window must be
below the top of the screen for any resize that is both (1) triggered by
a user and (2) is a resize that affects only the left, right, or bottom
edges of the window.  This allows users to move a window partially above
the screen and then resize the window to be wider or resize the bottom
edge of the window to make it taller or shorter.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1206
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3764>
2024-06-28 20:49:10 +00:00
Jonas Ådahl
fbab46c880 display: Fix fallback MetaX11Display typedef
It was missing a _.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3851>
2024-06-28 18:51:10 +00:00
Jonas Ådahl
ae0b8a71dc x11-keybindings: Include config.h
This unbreaks building here. The compilation error was due to
MetaX11Display having an incorrect typedef in a now preprocessed out
part, which will be fixed in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3851>
2024-06-28 18:51:10 +00:00
Orko Garai
f214eb5134 Use byte offset for cursor_end/anchor value sent in preedit_string.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3845>
2024-06-28 17:23:30 +00:00
Michel Dänzer
94f3bbd94b wayland/surface: Can't send scale events with NULL surface->resource
The committed state can't have any children sub-surfaces either, so
just bail.

Fixes: ae403f2e94 ("wayland: Use new highest scale monitor tracking for fractional_scale_v1")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3552

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3849>
2024-06-28 16:17:05 +02:00
Bilal Elmoussaoui
b6fb8d87f4 x11/display: Keep track of stage input region
It makes more sense for Mutter to track that instead of gnome-shell
allowing gnome-shell to no longer have an ifdefed struct field

Context:
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3362#note_2151381

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
fd9957b81a keybindings: Move X11 bits to a separate header
Reduces the noise in terms of ifdef and makes it much easier
to spot which X11 bits are still mixed in the generic
keybindings file

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
beae45a060 build: Expose some features as variables in pkgconfig
Allows gnome-shell or other compositors to detect which features
were built when building libmutter automatically without having to
expose various build options themselves

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
5a6b0fcee3 build: Conditionally include xlib libraries for Meta gir file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
831b563a3c context/main: Disable X11 specific arguments
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
08a3c57aad build: Only install group.h header when built with x11
Also rename the header to file to be consistent with other x11-only
headers

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
c8ba4f1cda x11/group: Make various functions private
Nothing uses them and they are X11 only

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
f7131b2b2f keybindings: Guard X11 calls
This is absolutely not a great commit. As the keybindings could use a
decent
refactoring, see https://gitlab.gnome.org/GNOME/mutter/-/issues/3363 for
more details.
And as this is the last remaining item in getting a wayland-only build,
I think
it is a good 'comporomise' for the time being and makes it clear which
bits of code are
used in x11-only code paths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
33d490f472 stack-tracker: Add missing headers includes
Required when building without x11

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
0814d5029d x11: Introduce a meta-x11-types header
Used to define x11 only types. Future commits will introduce
a way for compositors to detect if they can use x11 features or not

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Bilal Elmoussaoui
50058b79d1 x11: Don't expose MetaFrame type
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3776>
2024-06-27 16:31:56 +02:00
Sebastian Wick
6ee7c2da7c tests/stacking: Do not wait after move action
Moving a window is a compositor action and happens immediately. Waiting
here is pointless. Make sure instead that the action happens immediately
by asserting the position.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3842>
2024-06-27 14:00:02 +00:00
Sebastian Wick
4e82896533 tests/stacking: Use wait_size for resizes
wait and wait_configure after a single resize is useless and a race.
Resize is a client side action which doesn't result in a configure and a
wait doesn't sync for a resize as well.

Sometimes the resize is paired with another action, such as maximize,
fullscreen or show. In those cases a configure will be generated and a
previous resize is accounted for.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3842>
2024-06-27 14:00:02 +00:00
Sebastian Wick
be46852292 wayland/dnd-surface: Chain up in the assigned vfunc
Commit e775052429 changed the code such that resetting the actor is done
when a surface role is assigned. The dnd surface assigned vfunc doesn't
chain up which means the code to reset the actor is never hit and the
dnd surface never shows up.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3540
Fixes: e775052429 ("wayland/actor-surface: Reset the actor on role-assignment")
2024-06-26 18:37:34 +00:00
Jonas Ådahl
422ee4515d Compile with -Wfloat-conversion
This means we'll get warnings whenever a floating point value looses
precision, e.g. gets implicitly casted to an integer. It also warns when
implicitly casting double's to float's, which arguably is less of a
problem, but there are no warning for just float/double to int.

This would have caught
https://gitlab.gnome.org/GNOME/mutter/-/issues/3530.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3822>
2024-06-25 20:48:24 +02:00
Michel Dänzer
fab78d951a wayland/actor-surface: Don't sync actor state for frozen actors
This ensures that sub-surfaces remain visible during the fade-out
animation of their window.

Fixes: be4bf8da9c ("wayland/surface: Keep applied sub-surface branch node linked up")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3508
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3840>
2024-06-25 13:35:46 +00:00
Michel Dänzer
03f3c18d27 window-actor/wayland: Sync actor state when actor is thawed
This is currently redundant, but will be needed with the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3840>
2024-06-25 13:35:46 +00:00
Carlos Garnacho
a48a149c61 backends: Use floating point checks in MetaViewportInfo
In these checks, it's an important detail to preserve subpixel information
in order to correctly determine whether the coordinates are inside or
outside a view.

Otherwise, small enough motion towards the left/top might get rounded
to 0, be seen as "inside the view", and the pointer coordinates be allowed
to escape the viewport constraints.

This was figured out by Pascal Nowack before me, with a difference of
minutes. Credit where credit is due.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3530
Fixes: 6c972546f1 ("mtk: Add Rectangle.contains_point")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3820>
2024-06-25 01:44:30 +02:00
Georges Basile Stavracas Neto
de2aac7a3d src/seat-impl: Keep device variable alive for longer
In meta_seat_impl_remove_virtual_input_device(), the 'device'
variable is first removed from MetaSeatImpl, then a "device
removed" event is generated with it.

The problem here is that, if this is the last reference of
'device', the removal from MetaSeatImpl will destroy it. Then
the freed variable will be used to create the "device removed"
event, which is a use-after-free situation.

Fix that by owning an extra ref to 'device' as long as the
function is executing. Do this by declaring a g_autoptr
variable with the extra ref. This g_autoptr variable is cleaned
up by the end of the function, which achieves the desired effect.

Spotted by Coverity.

CID: #1594046
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3835>
2024-06-24 12:04:08 +00:00
Bilal Elmoussaoui
6e1c761330 Remove unused variables
Detected through codeql

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3837>
2024-06-22 23:53:49 +00:00
Michel Dänzer
eb8c2f600a kms/impl-device: Use priv->path in _open_non_privileged_fd
This can work even if priv->device_file == NULL, e.g. with a secondary
GPU with no displays connected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3833>
2024-06-21 21:39:41 +00:00
Sebastian Wick
4eacf97678 wayland/surface: Send unmapped signal when the surface goes away
This was the intention anwyway but it didn't work properly because
GObject::dispose removes all signal handlers and we unmap surfaces in
WaylandShellSurface::finalize. Move all the unmanaging and unmapping to
the dispose vfunc where we can still run all the signal handlers.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3501
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3783>
2024-06-21 22:07:45 +02:00
Sebastian Wick
3e7b1d9cbd wayland: Handle unmapping surfaces
Right now the unmapped signal doesn't always fire which means we didn't
see a surface that's being unmapped in these code paths before. In
particular the resource, window and role can be gone. Handle those
cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3783>
2024-06-21 22:07:42 +02:00
Sebastian Wick
dbdc8dd958 wayland/activation: Keep around all pending activation reuqests
Instead of throwing away and not finishing a previous request, let's
queue up all activation requests until a window becomes mapped or
unmanaged.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3798>
2024-06-21 18:44:25 +00:00
Sebastian Wick
750459ddfe wayland/activation: Activate existing window with activations only
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3798>
2024-06-21 18:44:25 +00:00
Sebastian Wick
b9ba34ac6f wayland/activation: Fix signal callback signature
Parameter notify signals have a GParamSpec as second parameter.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3523
Fixes: c166b3fc5 ("wayland/activation: Apply xdg-activation request when window gets mapped")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3798>
2024-06-21 18:44:25 +00:00
Jonas Ådahl
b41d1437a7 tests/backend: Make test device removal function name consistent
The add function is add_test_device(), but the remove one was
remove_device(). Lets add a test_ to the former to make them consistent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
465af4b2d3 build: Make native backend mandatory for all tests
This allows us one less level of indentation of all the tests. It is not
entirely true, the X11 backend test case script can run without it, but
it isn't valuable enough to run without the native backend being enabled
to complicate building.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
a3082b8eb3 backend/native: Let get_seat_id() handle all modes
Instead of having get_seat_id() handle most cases, and then special
casing another case outside of it, let it handle them all, making all
users just able to call get_seat_id().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
16efcd4f9a Stop using xvfb-run in tests
Except the X11 backend test, it still needs an X server. Eventually we
can replace it with the equivalent that uses Xwayland, but that needs a
"scaled down" mutter that runs as the host compositor for Xwayland, that
doesn't expose anything on the session bus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
cb5b2dbaa7 tests/monitor-manager: Hook back up the 'handles_transforms' state
Now directly changing the CRTCs, where it'll be used via MetaCrtcNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
dfb56fcd65 x11/nested: Remove a vfunc that was only used by the test backend
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
bed5875f30 tests: Make the test backend derive from the native backend
It's constructed as a native backend headless backend, but uses a custom
monitor manager (based on MetaMonitorManagerNative) that creates a fake
monitor. Rendering is unconditionally done with the surfaceless
renderer.

The test devices used now use virtual devices, meaning some changes to
the tests to e.g. not set names, and not dealing with input devices
directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
e6fc515ea4 backend/native: Export output, crtc and monitor manager types
They will be derived from the test backend, which lives in its own
library.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
81ff760b10 backend/native: Move update_viewports signal connection to post_init()
This is where the viewports are updated, and so lets move connecting the
signal together with it. It also helps a future change to the test
backend where it creates a custom monitor manager.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
4b29d81a78 monitor-manager: Remove unused is_transform_handled() vfunc
This leaves some dead code in the test monitor manager, but lets leave
it there for now and actually hook that up to something again later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
c8d3465e83 tests/monitor-manager: Move out CRTC and output to separate files
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
b94a5de39d tests/monitor-unit: Don't double remove test touch devices
Test touch devices are autocleaned up, but if a test case explicitly
needs it to be removed at a certain point, make sure to also clear the
pointer so that it doesn't get removed twice.

Right now it's harmless, but in a later commit it'll expected to only
remove a device once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
5fee5da3d2 tests/monitor-unit: Remove trailing whitespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
5fc60eac9d seat-impl: Keep track of virtual input devices too
Virtual input devices too are dealt with inside the input thread, as
without this, things like touch mode won't get updated correctly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
54ba9448ed backend/native: Rename test mode to TEST_VKMS
A later commit will add another test mode mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
d9d2f2c06f monitor-manager/native: Make type derivable
Will be derived by the test backend to override some state for testing
purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Jonas Ådahl
4bdc51454d backend/native: Make type derivable
This will be used as the basis for the test backend, instead of the
nested X11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
2024-06-21 17:22:20 +00:00
Daniel van Vugt
5745b397f8 onscreen/native: Return the framebuffer by result, not parameters
`update_secondary_gpu_state_post_swap_buffers` decides what our front
buffer object will be. There is only one answer. So return it as the
function result instead of making the caller figure it out.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3830>
2024-06-21 15:46:48 +00:00
Daniel van Vugt
88b7f00085 onscreen/native: Remove frame parameter from flip_crtc
It's always equal to `onscreen_native->next_frame` and we can't eliminate
that copy so easily. Removing the parameter removes all ambiguity about
where the next frame will come from.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3829>
2024-06-21 15:10:37 +00:00
José Expósito
e4c749e5f2 native/kms-lease: Fix uninitialized autoptr
Spotted by Coverity.

CID: #1594038
Fixes: 4a5fcef38d ("native/kms-lease: Implement leasing out a set of connectors")
Reported-by: Carlos Garnacho <carlosg@gnome.org>
Link: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746#note_2147092
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3831>
2024-06-21 13:57:21 +00:00
Sebastian Wick
397c8763a4 tests/kvm: Update the kernel to prevent hangs with newer mesa
Starting in mesa 24.1 (good in 24.0.9, bad in 24.1.1), the current
kernel somehow manages to hang our VKMS based tests. Let's update the
kernel so we can bump the CI image without running into those hangs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3826>
2024-06-21 14:18:24 +02:00
Jonas Ådahl
8d5beea246 wayland: Add DRM lease manager
Now that all the required pieces to support DRM lease are in place,
expose the protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
a76708350f wayland/drm-lease: Handle DRM lease requests
When a client wants to lease DRM resources, it will attach the list of
connectors is wants to lease and then submit the request.
Once the request is submitted, destroy the DRM lease request object.

Co-authored-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
5e5d5f0ecb wayland/drm-lease: Update available devices
When a new device is connected, register a new global for it.

When a device is gone, remove the global. Upon receiving this event,
the client should destroy any matching wp_drm_lease_device_v1 object.

To destroy a wp_drm_lease_device_v1 object, the client must first
issue a release request. Upon receiving this request, send a released
event and destroy the object.

Co-authored-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
a8a8404cdd wayland/drm-lease: Update available connectors
When the list of connectors available for lease changes send
wp_drm_lease_device_v1.connector events for added connectors and
wp_drm_lease_connector_v1.withdrawn events for removed connectors,
followed by a wp_drm_lease_device_v1.done event.

Co-authored-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
fb08a597e1 wayland/drm-lease: Advertize initial connectors
After sending the drm_fd event, send zero, one or more connector events.
After all currently available connectors have been sent, send a
wp_drm_lease_device_v1.done event.

Co-authored-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
José Expósito
145de4df8d wayland/drm-lease: Send non-master DRM fd
Some time after a client binds to the wp_drm_lease_device_v1 global,
send a drm_fd event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
536c52bdb1 wayland/drm-lease: Advertise initial devices
Advertise one wp_drm_lease_device_v1 global for each DRM node.

Co-authored-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
José Expósito
4e4d88e537 kms/impl-device: Add function to get a non-master fd
Add meta_kms_impl_device_open_non_privileged_fd() that returns a
non-master file descriptor for a MetaKmsImplDevice.

It'll be required to implement wp_drm_lease_device_v1_send_drm_fd() in a
future commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Sebastian Wick
4a5fcef38d native/kms-lease: Implement leasing out a set of connectors
The manager keeps track of which connectors are leasable in general,
which connectors and resources are already part of a lease, and keeps
track of when leases get revoked.

When leasing out connectors, the required drm resources to drive the
connectors are included in the lease as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Sebastian Wick
647f45bfa6 native/crtc-kms: Don't assign leased primary planes to CRTCs
When a plane is leased, it is assigned to a CRTC which is leased. When
trying to find a primary plane for a modeset, skip the assigned planes
on leased CRTCs to avoid sharing the resources with the leased process.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Sebastian Wick
af8ef6cf02 native/crtc-kms: Unset config of CRTCs which are not part of a modeset
This allows us to keep track when primary and cursor plane assignments
on a CRTC are unassigned. With this commit, all planes which are
assigned are actually in use and can't be assigned to anything else.

We'll make use of that fact when we search for a leasable primary plane.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Sebastian Wick
46493a986b udev: Listen for lease events
Lease events are sent when drm leases disappear. This event will help us
track leased out drm resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
aaa8cefc25 kms-device-impl: Implement leasing, revoking and listing leases
The lease_objects function takes connectors, CRTCs and planes which are
turned into a drm lease. The resulting lease can be revoked with
revoke_lease. With list_lessees the currently active leases can be
queried.

Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
498310ec7c monitor-config-manager: Consider leased CRTCs assigned
With leasing, we will give another client control over connectors but
they also need a CRTC to drive them. Those CRTCs won't be available to
the desktop/monitor-manager.

Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
a001dbae59 kms: Add 'device-added' signal
This signals when there was a mode setting device added.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00