Commit graph

7347 commits

Author SHA1 Message Date
Simon Ser
428279a319 build: add Meson wrap manifests for our dependencies
Add Meson wrap manifests for all of our dependencies which can
fallback to a subproject. This makes it easier to build wlroots
on platforms where system packages are outdated. Users can now
opt-in via `meson configure --wrap-mode=default` and Meson will
download and build any missing dependency.

Don't download by default because this can be quite surprising and
undesirable for some users (e.g. if they are just missing some -dev
package).
2024-12-22 21:24:03 +00:00
Kirill Primak
90530d43fe xdg-dialog-v1: add implementation 2024-12-22 20:46:19 +00:00
Consolatis
be555a9a99 backend/drm: make drm_lease implementation follow docs
This ensures compositors get a output_destroy signal when the
lease is granted and a new_output signal when the lease is revoked.
2024-12-21 01:00:12 +01:00
Consolatis
c6de47d415 wlr-foreign-toplevel: version guard fullscreen state 2024-12-21 01:20:53 +03:00
Consolatis
bd3724aa26 wlr-foreign-toplevel: convert to stack backed states array 2024-12-21 01:20:53 +03:00
Consolatis
648c64b7e4 wlr-foreign-toplevel: slight refactor 2024-12-21 01:19:17 +03:00
Consolatis
41e2331843 xwm: add missing NET_WM_STATE states
https://specifications.freedesktop.org/wm-spec/latest/ar01s05.html#id-1.6.8
2024-12-20 21:47:17 +00:00
Simon Ser
776f2c4e4d output: adjust warning when hardware cursors are unsupported
We'd print "cursor texture size exceeds hardware limitations" when
some hardware doesn't support cursors at all. Change the message
to better indicate the cause.
2024-12-20 10:39:42 +00:00
M Stoeckl
b97106ddcb wlr_cursor: use default shape if requested shape missing 2024-12-16 15:34:45 +00:00
Simon Ser
2b4f30dc1d render/gles2: validate shaders at build time
Use glslang to validate GLSL shaders at build time. This is
optional: if glslang is not found, shader validation is skipped.
2024-12-15 13:59:42 +01:00
Consolatis
546c5d000d xwayland: fix xdg->xwayland drag-and-drop
As struct wlr_drag is destroyed on drop and in the process resets
the focus, a xwayland dnd listener would also reset xwm->drag_focus.

This prevents the xcb replies from being processed and also prevents
the transfer if a compositor would not additionally request new focus
in its wlr_drag destroy handler (which is something usually only done
when in a focus-follows-mouse setting).

This patch creates a new xwm->drop_focus pointer which is a copy of
xwm->drag_focus at drop time. The xcb reply handler and transfer
logic now use the new xwm->drop_focus for their authorization checks.
2024-12-11 08:51:10 +01:00
Simon Ser
71943b3b1e data-device: reset focused surface when destroyed
The surface may be destroyed before the struct wlr_seat_client.

Spotted by Consolatis.
2024-12-11 07:15:02 +00:00
Simon Ser
a7ebe7c026 xwayland: remove loop to find drag focus surface
We can just use wlr_xwayland_surface_try_from_wlr_surface() here
instead.
2024-12-07 14:49:26 +01:00
Simon Ser
c7acfe906b xwayland: listen to drag focus destroy signal
The wlr_drag takes care of resetting the focused wlr_surface when
it's destroyed, however we store the wlr_xwayland_surface, which
may be destroyed before.
2024-12-07 14:49:26 +01:00
Simon Ser
9649fbe443 render/vulkan: fix crash on OOM
Closes: https://github.com/swaywm/sway/issues/8485
2024-12-06 14:28:40 +00:00
Tycho Andersen
631e5be0d7 xwayland: don't fail on SIGCHLD
SIGCHLD here isn't fatal: we have other means of notifying that things were
successful or failure, and it causes many compositors to have to do a bunch
of extra work:

https://github.com/qtile/qtile/issues/5101
https://github.com/flacjacket/pywlroots/pull/207#issuecomment-2502680133
https://github.com/djpohly/dwl/pull/212

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
2024-12-06 14:09:28 +00:00
Consolatis
be3d2b74cf dnd: ensure internal dnd handlers are unlinked on xwm_destroy()
Fixes #3925
2024-11-29 13:42:55 +00:00
Simon Ser
c6dd5e3c2e backend/drm: check buffer format for multi-GPU
Fixes on-screen corruption when displaying a fullscreen client
with an implicit modifier on the secondary GPU.

What happens here:

- Client allocates a buffer with an INVALID modifier on primary GPU.
- Compositor attempts to scan-out this buffer on an output connected
  to secondary GPU.
- Buffer is imported to secondary GPU, and is interpreted as if it had
  the secondary GPU's implicit tiling, even though it has the primary
  GPU's implicit tiling.

We need to forbid cross-device imports with implicit modifiers.
The mgpu_formats list is stripped from any INVALID modifier so
checking that fixes the bug.

Using the mgpu_formats list has an additional benefit: the buffer
is rejected in the test commit if it doesn't have a format supported
by the multi-GPU renderer.

Requires this Mesa bugfix:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31725
2024-11-28 20:27:48 +01:00
Simon Ser
2424b1ecdd render/drm_format_set: fix corruption in wlr_drm_format_set_remove()
A single byte was moved instead of a full uint64_t. This results
in corrupted lists containing bogus modifiers.
2024-11-28 19:14:31 +00:00
tokyo4j
e21899037a wlr_keyboard: don't emit key event for duplicated keycodes
This fixes the memory leak in wlr_keyboard_group.keys. The leak happened
because wlr_keyboard.keycodes never contains duplicated keycodes while
wlr_keyboard_group.keys can, so calling wlr_keyboard_finish() for all
the wlr_keyboards in wlr_keyboard_group doesn't always free all the keys
in wlr_keyboard_group.keys.
2024-11-28 16:24:57 +00:00
Kirill Primak
c0d4d7217b Add missing destroy events on automatically destroyed objects 2024-11-26 17:49:22 +00:00
Simon Ser
3e651b4642 backend/drm: fix drmModePageFlip() when disabling CRTC on legacy uAPI
drmModePageFlip() will fail with EBUSY on a disabled CRTC.

We can't fix this by clearing the DRM_MODE_PAGE_FLIP_EVENT when
performing a commit which disables CRTCs, because some device-wide
commits might also page-flip other enabled CRTCs (and skipping the
page-flip event would mess up our buffer tracking).

Fix this by immediately completing page-flips which disable a CRTC
on the legacy uAPI.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3918
2024-11-23 15:29:44 +01:00
Kirill Primak
9aca985865 tinywl: don't pass time to cursor mode motion handlers
It's unused.
2024-11-23 00:50:28 +03:00
Simon Ser
b2c3c371fc scene: assert on bad wlr_scene_buffer params
We assert in wlr_renderer if these are invalid. Assert earlier to
make debugging easier.
2024-11-22 18:49:50 +00:00
Alexander Orzechowski
0d6cc471e9 scene: Assert all signals are clear when destroying 2024-11-22 09:55:51 -05:00
Kirill Primak
24597bb971 meson: require wayland >=1.23.1 2024-11-21 16:46:55 +00:00
Kirill Primak
2ff95e5c97 meson: use kwargs for wayland deps 2024-11-21 16:46:55 +00:00
Kirill Primak
f233d25e86 tinywl: don't pass surface to focus_toplevel()
It's not required.
2024-11-16 22:05:01 +03:00
Kirill Primak
0b720ae5ea seat: drop last_event 2024-11-12 08:28:50 +00:00
Guido Günther
85e2b662f1 renderer: Drop mention of wlr_renderer_begin_with_buffer
It got removed in 3ed1268f ("render: Nuke old read pixels API")

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-11-11 22:48:50 +00:00
Simon Ser
2c3053370c output-management-v1: only create custom mode object for enabled heads
We were always creating a custom mode object when the output didn't
have a fixed mode. This is important to handle two cases:

- Virtual outputs with no concept of fixed modes.
- DRM outputs with a list of fixed modes but with a custom mode set.

However, in the case where an output didn't have a fixed mode and
was disabled, we were also creating the custom mode object. Clients
would then see a "ghost" mode: a mode object with no properties at
all.

Fix this by only creating the custom mode object if the output is
enabled.

Fixes: 5de9e1a99d ("wlr-output-management: Send custom modes to clients")
Closes: https://github.com/swaywm/sway/issues/8420
2024-11-11 19:18:32 +00:00
Simon Ser
e9a6b3b85d backend/wayland: add support for explicit sync
wl_buffer.release event delivery becomes undefined when using the
linux-drm-syncobj-v1 protocol, so we need to wait for buffer
release via a timeline point instead.

The protocol requires both wait and signal timelines to be set, so
we need to create one when the compositor only supplies a wait
timeline.
2024-11-11 15:22:22 +00:00
Simon Ser
ca29f43a54 render/drm_syncobj: add addon set 2024-11-11 15:22:22 +00:00
Simon Ser
8e36040e88 render/drm_syncobj: de-duplicate drm_syncobj timeline init 2024-11-11 15:22:22 +00:00
Kenny Levinsen
c3acef0dc0 scene: Only unwrap client buffer when underlying buffer is held
Client buffers backed by wl_shm is aggressively released, in which case
we are not allowed to access it. Locking an already released buffer and
later unlocking it will also re-trigger release, confusing clients.

As a quick workaround, guard the unwrap by checking if the buffer is
locked, which will be the case for non-wl_shm buffers.
2024-11-10 00:22:17 +01:00
Kenny Levinsen
f440c60128 backend/drm: Remove redundant error logs
wlr_renderer and wlr_allocator will print out errors as they go, and end
with a final error if they fail to create anything. The caller of this
function will also log when it fails.

Skip the redundant errors emitted here.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
0108506c77 backend/drm: Allow proceeding with render-less mgpu
If an mgpu device does not have a renderer, continue without one rather
than ignoring it entirely. It is not guaranteed that we will be able to
scan out to it in any particular configuration, but that is true for any
output regardless, and having the output visible is not harmful even if
it cannot light up.

To proceed safely, we strip implicit modifier support from all planes,
while avoiding duplication of the same logic for mdgpu_formats.

This helps GUD and DisplayLink scenarios.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
66ddd62e42 backend/drm: Move mgpu renderer setup to function
This helps readability a bit and will make error handling in a coming
commit easier.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
b2bb111f03 backend/drm: Check for mgpu_renderer instead of parent
The presence of the renderer is what matters with respect to blitting.
Having a parent without the need to blit will be allowed later.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
1dd05437bf backend/drm: Bail if renderer cannot import DMA-BUFs
We create a renderer for the sole purpose of blitting buffers from a
primary renderer that we might not be able to scan-out from. If we end
up with the pixman renderer, it either won't work becuase it cannot
import dmabufs from the primary renderer, or won't have any effect
because the primary renderer already uses dumb buffers.

We test for DMA-BUF capabilities specifically to make it clear what our
interest is, rather than focusing too much on the pixman renderer.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
55f15d1abd backend/drm: Ensure renderer is set to NULL on error
If init_drm_renderer failed, it would destroy the renderer but would not
set it to NULL, leading to use-after-free.

NULL the renderer after destroying it.
2024-11-08 13:45:05 +01:00
Kenny Levinsen
70d3635985 drm_format_set: Add wlr_drm_format_set_remove
wlr_drm_format_set_remove lets you remove a modifier from the specified
format, useful for filtering implicit modifiers.
2024-11-08 13:45:05 +01:00
Kenny Levinsen
014023c14f backend/drm: Set timeline support based on capability
We assumed that all atomic backends supported syncobj, but gud does not.
Instead, query DRM_CAP_SYNCOBJ_TIMELINE when using the atomic backend.
2024-11-08 13:45:05 +01:00
Simon Ser
c0945b6613 render/allocator: drop allocator_autocreate_with_drm_fd()
This is now unused.
2024-11-07 18:55:01 +01:00
Simon Ser
4c4d74a564 backend/drm: use public wlr_allocator_autocreate()
We don't need any custom behavior since d8c0707e27 ("backend/drm: return
secondary backend DRM FD").
2024-11-07 18:50:25 +01:00
Simon Ser
4ec1defb3e all: use public <wlr/render/allocator.h>
We don't need to use the private header in these files.
2024-11-07 18:48:20 +01:00
Simon Ser
baeecc8dbd backend/wayland: handle DMA-BUF import failures
create_immed() is a bit dangerous because on failure, either the
connection is closed or the buffer is silently ignored.

Use create() with a roundtrip to figure out whether the import
succeeded.
2024-11-07 14:42:01 +00:00
Simon Ser
9e71c88467 scene: unwrap wlr_client_buffer for direct scan-out
Passing the wlr_client_buffer directly has a downsides because a
fresh wlr_buffer pointer is passed each output commit instead of
cycling through existing wlr_buffer objects:

- The FDs are re-imported each time in the backend.
- Any import failure is logged every output commit [1].
- The Wayland backend cannot handle import failures without
  roundtripping each output commit [2].

Instead, extract the source buffer from the wlr_client_buffer and
pass that to the backend.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4836
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4841
2024-11-07 14:17:35 +00:00
Kenny Levinsen
63fabecee2 backend/wayland: Account for shm buffer offset
If we are trying directly scan-out a shm buffer, we create a temporary
buffer pool to instantiate a wl_buffer from, created in accordance to
our buffers size. If the buffer has an offset, it will end up out of
bounds of the created pool.

Extend the temporary pool by the buffer offset to compensate. Matching
the original pool size does matter unless we want to optimize away the
temporary pool to reduce mappings in the parent compositor.
2024-11-07 14:45:23 +01:00
xurui
3f314bc183 output-power-management-v1: use enum_is_valid functions
Signed-off-by: xurui <xurui@kylinos.cn>
2024-11-07 10:20:03 +00:00