Commit graph

2941 commits

Author SHA1 Message Date
Kenny Levinsen
651f85cb81 Merge branch 'predictive-frame-scheduling' into 'master'
Draft: wlr_frame_scheduler: Add predictive frame scheduler

See merge request wlroots/wlroots!5332
2026-04-09 11:07:53 +00:00
Dylan Donnell
8a9e3a84b5 ext_background_effect_v1: add implementation 2026-04-09 10:43:46 +00:00
Simon Ser
c393fb6bfa wlr_virtual_keyboard_v1: specify size when creating keymap
xkb_keymap_new_from_string() assumes that the string is
NULL-terminated, but we don't check this so the function might
access outside the mmap'ed region. Use the safer
xkb_keymap_new_from_buffer() function.

Reported-by: Julian Orth <ju.orth@gmail.com>
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/work_items/4072
2026-04-07 09:43:08 +00:00
Kenny Levinsen
df562a8e70 wlr_frame_scheduler: Add predictive frame scheduler
The predictive frame scheduler builds upon the presentation scheduler,
adding a delay based on the measured CPU and GPU time required to
prepare a frame to place the frame event as close as safely possible to
the commit deadline.
2026-04-06 23:44:57 +02:00
Kenny Levinsen
411a3e6a6e scene: Deprecate wlr_scene_output_needs_frame
Previously, needs_frame was only set specifically when a non-damaging
update was required, and would only be cleared when the backend
committed the frame.

Under the new frame scheduler, needs_frame is always set when a frame is
scheduled, with effectively a single scheduling path for all change
sources, and needs_frame must have been true for a frame to be emitted.

Drop wlr_scene_output_needs_frame to make it clear that such a check is
no longer meaningful.
2026-04-06 23:25:55 +02:00
Kenny Levinsen
d560a30adc scene: Add wlr_scene_output_set_frame_scheduler
This allows the compositor to replace frame schedulers for a given scene
output at runtime.
2026-04-06 23:22:44 +02:00
Simon Ser
d99ee40a1d output: drop wlr_output.needs_frame
The frame scheduler is responsible for de-duplicating needs_frame
events.
2026-04-06 23:19:40 +02:00
Rose Hudson
0967873a20 output: remove old frame scheduling 2026-04-06 23:19:40 +02:00
Kenny Levinsen
0b59a49179 ext_image_capture_source_v1: switch to new frame scheduling 2026-04-06 23:19:40 +02:00
Rose Hudson
b2550a88ff scene: switch to new frame scheduling 2026-04-06 23:19:40 +02:00
Rose Hudson
ee100e2586 Add interval frame scheduler
Headless present events aren't suitable for the present scheduler. This
new scheduler is a good place for headless' existing frame logic to go,
so move it into there.

With this decoupling, there's nothing tying the scheduler to the
headless backend, hence the generic name.
2026-04-06 23:19:40 +02:00
Rose Hudson
ad145dce86 Add wl_surface.frame based frame scheduler 2026-04-06 23:19:40 +02:00
Rose Hudson
98cbf09f8a Add frame scheduler interface 2026-04-06 23:19:40 +02:00
Isaac Freund
9de0ec3089 keyboard: fix modifiers event when no keymap set
Actually send the modifiers event when there is no keymap set.

Compositors may need lower-level "raw" access to the key/modifiers
events from the backend. Currently it is impossible for a compositor
to get modifier events from the backend without them being filtered
through an xkb_state controlled by wlroots.

I need this feature for river in order to fix some keyboard state
synchronization bugs.

Note that setting a keymap resets the modifiers so I don't think setting
wlr_keyboard->modifiers directly here is a concern.
2026-04-05 10:52:25 +00:00
Isaac Freund
e22084f639
ext_image_capture_source_v1/scene: fix extents
Currently the width/height of the extents is too small if the first node
visited has position/dimensions 0,0,100,100 and the second node has
position/dimensions -20,-20,10,10.

In this case the current code calculates total extents as
-20,-20,100,100 but the correct extents are -20,-20,120,120.

References: https://codeberg.org/river/river-classic/issues/17
2026-03-30 17:23:02 +02:00
Félix Poisot
fd870f6d27 linux_drm_syncobj_v1: fix handling of empty first commit
As reported in
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4979#note_3385626,
bfd6e619fc did not correctly handle clients
that don't immediately follow their call to
`wp_linux_drm_syncobj_manager_v1.get_surface` with a commit attaching
a buffer

Fixes: bfd6e619fc
2026-03-20 15:36:16 +00:00
Simon Ser
4ca40004fd color_management_v1: ignore surface update if no-op
If the new image description is identical to the old one, skip the
event.
2026-03-19 21:46:28 +00:00
Simon Ser
7287f700ab color_management_v1: use early continue in surface loop 2026-03-19 21:46:28 +00:00
Félix Poisot
b2f6a390a4 scene: transfer sample syncobj to client timeline 2026-03-17 18:14:35 +00:00
Félix Poisot
bfd6e619fc linux_drm_syncobj_v1: add release point accumulation
This changes the behavior of wlr_linux_drm_syncobj_surface_v1 to
automatically signal release of previous commits as they are replaced.

Users must call wlr_linux_drm_syncobj_v1_state_add_release_point or
wlr_linux_drm_syncobj_v1_state_signal_release_with_buffer to delay the
signal as appropriate.
2026-03-17 18:14:35 +00:00
Félix Poisot
1f3d351abb scene: add buffer release point to 'sample' event 2026-03-17 18:14:35 +00:00
Félix Poisot
0af9b9d003 render/drm_syncobj: add wlr_drm_syncobj_timeline_signal() 2026-03-17 18:13:10 +00:00
David Turner
80bcef908b scene: Set color representation on scanout
When doing direct-scanout, if the surface has color-representation
metadata present then pass on that metadata to the output state.

Also, if a buffer has color representation IDENTITY+FULL then normalise
this to NONE+NONE which is equivalent.
2026-03-17 16:32:30 +00:00
David Turner
58c158dba6 output: Add color-representation to output state
Add color_representation to wlr_output_state, holding color
representation metadata about the primary buffer.  This can be set
using wlr_output_state_set_primary_color_representation() and a
new enum value WLR_OUTPUT_STATE_COLOR_REPRESENTATION in
wlr_output_state.committed indicates when this data is present.

Also add color-representation to wlr_output, and discard
color-representation in wlr_output_state if it matches what's already
been committed to the output.
2026-03-17 16:32:30 +00:00
Isaac Freund
1fa8bb8f7a
virtual-keyboard: handle seat destroy
We must make the virtual keyboard inert when the seat is destroyed.
2026-03-17 09:53:32 +01:00
Isaac Freund
ec746d3e3e virtual-keyboard: add wlr_virtual_keyboard_v1_from_resource()
I want to use the zwp_virtual_keyboard_v1 object in a custom river
protocol and need to be able to obtain the corresponding wlroots struct.
2026-03-17 08:45:12 +00:00
Scott Moreau
1fc928d528 wlr_ext_image_copy_capture_v1: Fix crash when client creates a cursor session not implemented server side
This guards against a crash where the server implements
wlr_ext_image_capture_source_v1_interface without setting .get_pointer_cursor().
In general, we should install a NULL check here because this is a crash
waiting to happen. Now, instead of crashing, the resource will be created and
the copy capture session will be stopped.
2026-03-14 19:04:42 +00:00
llyyr
3cb2cf9425 scene: use wl_list_for_each_safe to iterate outputs
The outputs loop in handle_scene_buffer_outputs_update may remove entries
from the list while iterating, so use wl_list_for_each_safe instead of
wl_list_for_each.

Fixes: 39e918edc8 ("scene: avoid redundant wl_surface.enter/leave events")
2026-03-13 23:32:06 +05:30
Alexander Orzechowski
7f87c7fe90 wlr_scene: Nuke buffer output_enter / output_leave
outputs_update should be used instead.
2026-03-13 13:19:06 -04:00
Isaac Freund
39e918edc8
scene: avoid redundant wl_surface.enter/leave events
Currently we send wl_surface.enter/leave when a surface is hidden
and shown again on the same output. In practice, this happens very
often since compositors like river and sway enable and disable
the scene nodes of surfaces as part of their atomic transaction
strategy involving rendering saved buffers while waiting for
clients to submit new buffers of the desired size.

The new strategy documented in the new comments avoids sending
redundant events in this case.
2026-03-13 17:59:13 +01:00
Kenny Levinsen
7ccef7d9eb Adopt wlr_box_intersects where useful
This makes wlr_scene_node_at roughly 50% faster, and gives a minor boost
to node modification as well.

Before:

create test tree:               7030 nodes, 473.510 s, 15 nodes/ms
wlr_scene_node_at:              10000 iters, 894.945 s, 78552 nodes/ms (hits: 10/10000)
wlr_scene_node_for_each_buffer: 10000 iters, 330.597 s, 212646 nodes/ms (hits: 0/10000)

After:

create test tree:               7030 nodes, 385.930 s, 18 nodes/ms
wlr_scene_node_at:              10000 iters, 586.013 s, 119963 nodes/ms (hits: 10/10000)
wlr_scene_node_for_each_buffer: 10000 iters, 334.559 s, 210127 nodes/ms (hits: 0/10000)
2026-03-09 22:09:40 +00:00
Christopher Snowhill
9a931d9ffa scene: fix color format compare
bool doesn't really support negative values.

Fixes: 7cb3393e7 (scene: send color_management_v1 surface feedback)
2026-03-06 18:44:26 -08:00
Andri Yngvason
3336d28813 image_capture_source/output: Update constraints on enable
Without observing the enable event, clients receive no pixel formats and
buffer dimensions are reported as 0 after an output has been re-enabled.
2026-03-05 21:28:55 +00:00
liupeng
1b8c3ea8c5 screencopy: simplify capture error handling
Signed-off-by: liupeng <liupeng01@kylinos.cn>
2026-03-04 21:09:47 +08:00
Diego Viola
6d9aa17572 treewide: fix typos
Signed-off-by: Diego Viola <diego.viola@gmail.com>
2026-02-28 04:26:47 -03:00
Kenny Levinsen
1ce992d7cb scene/layer_shell_v1: Add support for exclusive_edge
The v5 layer shell interface allows the client to specify which edge the
exclusive zone will apply to, instead of deducing it from the anchor
points. Add support for this to the layer shell scene helper.
2026-02-24 13:28:46 +00:00
Steve Williams
436bcf9a47 color-representation-v1: fix condition in surface commit 2026-02-07 08:36:29 +04:00
Steve Williams
ef88246642 types/wlr_buffer: add buffer_get_drm_format helper function 2026-02-06 13:53:46 +00:00
Steve Williams
bb78861ca9 color-representation: add support for identity+full 2026-02-06 13:53:46 +00:00
Steve Williams
439985fe95 color_representation: ensure encoding/range/drm formats compatibility 2026-02-06 13:53:46 +00:00
YaoBing Xiao
dfccf5ff02 output/cursor: fix missing newline at end of file 2026-02-06 09:05:52 +00:00
rewine
bc11ac92ab
ext_image_capture_source_v1: remove unused variable 2026-02-06 10:41:42 +08:00
rewine
7cb4e30bfd
wlr_cursor: fix event type in handle_tablet_tool_button 2026-02-03 21:25:50 +08:00
rewine
4fe51aa439 types: Simplify wlr_keyboard_group_destroy
If the wlr_keyboard_group_remove_keyboard function is expanded, the code
is equivalent to:

```
	wl_list_for_each_safe(device, tmp_device, &group->devices, link) {
		struct wlr_keyboard_group *_group = group;
		struct wlr_keyboard *_keyboard = device->keyboard;
		struct keyboard_group_device *_device, *_tmp;
		wl_list_for_each_safe(_device, _tmp, &_group->devices, link) {
			if (_device->keyboard == _keyboard) {
				remove_keyboard_group_device(_device);
				continue;
			}
		}
	}
```

It's just running one more loop meaninglessly.
2026-02-02 10:46:20 -05:00
Simon Ser
d6c7a161c7 color_representation_v1: send chroma_location protocol error
This error has been added in:
46f46863b7
2026-02-01 20:09:45 +00:00
tokyo4j
82d5ffb09e ext-workspace-v1: add implementation
Co-authored-by: Consolatis <40171-Consolatis@users.noreply.gitlab.freedesktop.org>
2026-01-31 01:44:23 +09:00
Kenny Levinsen
5e32b6663b ext_image_copy_capture_v1: Only render scene source on damage
wlr_scene_output_needs_frame checks wlr_output.needs_frame and
wlr_scene_output.gamma_lut_changed, neither of which incur damage. The
needs_frame flag is often set by e.g., cursor movement.

For the purpose of a capture frame we are only interested in frames with
damage. Continue without damage causes session_handle_source_frame to
silently skip copying the frame, which causes the session to get stuck:
no ready or failed event is emitted, and frame_pending is still set so
no further output frame events will occur.

Only render in case there is damage, but send frame callbacks
regardless.
2026-01-24 22:49:40 +00:00
Félix Poisot
5a40da7e15 render: don't infer luminance multipliers from color TF
Make scene pass them explicitly instead. Ref #3995
2026-01-23 19:41:14 +00:00
Félix Poisot
68052f34d3 color_management_v1: new enum value for 'srgb' transfer function
ref https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/442
2026-01-23 18:50:09 +00:00
Félix Poisot
bb882e97f1 color_management_v1: use 64bit image description identities
ref https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/385
2026-01-23 18:50:09 +00:00