The name pointer points into the drmDevice structure, which is freed by
drmFreeDevice(). The error log was using name after the free, which is
undefined behavior.
Move the error log before drmFreeDevice() so name is still valid when
used in the log message.
Signed-off-by: Wang Yu <wangyu@uniontech.com>
Send the failed event immediately when a client sends capture_output
or capture_output_region for an output that already has a live frame
owned by that client.
Enforces one frame per (client, output) pair, matching ext-image-copy-
capture-v1's create_frame restriction without adding a new error code
or bumping the interface version.
When a compositor uses color transforms (ICC profiles) the output's
postrender buffer is in the display's color space, not sRGB. A
screenshot client receives this buffer and saves it as an untagged PNG,
which appears oversaturated in non-colormanaged viewers.
To fix this without altering the semantics of the raw output source
(which must deliver the exact hardware scanned buffer, including
overlays and direct scanout), add an optional, compositor driven
scene-per-output capture source. This source re-renders the entire scene
graph for a given output with an identity color transform (sRGB), using
a hidden headless output to avoid flicker.
The new function
`wlr_ext_image_capture_source_v1_create_with_scene_output()` takes a
wlr_scene, a reference wlr_output (for dimensions, scale,
renderer/allocator), and an optional wlr_output_layout (for correct
positioning). The source is created on demand in the existing output
capture manager when the compositor has called
`wlr_ext_output_image_capture_source_manager_v1_set_scene()` and
`wlr_ext_output_image_capture_source_manager_v1_set_layout()`.
If the compositor never provides a scene, the manager continues to
create the original raw output source, preserving backward compatibility
and hardware plane capture for compositors that need it.
current attempts at copying regions outside the first output end up
wrapping into the first output. Fix this by allowing compositors to
expose the layout.
screencopy
When a compositor uses color transforms (ICC profiles), the output's
post-render buffer is in the display's color space, not sRGB. A
screenshot client like grim receives this buffer and saves it as an
untagged PNG, which then appears over-saturated in non-color-managed
viewers.
To avoid this, the output capture source now creates a hidden headless
output that re-renders the same scene graph with an identity color
transform (sRGB). The hidden output is driven entirely within the
capture source and does not affect the real output or cause any visual
flicker.
In handling scene buffer output updates, wlroots would send a leave event to
all entered outputs, even those that the scene root for the scene output update
event did not own. Leaving the output list inaccurate.
Sending leave events only for the given scene introduces a problem, though:
existing logic to de-duplicate leave events stops us from sending a leave event
when we leave all the outputs in a scene, and when the surface then becomes
visible in another scene, the frame pacing output cannot be selected
accurately. This breaks screen capture for off-screen windows in sway.
So, let us also mark outputs that would have been left but were spared by the
deduplication logic as "suspended" indicating they are ineligible as frame
pacing outputs.
Fixes: https://github.com/swaywm/sway/issues/9094
When locking surface state, surface_cache_pending will move the pending
surface state to a new, empty `wlr_surface_state`. This new surface
state will only contain the fields committed in the pending state, as
surface_state_move does not copy anything else.
surface_update_damage is called before we move state from pending to
current to merge buffer damage and surface damage, and it expects that
the pending surface state still contains prior committed details such as
scale and transform. This is not the case when we finally commit the
cached surface state.
Move surface_update_damage after surface_state_move and make it operate
purely on the current surface state.
Prior to this patch, when the client binds the manager, the existing
toplevel handles were notified in the opposite order of their creation,
as wl_list_insert() adds a new handle to the head of the list and
wl_list_for_each() iterates from head to tail.
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
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.
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
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.
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.
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.
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.
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")
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.