Commit graph

2889 commits

Author SHA1 Message Date
Robin Ebert
ba76d37b0b
wlr_ext_image_copy_capture_v1: Fix segmentation fault when using cursor session
Fixes: 3b9f599cbe
2026-01-12 12:40:34 +01:00
Alexander Orzechowski
1f0fb95e3b wlr_scene: Add documentation to scene_node_update() 2026-01-08 13:03:46 -05:00
Alexander Orzechowski
ed7b633669 wlr_scene: Only do disable cleanup when explicit damage is given
We don't want to iterate the subtree for trivial update scenarios. We only
care when a scene is reparented or disabled in which both cases provides
us with explicit damage
2026-01-08 13:03:46 -05:00
Alexander Orzechowski
ef19f52ca9 wlr_scene: Update outputs when node is disabled 2026-01-08 13:03:46 -05:00
Alexander Orzechowski
56eb27ab0b wlr_scene: Don't recurse when disabling scene node if a child is already disabled
If a child is disabled, that means the node already went through the
rigamarole of cleaning up its state. Don't do it again.
2026-01-08 13:03:46 -05:00
Alexander Orzechowski
edc12e81d9 wlr_scene: Make restack_xwayland_surface_below generic
more stuff will be put here
2026-01-08 13:03:46 -05:00
Peter Kaplan
49576469ec image_capture_source: wlr_output_try_from_ext_image_capture_source_v1() 2026-01-07 09:18:25 +01:00
Peter Kaplan
3b9f599cbe wlr_ext_image_copy_capture_v1: new_session event
And a destroy event in wlr_ext_image_copy_capture_session_v1.
2026-01-07 09:18:25 +01:00
Simon Ser
368dcfb9f6 ext_image_capture_source_v1: wait for capture client before sending frame event
We were sending an output frame event as soon as we were done
rendering. As a result, the output would render in a busy loop when
a client was using the capture output for frame pacing purposes.

Instead, use the request_frame hook introduced in the previous
commit to throttle output frame events.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/4036
2026-01-05 15:03:18 -05:00
Simon Ser
f93865ed1f ext_image_copy_capture_v1: replace schedule_frame with request_frame
schedule_frame is only called when the client has submitted damage
and a new frame should be rendered immediately. schedule_frame is
not called when the capture client is waiting for the next frame
but hasn't submitted damage.

Sources implementing a rendering loop based on the capture rate
need to know when a capture client is ready to accept a new frame.
Such sources want to trigger a redraw if and only if (1) they are
dirty (their contents have changed) and (2) the capture client is
ready to accept a new frame.

Replace schedule_frame with request_frame, triggered each time a
client sends a capture request. A flag indicates whether the capture
client has submitted damage.
2026-01-05 15:03:18 -05:00
Simon Ser
53d75a41c7 cursor: use wlr_xcursor_image_get_buffer() 2026-01-05 10:10:32 -05:00
Simon Ser
2c64b30a67 scene: add knob to turn off Xwayland surface restacking
This is useful in these cases:

- The same surface is added to two different scene-graphs. wlroots
  can't figure out on its own which scene-graph should drive the
  Xwayland stacking.
- A compositor uses multiple Xwayland servers (e.g. one per app).
  wlroots will try to restack surfaces from different Xwayland
  instances and this will not go well.
2026-01-04 16:02:52 +00:00
Simon Ser
b094f8aeb3 scene/surface: don't cache frame pacing output
Storing the frame pacing output in a per-scene and per-surface
struct doesn't play well with multiple scenes. outputs_update is
only triggered for outputs the scene knows about, but operates on
all outputs the surface has entered regardless of the scene. Thus
leaving an output on one scene will not refresh the frame pacing
output on other scenes, and these other scenes will operate with
a stale frame pacing output. The surface will not receive any more
wl_surface.frame done events.

This also avoids keeping a dangling pointer around when the frame
pacing output is destroyed but the output isn't added in the scene.

References: https://github.com/swaywm/sway/issues/8885
2026-01-04 14:40:18 +01:00
Simon Ser
2699b68b34 ext_image_capture_source_v1/scene: fix stop for parallel captures
The stop handler disables the output. However, the same source can
be captured multiple times in parallel. In that case, stop might
be called while another capture session is still ongoing.

Only disable the output if the last session is stopped.
2026-01-04 00:34:39 +00:00
Simon Ser
3f9a164484 scene: keep last preferred configuration when leaving last output
Before this patch, when a surface became occluded on all outputs,
we'd reconfigure it with a base configuration (scale set to 1,
transform set to NORMAL, image description set to gamma 2.2/sRGB).
As a result, when quickly hiding a toplevel and showing it again,
the client would render to switch to the base configuration, then
render again to switch to the output configuration.

Avoi this needless back-and-forth by retaining the last sent
preferred configuration when a surface leaves all outputs.
2026-01-04 00:24:47 +00:00
Simon Ser
53cdceb371 scene: constify pixman_region32_t
Makes it easier to figure out which functions build regions, and
which functions consume them.
2025-12-28 22:56:55 +01:00
Simon Ser
8611aa8440 scene: don't assign outputs to invisible nodes
If a node has no visible areas, leave active_outputs empty.

Fixes: 95b2771bfd ("scene: ignore outputs with too small intersection with nodes")
2025-12-28 22:30:25 +01:00
Félix Poisot
32d5fc1d11 render/color: introduce color_transform_compose
It flattens color transform pipelines, and facilitates building
pipelines of variable content
2025-12-18 14:58:28 +00:00
Simon Ser
3d8c471aef color_management_v1: add BT.1886 to TF-from-renderer helper
BT.1886 support has been added to wlroots after this helper got
written.
2025-12-18 09:54:27 -05:00
Simon Ser
9b4d9eabb1 color_management_v1: add helpers to get supported TFs/primaries
This avoids hardcoding lists of TFs/primaries in compositors.

I've considered adding wlr_color_manager_v1_create_with_renderer()
instead, but I'm worried that some aspects of the options struct
don't really depend on the renderer, but on the compositor. Such
things are features and render intents.

I've considered returning a const array, but this would tie our
hands if we want to make the renderer advertise the set of
TFs/primaries it supports, instead of having a single flag gating
all of them.
2025-12-15 11:07:26 -05:00
Ilia Bozhinov
0e9c6ddefa seat: add wlr_seat_touch_notify_clear_focus
This is needed for cases where the touch operation goes over a region
where no surfaces are present. In this case, we'd want to notify the
touch grabs (for example DnD grabs) that no focus is currently focused.
2025-12-11 21:10:59 +00:00
Ilia Bozhinov
03b465f324 drag: destroy data source on touch_up
This is in case we drop the drag with no focus, we want to destroy the
drag to tell the client the drag was cancelled.
2025-12-11 21:10:59 +00:00
llyyr
c45b3b1f5f color_representation_v1: don't leak supported_* on display destroy 2025-12-04 15:27:22 +05:30
tokyo4j
abf80b529e wlr-foreign-toplevel: avoid wl_resource_find_for_client()
If the client application is composed of multiple components and they
bind the manager global separately, choosing a single toplevel resource
with wl_resource_find_for_client() may result in a component only seeing
unknown toplevel handles from another component.

Maybe we should track which toplevel handle resource originate from
which manager resource so that a component never sees toplevel handles
resources from another component, but it's too annoying to implement.
2025-11-25 18:54:20 +00:00
Félix Poisot
811765ffa0 output: don't rebuild cursor color transform for each update 2025-11-24 23:26:14 +00:00
Félix Poisot
7101a69804 scene: don't rebuild color transforms each frame 2025-11-24 23:26:14 +00:00
Félix Poisot
3d3d5fb1b7 render: remove buffer primaries from pass options
colorspace conversion is now carried explicitely by setting a
wlr_color_transform_matrix in the color transform
2025-11-24 23:26:14 +00:00
Félix Poisot
fdb473e675 scene: always apply user gamma after scene color transform
Fixes 989cffe, making renderer-applied transform consistent with
hardware-applied transform
2025-11-24 23:26:14 +00:00
Félix Poisot
106f0f9506 output/state: add missing unref for color_transform 2025-11-14 11:10:37 +00:00
Simon Ser
fa7b66bcf4 color_representation_v1: add helper to create global from renderer 2025-11-13 10:35:56 -05:00
Simon Ser
87c3cb5c52 scene: add support for color-representation-v1 coeffs and range 2025-11-13 10:35:56 -05:00
Simon Ser
2fbc0b5ac1 scene: add support for color encoding and range 2025-11-13 10:35:56 -05:00
Félix Poisot
0d24cdb822 cursor: apply output image description when preparing texture 2025-11-11 21:55:06 +00:00
David96
aef84f0e4d wlr_virtual_pointer: Set axis source on all axis
Currently it is possible to crash a wlroots compositor by setting any
axis source other than 0 and sending an axis event in the HORIZONTAL
direction from wlr_virtual_pointer since the axis source is only set on
the first axis.
This then hits the assert in wlr_seat_pointer.c:332.

Fix by always setting the source on all axis.
2025-11-06 16:02:58 +00:00
xurui
47d0a90274 types/wlr_input_device: name maybe NULL
Signed-off-by: xurui <xurui@kylinos.cn>
2025-11-04 17:29:23 +08:00
Simon Ser
989cffe70d scene: add software fallback for gamma LUT 2025-10-18 20:36:01 +02:00
Simon Ser
3e08e3be4a gamma_control_v1: introduce fallback_gamma_size 2025-10-18 20:36:01 +02:00
Simon Ser
91f4890ec2 gamma_control_v1: add wlr_gamma_control_v1_get_color_transform() 2025-10-18 20:36:01 +02:00
Simon Ser
74ce6c22a5 output: check for color transform no-op changes
This allows callers to always set this state and not care whether
the output currently has the same color transform applied.
2025-10-18 20:36:01 +02:00
Simon Ser
6d63871f05 linux_drm_syncobj_v1: fix use-after-free in surface_commit_destroy()
surface_commit_destroy() accesses a field from
struct wlr_linux_drm_syncobj_surface_v1, however that struct may have
been free'd earlier:

    ==1103==ERROR: AddressSanitizer: heap-use-after-free on address 0x7cdef7a6e288 at pc 0x7feefaac335a bp 0x7ffc4de8f570 sp 0x7ffc4de8f560
    READ of size 8 at 0x7cdef7a6e288 thread T0
        #0 0x7feefaac3359 in surface_commit_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:195
        #1 0x7feefaac34cd in surface_commit_handle_surface_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:211
        #2 0x7feefbd194cf in wl_signal_emit_mutable (/usr/lib/libwayland-server.so.0+0x84cf) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #3 0x7feefaa52b22 in surface_handle_resource_destroy ../subprojects/wlroots/types/wlr_compositor.c:730
        #4 0x7feefbd1bb9f  (/usr/lib/libwayland-server.so.0+0xab9f) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #5 0x7feefaa46a18 in surface_handle_destroy ../subprojects/wlroots/types/wlr_compositor.c:65
        #6 0x7feef89afac5  (/usr/lib/libffi.so.8+0x7ac5) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)
        #7 0x7feef89ac76a  (/usr/lib/libffi.so.8+0x476a) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)
        #8 0x7feef89af06d in ffi_call (/usr/lib/libffi.so.8+0x706d) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)
        #9 0x7feefbd17531  (/usr/lib/libwayland-server.so.0+0x6531) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #10 0x7feefbd1cd2f  (/usr/lib/libwayland-server.so.0+0xbd2f) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #11 0x7feefbd1b181 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa181) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #12 0x7feefbd1d296 in wl_display_run (/usr/lib/libwayland-server.so.0+0xc296) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #13 0x555bf0a55a40 in server_run ../sway/server.c:615
        #14 0x555bf0a4a654 in main ../sway/main.c:376
        #15 0x7feef9227674  (/usr/lib/libc.so.6+0x27674) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
        #16 0x7feef9227728 in __libc_start_main (/usr/lib/libc.so.6+0x27728) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
        #17 0x555bf0a03f54 in _start (/home/leo/code/stuff/sway/build/sway/sway+0x390f54) (BuildId: e3d4e653af1aa0885f0426c403e16fc87c086d33)

    0x7cdef7a6e288 is located 8 bytes inside of 176-byte region [0x7cdef7a6e280,0x7cdef7a6e330)
    freed by thread T0 here:
        #0 0x7feefb71f79d in free /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:51
        #1 0x7feefaac29f1 in surface_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:84
        #2 0x7feefaac2e47 in surface_handle_resource_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:143
        #3 0x7feefbd1bb9f  (/usr/lib/libwayland-server.so.0+0xab9f) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #4 0x7feefaac2a12 in surface_handle_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:89
        #5 0x7feef89afac5  (/usr/lib/libffi.so.8+0x7ac5) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)

    previously allocated by thread T0 here:
        #0 0x7feefb7205dd in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:74
        #1 0x7feefaac4abd in manager_handle_get_surface ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:313
        #2 0x7feef89afac5  (/usr/lib/libffi.so.8+0x7ac5) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)

Fix this by storing the struct wlr_surface in the field.

Closes: https://github.com/swaywm/sway/issues/8917
2025-10-17 09:05:53 +00:00
Furkan Sahin
06275103f2 input-method-v2: Destroy keyboard grab before input method
Fixes race condition in where the keyboard grab tries to reference the
input manager after it's been set to null.
2025-10-16 12:07:47 +00:00
llyyr
5529aae3e6 wlr_scene: fix direct scanout for gamma2.2 buffers
Fixes incorrectly rejecting scanout for gamma2.2 buffers when the output
has no image description set. This happens on `hdr off` mode on sway.

Also refactor the scanout check into its own function while at it to
make it easier to follow.
2025-10-05 23:53:25 +05:30
llyyr
6e1c8748ff render: introduce bt.1886 transfer function 2025-10-04 18:13:37 +05:30
Félix Poisot
d8fb7adcf0 scene, render: use Gamma 2.2 TF as default 2025-10-03 19:48:12 +00:00
Félix Poisot
c2d9ae2142 render: introduce Gamma 2.2 color transform 2025-10-03 19:39:17 +00:00
Simon Ser
6978509f64 Revert "wlr_scene: fix tf/prim comparison for scanout attempt"
This reverts commit dde07b6840.

This is incorrect as discussed here:
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5163#note_3118744
2025-10-03 20:42:21 +02:00
llyyr
2252854297 wlr_scene: return scene_direct_scanout_result instead of bool 2025-10-02 13:51:41 +05:30
llyyr
dde07b6840 wlr_scene: fix tf/prim comparison for scanout attempt
We were incorrectly doing comparison with `!= 0` to detect non-sRGB
tf/primaries. Since these enums are bit flags, the default sRGB values
are 1, not 0, so sRGB buffers were incorrectly rejected.

Fixes: bf40f396bf ("scene: grab image description from output state")
2025-10-02 11:57:52 +05:30
Simon Ser
7cb3393e75 scene: send color_management_v1 surface feedback
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3999
2025-09-23 09:22:00 -04:00
Simon Ser
26c1476827 color_management_v1: add destroy event to manager 2025-09-23 09:22:00 -04:00