1
0
Fork 0
Commit graph

12652 commits

Author SHA1 Message Date
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
José Expósito
7784c0d0aa kms/connector: Allow to force connectors for lease
Add an environment variable (MUTTER_DEBUG_LEASE_CONNECTORS) that allows
set a ":" separated list of connector names as available for lease.

The names of the connectors can be found in "/sys/class/drm".

To illustrate it with an example, the names of the connectors and its
status can be fetched with this command:

  $ for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n "${con#*/card?-}: "; cat $p; done
  DP-1: disconnected
  DP-2: disconnected
  DP-3: disconnected
  DP-4: disconnected
  DP-5: connected
  DP-6: connected
  DP-7: disconnected
  eDP-1: connected
  HDMI-A-1: disconnected

And, to set "DP-5" and "DP-6" available for lease, the environment
variable can be set like:

  MUTTER_DEBUG_LEASE_CONNECTORS=DP-5:DP-6

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Jonas Ådahl
9da43a3420 kms/connector: Add 'for-lease' getter
This is intended to be used to filter out what connectors will be
available for lease, i.e. non-desktop ones.

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
Sebastian Wick
9e6f8a250f monitor-config-manager: Use autoptr in more cases
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
2024-06-20 09:31:02 +00:00
Pascal Nowack
0dd4080509 backends/screen-cast-stream-src: Always initially set buffer stride
When mutter creates a dma-buf buffer for screencasting, the buffers
stride will, among other attributes, also be defined.
However, mutter currently only sets the buffer stride, when actually
recording a frame, but not when adding it.
This behaviour disallows screencast consumers (clients) to already
import the respective buffer (i.e. for Vulkan creating a VkImage for the
dma-buf image), as the stride is not yet communicated to the client.

Since the stride won't change after adding the respective buffer,
directly set the buffer stride, when adding the PipeWire buffer. This
allows screencast consumers (clients) to do optimizations in their
encoding paths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3827>
2024-06-20 07:14:09 +02:00
Jonas Dreßler
e0c1dff45c Revert "tests/clutter/conform: Wait for stage update right after showing stage"
This turned out to not be needed, see the preceding commit for the proper
fix.

This reverts commit 530659c643.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3807>
2024-06-19 13:54:15 +00:00
Jonas Dreßler
76f689195e tests/utils: Actually block while waiting for input thread flushing
meta_flush_input() creates and runs a main loop in order to block until the
input thread has flushed all its events. This main loop is created on the
default main context though (NULL is passed to g_main_loop_new()), which
means that while the main loop runs, the default main context is active (aka
stage updates will happen).

This causes an issue with tests, specifically when there already is a stage
update queued before running meta_flush_input(): meta_flush_input() will
(as expected) block until the input thread flushed all its events to the
main thread. But while that is happening, the main thread will be doing the
stage update that was already queued, without the new events (the input
thread is just starting to flush those). Then meta_flush_input() returns,
and in our test we see that the stage has been updated, except it wasn't
updated with the latest events. The test now continues and fails.

To fix the issue, make meta_flush_input() truly blocking, so that it only
flushes the input thread, but doesn't drive the global main context while
waiting for that. After the flushing is finished, tests must now manually
iterate the main context themselves to ensure that a stage update happens.

This breaks a few stacking tests, because "move_cursor_to" and "click" use
meta_flush_input() internally. For those commands we now need to dispatch
a stage update afterwards.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3807>
2024-06-19 13:54:15 +00:00
Bilal Elmoussaoui
8b2aa05103 cogl: Remove no longer useful headers
I suppose they were useful at times when cogl was a separate library
where you could use cogl- but that is no longer a thing

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3813>
2024-06-18 13:32:13 +00:00
Jonas Ådahl
2e2c54e356 onscreen/native: Track next and presenting buffers via ClutterFrame
Let the ClutterFrame (or rather MetaFrameNative) own both the scanout
object and the framebuffer object, and let the frame itself live for as
long as it's needed. This allows to place fields that is related to a
single frame together, aiming to help reasoning about the lifetime of
the fields that were previously directly stored in MetaOnscreenNative.

Also take the opportunity to rename "current" to "presenting", to make
it clearer that frame's buffer is what is currently presenting to the
user.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3799>
2024-06-18 10:24:40 +00:00
Sebastian Wick
42102006b0 tests/wayland-test-clients: Reuse surface for XDG toplevels
It's possible to destory the xdg_toplevel and xdg_surface which removes
the surface role and then re-use the surface on a new toplevel.

Mutter used to not create new SurfaceActors for the new toplevel which
were then shared between the old and new toplevel. This happens because
the actors can stay around after the wl resource is destroyed (e.g. for
closing effects).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3667>
2024-06-17 15:27:20 +00:00
Sebastian Wick
82c71426cc wayland/xdg-shell: Reset XDG surface roles when role is assigned
Instead of resetting in the xdg_surface.get_toplevel call.

It also changes XDG popus handling to deal with cases where the surface
was part of a window before, the same way the toplevel does.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3667>
2024-06-17 15:27:20 +00:00
Sebastian Wick
e775052429 wayland/actor-surface: Reset the actor on role-assignment
This makes sure we always have new SurfaceActors when reassigning the
same role to a previously used surface

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3667>
2024-06-17 15:27:20 +00:00
Daniel van Vugt
807c99fca6 x11: Add another fallback to legacy X11 cursor names
For X11 apps that don't specify their own.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3403
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
2024-06-17 11:39:00 +00:00
Daniel van Vugt
d2c6b77059 backends: Restore support for loading X11 cursor themes missing "default"
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3184
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
2024-06-17 11:39:00 +00:00
Daniel van Vugt
4a4ab8c533 backends: Add meta_cursor_get_legacy_name()
To aid loading of legacy cursor themes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
2024-06-17 11:39:00 +00:00
Daniel van Vugt
13b2803a03 backends: Fix parameter alignment check-code-style complains about
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
2024-06-17 11:39:00 +00:00
Daniel van Vugt
847f015017 backends/x11: Avoid defining (and freeing!) nonexistent cursors
Such as "default" for legacy X11 themes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3454
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
2024-06-17 11:39:00 +00:00
Jonas Ådahl
6d8c93ba66 tests: Mark some tests as skippable
Wayland tests also get kvm and tty test variants, but running tty tests
on your main session makes them fail. The intention for tty tests is to
skip when not run from a tty, so fix that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3811>
2024-06-17 11:24:20 +00:00
José Expósito
4ae305f19e backends/eis-client: Release buttons on device remove
Due to a copy and paste error, buttons were not released when the device
was removed.

Found by Coverity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3809>
2024-06-14 17:04:20 +02:00
Bilal Elmoussaoui
69835c9ec1 cogl: Remove CoglFence
Nothing was really using it...I am removing too much?

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3806>
2024-06-14 12:12:34 +02:00
Daniel van Vugt
e951265806 backends: Handle null views instead of creating dummy views
If view initialization fails then don't add the view, rather than
adding a dummy offscreen view. This avoids flooding the log with
offscreen frame clock confusion:

Before:
```
libmutter-WARNING **: 15:47:27.763: Failed to allocate onscreen framebuffer for /dev/dri/card0: Failed to allocate surface: Function not implemented
Clutter-WARNING **: 15:47:28.557: (../clutter/clutter/clutter-frame-clock.c:419):clutter_frame_clock_notify_presented: code should not be reached
Clutter-WARNING **: 15:47:28.563: (../clutter/clutter/clutter-frame-clock.c:419):clutter_frame_clock_notify_presented: code should not be reached
Clutter-WARNING **: 15:47:28.567: (../clutter/clutter/clutter-frame-clock.c:419):clutter_frame_clock_notify_presented: code should not be reached
(repeats forever)

```

After:
```
libmutter-WARNING **: 16:09:04.945: Failed to create view for Unknown 46" on None-1: Failed to allocate onscreen framebuffer for /dev/dri/card0: Failed to allocate surface: Function not implemented
```

Relates to:
https://launchpad.net/bugs/1967707
https://gitlab.gnome.org/GNOME/mutter/-/issues/2489
https://gitlab.gnome.org/GNOME/mutter/-/issues/2295

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3115>
2024-06-14 16:12:52 +08:00
Daniel van Vugt
b684b5cf05 build: Compile schemas locally for use in build tests
So they don't need to be installed system-wide before build testing
can work.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3368
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3800>
2024-06-13 22:14:51 +00:00
Marco Trevisan (Treviño)
3e6cf75eec tests/cogl/read-texture-formats: Do not skip any test when using AMD
All the tests are correctly passing with an AMD card, so let's enable
them all in such case, so we can catch when the test will regress even
there

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
18fa5bd81e tests/cogl/journal: Use different behavior when running in AMD
AMD driver is buggy when it comes to generate textures of 1px height [1]
while this is not a mutter problem, we should not block on that either.

So, given that the test purpose is to check the journal flushing during
unref more than its behavior, we can still check this in all the drivers
keeping a warning in the AMD case.

See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11269
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
03ef333937 cogl/context: Add test util function to get the GL/GLES driver vendor
Some tests sadly behaves differently depending on the driver in use.
While this shouldn't happen we can't block on these driver issues, so
add a test utils private function to get the driver information so that
we can adapt test behavior depending on this.

This will allow to disable / enable tests at runtime instead of failing
in all the implementations, which is still better for catching
regressions in the parts we may be ignoring otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
615fe1e703 tests/cogl/conform: Skip known failing tests parts in undefined mode
When running the tests in non-undefined mode we should skip the known
failing tests instead of the whole suite, so mark them as such so that
we can still run the tests partially checking the things that still
work, avoiding to regress on them too.

We also run the tests in normal mode so that we can ensure that the
failures are still happening in that way.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
ed35ff72e0 tests/cogl/conform: Run known failures tests in no-undefined mode
In this way we can just skip the single test cases that are failing

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
9c181e2407 tests/cogl/read-texture-formats: Split tests by cases to improve logging
Use multiple test cases for each format test so that it's easier to
understand what's failing and in case just skip a single test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
bce00cb9f4 tests/cogl: Add cogl winsys debug info when running tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
504e0386cc ci: Do not run create runtime dir on script setup
We do this per each test now.

As per this we need to ensure that one exists when running the virtme
tests

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
fec38819ac tests/dbusrunner: Use separate HOME, Temp and XDG Runtime dirs
We need to use a different $XDG_RUNTIME_DIR path to be able to start most
tests in parallel, and we can use a temporary directory for that which python
cleans up when done.

Also, given that most of settings are stored in HOME use temporary one
for that too, to prevent mutter to fail because it may load some local
configuration (e.g. monitors.xml) that don't meet the expectations or
that may change the test behavior in an unexpected way.

As per this, CI needs to be adapted for new args handling

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
d01d153f56 tests/dbusrunner: Print the subprocess PID that has been launched
It can be useful for debugging purposes

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
c6631077d7 backend/native: Ignore not found errors when adding drm device in headless
When testing mutter using `META_DBUS_RUNNER_WRAPPER=rr` we may get a
not found-device error, given that it's not a case we support, we can
ignore it as we do with permission denied one, limiting this to the RR
case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Marco Trevisan (Treviño)
2a1cc195a3 tests/dbusrunner: Add shortcut for recording with rr
RR now supports mutter, as per some upstream fixes [1], so we can add a
simple shortcut for the recorder

[1] https://github.com/rr-debugger/rr/pull/3140/

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
2024-06-13 21:21:49 +00:00
Bilal Elmoussaoui
99415aad4b cogl/tests: Try harder to avoid floating points issues
Comes from the conversions between floats and integers all over Color usage.
Although, those changes should simplify a future change of the Color API to floats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544>
2024-06-13 15:25:40 +02:00
Bilal Elmoussaoui
e93fe16241 tests: Move color conform tests from clutter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544>
2024-06-13 14:45:53 +02:00
Bilal Elmoussaoui
dc52ccc75a cleanup: Port from ClutterColor to CoglColor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544>
2024-06-13 14:45:53 +02:00
Sebastian Wick
8709fc5353 wayland: Bump connection buffer size to 1MB
Let's increase the connection buffer size a bit to avoid killing
clients which stall just for a few ms when they receive high
frequency input updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3693>
2024-06-13 11:58:14 +00:00
Jonas Dreßler
530659c643 tests/clutter/conform: Wait for stage update right after showing stage
Showing the stage always results in an initial update being queued. If the
virtual input events from the test ends up being dispatched after that, the
`wait_for_update()` checks gets out of sync, as the first update ended up
waiting for the initial update, not the one from the input event.

Fix the gesture test by adding another call to `wait_stage_updated()` right
after `clutter_actor_show()`.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3521
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3795>
2024-06-12 18:45:29 +00:00
Bilal Elmoussaoui
74ece2ad92 clutter: Drop various Color constructors
The fields are writable, there is no need to provide a custom constructor.
This shapes the Color API to be similar to GdkRGBA

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3802>
2024-06-12 16:25:18 +00:00
Bilal Elmoussaoui
04842393aa clutter: Drop Color.from_pixel
Goes along with https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3367
Helps https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3802>
2024-06-12 16:25:18 +00:00
Jonas Ådahl
9d11cc679e screen-cast/window: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-12 15:11:04 +00:00
Jonas Ådahl
897c535bd8 screen-cast/monitor: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-12 15:11:04 +00:00
Jonas Ådahl
dd8a503f3d screen-cast/area: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-12 15:11:04 +00:00
Jonas Ådahl
bbd59ab9e6 screen-cast/virtual: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3220
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-12 15:11:04 +00:00
Jonas Ådahl
91d43bfbe1 screen-cast/src: Allow dropping cursor-frame if nothing changed
Allow a screen cast stream source to say that nothing changed in terms
of cursor metadata, and treat this together with a cursor-only frame as
we not recording anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-12 15:11:04 +00:00
Jonas Ådahl
5bca761148 kms: Don't use kernel thread when headless
We're not doing anything significant in the KMS thread anyway, so don't
make it a kernel thread, and don't ask to be real time scheduled (which
we wouldn't be anyway, but for clarity).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3805>
2024-06-12 11:06:54 +00:00
Jonas Ådahl
6bd2fd6a74 backend/native: Find render node directly via udev
Don't try to find the card, and then the render node from it, just ask
udev to list the render nodes directly. This avoids running into
permission errors when the user cannot open /dev/dri/card* even without
mode setting capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3805>
2024-06-12 11:06:54 +00:00
Bilal Elmoussaoui
bb29fa68fe cogl: Remove AtlasTexture.new_from_data
Nothing uses it, allows to drop the corresponding test case as well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3804>
2024-06-12 00:42:45 +00:00
Bilal Elmoussaoui
6c972546f1 mtk: Add Rectangle.contains_point
By turning a macro that exists in the codebase to a proper
function so that gnome-shell could make use of it as well
instead of using a region for it contains_point api...

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3801>
2024-06-11 00:49:28 +02:00
Daniel van Vugt
2f8a598582 kms/impl-device: Add debug logging for deadline dispatch lateness
And also "completion" time to measure when the commit returned.

This is structured so as to measure all timestamps first before logging
anything. That way our results shouldn't be (don't seem to be) affected
by the logging itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3265>
2024-06-10 13:55:21 +08:00
Daniel van Vugt
cf87eae00b kms/impl-device: Remember the expected deadline dispatch time
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3265>
2024-06-10 13:55:21 +08:00
Daniel van Vugt
052def76e6 Add debug topic "kms-deadline"
Which will allow us to report on deadline timings without influencing
the CPU clock like the busy "kms" topic does.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3265>
2024-06-10 13:55:21 +08:00
Carlos Garnacho
e731f2a055 wayland: Double check surface/window before looking for modals
While it should not be expected that we pick the pointer into a
MetaSurfaceActor that is disembodied of its MetaWaylandSurface/MetaWindow,
the paths where this should be enforced are somewhat scattered.

So account for the situation in picking code, and prefer a NULL surface
over a crash. This operates on the assumption that this inconsistent state
where Mutter didn't know better to pick a correct surface actor will be fixed
by later crossing events resolving the intermediate state, and that no
other input events will be received meanwhile.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3393
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3729>
2024-06-07 17:02:14 +02:00
Carlos Garnacho
66e23b009c wayland: Make subsurface actors unreactive early during destruction
When unmapping a subsurface, it does lose early its connection to the
parent surface. This is however a deciding factor in determining whether
the surface (role) has a window.

Make the subsurface actor unreactive if its connection to the parent
MetaWindow was severed, since it should not be eligible for picking anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3729>
2024-06-07 17:02:13 +02:00
Carlos Garnacho
17dc9393e0 compositor: Make surface actors unreactive after losing their surface
These actors are expected to be destroyed along with their surface, this
however happens later in the process, so there is a moment where actors
are eligible for picking, but do not have a surface anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3729>
2024-06-07 17:01:26 +02:00
Sebastian Wick
c166b3fc5b wayland/activation: Apply xdg-activation request when window gets mapped
If the window is not mapped yet and we get an activation request, we
will wait for the window to get mapped or destroyed to try to fullfil
the request.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3728>
2024-06-07 12:06:12 +02:00
Sebastian Wick
77b115399c window/x11: Remove unnecessary user_data
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3728>
2024-06-07 12:05:36 +02:00
Sebastian Wick
fdf9c32dac window: Replace map/unmap vfunc with signal
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3728>
2024-06-07 12:04:27 +02:00
Sebastian Keller
a99e139a68 events: Don't check for stage grabs before sending events to ibus
Prior to the grabs/focus rework in !3420, Wayland grabs were handled
separately from ClutterGrabs. This required explicitly checking for
ClutterGrabs as those were expected to prevent events from reaching
Wayland clients.

Now after !3420, Wayland client grabs also result in ClutterGrabs, which
means that this check causes input events for popups with grabs to not
get sent to ibus anymore. Instead the events are getting sent to the
client directly, which results no ibus support in popups (unless the
client handles that itself by using a different GTK_IM_MODULE).

However due to the changes from !3420 checking for ClutterGrabs is also
no longer necessary and the meta_wayland_text_input_update() focus check
is now sufficient to only forward events to ibus, when the focus is
actually on a Wayland client. So to fix this we can simply remove the
check.

Fixes: 2a584a8f0 ("wayland: Make use of Wayland event grabbing mechanism")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3502
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3787>
2024-06-05 15:53:40 +00:00
adarshgm
0ca933baec backend/native: Adds support for SIZE_HINTS Cursor Plane Property
Reads exposed size hints for the given cursor plane. Chooses nearest
minimum cursor size out of the hints with respect to the user chosen
cursor size from the UI. Allocates optimized Hardare cursor size,
hence drm buffer

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3165>
2024-06-04 16:39:16 +00:00
Jonas Ådahl
297ae74771 window: Replace 'winsys_id' for monitor matching
Instead use an abstract "logical monitor id" that is generated from the
logical monitor. Instead of using low level numbers from the mode
setting devices, use either data from the EDID, or the connector, if the
EDID is not useful.

This should help with windows remembering monitor positions when the
same monitor reappears but with another mode setting device ID.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3753>
2024-06-04 16:09:50 +00:00
Carlos Garnacho
ad60d7123b Revert "wayland: Add meta_wayland_seat_get_input_focus_client() call"
This reverts commit 743fb6df30.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3789>
2024-06-03 09:51:30 +00:00
Carlos Garnacho
b968796f1f wayland: Fix possibly out of sync clipboard selections
Replace the sync_focus() calls with a set_focus() do-it function taking
a surface. This is in line with the rest of the things that happen at
the default MetaWaylandEventInterface.focus implementation, and will
make these correctly observe the presence of grabs, since
meta_wayland_seat_get_input_focus() will return the would-be focus
in these cases.

This change makes the "focused" client selection truly
in sync with the keyboard focus.

Fixes: 5ca10c31d1 ("wayland: Follow seat's input focus client for clipboard selections")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3490
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3789>
2024-06-03 09:51:30 +00:00
Carlos Garnacho
9dab806a18 wayland: Fix possibly out of sync primary selections
Replace the sync_focus() calls with a set_focus() do-it function taking
a surface. This is in line with the rest of the things that happen at
the default MetaWaylandEventInterface.focus implementation, and will
make these correctly observe the presence of grabs, since
meta_wayland_seat_get_input_focus() will return the would-be focus
in these cases.

This change makes the "focused" client selection truly
in sync with the keyboard focus.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3498
Fixes: 9bdb00c459 ("wayland: Follow seat's input focus client for primary selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3789>
2024-06-03 09:51:30 +00:00
Georges Basile Stavracas Neto
1d0dc6d6d8 src/backends: Add MetaSubpixelOrder
An exact copy of CoglSubpixelOrder, without the Cogl dependency.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3792>
2024-06-03 08:31:58 +00:00
Marco Trevisan (Treviño)
467746c8a7 core/context: Add typecheck guards to the public functions
In the shell side we ended up calling the wrong function [1] and mutter
didn't stop us from doing it, so add some type-check guards to ensure we
don't do similar errors again

[1] https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3355

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3791>
2024-05-31 14:51:13 +00:00
Marco Trevisan (Treviño)
0fda3ab8a1 backends/x11/backend-x11-nested: Cleanup the cursor renderer on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
6a04ea9a59 backends/input-settings: Clear the devices list on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
b630c3baa6 backends/backend: Clear egl object if any
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
de8691c7ff backends/color-store: Unify and simplify codepaths for profile ready
Just steal from the hash table all the times, and use autopointers
to cleanup if needed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
430e55a535 backends/color-store: Clarify the color profile ownership fixing the key leak
We were leaking the color profile path keys but also it wasn't clear how
the ownership was passed to the new hash-table, so let's just remove it
from the pending hash table and add it to the new one including the
expected reference.

This is safe because we were still adding a temporary extra ref to the
profile

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
c2cc26b370 backends/native/backend-native: Free the device path when stealing the device
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
ce1dd40f7b backends/native/thread: Unref the callback sources hashtable on finalize
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
f74a46d98d backends/remote-access-controller: Own and free the session managers
We were leaking the session managers list, but at this point I feel it
looks cleaner to also own it fully

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
c33a02dd32 backends/backend: Cleanup MetaDnd on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Carlos Garnacho
b35129db61 wayland: Check focus surface to set a pointer cursor
The cursor was following the "current" surface (i.e. the logical
focus, unaffected by e.g. grabs), so MetaWaylandPointer was always
providing window cursors, just so the MetaCursorRenderer would maybe
discard them and show the compositor cursor instead. E.g. in the
presence of grabs.

This clear barrier between grabs being compositor business deserving
a compositor cursor, and non-grabs being client business turned a bit
blurrier in grabs-pt5 where "client" things like popups and DnD would
also involve grabs. The fixes in that regard in the branch went on
the lenient side, introducing situations where grabs do exist but we
are preferring client-side cursors anyways.

Fix this by making MetaWaylandPointer aware of grabs at the time of
updating the client-side cursor, by following the "focus" surface
(i.e. the effective focus, affected by grabs outside of MetaWaylandInput).
The focus surface and cursor will be updated on focus changes, also
induced by grab changes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3460
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3736>
2024-05-30 19:18:49 +00:00
dcz
11a4d56185 keybindings: Send trigger when a key accelerator is deactivated
This is neccessary to support the GlobalShortcuts portal which demands Deactivate events.

https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/47

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3680>
2024-05-28 09:27:39 +00:00
Marco Trevisan (Treviño)
b0df2d0f7d frame: Handle X11 errors earlier on frame setting
Avoid changing the stack information if we fail earlier than that

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
e1dbf102dc frame: Handle reparent failure avoiding duplicate stack windows instances
In some cases, reparenting a window with its frame may fail; this seems
to happen especially during initialization of a window that may be
unmapped and re-mapped quickly and multiple times.

If this happens, we're never going to receive a remove event on the
stack tracker and so we may end up adding it twice to the list of the
windows to synchronize with the compositor, breaking its assumption that
the stack list is unique, and eventually leading to a crash because we
do not end up removing all the instances of a window on its destruction.

In particular we may end up in this situation:

  Syncing Window 10485927: 0x555558863540 (actual xid is 10485927),
    user time is 10485928 frame is 0x5555588715c0, frame xid 6291591
  Syncing Window 14680081: 0x5555588664b0 (actual xid is 14680081),
    user time is 14680082 frame is 0x555558871d80, frame xid 6291595
  Syncing Window 6291460: 0x55555796dc80 (actual xid is 10485763),
    user time is 10485764 frame is 0x555557a6f630, frame xid 6291460
  Syncing Window 6291465: 0x555557a68af0 (actual xid is 14680067),
    user time is 14680068 frame is 0x555557a73e80, frame xid 6291465
  Syncing Window 6291509: 0x555557f9d830 (actual xid is 8388623),
    user time is 0 frame is 0x555557fac780, frame xid 6291509
  Syncing Window 6291586: 0x5555586e1690 (actual xid is 4194363),
    user time is 0 frame is 0x55555886e550, frame xid 6291586
  Syncing Window 6291591: 0x555558863540 (actual xid is 10485927),
    user time is 10485928 frame is 0x5555588715c0, frame xid 6291591

Where the same meta window 0x555558863540 is added twice because that's
both mapped by the window itself (10485927) and by its frame (6291591).

This happens because for historical reasons the xids hash table managed
by the x11-display maps both the X11 windows, their frames and their
user time windows as the meta-window, and so if we don't filter out them
properly we end up duplicating the entries in the compositor list.

Such duplicates finally end up making mutter to crash in
meta_compositor_sync_stack() because we could end up trying to access
to an invalid window, given its actor has been destroyed but not all the
instances have been removed from the compositor windows list:

  0x00007ffff71059 in meta_compositor_sync_stack (compositor=0x555555b8,
  stack=0x555558701b80) at ../../mutter/src/compositor/compositor.c:773
  773	          if ((old_window->hidden || old_window->unmanaging) &&
  (gdb) print old_window
  $1 = (MetaWindow *) 0x0

So, in order to prevent this, check that XReparentWindow does not fail,
and in case of failure, reset the window state to the one it had before
we failed and more importantly, remove the association between the frame
X11 window and the MetaWindow, since this is not true anymore and so
that at the next stack synchronization there won't be any meta window
associated to that frame XID (unless there aren't further stack changes
impacting on that). Without this we would have instead waited for the
remove event that we predicted, but that could never happen because no
ReparentNotify is emitted in such case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
2065214b71 frame: Associate the frame to the window after reparenting
Since we listen the X events in the same thread, and they are delivered
through the main loop, there's not any need to set the frame details on
windows before the reparent operation, because such action could fail.

So move the code order, as preparation for handling the error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
4eb76b565f frame: Define a free function for MetaFrame and use via autoptr
Use clearer memory management for the MetaFrame making it easier
to destroy it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
5b1c0c2123 stack-tracker: Improve documentation why we need to filter x11 windows
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
c202662ca3 stack-tracker: Improve logging when an operation is ignored
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
0653b829c1 stack-tracker: Avoid multiple casts to Window type
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
e3d3b257ae window-private: Actually remove frame instance
As per GNOME/mutter!3254 MetaFrame is part of MetaWindowX11Private, but
MetaWindow has still the frame field.

Drop it since it's unused now and can lead to confusion

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3784>
2024-05-27 17:11:55 +02:00
Bilal Elmoussaoui
0f19c6f5b6 window: Stop caching frame_bounds
That was only there to force updating MetaFrame's bounds
but that is something that is already updated in
MetaWindowX11.move_resize_internal. So just drop all of that

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
d1b04ffb55 window: Move frame_bounds to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
bcb069f454 window: Move frame field to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
503c70e284 window: Replace get_titlebar usages
Uses the hardcoded value that was used for wayland
clients for x11 ones as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
70f8cc433e window: Move get_session_geometry to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
751ef5abd2 window/x11: Add a is_ssd helper
Would be useful for moving frame field to WindowX11 in the upcoming commits

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
fff528cbf1 window: Remove shove titlebar onscreen functions
Mutter side of
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3332

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
acbb14f34b window: Move has_custom_frame_extents to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
b4b896d4db core: Move frame related types to x11
Also rename the files to meta-x11-frame* for consistency

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Philip Withnall
173332e928 tests: Fix a -Wmaybe-uninitialized warning
Since the `switch` didn’t have a default case, the `cull_front` and
`cull_back` variables could technically be used uninitialised if the
`cull_mode` was unrecognised.

That seems unlikely to happen as presumably other code makes sure the
`cull_mode` is valid, but it doesn’t hurt to add a `default:` case to
squash the compiler warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3770>
2024-05-26 09:19:17 +00:00
Philip Withnall
ca1434ff1e display: Fix a -Wmaybe-uninitialized warning
Depending on whether the input mapper was found, these variables could
indeed be used uninitialised, so this is a true positive warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3770>
2024-05-26 09:19:17 +00:00
Bilal Elmoussaoui
7f213c2a2f x11: Use the embedded xcursor functions where possible
Makes those functions that are intended to be used in wayland-only
builds to be tested in x11 code paths as well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3607>
2024-05-24 13:02:42 +00:00
Bilal Elmoussaoui
0a46ca67ec core: Include a small subset of xcursor in-tree
For a Wayland only build, we would like to avoid linking against
libXcursor which on it turn, links back to some of the X11 deps.
In order to achieve that, we include a small subset of xcursor.

In case Mutter is built with X11 or with both Wayland & X11, we link
against libXcursor and don't make use of the in-tree implementation.

This patch mimics what GTK 4 do by shipping an in-tree copy of xcursor.
Especially that libwayland-cursor does not provide an alternative to
xcursor itself.

Helps #2272

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3607>
2024-05-24 13:02:42 +00:00
Sebastian Keller
650ef9b57f wayland/pointer-constraints: Don't steal regions for new constraints
meta_pointer_constraint_new() does not take ownership of the passed
regions but instead creates a copy, resulting in a leak in the calling
functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
2024-05-23 22:34:19 +00:00
Sebastian Keller
c3e626405f wayland/pointer-constraints: Disconnect focus surface handler early
When meta_wayland_pointer_constraint_remove() is called, it can trigger
a meta_wayland_event_handler_invalidate_focus() via:

meta_wayland_pointer_constraint_destroy()
meta_wayland_pointer_constraint_disable()
meta_wayland_input_detach_event_handler()
meta_wayland_input_invalidate_all_focus()
meta_wayland_event_handler_invalidate_focus()

Which then would result in a "focus-surface-changed" signal which would
call meta_wayland_pointer_constraint_remove() a second time. This
happens after surface_remove_pointer_constraints() has already been
called in the first meta_wayland_pointer_constraint_remove() call,
leading to "data" being NULL.

To prevent this issue disconnect the signal handler before calling
meta_wayland_pointer_constraint_disable() when destroying a constraint.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3476
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
2024-05-23 22:34:19 +00:00