Commit graph

7168 commits

Author SHA1 Message Date
liupeng
1a6702938d screencopy-v1: drop output_enable listener
(cherry picked from commit 31f9d6bb97)
2025-10-21 22:25:46 +00:00
Kenny Levinsen
f57e7e40d3 scene/surface: Do not use buffer dimensions for clip
The surface's buffer dimensions were used to scale the clip's x/y
offset. If a surface had a larger buffer than src_box, the calculations
to scale the x/y portion of the clip would be incorrect, yielding
graphical glitches.

This was noticed with Chromium in sway, which during resize uses a
viewport with a src_box to avoid immediate buffer reallocation. While
the viewport was in use, the surface would be shifted so that too much
content was cropped in the upper left, and damage glitching was visible
in the lower right.

Use the buffer source box dimensions instead.

(cherry picked from commit dc7dba8b1f)
2025-10-21 22:25:46 +00:00
tokyo4j
766a228da4 wlr_keyboard_group: fix leak of wlr_keyboard_group->keys
If the underlying wlr_keyboard emits duplicated key-presses,
wlr_keyboard_group->keys might not be empty even after calling
wlr_keyboard_group_remove_keyboard() for all of the keyboards.
2025-04-04 08:14:41 +03:00
tokyo4j
ff55f91055 Revert "wlr_keyboard: don't emit key event for duplicated keycodes"
This reverts commit 86eaa44a3a.

That commit caused a regression for IME users in many compositors:
when a input_method is activated while a key is pressed, and a virtual
keyboard is created by IME, the following key-release event via the
virtual keyboard is missed since the key in the virtual keyboard haven't
been pressed. For example, pressing and releasing Ctrl+F in Firefox with
fcitx5 running triggered repeated keys (ffffff...) in the opened input
box.
2025-02-15 23:55:41 +09:00
Guido Günther
d981860314 seat: Don't forget to destroy touch points on touch up
Otherwise the number of touch points goes up constantly and d'n'd via
touch can't work as validation always fails.

Fixes 75ecba44 ("seat: add serials to touch up events")

Signed-off-by: Guido Günther <agx@sigxcpu.org>
(cherry picked from commit fef4f3637a)
2025-02-13 17:47:25 +01:00
Simon Ser
cda69b696d build: bump version to 0.18.2 2024-12-11 23:59:09 +01:00
Consolatis
0c437f6e98 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.

(cherry picked from commit 546c5d000d)
2024-12-11 09:29:55 -05:00
Simon Ser
35ab453360 data-device: reset focused surface when destroyed
The surface may be destroyed before the struct wlr_seat_client.

Spotted by Consolatis.

(cherry picked from commit 71943b3b1e)
2024-12-11 09:29:35 -05:00
Simon Ser
1fc9409df2 xwayland: remove loop to find drag focus surface
We can just use wlr_xwayland_surface_try_from_wlr_surface() here
instead.

(cherry picked from commit a7ebe7c026)
2024-12-11 09:28:03 -05:00
Simon Ser
885bf8f5e8 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.

(cherry picked from commit c7acfe906b)
2024-12-11 09:27:50 -05:00
Simon Ser
74be9ddaab render/vulkan: fix crash on OOM
Closes: https://github.com/swaywm/sway/issues/8485
(cherry picked from commit 9649fbe443)
2024-12-11 09:27:19 -05:00
Consolatis
b28b269106 dnd: ensure internal dnd handlers are unlinked on xwm_destroy()
Fixes #3925

(cherry picked from commit be3d2b74cf)
2024-11-29 08:46:18 -05:00
Simon Ser
f870d63bad 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
(cherry picked from commit 3e651b4642)
2024-11-29 08:42:38 -05:00
Simon Ser
bdc75d058b 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

(cherry picked from commit c6dd5e3c2e)
2024-11-29 08:42:21 -05:00
tokyo4j
86eaa44a3a 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.

(cherry picked from commit e21899037a)
2024-11-29 08:40:33 -05:00
Simon Ser
0e002db57c 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
(cherry picked from commit 2c3053370c)
2024-11-11 14:21:21 -05:00
Isaac Freund
b29ebe4a1c backend/headless: actually perform output test
Currently the headless backend does not actually implement the
wlr_output_test function, causing tests containing output state
unsupported by the headless backend to succeed while committing the same
state will always fail.

This commit fixes that by actually hooking up the already exisiting test
function.

References: https://codeberg.org/river/river/issues/1154
(cherry picked from commit da8f7a07ba)
2024-11-11 14:11:23 -05:00
Simon Ser
efe820f575 backend/drm: check whether clipped damage is empty
We were checking whether the damage region was empty before
clipping. However a non-empty damage region can become empty after
clipping. Instead, check whether the clipped region is empty.

Fixes: 4339c37f99 ("backend/drm: clip FB damage")
(cherry picked from commit e8e76dc295)
2024-11-11 14:11:06 -05:00
Kenny Levinsen
a21c618cd3 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.

(cherry picked from commit 63fabecee2)
2024-11-11 14:09:50 -05:00
Simon Ser
5bc39071d1 build: bump version to 0.18.1 2024-09-20 12:51:54 +02:00
Simon Ser
6f2ce4766f render/vulkan: use non-coherent memory for read_pixels()
The spec for VkMemoryPropertyFlagBits says:

> device coherent accesses may be slower than equivalent accesses
> without device coherence [...] it is generally inadvisable to
> use device coherent or device uncached memory except when really
> needed

We don't really need coherent memory so let's not require it and
invalidate the memory range after mapping instead.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3868
(cherry picked from commit 52dce29e06)
2024-08-23 13:42:57 -04:00
Simon Ser
f43ac6cf9c backend/drm: use CRTCs in-order
When lighting up a new connector, we'd use the last CRTC instead of the
first one. This causes issues because drivers have the expectation that
userspace will match CRTCs to connectors in-order [1].

The order has regressed a long time ago in 5b13b8a12c ("backend/drm:
consider continue not using resources"). That commit was a fix to
avoid moving a connector between CRTCs [2]. Revert that commit and
use a different approach: even if we've found a solution, always try
not using a CRTC in the hope that we'll find another solution with
less CRTC replacements.

[1]: https://lore.kernel.org/dri-devel/20240612141903.17219-2-ville.syrjala@linux.intel.com/
[2]: https://github.com/swaywm/wlroots/issues/1230

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3098
(cherry picked from commit d2a5dbe104)
2024-08-23 09:30:33 -04:00
Kirill Primak
0a4cd88637 scene: resize damage ring on geometry update
(cherry picked from commit cf93d31736)
2024-08-23 09:30:19 -04:00
Kirill Primak
b79fc11df8 scene: update output geom on commit after dropping pending damage
Otherwise the whole output damage gets ignored.

(cherry picked from commit 62cc96b3a4)
2024-08-23 09:30:07 -04:00
Dudemanguy
1f96bcc1db backend/drm: fix a use-after-free
The page_flip can be destroyed, but it is unconditionally accessed later
on when setting present_flags. Fix this by simply setting the
present_flags before the page_flip gets destroyed.

(cherry picked from commit 3d2f09bace)
2024-08-23 09:29:52 -04:00
zhoulei
0992422493 xwayland/xwm: listen shell destroy signal
Otherwise we got invaild write in wl_list_remove.

Fixes: e209fe2d0 ("Fix memory leak in xwayland.c")

Signed-off-by: zhoulei <zhoulei@kylinos.cn>
(cherry picked from commit 2c64f36e88)
2024-08-23 09:29:38 -04:00
Leonardo Hernández Hernández
4900daa787 linux-drm-syncobj-v1: actually use the requested version
(cherry picked from commit baaec88e2f)
2024-08-23 09:29:27 -04:00
Alexander Orzechowski
72a290ba01 wlr_scene: Fix WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT when output is transformed
(cherry picked from commit 4f1104654f)
2024-08-15 11:27:42 -04:00
Alexander Orzechowski
055c0d28d1 wlr_scene: Don't special case swapchain buffers
This fixes direct scanout VRR. As direct scanout buffers are not part
of the swapchain, we would mistakenly union instead of subtract the damage
meaning it will just accumulate indefinitely.

The reason for this existing in the first place is for compositors that
might want to sidestep scene and commit their own buffers to the output.
In this case, scene could theoretically acknowledge that and update the
damage. Except, this really didn't work because WLR_OUTPUT_STATE_DAMAGE
would need to be defined which is optional. This patch also properly
acknowledges commits without damage.

In the use case of a weird compositor that might want to sidestep scene,
they can just trash the damage ring themselves.

Fixes: #3871
(cherry picked from commit 14e1987f50)
2024-08-15 11:27:36 -04:00
Alexander Orzechowski
a4cafc1ef5 wlr_scene: Inline output_state_apply_damage
(cherry picked from commit 3e1358fec9)
2024-08-15 11:27:28 -04:00
Alexander Orzechowski
f9de859194 wlr_scene: Immediately apply pending output commit damage
There were two problems with the old implementation:
1. wlr_scene_output_commit would bail early if a frame wasn't requested
and there was no commit damage, however commit damage could never accumulate
until rendering happens. The check was subtly wrong as a result.
2. Previously, we would fill the pending commit damage based on the
current state of the damage ring. However, during direct scanout, the
damage would accumulate which would mean we would submit damage from
previous frames even if we didn't need to.

(cherry picked from commit 147c5c37e3)
2024-08-15 11:27:21 -04:00
Alexander Orzechowski
43388cd277 wlr_scene: Funnel all damage operations through scene_output_damage
We want to add logic to this function later

(cherry picked from commit 78dfa4f06d)
2024-08-15 11:27:12 -04:00
Isaac Freund
89e1ea130d backend/drm: don't set vsync present flag if page flip was async
(cherry picked from commit 08495d2596)
2024-08-15 11:13:05 -04:00
Kirill Primak
b4bec0cd3a backend/wayland: process initial events from globals correctly
Previous logic could lead wlr_wl_backend.drm_render_name being written
to twice, causing a memory leak. This commit fixes the race condition.

(cherry picked from commit 3103ea3af9)
2024-08-15 11:06:50 -04:00
Kirill Primak
7df7b0e092 linux-drm-syncobj: add missing decls in the header
(cherry picked from commit ee21deb458)
2024-08-15 11:06:02 -04:00
Kirill Primak
a095120b7d pointer-constraints: don't init/finish current/pending states
wlr_surface_synced does it automatically.

Reported-by: llyyr <llyyr.public@gmail.com>
(cherry picked from commit 70c99460ca)
2024-08-15 11:05:44 -04:00
Kirill Primak
9e107e3c77 xdg-popup: don't set a role resource destroy handler
wlr_xdg_surface tracks role resource destruction itself.

(cherry picked from commit c52e01e85f)
2024-08-15 11:05:32 -04:00
Consolatis
490769f2a6 ext-foreign-toplevel-list: use correct interface and add missing handler
Without this patch, a client calling handle.destroy() will trigger
an assert in libwayland due to a NULL pointer for the destroy handler.

Also implement a missing .destroy handler for the manager itself
and delay destruction of the manager resource from the .stop handler
to the .destroy handler.

(cherry picked from commit adf9d8b0be)
2024-08-15 11:05:20 -04:00
project-repo
2b8f94cf09 Fix memory leak in xwayland.c
(cherry picked from commit e209fe2d05)
2024-08-12 10:08:27 -04:00
project-repo
52834f29ad Fix memory leak in drm.c
(cherry picked from commit 3cae2a2c01)
2024-08-12 10:08:20 -04:00
Alexander Orzechowski
03f06207f0 wlr_scene: Force blend mode to PREMULTIPLIED if calculate visibility is disabled
We do it here so WLR_SCENE_HIGHLIGHT_TRANSPARENT_REGION doesn't break

(cherry picked from commit 4481c6b243)
2024-08-06 08:09:40 -04:00
Kirill Primak
81a08aeeb0 output-power-management: send zwlr_output_power_v1.failed on output destroy
From the event description:

This event indicates that the output power management mode control is no
longer valid. This can happen for a number of reasons, including:
<...>
- The output disappeared

(cherry picked from commit de574ac098)
2024-08-06 08:09:28 -04:00
chenyongxing
6cc80472cb render/vulkan: Fix draw rect clip region invalid in blend none mod
(cherry picked from commit 015bb8512e)
2024-08-06 08:09:15 -04:00
Isaac Freund
2005cc0fd6 docs: update comments for wlr_output API changes
The old wlr_output_{commit,test}() functions are still mentioned in
multiple places.

(cherry picked from commit 7550e483ae)
2024-07-15 09:58:22 -04:00
Isaac Freund
7d0f337a35 wlr_output: remove dead function
(cherry picked from commit 2a8a23c467)
2024-07-15 09:58:22 -04:00
Bill Li
4534421279 ci: use package x11-servers/xwayland instead of x11-servers/xwayland-devel
(cherry picked from commit 22adc65586)
2024-07-15 09:58:22 -04:00
Simon Ser
4666996b2a build: bump version to 0.18.0 2024-07-12 23:39:50 +02:00
Simon Ser
e34cc23549 scene: only skip bottom-most black rects with fractional scaling
We were relying on the fact that we wouldn't paint anything on top
of the black background in the region of a black rect. However
when fractional scaling is used the repaint region might get
expanded to nearby pixels by scale_output_damage(). As a result
the neighbour scene nodes might leak into the skipped black rect's
region.

Avoid this by using this optimization for bottom-most black rects
only when fractional scaling is used.

References: https://github.com/swaywm/sway/issues/8233
2024-07-11 21:03:27 +02:00
Simon Ser
f057239b6a ci: use tinywl built by Meson
This removes the need for repeating and keeping in sync build
options for Meson and make invocations.
2024-07-11 02:54:26 +00:00
Simon Ser
a35b4f059d backend/drm: add support for SIZE_HINTS property
This property allows the driver to advertise support for multiple
cursor sizes. On Intel, using a smaller buffer size reduces power
consumption.

References: https://lore.kernel.org/dri-devel/20240227193523.5601-2-ville.syrjala@linux.intel.com/
2024-07-10 22:42:44 +00:00