Commit Graph

2432 Commits

Author SHA1 Message Date
vaxerski c2aa7fd965 backend/drm: Add async page flip support to legacy
Atomic doesn't support such flags yet.
2023-09-28 16:53:08 +00:00
vaxerski 5dec1c8bcb staging/tearing-control: Add protocol support 2023-09-28 16:53:08 +00:00
Brian J. Tarricone eacb4cf6d2 Fix possible crash in server-decoration when surface destroyed
If the underlying surface is destroyed, but the client has not yet
destroyed the server decoration object, and then tries to call
request_mode() on it, the compositor will crash, because the
wlr_server_decoration struct has been freed, and the wl_resource's
user_data member has been NULLed out.

Yes, this is certainly an error for the client to do that, but I
shouldn't be able to write a buggy (or malicious) Wayland app that can
take down the entire compositor.
2023-09-27 23:54:51 -07:00
Manuel Stoeckl dbc7a5cada screencopy_v1: only bind, not render with, buffer in shm copy path
wlr_renderer_read_pixels does not need to be called inside a render
pass; rather, it only needs to have the correct buffer bound to
the renderer. This commit optimizes the implementation of
frame_shm_copy(...) by only binding the source buffer instead of
starting a no-op render pass with it.
2023-09-11 20:25:07 -04:00
Alexander Orzechowski 6c54c34713 output: Mutate frame_pending needs_frame when there is an explicit output commit
These states would be set if output_init is invoked with a enabled state.
This would make frame_pending == true which means wlroots will ignore
any further frame events and the compositor will appear dead.
2023-09-11 03:28:01 -04:00
Leo Li b18a849fc3 wlr_scene: Use cached node coordinates where possible
Avoids recalculating node coordinates.
2023-09-08 21:11:19 +00:00
Kirill Primak e315068b98 xdg-popup: validate parent
This matches Mutter's behavior.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3576
2023-09-01 12:48:36 +03:00
Simon Ser e5fc8cd4c7 output: trigger frame/present events on all commits on enabled output
Up until now, frame/present events were only triggered when the
user submitted a buffer. Change the wlr_output API so that these
events are triggered when any commit is applied on an enabled
output.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3708
2023-08-23 15:42:22 +00:00
Rose Hudson 462f04db9e output: don't forbid multiple commits per frame
It's still not possible to commit while a page flip is pending in DRM,
but we don't need to enforce that here and allowing it through the
common interface can be useful for other backends.

This decouples commits from frame scheduling, which is going to make the
new frame schedulers easier to implement.
2023-08-23 16:37:07 +02:00
Rose Hudson f5917f0247 scene_output_layout: make output adding explicit
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3709
2023-08-22 11:53:28 +02:00
Rose Hudson 91f813ffb7 output_layout: return wlr_output_layout_output when adding output
This will be used for the scene-graph integration.
2023-08-22 11:53:25 +02:00
Alexander Orzechowski e85c79051c wlr_output: Set current_mode during new custom mode
When setting a custom mode current_mode will not be reset. That means
that next time the compositor tries to reset back from the custom mode,
it will compare against the stale current_mode and unset
WLR_OUTPUT_STATE_MODE erroneously.
2023-08-22 09:46:24 +00:00
Simon Ser 72787db98a compositor: drop wlr_surface_destroy_role_object()
This function is now unnecessary.
2023-08-21 18:56:09 +02:00
Kirill Primak bd5c4f4a4a xdg-shell: rework roles 2023-08-21 16:30:29 +00:00
Kirill Primak e5300c225e xdg-popup: avoid using wlr_surface_destroy_role_object() 2023-08-21 16:30:29 +00:00
Kirill Primak 10ba8ebc70 Don't assume xdg_surface.{toplevel,popup} is non-NULL
This assumption will become incorrect with future commits.
2023-08-21 16:30:29 +00:00
Kirill Primak f0cc712af1 xdg-shell: don't return anything from create_xdg_surface() 2023-08-21 16:30:29 +00:00
Leonardo Hernández Hernández bdc34401ba
xdg-decoration: store an xdg_toplevel instead of xdg_surface
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3685
2023-08-19 11:10:36 -06:00
Alexander Orzechowski 568b1943b9 wlr_output: Nuke wlr_output_update_enabled 2023-08-16 18:37:55 +02:00
Alexander Orzechowski 63351cf81f output: Schedule mode updates to happen with rest of output events 2023-08-16 18:37:55 +02:00
Alexander Orzechowski f042de3f51 output: Inline wlr_output_update_{custom,}_mode 2023-08-16 18:37:55 +02:00
Alexander Orzechowski f1ba70ffa6 wlr_output: Make wlr_output_update_{custom,}_mode private
Backends should be using wlr_output_send_request_state to request
modesets to the compositor. This will be inlined and removed next commit.
2023-08-16 18:37:55 +02:00
Alexander Orzechowski 6cda3e251c output: Add initialization state to wlr_output_init 2023-08-16 11:46:27 -04:00
Alexander Orzechowski 8f67446cc7 output: Extract common commit logic 2023-08-16 11:46:26 -04:00
Alexander Orzechowski aee31edaad screencopy_v1: Implement copy regions with gpu blit path 2023-08-12 10:16:51 +00:00
Alexander Orzechowski b4cbaa4549 screencopy_v1: Use new renderer API for gpu blit path 2023-08-12 10:16:51 +00:00
Simon Ser c74f89d4f8 Avoid using memcpy() to copy structs
We can just use a regular assignment instead. This is more
type-safe since there is no need to provide the struct size.

The remaining memcpy() calls perform array copies or copies from
void pointers (which may be unaligned).
2023-08-03 14:40:28 +00:00
JiDe Zhang 73db481037 wlr_output: update cursor when scale changed
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3699
2023-08-03 02:13:00 +00:00
JiDe Zhang 61903ed66b wlr_output_cursor: assert renderer isn't NULL
When a wlr_output add to wlr_output_layout, wlr_cursor will create
wlr_buffer of xcursor for the wlr_output, this behavior depends
wlr_renderer of wlr_output, using assert to ensure renderer is
initialized before wlr_output_layout_add and wlr_cursor_set_buffer/
wlr_cursor_set_xcursor.
2023-08-03 02:13:00 +00:00
Simon Zeni 60ca6f17eb types/wlr_drm_lease_v1: downgrade DRM backend error message to debug
Downgrades the error message printed out when no DRM backend is given from `WLR_ERROR` to
`WLR_DEBUG`
2023-07-27 22:14:46 -04:00
Kirill Primak 7df11ada5e Unmap wlr_surface before making its role object inert 2023-07-26 20:39:03 +00:00
Leonardo Hernández Hernández e8d545a977
xdg-shell: add support for v6
This adds the suspended toplevel state
2023-07-23 20:30:43 -06:00
Simon Ser 04e4e06986 cursor-shape-v1: new protocol implementation
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/194
2023-07-24 01:00:19 +00:00
Alexander Orzechowski fd540f6d07 wlr_scene: Don't damage when setting opaque region
Opaque region is a optimization hint, (bugs outstanding) it will not
change the output contents, therefore damage does not need to be submitted.

However, we still need to update the visibility state of the other
nodes in the tree. To do this call scene_update_region() by ourselves
but not `scene_node_update()` which will damage the outputs.
2023-07-22 19:23:36 -04:00
Alexander Orzechowski a32180afa7 wlr_scene: Fix damage tracking with non atomic opaque region configuration
We need to intersect the opaque region with the node size or else we'll
get damage tracking effects with compositors attempting to use
wlr_scene_buffer_set_opaque_region() along with resizing the buffer
at the same time in a certain order.

Consider this: I have a new buffer that I want to commit to my scene buffer
that is smaller than the old one. However, I still have the old opaque
region that is the size of the old larger buffer, so that means that
for the small moment between when we reconfigure the opaque region for the
new buffer the opaque region will be oversized. Scene logic will then
try to apply occluding optimizations outside of the node boundaries
causing damage artifacts.
2023-07-22 19:23:36 -04:00
Rouven Czerwinski 63f5851b6f session-lock: add missing lock_surface_destroy
Add the missing lock_surface_destroy which was removed in dc7686c114
("session-lock: don't remove inert role resource"). Otherwise we never
remove the surface from our internal state, leading to us killing the
locking daemon with a protocol error that is totally our fault.
2023-07-21 18:56:14 +02:00
Rose Hudson 71daec9441 export-dmabuf, screencopy: schedule_frame -> needs_frame
needs_frame is for backends to trigger frames for reasons that
compositors couldn't see coming. schedule_frame is freaky and I want to
remove it. These protocols aren't backends but in this case they're
close enough, so switch to needs_frame.

CC #3664
2023-07-18 12:01:16 +01:00
Simon Ser 000081db19 cursor, output: apply viewport to cursor
Instead of passing the scale, pass the source and destination
boxes.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3676
2023-07-17 14:55:22 +00:00
Ronan Pigott b18c76642a scene: apply rounding when translating buffer damage
Without a round in this case the damage region is translated to truncated coordinates, potentially
misplacing it relative to the actual position of that region in the output buffer.
2023-07-16 02:55:09 -07:00
Leonardo Hernández Hernández 4de9c9c47f scene: send wl_surface.preferred_buffer_scale 2023-07-15 10:28:25 +00:00
Simon Ser 67447d6cb4 presentation-time: add separate helper for zero-copy
The backend is not able to tell whether a surface is being
presented via direct scan-out or not. The backend will set
ZERO_COPY if the buffer submitted via the output commit was
presented in a zero-copy fashion, but will no know whether the
buffer comes from the compositor or the client.
2023-07-14 15:20:35 +02:00
Simon Ser fe84bfc8d9 scene: add wlr_scene_output_sample_event
This contains the output and a bool indicating direct scan-out.
2023-07-14 15:16:12 +02:00
Simon Ser 88942d43fd scene: rename output_present event to output_sample
Using "present" is confusing here: the event is emitted when the
buffer is being sampled to be displayed on an output, not when it's
being presented on-screen.

Rename to match the presentation-time terminology.
2023-07-14 15:06:13 +02:00
Alexander Orzechowski d8585d661c wlr_scene: Fix buffer damage for output state
We would transform the damage based on output state which might be
out of date.
2023-07-12 17:20:12 +00:00
Simon Ser fe06e5f49a Use wl_container_of() instead of casts
This slightly improves type safety.

The culprits were found with:

    git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
2023-07-11 20:16:17 +02:00
Rose Hudson 214df8eda0 scene_output: optionally record and report timings 2023-07-10 09:57:02 +00:00
Kirill Primak f4eaab12a0 input-method-v2: don't remove inert role resource 2023-07-10 10:03:24 +02:00
Kirill Primak dc7686c114 session-lock: don't remove inert role resource 2023-07-10 10:03:24 +02:00
Kirill Primak 7f2ed1e62c layer-shell: don't remove inert role resource 2023-07-10 10:03:24 +02:00
Kirill Primak 7d176b6237 subcompositor: don't remove inert role resource
Now that role objects are stored as resources, we can distinguish
the inert object case from it being destroyed by the client:

- When the resource is destroyed by the client, role_resource == NULL
- When the resource is made inert, role_resource != NULL but its
  user_data is NULL
2023-07-10 10:03:08 +02:00
Simon Ser 7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Kirill Primak 4966857f21 viewporter: check for an existing viewport 2023-07-07 12:49:06 +03:00
Simon Ser 6f8287128b output: drop wlr_output_cursor_set_image()
This function takes a pointer to memory with a hardcoded format
and many parameters to describe the pixel buffer.
wlr_output_cursor_set_buffer() can be used instead.
2023-07-03 09:46:54 +02:00
Simon Ser f8d70fbece cursor: remove usage of wlr_output_cursor_set_image()
Stop using wlr_output_cursor_set_image() because it's getting
dropped. Instead, use wlr_output_cursor_set_buffer().

This mirrors what wlr_output_cursor_set_image() is doing
under-the-hood.
2023-07-03 09:45:34 +02:00
Simon Ser 0fc532f8de cursor: remove wlr_cursor_set_image()
Superseded by wlr_cursor_set_buffer().
2023-07-02 22:42:37 +00:00
Simon Ser 18bafbfc57 xcursor-manager: drop wlr_xcursor_manager_set_cursor_image() 2023-07-02 22:42:37 +00:00
Simon Ser 71c87ff4b8 cursor: add wlr_cursor_set_buffer()
A saner replacement for wlr_cursor_set_image():

- Takes a wlr_buffer instead of numerous parameters and a hardcoded
  format.
- The scale is not used to filter outputs.
- A ref to the buffer is kept to apply it to new outputs.
2023-07-02 22:42:37 +00:00
Simon Ser bb91787b5f cursor: stop using set_image() in wlr_cursor_unset_image()
set_image() will go away.
2023-07-02 22:42:37 +00:00
Manuel Stoeckl bbd53b3b46 screencopy-v1: fix logical->physical region transform
This now matches the transformations used for e.g. cursor scissor
regions and damage.
2023-07-01 10:05:30 -04:00
Alexander Orzechowski 57a0313779 wlr_scene: Don't recompute node location during rendering
We already compute it during the render list creation, we should cache
it and re-use the value.
2023-07-01 09:48:25 +00:00
Alexander Orzechowski 48f2a7a3a1 wlr_scene: Simplify direct scanout handling
By adding a sent_feedback bool into the list entry that we can mutate
we no longer need to maintain this `sent_direct_scanout_feedback` variable.

sent_feedback will also be useful for output layers.
2023-07-01 09:48:25 +00:00
Alexander Orzechowski 9613b3bc8a wlr_scene: Wrap render_list nodes in struct
We will be able to add more state here
2023-07-01 09:48:25 +00:00
Simon Ser 53b07b5b72 cursor: set image for new outputs
When an output is added to wlr_cursor, update its cursor image.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2119
2023-06-30 17:24:44 +00:00
Simon Ser d5581e42d4 cursor: add cursor_update_outputs()
Sets the cursor image for each output depending on the wlr_cursor
state.
2023-06-30 17:24:44 +00:00
Simon Ser d1d6cd9008 cursor: keep track of XCursor manager and name
Will be useful to apply the current cursor to new outputs.
2023-06-30 17:24:44 +00:00
Simon Ser 69c44de22f cursor: track surface globally, instead of per-output
Most of the surface-related state does not need to be per-output.
Move it to wlr_cursor_state.
2023-06-30 17:24:44 +00:00
Simon Ser c46fabe45c cursor: use wlr_cursor_unset_image() in wlr_cursor_set_surface() 2023-06-30 17:24:44 +00:00
Simon Ser f0b8a68654 cursor: store wlr_cursor inline in wlr_cursor_state
Removes one allocation, makes this a bit more consistent with the
rest of wlroots.
2023-06-30 17:24:44 +00:00
Alexander Orzechowski 8243399385 output: Set output mode during main commit
Removes duplication across all the backends to finally apply the mode
to the output.
2023-06-27 11:47:58 -04:00
Alexander Orzechowski ea3c6fde3a wlr_scene: Add opaque region blend mode optimization
If we are only rendering within a region of the surface that is
advertised as opaque, we can choose no blending
2023-06-27 14:02:25 +00:00
Kirill Primak 71b57b8d27 fullscreen-shell: set surface role 2023-06-23 22:09:54 +03:00
Simon Ser be05097968 output: add wlr_output_state_init()
This changes the semantics of wlr_output_state. Instead of having
fields with uninitialized memory when missing from the committed
bitflag, all fields are always initialized (and maybe NULL/empty),
just like we do in wlr_surface_state. This reduces the chances of
footguns when reading a field, and removes the need to check for
the committed bitfield everywhere.

A new wlr_output_state_init() function takes care of initializing
the Pixman region.
2023-06-23 18:07:26 +00:00
Simon Ser 8a5b5e6f28 compositor: listen to role_resource destroy signal
Call wlr_surface_destroy_role_object() when the role_resource is
destroyed.
2023-06-23 14:33:26 +02:00
Simon Ser 89cb484220 compositor: replace role_data with role_resource
This increases type safety, makes it more obvious that role_data
must represent the role object, and will allow for automatic
cleanup when the resource is destroyed.
2023-06-23 14:23:27 +02:00
Simon Ser 00f1870d35 input-method-v2: add popup_surface_from_resource()
This checks the resource type before casting its user data pointer.
2023-06-23 14:14:36 +02:00
Kirill Primak fc9b58e84d compositor: don't call role unmap hook without an object 2023-06-23 11:54:05 +00:00
Kirill Primak 0f67580aab compositor: introduce wlr_surface_set_role_object() 2023-06-23 11:54:05 +00:00
Kirill Primak 0040c78c0b compositor: fix wlr_surface_set_role() error messages 2023-06-23 11:54:05 +00:00
Simon Ser d59749aa44 cursor: add support for animated XCursor 2023-06-22 14:55:32 +02:00
Simon Ser 6dd8b092e9 output/swapchain: fix error return value types
This function returns a bool, not a pointer.
2023-06-22 13:55:45 +02:00
Alexander Orzechowski b5eaa47049 scene: Use wlr_output_state_copy for direct scanout path 2023-06-22 11:56:30 +02:00
Alexander Orzechowski 4b7c526578 output: Introduce wlr_output_state_copy() 2023-06-22 11:56:20 +02:00
Simon Ser 1e68e1f661 seat: fix keyboard/pointer/touch resource destroy
We need to always unlink the resource, even if it's already inert.
seat_client_destroy_*() may be called multiple times on the same
resource.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3638
2023-06-20 20:14:49 +00:00
Simon Ser c4d4409deb output: stop using wlr_output.back_buffer in output_ensure_buffer()
This allows us to use the new render pass API, and drops some
implicit state usage.
2023-06-20 16:33:41 +00:00
Simon Ser b625a13156 output: attach buffer to state in output_ensure_buffer() 2023-06-20 16:33:41 +00:00
Alexander Orzechowski 2ac31fc630 wlr_scene: Introduce wlr_scene_buffer_set_filter_mode 2023-06-20 09:04:35 +00:00
Alexander Orzechowski 64c0272f81 output_state: Gamma lut should be freed only if committed
We consider state that is not committed to be uninitialized.
2023-06-19 00:19:50 -04:00
Simon Ser 220402b717 cursor: add wlr_cursor_unset_image()
It's pretty awkward to call wlr_cursor_set_image() with 6 zeroes.
Hide that awkwardness in wlroots.
2023-06-15 18:40:33 +02:00
Simon Ser da04b066ea cursor: add wlr_cursor_set_xcursor()
This keeps track of the last set XCursor. If it hasn't changed,
skip the texture upload.

In the future, support for animated XCursors can be added.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3436
2023-06-15 18:28:43 +02:00
Alexander Orzechowski 58a2f8bd5c wlr_scene: Clear damage ring on transform change 2023-06-15 14:57:51 +00:00
Alexander Orzechowski 61667404ce wlr_scene: Clear damage ring on scale change
If we were trying to change the scale in wlr_scene_output_build_state,
we would be using incorrect damage
2023-06-15 14:57:51 +00:00
Alexander Orzechowski 96b95bf775 wlr_scene: Reset damage ring bounds every frame
This fixes damage issues when a output state attempts to change
the transformed size in some way
2023-06-15 14:57:51 +00:00
Alexander Orzechowski 4391845910 wlr_damage_ring_set_bounds: Ignore duplicate size requests 2023-06-15 14:57:51 +00:00
Alexander Orzechowski 3896b6b107 wlr_scene: Fix transforms with non 1 scale
wlr_region_transform / wlr_box_transform want unscaled coordinates here
2023-06-15 14:57:51 +00:00
Kirill Primak 753f3cc4fa compositor: add wlr_surface_role.no_object
This commit allows to make a role as not represented by an object,
which fixes calling role commit handlers for roles like cursor
surfaces.

Fixes: 099b9de752
2023-06-14 14:06:28 +00:00
Simon Ser 670915eeea output: add wlr_output_state_set_layers() 2023-06-13 12:02:49 +00:00
Alexander Orzechowski 0925a500d1 wlr_scene: Don't use direct scanout if trying to commit a new render_format
Found by inspection.
2023-06-12 20:30:09 -04:00
Alexander Orzechowski a09bb1314d wlr_output_state: Consider gamma_lut uninitialized if not committed 2023-06-12 18:24:00 +00:00
Alexander Orzechowski b80e67d6e6 wlr_output_state: Consider buffer uninitialized if not committed 2023-06-12 18:24:00 +00:00
Simon Ser 6e8fb5509f cursor: only reset the cursor when the surface changes
If the set_cursor request is used with the same surface, don't call
cursor_output_cursor_reset_image(). That function sends
wl_surface.leave and can cause an infinite feedback loop with some
clients (submitting a LoDPI cursor when the surface leaves an HiDPI
output).

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3669
2023-06-12 12:42:31 +00:00