1
0
Fork 0
Commit graph

1943 commits

Author SHA1 Message Date
Sebastian Wick
b4b9a7c90f core: Move remaining default focus window handling to workspace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Jonas Ådahl
dad384376a wayland/data-device: Clean up coding style a bit
There were a few very long lines, it partly didn't follow function
argument alignment and used glib types instead of stdint types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
c676beea6c xwayland: Move "code like" declarations to the bottom
They'll be closer to the code but still after the "boring" declarations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:00 +00:00
Jonas Ådahl
1d4cdd1eb5 wayland/dma-buf: Always send modifiers when using surfaceless
We'll never scan out, which is why ADDFB2 is required otherwise, and we
won't enable the DMA buffer extension if
'EGL_EXT_image_dma_buf_import_modifiers' is missing, so send modifiers
in this case.

This also happens to avoid crashing when the GPU is null, since we'd
otherwise attempt to dereference it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Simon McVittie
4bc5833144 Consistently pass timestamp as uint64 when creating MetaStartupSequence
Passing the wrong type to a varargs function can cause a mismatch
between marshalling and unmarshalling on the stack, particularly on
32-bit architectures. This results in a build-time test failure.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2065
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2182>
2022-09-02 15:21:27 +00:00
Carlos Garnacho
a9ae43ff43 wayland: Ignore text_input requests from unfocused clients
This is what the protocol says we should do, and even though normally
an out of focus client should not have any reason to create IM requests,
there is a bit of a grey area around focus changes, as both the client
losing focus and the client gaining focus may respectively try to
disable/enable in an undetermined order.

Anyways, since in that situation the client losing focus is not aware
of the requests being ignored, the serial should always be incremented
in order not to break accounting of .done/.commit for that specific
client.

Fixes the IM focus being possibly "lost" after changing focus between
clients, if the race condition turned the odds in that direction.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2585>
2022-09-02 09:19:42 +00:00
Jonas Ådahl
ccb6a7e84f monitor: Allow vendor/product/serial to return NULL
Same applies to MetaOutput. The reason for this is to make it possible
to more reliably know when there was EDID telling us about these
details. This will be used for colord integration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Carlos Garnacho
9d558e334c wayland: Unlink surface listener when freeing token
If the token ended up consumed and freed, we might leave a dangling
destroy listener after freeing the token struct.

Fixes: ed516dde89 (wayland: Add destruction listener to activation token surface)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2594>
2022-08-25 11:15:01 +02:00
Carlos Garnacho
ed516dde89 wayland: Add destruction listener to activation token surface
In the timespan between an activation token being created and the
token being used by the activated application, the surface that started
the activation request may end up destroyed/disposed.

In that case, the token would be left with a stale surface pointer,
maybe causing crashes later on. Set up a destroy notification listener
so that we do know to unset the token surface if that situation arises,
this will result in Mutter not considering the token activatable, thus
maybe issuing the "Application needs attention" notification if the
activated surface did not immediately get focus. In any case this is
better than a compositor crash.

A typical situation where this may happen is "Open With..." dialogs,
since those don't live long after launching the application.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2390
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2592>
2022-08-23 22:56:42 +02:00
Carlos Garnacho
9c402bd091 wayland: Ensure to remove destroy listener for MetaWaylandBuffer
Avoid the chance of invalid memory access by leaving the wl_listener
behind when handling the destroy notification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2588>
2022-08-23 17:06:07 +00:00
Carlos Garnacho
f4f39d3a2c wayland: Ensure to unlink destroy listeners for subsurfaces
There is some surface tracking going on here, and all notify handlers
are possibly leaving the linked wl_listener behind. Ensure it is unlinked
in all destroy notification functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2588>
2022-08-23 17:06:07 +00:00
Carlos Garnacho
51064c1b4e wayland: Ensure to unlink destroy listeners after destruction
This is missed in some wl_listeners added
through wl_resource_add_destroy_listener(). Ensure this is done consistently
for all notify functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2588>
2022-08-23 17:06:07 +00:00
Carlos Garnacho
0d47b467f6 wayland: Fix thinko in paired tablet loop filter
This condition is inverted of how it should be. Since pad focus relies
on grouped devices lookups (e.g. pads not grouped with a tablet do not
focus surfaces), this fixes issues in pad focus and event propagation to
wayland clients.

Fixes: fff3654941 - wayland: Check input device capabilities in tablet seats
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2573>
2022-08-13 00:39:54 +02:00
Jonas Ådahl
5f96194e9e window/wayland: Always update the monitor when updating
If the window didn't have a size, it would still have a monitor, and
when we are asked to update, we must update, as the old monitor might
not be kept around, leaving us vulnerable to use after free.

Avoid not updating the monitor by using the stored IDs (preferred, or
previous) to find suitable logical monitors, with the primary monitor
being the last fallback unless we're completely headless.

This fixes the assert

  !window->monitor ||
  g_list_find (meta_monitor_manager_get_logical_monitors (monitor_manager),
               window->monitor)

in meta_window_update_for_monitors_changed() being hit when a Wayland
window has been created, but not mapped, when a hotplug happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
24965a78da window: Make monitor from rect finder helper more clearly named
The function finds a suitable logical monitor given the window
rectangle; this wasn't all that clear from the name
"calculate_main_logical_monitor".

This is in preparation for finding a new logical monitor using things
other than the geometry of the window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Robert Mader
01a4ec1841 wayland/outputs: Report actual monitor transform
Now that we support Wayland buffer transforms in all cases, we can
properly report them to outputs.
Also make sure we resend the output geomerty on transform changes.

This partly reverts commit bda9c359

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/344>
2022-08-05 20:30:50 +02:00
Robert Mader
385df73276 wayland/cursor-surface: Pass buffer-transform to cursor sprite
This was previously forgotten, effectively disabling pre-rotated
hardware cursors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/344>
2022-08-05 20:30:50 +02:00
Jonas Ådahl
a07fd4ee66 wayland/dma-buf: Only try to query KMS device on native backend
This fixes a crash when using the nested backend and DMA buf Wayland
clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2553>
2022-08-04 09:38:47 +02:00
Jonas Ådahl
2cb7499735 wayland: Add single pixel buffer support
The "single pixel buffer" Wayland protocol extension provides a way for
clients to create 1x1 buffers with a single color, specified by
providing the color channels (red, green and blue) as well as the
alpha channel as a 32 bit unsigned integer.

For now, this is turned into a 1x1 texture. Future potential
improvements is to hook things up to the scanout candidate logic and
turn it into a scanout capable DMA buffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2246>
2022-08-02 12:19:42 +00:00
Jonas Ådahl
34475e7e98 wayland/dma-buf: Always send modifiers if AddFB2() is supported
To Wayland clients, it doesn't matter how we configure our onscreen
buffers, since they don't necessarily have the same bandwidth issues
related to mode setting, whichis the primary reason why we disable
modifiers using the udev rule, so simply check whether importing with
modifiers will work at all and advertise modifiers if so is the case.

This might help avoid issues using legacy non-modifiers path in drivers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2546>
2022-08-02 10:04:52 +00:00
Jonas Ådahl
1844dcc08e wayland/dma-buf: Get backend via MetaContext
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2546>
2022-08-02 10:04:52 +00:00
Jonas Ådahl
bd4dd6b1e8 wayland/compositor: Add MetaContext getter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2546>
2022-08-02 10:04:52 +00:00
Robert Mader
9e71278488 Revert "wayland/surface: Swap 90 and 270 degree transforms"
As testing of direct scanout revealed, `META_MONITOR_TRANSFORM`
does actually match `WL_OUTPUT_TRANSFORM` enums. The fact that
things rendered correctly with 90/270 degree values swapped
was because other parts of the stack got the interpretation
wrong, most notably `meta_rectangle_transform()`.
Thus lets revert this change and fix the stack accordingly.

This reverts commit 8d9bbe109b.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2459>
2022-07-26 18:41:43 +00:00
Michel Dänzer
d928b6baa6 wayland: Clean up tablet manager state
Fixes memory leak:

==995170== 936 (40 direct, 896 indirect) bytes in 1 blocks are definitely lost in loss record 15,090 of 15,641
==995170==    at 0x48445EF: calloc (vg_replace_malloc.c:1328)
==995170==    by 0x4B211D0: g_malloc0 (gmem.c:155)
==995170==    by 0x4A56693: meta_wayland_tablet_manager_new (meta-wayland-tablet-manager.c:109)
==995170==    by 0x4A56693: meta_wayland_tablet_manager_init (meta-wayland-tablet-manager.c:126)
==995170==    by 0x4A3FA95: meta_wayland_compositor_new (meta-wayland.c:626)
==995170==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
==995170==    by 0x10F065: main (mutter.c:148)

Fixes: 745cb67988 ("wayland: Initialize the MetaWaylandTabletManager")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>
2022-07-25 14:55:59 +00:00
Michel Dänzer
f3cd2b8ce7 wayland: Clean up output state
Fixes memory leak:

==995170== 383 (96 direct, 287 indirect) bytes in 1 blocks are definitely lost in loss record 14,733 of 15,641
==995170==    at 0x483F7B5: malloc (vg_replace_malloc.c:381)
==995170==    by 0x4B21178: g_malloc (gmem.c:125)
==995170==    by 0x4B395C0: g_slice_alloc (gslice.c:1072)
==995170==    by 0x4B0766D: g_hash_table_new_full (ghash.c:1071)
==995170==    by 0x4A4A8B4: meta_wayland_compositor_update_outputs (meta-wayland-outputs.c:483)
==995170==    by 0x4A4ABAB: meta_wayland_outputs_init (meta-wayland-outputs.c:716)
==995170==    by 0x4A3FA65: meta_wayland_compositor_new (meta-wayland.c:620)
==995170==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
==995170==    by 0x10F065: main (mutter.c:148)

v2:
* Use meta_backend_get_monitor_manager. (Jonas Ådahl)

Fixes: 9a4783e364 ("Integrate the monitor manager with wayland")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>
2022-07-25 14:55:59 +00:00
Michel Dänzer
806e64dcb0 wayland: Clean up presentation-time state
Fixes memory leak:

==995170== 288 (96 direct, 192 indirect) bytes in 1 blocks are definitely lost in loss record 14,607 of 15,641
==995170==    at 0x483F7B5: malloc (vg_replace_malloc.c:381)
==995170==    by 0x4B21178: g_malloc (gmem.c:125)
==995170==    by 0x4B395C0: g_slice_alloc (gslice.c:1072)
==995170==    by 0x4B0766D: g_hash_table_new_full (ghash.c:1071)
==995170==    by 0x4A4F973: meta_wayland_init_presentation_time (meta-wayland-presentation-time.c:222)
==995170==    by 0x4A3FB04: meta_wayland_compositor_new (meta-wayland.c:635)
==995170==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
==995170==    by 0x10F065: main (mutter.c:148)

Fixes: dccc60ec3e ("wayland: Implement stub presentation-time")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>
2022-07-25 14:55:59 +00:00
Michel Dänzer
b329dce070 wayland: Clean up xdg-activation state
Fixes memory leak:

==995170== 240 (48 direct, 192 indirect) bytes in 1 blocks are definitely lost in loss record 14,428 of 15,641
==995170==    at 0x48445EF: calloc (vg_replace_malloc.c:1328)
==995170==    by 0x4B211D0: g_malloc0 (gmem.c:155)
==995170==    by 0x4A3CDB3: meta_wayland_activation_init (meta-wayland-activation.c:383)
==995170==    by 0x4A3FB0C: meta_wayland_compositor_new (meta-wayland.c:636)
==995170==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
==995170==    by 0x10F065: main (mutter.c:148)

Fixes: ec390b68c5 ("wayland: Implement the xdg-activation protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>
2022-07-25 14:55:59 +00:00
Michel Dänzer
4ddefb9a69 wayland: Clean up scheduled_surface_associations hash table
Fixes memory leak:

==995170== 192 (96 direct, 96 indirect) bytes in 1 blocks are definitely lost in loss record 14,260 of 15,641
==995170==    at 0x483F7B5: malloc (vg_replace_malloc.c:381)
==995170==    by 0x4B21178: g_malloc (gmem.c:125)
==995170==    by 0x4B395C0: g_slice_alloc (gslice.c:1072)
==995170==    by 0x4B0766D: g_hash_table_new_full (ghash.c:1071)
==995170==    by 0x4A3F3A4: meta_wayland_compositor_init (meta-wayland.c:477)
==995170==    by 0x4E1F509: g_type_create_instance (gtype.c:1929)
==995170==    by 0x4E03DFC: g_object_new_internal (gobject.c:2011)
==995170==    by 0x4E0538C: g_object_new_with_properties (gobject.c:2181)
==995170==    by 0x4E05D40: g_object_new (gobject.c:1821)
==995170==    by 0x4A3F8C4: meta_wayland_compositor_new (meta-wayland.c:590)
==995170==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
==995170==    by 0x10F065: main (mutter.c:148)

Fixes: 8df2a1452c ("wayland: Notify actively of xwayland window/surface associations")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>
2022-07-25 14:55:59 +00:00
Michel Dänzer
39fd32c362 wayland: Disconnect signals when Wayland compositor object is finalized
Fixes potential use-after-free during mutter shutdown, e.g.:

==993876== Invalid read of size 8
==993876==    at 0x4A4FCA3: meta_wayland_presentation_time_ensure_feedbacks (meta-wayland-presentation-time.c:373)
==993876==    by 0x4A3F07F: on_presented (meta-wayland.c:282)
==993876==    by 0x661B7E9: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==993876==    by 0x661A922: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==993876==    by 0x4DFF4BC: g_cclosure_marshal_generic_va (gclosure.c:1648)
==993876==    by 0x4DFE948: _g_closure_invoke_va (gclosure.c:893)
==993876==    by 0x4E17498: g_signal_emit_valist (gsignal.c:3406)
==993876==    by 0x4E176BE: g_signal_emit (gsignal.c:3553)
==993876==    by 0x51D9DB5: clutter_stage_view_notify_presented (clutter-stage-view.c:1226)
==993876==    by 0x499ACD2: frame_cb (meta-stage-view.c:83)
==993876==    by 0x499ACD2: frame_cb (meta-stage-view.c:43)
==993876==    by 0x50CAA41: notify_event (cogl-onscreen.c:175)
==993876==    by 0x50CAA41: _cogl_onscreen_notify_complete (cogl-onscreen.c:545)
==993876==    by 0x4A877F5: meta_onscreen_native_notify_frame_complete (meta-onscreen-native.c:211)
==993876==  Address 0x24b7be58 is 296 bytes inside a block of size 344 free'd
==993876==    at 0x484217B: free (vg_replace_malloc.c:872)
==993876==    by 0x4E1F88B: g_type_free_instance (gtype.c:2001)
==993876==    by 0x49C793C: meta_context_dispose (meta-context.c:675)
==993876==    by 0x4E037E0: g_object_unref (gobject.c:3636)
==993876==    by 0x4E037E0: g_object_unref (gobject.c:3553)
==993876==    by 0x10F145: glib_autoptr_clear_GObject (gobject-autocleanups.h:27)
==993876==    by 0x10F145: glib_autoptr_clear_MetaContext (meta-context.h:32)
==993876==    by 0x10F145: glib_autoptr_cleanup_MetaContext (meta-context.h:32)
==993876==    by 0x10F145: main (mutter.c:126)
==993876==  Block was alloc'd at
==993876==    at 0x483F7B5: malloc (vg_replace_malloc.c:381)
==993876==    by 0x4B21178: g_malloc (gmem.c:125)
==993876==    by 0x4B395C0: g_slice_alloc (gslice.c:1072)
==993876==    by 0x4B39C29: g_slice_alloc0 (gslice.c:1098)
==993876==    by 0x4E1F544: g_type_create_instance (gtype.c:1901)
==993876==    by 0x4E03DFC: g_object_new_internal (gobject.c:2011)
==993876==    by 0x4E0538C: g_object_new_with_properties (gobject.c:2181)
==993876==    by 0x4E05D40: g_object_new (gobject.c:1821)
==993876==    by 0x4A3F864: meta_wayland_compositor_new (meta-wayland.c:585)
==993876==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
==993876==    by 0x10F065: main (mutter.c:148)

Fixes: 2ce3a050f0 ("wayland: Wire up presentation-time machinery")
Fixes: 8cff3b84f7 ("wayland/compositor: Process frame callbacks on 'after-update'")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>
2022-07-25 14:55:59 +00:00
Michel Dänzer
709d06e89e wayland/surface: The same sub-surface is not a valid sibling
The Wayland protocol documentation at
https://wayland.app/protocols/wayland#wl_subsurface:request:place_above
says:

 The reference surface must be one of the sibling surfaces, or the
 parent surface. Using any other surface, including this sub-surface,
 will cause a protocol error.

v2:
* Leave it as a single line. (Georges Basile Stavracas Neto)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2525>
2022-07-21 17:03:12 +02:00
Michel Dänzer
ddb7f84291 wayland/surface: Simplify is_child & is_sibling
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2525>
2022-07-21 17:03:12 +02:00
Carlos Garnacho
ffac294520 clutter: Pass anchor position to ClutterInputFocus
Some implementations may need this (namely, the one that drives
the Wayland protocol), so pass this along from the IM events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2517>
2022-07-19 11:04:56 +00:00
José Expósito
9dd6268d13 wayland/pointer: Send high-resolution scroll data
Upgrade the seat protocol to version 8 and change the scroll handler to
support new clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1962>
2022-07-14 22:29:56 +00:00
Dor Askayo
f037c9df66 wayland/dma-buf: Don't require modifiers support for scanout tranche
When building the list of formats to be sent as part of the scanout
tranche, avoid requiring modifier support by the DRM driver for
formats relying on implicit modifiers (DRM_FORMAT_MOD_INVALID).

Specifically, the previous check required the DRM driver to have
advertised some modifier support for the given format in its
IN_FORMATS KMS plane property, regardless of modifier it was. If it
hadn't, the format was left out of the list of formats to be sent
in the scanout tranche.

When no formats remained to be sent in the scanout tranche, the
tranche simply wasn't sent.

This resulted in the scanout tranche never being sent for GPUs where
modifiers aren't supported. In those cases, no formats are advertised
using the IN_FORMATS property, and thus the list of formats to be sent
in the scanout tranche remained empty.

Since Mesa doesn't use scanout-compatible buffers for native Wayland
clients unless specifically requested to do so using the "scanout"
tranche flag, it effectively means that direct scanout of native
Wayland clients wasn't supported for GPUs without modifiers support.

Sending a tranche with formats paired with the implicit modifier
(DRM_FORMAT_MOD_INVALID) is both allowed by the protocol and is
already done by default for GPUs with modifiers support, unless the
experimental support for explicit modifiers is enabled in Mutter.

So instead of requiring modifiers to be supported for each format
being evaluated for the scanout tranche, when processing formats
which rely on implicit modifiers, only check if the format in
question is supported by the DRM driver for scanout on the primary
plane.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2510>
2022-07-12 18:53:30 +03:00
Robert Mader
1a56a53909 wayland/actor-surface: Consider clones in is_on_logical_monitor()
While the check for `clutter_actor_has_mapped_clones` clearly indicates
an intention to take clones into account, the following code
does not do so, likely because it predates the introduction of
`clutter_actor_is_effectively_on_stage_view()`.

Switch to that newer API in order to take clones into account. This
avoids unnecessary `wl_surface_send_enter()` and `wl_surface_send_leave()`
events when entering the overview, reducing client work.

This also avoids unnecessarily allocating a `cairo_region_t`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2502>
2022-07-11 18:18:56 +00:00
Robert Mader
57881ba612 wayland/subsurface: Move actor unparenting back to rebuild_surface_tree()
Unparenting the surface actor when the subsurface object is destroyed
has several issues:
 - subsurface actors can be unparented while a close animation is
   still ongoing, breaking the animation for e.g. Firefox.
 - adding and removing the actor to/from the parent is not handled in
   one place, making the code harder to follow.
 - if the destroyed subsurface had children of its own, they potentially
   stick around until a surface-tree rebuild. This makes the Firefox
   hamburger menu not close with the "compositor" backend.

Move the unparenting back to
`meta_window_actor_wayland_rebuild_surface_tree()` and instead just
notify the parent of a state change, if it still exist. This will ensure
a correct mapping between the subsurface node tree and the flat surface
actor list. In case of the closing animation the parent will already be
removed and the call is skipped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2501>
2022-07-11 17:23:10 +00:00
Dor Askayo
cd68d5b26c wayland/surface: Remove leftover function declarations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2485>
2022-07-01 16:05:33 +00:00
Michel Dänzer
4af54225de wayland/dma-buf: Free feedback in surface_feedback_surface_destroyed_cb
Fixes leak:

==14889== 2,168 (16 direct, 2,152 indirect) bytes in 1 blocks are definitely lost in loss record 15,308 of 15,584
==14889==    at 0x48445EF: calloc (vg_replace_malloc.c:1328)
==14889==    by 0x4BAC1D0: g_malloc0 (gmem.c:155)
==14889==    by 0x4AAFF60: meta_wayland_dma_buf_feedback_new (meta-wayland-dma-buf.c:298)
==14889==    by 0x4AAFFE0: meta_wayland_dma_buf_feedback_copy (meta-wayland-dma-buf.c:317)
==14889==    by 0x4AB16B6: ensure_surface_feedback (meta-wayland-dma-buf.c:1121)
==14889==    by 0x4AB1848: dma_buf_handle_get_surface_feedback (meta-wayland-dma-buf.c:1169)
==14889==    by 0x66F77E9: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==14889==    by 0x66F6922: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==14889==    by 0x5318750: ??? (in /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.20.0)
==14889==    by 0x5313B99: ??? (in /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.20.0)
==14889==    by 0x5316649: wl_event_loop_dispatch (in /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.20.0)
==14889==    by 0x4AA7C19: wayland_event_source_dispatch (meta-wayland.c:110)

Fixes: 64e6bedb6b ("wayland/dma-buf: Add support for scanout surface feedback")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2469>
2022-06-16 10:24:42 +00:00
Jonas Ådahl
ccde353fb3 wayland/pointer-confinement: Scale region with the geometry scale
Without applying the geometry scale, to both the region and the minimum
edge distance, the confinement area becomes too small and offset on
HiDPI setups.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2110
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2460>
2022-06-13 18:38:51 +00:00
Jonas Ådahl
6d46ffccbc pointer-constraints: Move min edge distance from backend to Wayland
The min distance to the right/bottom edge depends on Wayland concepts
(wl_fixed_t) and eventually geometry scale. Move the logic the Wayland
side of the pointer constraints machinery to avoid the backend trying to
figure this out without the proper data.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2460>
2022-06-13 18:38:50 +00:00
Jonas Ådahl
71ea01f54c wayland/surface-role: Make geometry scale API return int
Geometry scale are always ints, callers always assumed they were ints,
but they were doubles. Make them ints.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2460>
2022-06-13 18:38:50 +00:00
Robert Mader
11fc5b6c6c tests/wayland: Add more requests to test driver protocol
Add `sync_effects_completed()` and `verify_view()` in
order to allow Wayland test clients to trigger verifications
and add convenience functions to use them to client-utils.

Notes:
- `sync_effects_completed()` works in two stages in order
  to ensure it doesn't race with window effects. By the time
  `sync_effects_completed()` is processed, an effect could
  already have ended or not yet been scheduled. Thus we
  defer a check for pending effects to the next paint cycle,
  assuming that by then they should have been scheduled.
- `meta_ref_test_verify_view()` internally triggers the
  `paint` signal for the stage which is why it can not be run
  in the after-paint signal handler.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1055>
2022-06-03 09:03:10 +00:00
Robert Mader
8d9bbe109b wayland/surface: Swap 90 and 270 degree transforms
Our internal interpretation of output transforms is not in line with
the Wayland spec. Wayland describes them as the transform that a
compositor will apply to a surface to compensate for the rotation
or mirroring of an output device - counter-clockwise.

Mutter in turn interprets it the other way around. One could
argue it does the same but clock-wise - or it interprets the transform
from the viewpoint of the content, not the device.

In either way, the difference is that 90 and 270 degree values are
switched. Thus swap these accordingly when we translate from
`WL_OUTPUT_TRANSFORM` to `META_MONITOR_TRANSFORM`.

See: https://gitlab.freedesktop.org/wayland/weston/issues/99
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1055>
2022-06-03 09:03:10 +00:00
Jonas Ådahl
7bf4f850b8 wayland/dma-buf: Remove no longer used mesa macro duplication
We're bumped the required mesa version, so we don't need to keep this
around anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2417>
2022-06-02 08:59:13 +00:00
Jonas Ådahl
83ed7b7dfd xwayland: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
c9e7cf4ea1 xwayland: Add API to send signal to the Xwayland process
Will be used for test cases to fake-crash the Xwayland process.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
bdb34401c5 xwayland: Only warn on X IO errors when X11 is mandatory
This avoids warnings when we're just slightly unlucky when Xwayland went
away due to inactivity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
e1033951ef wayland: Add getter for XWayland manager object
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:54 +00:00
Florian Müllner
fabad0be9c wayland: Remove unnecessary COMPOSITOR_GRAB checks
Since the new ClutterGrab API replaced the old plugin-modal hook,
the event-route is never set to COMPOSITOR_GRAB.

The code in question already checks whether the stage has a grab,
so we can just remove old checks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Fernando Monteiro
d4bdd8b56f wayland: Remove Gtk primary selection protocol
This has been replaced for primary selection protocol from
wayland-protocols.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2184>
2022-05-18 20:15:08 +00:00
Fernando Monteiro
11bc19fbe8 wayland: Drop xdg-shell v6 protocol
There is no need to have this protocol as we already
have support for the xdg-shell stable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2207>
2022-05-18 19:29:08 +00:00
Jonas Ådahl
75ec27966d wayland/buffer: Only query Wayland EGL buffer if display bound
It's not allowed to call eglQueryWaylandBuffer() if the call to
eglBindWaylandDisplay() failed, and will result in an assert being hit
in mesa if called.

Avoid that by keeping track whether we succeeded to bind, and only
attempt to realize a legacy EGL wl_buffer if binding succeeded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2415>
2022-05-17 10:09:27 +00:00
Carlos Garnacho
f361e8032c wayland: Avoid repeated NULL preedit string updates
Simply signal preedit string changes from/to NULL once, in order
to avoid unwanted activity in the client side. We do still need to
send the preedit once each .done event, if there is one, in order
to behave according to the protocol when it matters the most.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2395>
2022-04-30 15:10:17 +00:00
Robert Mader
aa8d2d6fff wayland/dma-buf: Remove redundant error check
`meta_egl_*` functions are assumed to set an error on failure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2386>
2022-04-29 20:27:56 +00:00
Robert Mader
c8095b4306 wayland/dma-buf: Only advertise supported formats
Analogous to how we use `eglQueryDmaBufModifiersEXT()` to query
supported modifiers, use `eglQueryDmaBufFormatsEXT()` to ensure
we only advertise formats supported by both the compositor and the
driver.

If there is no overlap, don't advertise `zwp_linux_dmabuf_v1` at
all.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/2238

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2386>
2022-04-29 20:27:56 +00:00
Carlos Garnacho
cd0c47a25a clutter: Shuffle handling of IM reset on button presses
Unfortunately we cannot do this generically since the target of the
button/touch press does matter, e.g. tapping on the OSK, or clicking
the IBus candidates window. These situations should not trigger a
reset.

So be more selective about the situations where button/touch presses
trigger an IM reset, in the case of ClutterText these are still clicks
inside the actor, for Wayland's text-input it is when clicking the
surface that has text_input focus.

For all other situations where clicking anywhere else might make
sense to trigger an IM reset are covered by the focus changing paths,
that also ensure a reset before changing focus between surfaces/actors.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1961
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Carlos Garnacho
39ff8d15e2 wayland: Reset ClutterInputFocus on focus changes
Focus changes should trigger an IM reset, as some engines do want
to maybe commit the preedit string before changing focus. In addition,
we do not want the preedit string to be able to move between
windows/applications.

Ensure that the commit string is committed when the IM deems so, and
ensure we send a .done event disntinct to the .leave event, so that
the client doesn't miss the commit.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2030
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Carlos Garnacho
f5f49dfa46 wayland: Always acknowledge state changing .commit() events with .done()
As of currently, we only emit .done() on actual changes coming from the
ClutterInputMethod/ClutterInputFocus. With the recent changes in the
interpretation of serials, it becomes more important now that the
compositor acknowledges every .commit done by the client, in order to
keep them feeding future IM state updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2365>
2022-04-22 11:39:44 +00:00
Carlos Garnacho
be2a1d85a5 wayland: Always update preedit with text_input.done()
Compensate the protocol statelessness with our ClutterInputFocus
statefulness. This becomes more necessary now, since sending
consecutive .done() events is now considered acceptable behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2365>
2022-04-22 11:39:44 +00:00
Jonas Ådahl
47375897a5 wayland/shm: Add support for ABGR8888 and XBGR8888 formats
This avoids shuffling bits for clients drawing in these formats.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2200
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2352>
2022-03-30 14:43:10 +00:00
Olivier Fourdan
de8927e075 xwayland: Init DnD on every Xwayland start
Currently, meta_xwayland_shutdown_dnd() is called from the handler
on_x11_display_closing() triggered from the signal "x11-display-closing"
hooked up from meta_xwayland_init_display().

Once the signal has been triggered, on_x11_display_closing() removes the
signal handler, disconnecting from the signal.

As meta_xwayland_init_display() is called from meta_display_new() which
is issued only once, the signal handler is not restored again.

As a result, meta_xwayland_shutdown_dnd() is not called anymore after
Xwayland has been restarted, but meta_xwayland_init_dnd() will check and
assert that the manager's DND object is NULL.

Basically, restarting Xwayland more that once will trigger an assertion
failure in mutter. That's even more of a problem with autoclose-xwayland
where Xwayland is expected to terminate when there is no meaningful X11
client remaining, which can happen multiple times during the lifetime
of a user session.

To make sure that meta_xwayland_init_display() is called for every new
instance of Xwayland, simply keep the signal hooked in place by not
disconnecting it when triggered.

This reverts commit 9a10b8ff94.

Even though, originally, this issue was first introduced with commit
b4fe1fdd95 ("xwayland: Make setup/teardown
a bit more symmetrical") which didn't actually kept 'x11-display-setup'
and 'x11-display-closing' connected.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2168
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2339>
2022-03-30 13:51:26 +00:00
Carlos Garnacho
fff3654941 wayland: Check input device capabilities in tablet seats
Instead of looking for tablets and pads based on input device type,
check capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
844a729fa9 wayland: Set wayland seat capabilities based on input device capabilities
Instead of looking at device types, which might be incomplete.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2154
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Robert Mader
f9857cb8bd wayland/surface: Disable WL_SURFACE_ERROR_INVALID_SIZE check again
The check was introduces in ab17c98c94
but turned out to trigger client crashes in common cases.
Turn it into a warning for now until clients are fixed.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/2083
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/2163

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2335>
2022-03-24 15:15:08 +00:00
Robert Mader
7f93004809 compositor/native: Check that the surface can be scanned out untransformed
Before scanning out the surface of a native client we have
to check the following attributes that influence the
relationship between buffer and the defined result on screen:
 - buffer scale
 - buffer transform
 - viewport

In the future we can loose these checks again in cases where the
display hardware supports the required operations (scaling, cropping
and rotating).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2276>
2022-03-05 14:14:37 +00:00
Sebastian Keller
251bb45ec0 window/wayland: Always include a size when sending a configuration
Prior to 67033b0a mutter was accidentally including sizes for
configurations that were just focus state changes. This was not leading
to any known problems on the client side, but it was causing issues in
mutter itself when detecting whether a resize originated from the client
or the server.

Not including sizes in focus change configurations anymore however
revealed a bug in gtk. It was storing the window size when in a fixed
size mode (tiled/maximized/fullscreen), but not on any other server side
resizes. It was then restoring this stored size whenever there was a new
configuration without a size while in floating mode, i.e. the focus
change configurations generated by mutter after 67033b0a.

This change now addresses the issue 67033b0a was fixing in a way that
restores the previous behavior of always including the size whenever
sending a configuration.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2091
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2238>
2022-03-05 13:18:58 +00:00
Jonas Ådahl
590e32dc62 wayland/tablet-pad: Fix fallthrough warning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
a09b99261f wayland/dma-buf: Handle lack of gbm_device gracefully
In some configurations (e.g. NVIDIA driver 470) Xwayland may use DMA
buffer for passing buffers around. When this is done, we might attempt
to scanout these buffers when they are fullscreen, and to do so we
import them using gbm.

However, for the mentioned configuration, there is no gbm device
available for importing. This was not handled, and resulted in a crash;
avoid this crash by checking whether we have a gbm device and fail
gracefully if we don't.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2098
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2318>
2022-03-04 17:27:29 +00:00
Jonas Ådahl
370de58868 wayland/surface: Add support for wl_surface.offset
This aims to replace the x,y arguments in wl_surface.attach(); meaning
it can be used more sanely together with EGL, and at all when using
Vulkan.

The most common use case for the offset is setting the hotspot of DND
surfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1905>
2022-03-04 17:38:30 +01:00
Jonas Ådahl
fadffe3fad wayland/xdg-shell: Add toplevel bounds support
This implements the new 'bounds' event that is part of the xdg_toplevel
interface in the xdg-shell protocol. It aims to let clients create
"good" default window sizes that depends on e.g. the resolution of the
monitor the window will be mapped on, whether there are panels taking up
space, and things like that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
546b94545e window: Make a better guess at initial monitor
We'd guess the initial monitor before it was actually calculated by
looking at the initial geometry. For Wayland windows, this geometry was
always 0x0+0+0, thus the selected monitor was always the primary one.

This is problematic if we want to provide initial more likely
configurations to Wayland clients. While we're not doing that yet, it'll
be added later, and this is in preparation for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
213f0d8dd3 window/wayland: Pass x,y,width,height as rectangle
Will make the number of variables a bit more managable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Carlos Garnacho
9b6253bf3f wayland: Move away from clutter_event_get_source()
Instead ask the stage about the target actor, which is equivalent
and ensured to be up-to-date.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Robert Mader
8f91d831ee wayland/dma-buf: Fix typos in struct name
Fixes 7acecb1c72

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2297>
2022-03-04 09:16:28 +00:00
Robert Mader
5b9abecc1b wayland/dma-buf: Add missing wl_array_release()
So we don't leak the array.

Fixes 7acecb1c72

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2297>
2022-03-04 09:16:28 +00:00
Ivan Molodetskikh
bcf6ee5e55 Name unnamed sources
These names show up in GLib traces in sysprof, so let's make sure they
exist.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1928>
2022-03-04 10:10:05 +03:00
Jonas Dreßler
672696f823 dnd: Notify about events during compositor grab from event filter
Since the introduction of ClutterGrabs, MetaDnd now no longer gets
notified about input events on the stage during grabs (for example while
the alt-tab popup is shown) and thus can't move the grab feedback actor
anymore.

To fix this, forward events to MetaDnD directly from
meta_display_handle_event() when a ClutterGrab is in effect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2308>
2022-03-02 15:12:23 +00:00
Carlos Garnacho
32332fd53d wayland: Handle xdg_activation_v1_activate on non XDG activation tokens
The XDG activation support was missing interoperability with other
startup sequences, notably those coming from other means than XDG
activation.

In order to play nice with X11 startup sequence IDs, we not just
have to check for the startup ID being in the general pool, but
we also need to fallback into X11-style timestamp comparison so the
window ends up properly focused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2314>
2022-02-28 17:34:27 +01:00
Olivier Fourdan
fe41e69eea wayland/xdnd: Use multiple DnD X11 peers
When a drag and drop occurs from an X11 client to a Wayland native
client, mutter uses an internal X11 window as a peer for the DnD  drop
site.

That internal X11 window is moved and resized to match the Wayland
native windows as the drag destination moves.

When moving from one Wayland native window to another Wayland native
window, the same X11 window is used, and as a result no DND enter/leave
events is emitted.

In that case, the drop may occur on the wrong Wayland native window,
because no new XdndEnter/XdndLeave event were emitted.

To avoid that issue, use a pair of X11 windows instead of just one and
alternate between the two when repicking a new drop surface, so that
moving from a Wayland surface to another will always generate the
expected enter/leave events that we rely on.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2136
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2305>
2022-02-25 11:35:35 +01:00
Bilal Elmoussaoui
26790f7f39 wayland/keyboard: Remove unnused define
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2306>
2022-02-22 11:05:36 +01:00
Carlos Garnacho
7bf10de538 wayland: Warn and fix accounting on missed CLUTTER_TOUCH_END events
If we happen to handle a CLUTTER_TOUCH_BEGIN without a corresponding
CLUTTER_TOUCH_END at MetaWaylandTouch, we would still attempt to
reuse the older MetaWaylandTouchInfo, resulting in an assert triggered
as there is a stale touch reference on the previous surface.

Warn in place and create a new touch info struct to still fix the
broken surface accounting, instead of finding out the hard
way after the surface is destroyed. The assert is preserved to ensure
the accounting does not sneakily break anymore/further.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/584
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2251>
2022-02-14 13:54:33 +00:00
Florian Müllner
7ff52b6128 wayland/gtk: Only perform allowed titlebar gestures
The window functions "work" regardless of whether the client allows
the behavior or not. That is, it's up to the caller to not call
maximize and friends when the action isn't allowed.

Add appropriate checks, which should make the titlebar_gesture()
behavior identical to titlebar actions for server-side decorations.

https://gitlab.gnome.org/GNOME/mutter/-/issues/2139

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2281>
2022-02-10 20:00:15 +01:00
Carlos Garnacho
a88c9b9ff2 wayland: Use default cursor on tablet tools
Now that we "replace" the pointer cursor on tablet input, have it
use the default cursor so it blends in better.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Sebastian Wick
abadb29132 xwayland: Relax the ownership requirements of /tmp/.X11-unix
The `ensure_x11_unix_perms` function tries to detect systems on which
/tmp/.X11-unix is owned by neither root nor ourselves because in that
case the owner can take over the socket we create (symlink races are
fixed in linux 800179c9b8a1e796e441674776d11cd4c05d61d7). This should
not be possible in the first place and systems should come with some way
to ensure that's the case (systemd-tmpfiles, polyinstantiationm …). That
check however only works if we see the root user namespace which might
not be the case when running in e.g. toolbx.

This change relaxes the requirements such that in the root user
namespace we detect and abort if a vulnerable system is detected but
unconditionally run in toolbx.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2261>
2022-02-07 16:01:26 +00:00
Olivier Fourdan
8305c7bd06 wayland/client: Restore the NOFILE limit
Make sure the restore the original NOFILE limit prior to run the
trusted Wayland client so it does not inherit from the raised value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:47 +01:00
Carlos Garnacho
a840c039a0 core: Handle redirection changes in and out of ClutterGrab grabs
Wayland event processing and WM operations are themselves outside the
ClutterGrab loop so far. Until this is sorted out, these pieces of
event handling have got to learn to stay aside while there is a
ClutterGrab going on.

So, synchronize foci and other state when grabs come in or out, and
make it sure that Wayland event processing does not happen while
grabs happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Olivier Fourdan
b8870a11b8 xwayland: Warn when autoclose-xwayland is not usable
The experimental feature "autoclose-xwayland" requires a couple of
prerequisites:

1. Be able to (re)start Xwayland on demand, i.e. with systemd
2. Xwayland must support the terminate delay

Add a warning message if "autoclose-xwayland" was requested but any of
those prerequisites is not met.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2258>
2022-01-28 15:46:56 +00:00
Olivier Fourdan
6ce80ccc54 xwayland: Remove stop xserver timeout
Since commit 226afa24a - "Use Xwayland auto-terminate feature", the
callback function shutdown_xwayland_cb() does not check for the
autoclose-xwayland experimental feature anymore.

As a result, when running nested or outside of systemd,
gnome-shell/mutter would quit after 10 seconds unless some X11 window
was mapped.

But now that we rely on Xwayland's own terminate feature, there really is
no need to use any xserver timeout function anymore.

We do not need to keep track of X11 windows being created or unmapped, as
again, Xwayland does all that for us at the client level.

Remove all this code that we do not need anymore.

fixes: 226afa24a - Use Xwayland auto-terminate feature

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2258>
2022-01-28 15:46:56 +00:00
Olivier Fourdan
226afa24aa xwayland: Use Xwayland auto-terminate feature
When using Xwayland-on-demand (default), if the (experimental) autoclose
features is enabled, we can rely on Xwayland's auto-terminate feature
instead of explicitly killing the Xwayland process.

With it, gone is the mechanism that was added to check the X11 clients
connected and their executable to check whether we can (safely) kill
Xwayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1794>
2022-01-26 14:42:22 +01:00
Olivier Fourdan
42855b69e7 xwayland: Mark our X11 connection terminatable
The connection to the Xserver for the X11 window manager part of mutter
even on Wayland may prevent the Xserver from shutting down.

Currently, what mutter does is to check the X11 clients still connected
to Xwayland using the XRes extension, with a list of X11 clients that
can be safely ignored (typically the GNOME XSettings daemon, the IBus
daemon, pulseaudio and even mutter window manager itself).

When there is just those known clients remaining, mutter would kill
Xwayland automatically.

But that's racy, because between the time mutter checks with Xwayland
the remaining clients and the time it actually kills the process, a new
X11 client might have come along and won't be able to connect to
Xwayland that mutter is just about to kill.

Because of that, the feature “autoclose-xwayland” is marked as an
experimental feature in mutter and not enabled by default.

Thankfully, the Xserver has all it takes to manage that already, and
is even capable of terminating itself once all X11 clients are gone (the
-terminate option on the command line).

With XFixes version 6, the X11 clients can declare themselves
"terminatable", so that the Xserver could simply ignore those X11
clients when checking the remaining clients and terminate itself
automatically.

Use that mechanism to declare mutter's own connection to the Xserver as
"terminatable" when Xwayland is started on demand so that it won't hold
Xwayland alive for the sole purpose of mutter itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1794>
2022-01-26 14:42:22 +01:00
Robert Mader
dea9f8bbfe wayland/surface: Make ensure_cached_state() static
There is no reason for it to be public or have a return value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Robert Mader
e3f0efa065 wayland/surface: Ensure to apply cached state
It is possible that we never create a cached state for a surface
even if it is synced. That is the case if `commit()` is never called.
We still need to call `apply_state()` in this case in order to run
e.g. `role_post_apply_state()` or `parent_state_applied` on subsurfaces.

So just ensure to initialize the cached state instead of bailing out.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Robert Mader
03434e566a wayland/subsurface: Ensure cached state recursivly gets applied on set_desync()
Subsurfaces can be effectively synced indirectly via their ancestors.
Right now such indirectly synced surfaces don't apply their cached
state when their ancestor effectively becomes desync as by the time
we call `parent_state_applied()` on them, they are considered as
desync.

Thus sligthly reoder things so when the ancestors becomes desync
and applies its state, those surfaces still count as synced and
will thus apply their cached state as well.

While on it, add a check to prevent `set_desync()` to have side
effects when the target surface is not currently synced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Jonas Ådahl
a2382f3251 wayland/dma-buf: Don't warn if there was no render node
When running in KVM, the EGL driver supports querying the render node
path, but it returns NULL. Handle that better by falling back to
querying the device main device file, instead of falling back on v3 of
the protocol and logging a warning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Robert Mader
ab17c98c94 wayland/surface: Implement WL_SURFACE_ERROR_INVALID_SIZE check
From the spec:
> This means that at commit time the supplied buffer size must be
> an integer multiple of the buffer_scale. If that's not the case,
> an invalid_size error is sent.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1938

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2188>
2022-01-07 20:46:42 +00:00
Jonas Ådahl
926c34cc89 wayland/dma-buf: Fix typo
A = was placed where a ; should have been placed. Caught by coverity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2215>
2022-01-07 19:31:23 +00:00
Jonas Ådahl
5523242eb9 wayland/dma-buf: Define fallback EGL_DRM_RENDER_NODE_FILE_EXT
If the EGL header is not new enough, it will not contain that relatively
new macro definition, so to avoid breaking compilation, define it
ourselves for now. Should be possible to remove after some time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2214>
2022-01-07 18:25:41 +00:00
Fernando Monteiro
12de68abf3 wayland: Drop deprecated text input
This has been replaced for text-input-v3.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2185>
2022-01-05 22:30:21 +00:00
Fernando Monteiro
a8bf9d8c68 wayland: Drop wl-shell protocol
This protocol is deprecated since a long time, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2183>
2022-01-05 21:43:29 +00:00
Jonas Ådahl
8a2fcf3be0 wayland: Use new KMS update test API to try acquiring scanout
This significantly increases the chance of a fullscreen surface buffer
being scanned out instead of being painted via composition. This is
assuming the client supports the DMA buffer feedback Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
64e6bedb6b wayland/dma-buf: Add support for scanout surface feedback
Whenever a surface is promoted as a scanout candidate by
MetaCompositorNative, it'll get a CRTC set as the candidate CRTC.

When a client asks for DMA buffer surface feedback, use this property to
determine whether we should send a scanout feedback tranche.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
4c54b36126 wayland/dma-buf: Move should_send_modifiers() to the top
It's very much an auxiliary method; lets move it to where it belongs,
according to HACKING.md.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
43161c6660 compositor/native: Track what Wayland surface is a scanout candidate
For the current candidate, set the candidate CRTC on that surface. This
will later be used to send DMA buffer feedback for direct scanout purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
9a47766a96 wayland/dma-buf: Add tranche priorities
Unused for now, but will be added to prioritize scanout tranches higher
than render only ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
9c942a43d6 wayland/dma-buf: Make manager object a GObject
Will make certain operations easier, i.e. setting up a GQuark.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
90076cf268 wayland/surface: Remove unnecessary NULL check
This check has caused repeated confusion, as there are no current code
paths where this can ever end up in the true-branch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
2a16a750c5 wayland/dma-buf: Always advertise non-modifier fallback
This is done to explicitly tell clients that the compositor supports
implicit modifier paths (i.e. using modifier unaware API).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
7acecb1c72 wayland/dma-buf: Add basic support for DMA buffer feedback
This includes sending the default tranche, but so far only sends the
same for every surface feedback requested. Scanout tranche will be added
later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
1978e93f28 wayland/dma-buf: Prepare format/modifier map up front
As the format table is setup up front, it doesn't change when this
experimental feature setting change. Make the settings documentation
reflect that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
51308a9d78 wayland/dma-buf: Add manager struct
It'll be used to store state related to DMA buffer Wayland support.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Robert Mader
9ee03fe93b wayland: Fix some code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Robert Mader
f51cccbc29 wayland/surface: Fix code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Jonas Ådahl
32affbf05a wayland/dma-buf: Fix building without native backend
The usefullnes of Wayland without the native backend is questionable,
but since it's theoretically possible, make it at least compile again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:24:36 +01:00
Jonas Ådahl
06c215c747 wayland/surface: Remove unnecessary resource user data changing
We're in the destructor, it's pointless to unset the userdata as we'll
never ever see a request being invoked with it ever again, since the
resource itself will be destroyed or marked as destroyed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:19:33 +01:00
Ievgen Popovych
b596de2680 wayland/window-configuration: Fix missing horizontal maximized check
Signed-off-by: Ievgen Popovych <jmennius@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2187>
2021-12-28 20:21:52 +02:00
Jonas Ådahl
25ed64b61d cursor-sprite: Register all cursor sprites with the cursor tracker
This will later be used to invalidate GPU state when closing device
nodes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Robert Mader
c498ae337f wayland/surface: Do not uncoditionally process surface damage
Most clients nowadays switched to buffer damage, most notably Mesa
and Xwayland. Thus lets avoid the extra cost of allocating three
`cairo_region_t`s and doing some calculations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
c166811695 wayland/surface: Use correct default viewport for surface damage
If no viewport is set, the neutral viewport is the surface size
without viewport destination size applied - i.e. transform and
scale applied to the buffer size. Change it accordingly, giving
us the same values we'd return in `get_width` in this case.

As result, this only changes cases where a viewport destination
size but no viewport source rectangle is set.

The change fixes exactly such cases, e.g. the Gstreamer Wayland
sink. Can be tested with: `gst-play-1.0 --videosink=waylandsink`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
f4717d0ac5 wayland/surface: Switch order for calculating surface damage
Process surface damage in the right order, simplifying the
calculations.

No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Jonas Ådahl
0df12ebee6 xwayland: Don't remove /tmp/.X11-unix/X0 when running tests
When Xwayland was not initalized, we'd still clean things up. What this
accidentally meant was that the uninitialized display number 0 was
cleanud up, which very likely was main display of the host session.

What this meant in practice was that /tmp/.X11-unix/X0 was often
removed, causing every Flatpak X11 application to fail to start until
Xwayland was restarted nad the X0 socket file was restored.

Fix this in two ways: firstly only shutdown Xwayland if we ever started
it, i.e. if the X11 display policy was not 'disabled'. This should fix
the issue most of the times. Secondly only clean up the socket if it was
ever initialized. This should fix things if the socket creation failed,
as if it did, the name would be set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2162>
2021-12-19 16:52:45 +00:00
Jonas Ådahl
3602762a18 tests/wayland-unit-tests: Add test case for remapping popup with subsurface
This test reproduces the crash in
https://gitlab.gnome.org/GNOME/mutter/-/issues/1828. It does not
reproduce with 'window-actor/wayland: Remove subsurface actors on
dispose' (dd416dd3e2). applied. This test case differs slightly
from the one that came with the dd416dd3e2 as in that it uses
withdrawn popup surfaces instead of explicitly client managed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
8a43123765 xdg-shell/popup: Reset 'dismissed-by-client' state when remapping
A popup surface can be remapped multiple times using the same
wl_surface, if a new xdg_popup object is created. To properly handle
this, we need to reset the 'dismissed_by_client' boolean to false, as
otherwise we won't allow new buffer commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
José Expósito
cea5c47671 wayland/pointer: Return on scroll without client
Return early from handle_scroll_event if no client is focused to avoid
redundant calculations.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
José Expósito
d703ba56c3 wayland/pointer: Call wl_resource_get_version once
Call wl_resource_get_version once for each pointer resource.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
Carlos Garnacho
d2998a8e41 wayland: Check keyboard serials for activation
We are using internal API that has the benefit of checking that the
focus surface still matches, but has the drawback that it does not
check the MetaWaylandKeyboard state.

In order to fix this, look for keyboard focus and serial matches
specifically when triggering activation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2148>
2021-12-13 14:49:14 +00:00
Georges Basile Stavracas Neto
87a66830dc cogl: Drop cogl-wayland-server.h
This header only defines one function that doesn't exist anymore,
and nothing else. It can be safely dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2145>
2021-12-07 18:34:00 -03:00
Carlos Garnacho
eda7588190 backends: Replace MetaCursorSprite::prepare-at with in-place function
Since this signal is in a hot path during input handling, it makes sense
not to have this be a signal at all, currently most of the time spent in
it is in GLib signal machinery itself.

Replace it with a function/user data pair that are set on the sprite
itself. Only the places that create an sprite are interested in hooking
one ::prepare-at behavior per sprite, so we can do with a single pair.

This makes meta_cursor_sprite_prepare_at() inexpensive enough.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
5e93708d86 wayland: Mark sprite as invalid after cursor changes
This will be used to hint the backend that the cursor surface
might need uploading again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
508c08fa09 backends: Only reload sprite cursor on changes
Let the meta_cursor_sprite_realize() function return a boolean value
telling whether there was an actual change in the sprite cursor. E.g.
the surface/icon for it changed in between.

This is used in the native backend to avoid converting/uploading again
the cursor surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
c07c50d189 wayland: Make the pointer leave non-alive surfaces
Listen to changes in MetaWindow::is-alive, so that the pointer
can logically leave the surface as soon as that happens. This
helps prevent flooding the client socket while it is stalled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2122>
2021-12-07 17:15:21 +00:00
Jonas Ådahl
29141afd0f xwayland: Handle the died callback being cancelled more gracefully
If we were cancelled, it could mean we teared down, meaning fetching
manager instances will attempt to fetch past freed instances. Handle
this by waiting with the fetching until we know we weren't cancelled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2140>
2021-12-07 16:38:20 +00:00
Jonas Ådahl
ad0d70d5d5 wayland: Detach event source on tear down
No reason keeping it attached; would one continue using a main loop on
the default main context after tear down, we'd get callbacks causing
use-after-free issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2140>
2021-12-07 16:38:20 +00:00
JoseExposito
8d34b50918 wayland/pointer-gestures: Implement hold gesture
Update the pointer gestures protocol to version 3 and implement the new
hold gesture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
JoseExposito
c545ffac43 wayland/pointer-gestures: Update protocol to v2
Update the pointer gestures protocol to version 2 and implement the new
release method.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
Jonas Ådahl
7b83735aea wayland/output: Always set xdg_output interface implementation
This avoids the following crash, that could happen in certain rare race
conditions, e.g. in tests:

  0) wl_closure_invoke (closure=0x2fbf9e0, target=0x2e5b3d0, opcode=0)
     at ../src/connection.c:1014
  1) wl_client_connection_data () at ../src/wayland-server.c:432
  2) wl_event_loop_dispatch () at ../src/event-loop.c:1027
  3) wayland_event_source_dispatch () at ../src/wayland/meta-wayland.c:104
  4) g_main_dispatch () at ../glib/gmain.c:3381

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2127>
2021-12-02 20:07:49 +00:00
Carlos Garnacho
e74e8061a4 wayland: Specify workspace when looking for Xdnd drop target
The meta_stack_get_default_focus_window_at_point() function started silently
requiring a workspace, returning always NULL otherwise. Specify the current
workspace here.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2042
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2124>
2021-12-01 15:39:08 +01:00
Jonas Ådahl
7f720a40b4 wayland/activation: Don't grab if no serial or surface was provided
A client can create a token without any seat, serial, or surface. In
this case, we'd still try to grab, which would run into some unforseen
code paths, potentially resulting in the following crash:

  0) meta_wayland_tablet_seat_device_added (tablet_seat=0x55dff4271c90,
                                            device=0x7f87b80655b0) at
       ../src/wayland/meta-wayland-tablet-seat.c:200
  1) meta_wayland_tablet_seat_new (seat=0x0, manager=0x55dff3ec7b40) at
       ../src/wayland/meta-wayland-tablet-seat.c:283
  2) meta_wayland_tablet_manager_ensure_seat (manager=manager@entry=0x55dff3ec7b40,
                                              seat=seat@entry=0x0) at
       ../src/wayland/meta-wayland-tablet-manager.c:239
  3) meta_wayland_tablet_manager_ensure_seat (seat=0x0, manager=0x55dff3ec7b40) at
       ../src/wayland/meta-wayland-touch.c:595
  4) meta_wayland_seat_get_grab_info (seat=0x0, surface=0x55dff43ff5b0,
                                      serial=0, require_pressed=0, x=0x0, y=0x0) at
       ../src/wayland/meta-wayland-seat.c:479
  5) activation_activate (...) at
       ../src/wayland/meta-wayland-activation.c:261

Fix this by not trying to grab if not enough parameters was passed when
creating the token. Also add a test case that reproduces the above
crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Jonas Ådahl
c41657bc4f wayland/activation: Remove token from hash table on timeout
When an activation times out, we'll be signalled two signals on the
startup sequence object: "timeout", and "complete".

Normally, the "complete" signal is emitted when a startup sequence is
completed succesfully by it being used for activation, and in this case,
the xdg_activation implementation should remove the sequence from the
startup notification machinery.

However, in the timeout case, we should not remove it, as the startup
notification machinery itself will deal with this. If we would, we'd end
up with use-after-free issues, as the sequence would be finalized when
removed the first time.

To avoid this, just clean up the Wayland side in the "timeout" signal
handler, leaving the "complete" signal handler early out if it was
already handled by it.

This avoids crashes like:

  0) g_type_check_instance (type_instance=type_instance@entry=0xdd6740)
  1) g_signal_handlers_disconnect_matched (instance=0xdd6740, ...)
  2) meta_startup_notification_remove_sequence (sn=0x4cc890,
                                                seq=0xdd6740) at
       ../src/core/startup-notification.c:544
  3) startup_sequence_timeout (data=0x4cc890, ...) at
       ../src/core/startup-notification.c:504
  4) g_timeout_dispatch (...) at ../glib/gmain.c:4933

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Sebastian Keller
d66e3e2d8a window/wayland: Detect client resizes with pending non-resizes
The previous code was trying to detect client resizes by only
considering resizes without any pending configurations as client
resizes. There can however be pending configurations that do not involve
resizing, such as ones triggered by state changes. These may also stay
unacknowledged by the client until the next size change. This was
causing client resizes after showing the window (and therefore changing
its status to focused) to not be detected as client resize.

Fix this by checking whether the queue has any configuration with size
changes rather than just whether it is empty.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2023
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2103>
2021-11-23 00:51:01 +00:00
Sebastian Keller
67033b0acd wayland/window-configuration: Fix maximized check in fixed size check
This was always true and therefore resulting in all configurations being
considered as having a size, even when they don't change the size, such
as a state change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2103>
2021-11-23 00:51:01 +00:00
Sebastian Keller
8eb268fc3b window/wayland: Differentiate between requested and direct resizes
meta_window_wayland_finish_move_resize() is called for both, finishing
a resize that has been requested through/by mutter and for resizes
directly done by the client. This introduces a CLIENT_RESIZE flag to
differentiate the former from the latter. Having this distinction is
required to know what the last requested size by either the client or
mutter is while ignoring older requests that might only have been
applied now.

This excludes client resizes when there are still pending
configurations, because the resize is known to be only temporary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Quytelda Kahja
af6fb2a702 clutter: Fix event axes array indices in axis broadcasts
A clutter event's axes array is indexed by `ClutterInputAxis`.
However, a few lines accidentally use `ClutterInputAxisFlags` as
indices, reading incorrect values from elsewhere in memory. As a
result, broadcasted axis values for the tilt, rotation, and wheel
axes don't reflect actual event data.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1982
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2065>
2021-10-28 16:20:20 +00:00
Jonas Ådahl
c0bc821f62 wayland/output: Remove wl_output global when making it inert
This will make clients immediately aware of the output disappearing,
while still allowing for a grace period of 10 seconds for attempting to
bind to it before it turning into a protocol error. This API added as
part of wayland 1.18.

This requires us to not add the output resource to the output resource
list, if the output was made inert. This effectively makes the resource
useless, but that is harmless, since shortly after, the client will
clean it up anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 17:31:46 +02:00
Jonas Ådahl
257ccf5e80 xwayland: Unset shutdown idle id when source removed by callback
We failed to do this when the experimental "auto-close Xwayland" setting
was not enabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
1dd79c52ad xwayland: Trap errors when setting primary RANDR output
This will be crucial when we start to remove the global directly when an
output is removed, as that means Xwayland might have removed the output
before we managed to get our queries in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
39f80885c1 xwayland: Setup RANDR integration with MetaX11Display
This doesn't gain us anything right away, but will allow us to trap
errors, which will soon be necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
fb78ac4016 xwayland: Init/shutdown DND using MetaX11Display
Before it was passed an Display pointer, and had to e.g. fetch the root
window from GDK instead of the MetaX11Display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
b4fe1fdd95 xwayland: Make setup/teardown a bit more symmetrical
We setup Xwayland in an early phase of the X11 display, before we had a
MetaX11Display, and teared down in a couple of places happening when
tearing down the Xwayland integration if the X server died or
terminated. It was a bit hard to follow what happened and when it
happened. Attempt to clean this up a bit, with things being structured
as follows:

 * Early during X11 display connection setup, only setup the rudimentary
   X11 hooks, being the libX11 error callbacks, and adding the local
   user to XHost.

 * Move "initialize Xwayland component" code to a new
   'x11-display-setup' signal handler. Things setup here are cleaned up
   in the 'x11-display-closing' handler.

 * Connect to 'x11-display-setup' and 'x11-display-closing' up front,
   and stay connected to these two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:54:58 +02:00
Jonas Ådahl
69f9b36643 xwayland: Pass the manager object to XSetIOErrorExitHandler
This means we can avoid going through global singletons in the handler.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:32:27 +02:00
Carlos Garnacho
ccaa4c049b wayland: Plug leak in error condition
If we fail to bind the X11 socket, free the lock file string.

CID: #1505865
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00