1
0
Fork 0
Commit graph

12354 commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
2a88a3eb96 x11/window: Do not try to compare a wayland active window with X11
If a window sends a configure stacking request, we were comparing the
active window with the event window even though they were different
client types (e.g. wayland and x11).

This was leading to a critical error, so let's handle this by ensuring
that the active window is of the same kind of the event window before
doing x11-specific checks. Behaving as different applications in case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3727>
2024-05-03 12:38:01 +00:00
Daniel van Vugt
f3a52551f1 backends/native: Remove unused meta_kms_device_add_fake_plane_in_impl
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
2024-05-02 09:34:46 +00:00
Daniel van Vugt
14e18de90d backends/native: Add fake cursor plane using impl_device's crtcs
Because `meta_kms_impl_device_simple_initable_init` is called in the
middle of `meta_kms_device_new`, the crtcs list for `MetaKmsDevice`
has not been populated yet. And thus the loop to detect missing
cursor planes and create fake ones never iterated. But the crtcs list
does already exist in `MetaKmsImplDevice` so iterate over that instead.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3264
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
2024-05-02 09:34:46 +00:00
Daniel van Vugt
b620dbb188 kms/impl-device: Add function meta_kms_impl_device_has_cursor_plane_for
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
2024-05-02 09:34:46 +00:00
Michel Dänzer
dd32f3b3be wayland/transaction: Check surface pointer validity in _ensure_entry
If a caller passes in NULL or a non-NULL value which doesn't point to
a valid MetaWaylandSurface object, this will hopefully point in the
direction of the cause.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3725>
2024-04-30 17:14:56 +00:00
Michel Dänzer
b67f94ca7e wayland/subsurface: Hold sibling surface reference in placement ops
It was possible for the sibling surface to be already destroyed in
meta_wayland_transaction_add_placement_surfaces, in which case
g_object_ref would return NULL for it, and
meta_wayland_transaction_commit would then crash dereferencing a NULL
surface pointer.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3462
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3725>
2024-04-30 17:14:56 +00:00
Carlos Garnacho
243890a688 wayland: Do not forget immediately of key press serials on key release
Prior to commit 5dfed8a431, the MetaWaylandKeyboard would always remember
the last key press serial, and consider it valid after the key was released,
as long as no other key presses/releases happened in between.

That commit improved things so that MetaWaylandKeyboard can track multiple
keys being pressed simultaneously, but also changed so that the serial for
a key press is immediately forgotten after the key press event was received.
This may break in situations like testing or keyboard macros where key
press and release is handled in a quick sucession, so the client reaction
to the key press (e.g. popping up a menu) might arrive too late.

Add a sort of spiritual successor to this handling, and make keyboard
press serials corresponding to the last key up forgotten at the next
key press/release received.

Fixes: 5dfed8a431 ("wayland: Preserve serial for all pressed keys")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3458
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3721>
2024-04-26 19:15:06 +00:00
Carlos Garnacho
fb8ac5dff7 wayland: Track current tablet tool focus surface
We did not track the current surface (i.e. the logical focus) too
thoroughly, so there might be chances that a stale surface pointer
here becomes the focus. Track its destruction (like it's done at e.g.
MetaWaylandPointer) and unset the current surface early, in order
to avoid possible invalid memory access.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3372
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3715>
2024-04-25 14:33:28 +00:00
Mart Raudsepp
669d21daa2 x11: Drop obsolete libXrender dependency
It seems only the iconcache used to use it, but this is gone since
commit d16ddc42ce.
Even before that, the Xrender usage was removed in commit 556e7694de,
albeit leaving a redundant include <X11/extensions/Xrender.h> in its
place then, which comes from libXrender.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3716>
2024-04-22 10:16:31 +00:00
Robert Mader
6a81d5f0bb wayland/surface: Fix sending preferred buffer transform
Fix an obvious copy paste error that slipped through the cracks.
Fortunately it doesn't have a visual impact for well behaving clients
but only makes us not hit direct-scanout paths, assuming no other bugs
in the stack.

Fixes: f21762ea6e (wayland: Add support for preferred_buffer_scale/transform)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3717>
2024-04-22 11:39:31 +02:00
Carlos Garnacho
1fdae4f856 wayland: Drop meta_wayland_keyboard_get_focus_client()
All its users did not necessarily depend on a MetaWaylandKeyboard
existing, so were ported to using the MetaWaylandSeat global input
focus. This may now be dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Carlos Garnacho
9bdb00c459 wayland: Follow seat's input focus client for primary selections
The concept of "input focus" will exist regardless of a MetaWaylandKeyboard
being available or not, use the seat's focus for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Carlos Garnacho
5ca10c31d1 wayland: Follow seat's input focus client for clipboard selections
The concept of "input focus" will exist	regardless of a	MetaWaylandKeyboard
being available	or not,	use the	seat's focus for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Carlos Garnacho
743fb6df30 wayland: Add meta_wayland_seat_get_input_focus_client() call
This call is meant to replace meta_wayland_keyboard_get_focus_client(),
since we will always have a MetaWaylandSeat with an input focus (or not),
but we may or may not have a MetaWaylandKeyboard.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Sebastian Wick
cad9a65b07 clipboard-manager: Cancel selection transfers
When there is a new owner but there is no matching mime type we clear
the saved mimetype and the saved clipboard but an outstanding async
meta_selection_transfer_async can set the saved clipboard.

Abort the async transfer when we have a new owner.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3678>
2024-04-19 14:31:01 +00:00
Sebastian Wick
ce32d2b77a clipboard-manager: Make sure we always have mimetype
The precondition checks in meta_selection_source_memory_new can return
NULL if the mimetype is NULL but callers expect the error to be set when
NULL is returned.

Let's just make sure we never call it with a NULL mimetype.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3678>
2024-04-19 14:31:01 +00:00
Carlos Garnacho
5dfed8a431 wayland: Preserve serial for all pressed keys
The current code checking keyboard serials for popup/grab
validation is a bit simple, tracking one key press exclusively.
This may break expectations if a client uses a serial
corresponding to a previous key that is still pressed.

Keep track of the serials corresponding to all pressed keys,
and ensure these are reset across focus changes, since the
validity of those serials is already outdated. The code does
still keep track of a single (last) key release serial, since
the validity lifetime is somewhat underdefined with those if
we keep track of multiple keys simultaneously.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3267
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3644>
2024-04-19 13:50:08 +00:00
Jonas Ådahl
73990f011f window: Set the initial suspend state to 'hidden'
Instead of initializing to 'suspended', which will send the `SUSPENDED`
xdg_toplevel state, set it to hidden at first. If the window is placed
on an inactive workspace, it'll eventually enter the 'suspended' state,
but will have had some time in non-suspended state to get map, even if
not visibly.

This fixes inital suspended state when mapping a window maximized.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3229
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
cf176df006 window: Add internal meta_window_should_show() API
This, in contrast to meta_window_should_be_showing() reports whether a
window should be showing despite not being showable. This is useful to
know the intended visibility state that should happen in the immediate
future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
c5caa4afb5 tests/wayland/client-utils: Add optional xdg-shell v6 support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
f23e1218e3 tests/wayland/client/utils: Add way to mark surface as opaque
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
594cdc5b49 tests/wayland/client-utils: Track xdg_toplevel state
This allows tests to check whether a state is set or not at any given
time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
69c7ca02f4 tests/wayland: Replace wl_display_dispatch() with helper
In most cases, we just want to fail the test if dispatching fails, so
add a helper that does that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
4d8f6af487 test/wayland/client-utils: Add 'painted' signal
This is emitted when a client painted and committed new surface content.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
2d18b976c1 tests/wayland/client-utils: Add GObject parent instance field
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
eab06bcf24 window: Move out 'showable' check from should_be_showing_on_workspace()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
33ff998a10 tests/wayland/utils: Add method to synchronize with windows being shown
Can be used to wait for a window to be "shown", meaning it'll be added
to the stack and will be part of the next frame (assuming it's actually
not obscured etc).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
fd6d86d33d window: Add documentation to should_be_showing(_on_workspace)()
It's a bit unclear whether "should be shown" takes ability to actually
immediately show into account. Make this clear in a function doc
comment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Sebastian Keller
e4763d00e8 x11/window: Update comment and variable name to reflect current behavior
d991961ae changed this code from client rect to buffer rect to account
for the fact that for SSD windows the decorations are now included in
the bounding region, but it kept the variable name as client_area and
the comment was also still referring to the client rect.

Fixes: d991961ae ("x11: Use input region from frame window for decorated windows")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3697>
2024-04-19 13:18:39 +00:00
Sebastian Keller
6bd920b355 x11/window: Use correct bounding rect to determine NULL input region
When updating the input region we check whether the input shape reported
by XShape matches the bounding region of a window to determine when it
was not set by the client. We would then use a NULL input region instead
which always matches the full size of the window. The code however was
using the client rect for this comparison, which does not include the
window frame. Since d991961a the frame is considered part of the input
region.

This meant that for SSD windows where the input region would match the
bounding region, we would not detect that and fail to set the input
region to NULL, but instead set it to the reported input shape.

Usually this would not be the case due to the GTK frame window having
shadows and a resize region, but in the presence of an issue that causes
GTK to wrongly detect _GTK_FRAME_EXTENTS as not supported, GTK would not
draw shadows or set an input shape. And due to GTK not updating its
input shape, there would be no further calls to
meta_window_x11_update_input_region() after the initial one.
The input region would therefore remain at the fixed size from the
initial call. This was causing windows to become click-through outside
of the region corresponding to their initial size after being resized.

Fixes: d991961ae ("x11: Use input region from frame window for decorated windows")
Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6558
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3404
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3697>
2024-04-19 13:18:39 +00:00
Sebastian Keller
2e38ec6ce1 frame: Assume a size of 0 when extent properties are undefined
Previously the function would exit early, never changing the out value
which is usually passed in uninitialized. This would however only happen
in the presence of another issue leading to the properties being
undefined. We can still be a bit more defensive against this though.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/3404
Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6558
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3697>
2024-04-19 13:18:39 +00:00
Michel Dänzer
c25f6f2ded wayland/buffer: Pass g_object_unref to g_ptr_array_new_with_free_func
The release_points array holds pointers to MetaWaylandSyncPoint objects.

Fixes leaking references (and ultimately the underlying memory) for the
array elements.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3442
Fixes: e8b890ab53 ("wayland: Implement linux-drm-syncobj-v1")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3710>
2024-04-19 10:32:38 +00:00
Jonas Dreßler
bbb196bdde wayland/touch: Store touch serials more persistently
Right now we store touch serials on their according MetaWaylandTouchInfo
entries. These entries are gone as soon as the touchpoint ended though, and
it's not unlikely that clients will respond to that touch-end event after we
removed the touchpoint.

In this case we currently can't match the client provided serial to any of
our known touch sequences, which causes xdg_popup grabs that get requested
shortly after the touch-end to fail.

Let's be a bit more gentle on clients here and store the latest touch-down
serial on the MetaWaylandTouch, so that it continues to be around after the
touch-end and we can match the serial of the xdg_popup_grab() as expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2946>
2024-04-17 11:13:08 +00:00
Daniel van Vugt
d53da38198 onscreen/native: Avoid dereferencing gbm.next_fb when not in MODE_GBM
Such as with MODE_EGL_DEVICE.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3436
Fixes: 40950f99b3 ("drm-buffer-gbm: Do not call ensure_fb_id from...")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3708>
2024-04-17 13:34:22 +08:00
Daniel van Vugt
040800268f onscreen/native: Don't refuse primary GPU copy support based on egl_surface
Because that egl_surface is only used for secondary GPU copying, which
isn't relevant to primary GPU copies.

This is a partial revert of 41bfabad96 which is no longer required since
the previous commits have enabled secondary GPU copy support for nvidia-drm.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2551
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
7e27d297dd renderer/native: Remove cached program ID when EGLContext destroyed
In the rare event that hotplugs destroy and then create a new EGLContext
with the exactly the same ID, this ensures we will forget the old program
which presumably wouldn't work in the new context. It will be recreated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
ccca3709c2 renderer/native-gles3: Fix up function parameter alignment
check-code-style was complaining about this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
2d3a2a52b8 renderer/native-gles3: Add fallback using a shader
The EGL context can only import and blit an EGLImage if the
backing DMA buffer has a format modifier combination that is advertised
as supported and not marked as "external_only".

When the context can't blit the imported image, we can still paint using
it GL_OES_EGL_image_external using the texture target
GL_TEXTURE_EXTERNAL_OES.

However, treat drivers who doesn't support modifiers at all as if they
do support blitting, if the modifier is 'linear', to avoid regressions.

[jadahl: Make shader path a fallback to allow hardware to utilize copy
engines via blitting]

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6221
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2247
Related: https://launchpad.net/bugs/1970291

now only falls back if modifiers are supported, and they mark linear as
export only.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
b065dce194 renderer/native-gles3: Remember to set the glViewport
This is a critical part of any OpenGL program. Mesa allowed us to get
away without it and provided a sane default of the full buffer, but
Nvidia seems to default to an empty/zero viewport so would refuse to
paint any pixels.

In the OpenGL ES 2.0 spec this is ambiguous:

> In the initial state, w and h are set to the width and height,
> respectively, of the window into which the GL is to do its rendering.

because the first "window" used is EGL_NO_SURFACE in
init_secondary_gpu_data_gpu. It has no width or height.

In the OpenGL ES 3.0 spec the ambiguity is somewhat resolved:

> If the default framebuffer is bound but no default framebuffer is
> associated with the GL context (see chapter 4), then w and h are
> initially set to zero.

but not entirely resolved because neither spec says whether
EGL_NO_SURFACE should be treated as zero dimensions (Nvidia) or ignored
and not counted as the first "window" (Mesa).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
af98776224 onscreen/native: Finish primary GPU rendering before copying to secondary
As mentioned in the OES_EGL_image_external spec, there is no implicit
sync between the EGLImage producer and consumer. And in this code path
we don't have meta_drm_buffer_gbm_new_lock_front on the primary GPU to
do it for us either. So synchronization has to be done manually or else
the secondary GPU is likely to get an unfinished image.

This problem has only been observed when the secondary GPU is using the
Nvidia proprietary driver.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
5edb22d7d7 renderer/native: Flag when explicit sync between GPUs is required
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
8c6aabb9ca egl: Add function: meta_egl_query_string
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
9fee3a9ec1 onscreen/native: Fall back to gbm_surface_create without flags
The Nvidia driver will return ENOSYS if any flags are used. Bug filed
upstream on the NVIDIA forums.

https://forums.developer.nvidia.com/t/gbm-surface-create-fails-if-flags-0/279951

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Jonas Ådahl
32da2789bf meta/util: Move out debug topics and meta_topic()
The purpose is to not include all of clutter and cogl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Jonas Ådahl
a24b7956da meta/common: Put META_EXPORT in its own header
Want to include it without including all of clutter and cogl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Jonas Ådahl
0b91d22848 common/cogl-drm-formats: Split out format to string helper
It means it can be included in places that assume cogl and everything it
involves shouldn't be included, e.g. meta-renderer-native-gles3.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Sebastian Wick
f91851154e core/window: Do not rely on Monitor Numbering
When the monitors change meta_window_update_for_monitors_changed is
called which is responsible for updating window->monitor. It however can
go through the entire window placement and constraint machinery before
it's able to do so. In this period window->monitor points to the old
MetaMonitor where the monitor number doesn't reflect the index into the
MonitorManager anymore.

Avoid relying on the window->monitor->number and go through the Monitor
directly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3402
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3691>
2024-04-16 20:31:23 +00:00
Sebastian Wick
74a01e3f39 color-device: Use a sRGB profile if the EDID is missing
This makes sure the ColorDevice can initialize successfully even if the
display doesn't have an EDID.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3394
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3673>
2024-04-16 13:45:13 +02:00
Carlos Garnacho
d214583aa2 wayland: Do not bypass MetaWaylandInput changing keyboard focus
In every other device and circumstance, we update the logical focus
(i.e. the surface that would be focused, if no other circumstances
applied) but let the MetaWaylandInput figure out the surface that
should be effectively focused, if at all. This is where we apply the
actual compositor state (e.g. grabs) and result in an effective focus
window.

The only exception to this is `meta_wayland_seat_set_input_focus()`
where the logical focus for keyboards and related devices is set, but
also applied as the effective surface.

We should do the same as everywhere else, and let MetaWaylandInput
focus determine whether the logical focus is also the effective focus.
These replaced set_focus() internal calls will happen through the
default MetaWaylandEventInterface.focus implementation in MetaWaylandSeat.

This resulted in keyboard focus being set on windows in circumstances
it ought not to, like in the overview. Actual key events were never
sent in these circumstances, but changes to modifier state could.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7528
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3704>
2024-04-15 20:43:44 +00:00
Carlos Garnacho
3b5f467163 core: Allow fullscreen modals to move out of the center of their parents
If a modal dialog (i.e. with a "revolves around center of parent window" policy)
becomes fullscreen, we cannot neatly honor both the modal dialog going fullscreen
and the window staying around the center of its parent.

In order to make fullscreening work in this situation, allow fullscreen modal
dialogs to "snap out" of the parent. This rule will become again effective after
the window is unfullscreened.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3425
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3695>
2024-04-15 20:24:30 +00:00