1
0
Fork 0
Commit graph

1821 commits

Author SHA1 Message Date
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