Commit Graph

2568 Commits

Author SHA1 Message Date
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
Alexander Orzechowski 05dd08afe5 scene: introduce wlr_scene_output_build_state() 2023-06-12 14:13:09 +02:00
Alexander Orzechowski 7e67b8152b scene: Don't rely on output current state during rendering
In the next commit, state such as scale, transform, width/height that
we gather from the output might be outdated and incorrect.
2023-06-12 14:13:02 +02:00
Alexander Orzechowski ae7bad86dd output: introduce wlr_output_state_set_damage() 2023-06-12 14:12:47 +02:00
Simon Ser 36376e2ddf gamma-control-v1: stop applying gamma LUTs implicitly
Make the compositor responsible for doing that, so that they can
properly integrate with their output commit sequence.
2023-06-08 18:47:46 +00:00
Simon Ser ec9b79ef19 gamma-control-v1: add wlr_gamma_control_v1_send_failed_and_destroy() 2023-06-08 18:47:46 +00:00
Simon Ser 026fc6eda0 gamma-control-v1: add wlr_gamma_control_v1_apply() 2023-06-08 18:47:46 +00:00
Simon Ser 5d5cf34486 output: add wlr_output_state_set_gamma_lut() 2023-06-08 18:47:46 +00:00
Simon Ser 6e635d2fd3 gamma-control-v1: add wlr_gamma_control_manager_v1_get_control() 2023-06-08 18:47:46 +00:00
Simon Ser 70c1a57248 gamma-control-v1: introduce set_gamma event 2023-06-08 18:47:46 +00:00
Kirill Primak 63f3802e0f subcompositor: set role_data with wlr_surface_set_role() 2023-06-08 20:03:18 +02:00
Kirill Primak 24a479a501 drag: don't set icon's role_data
Currently, an icon surface's role_data is set manually to a struct
wlr_drag_icon, which is hacky, incorrect (as role_data is supposed
to be the surface's role object, and drag icons don't have them), and
will be disallowed by future changes.
2023-06-08 20:03:18 +02:00
Kirill Primak 31d958f70a cursor: fix applying hotspot offset
"On surface.attach requests to the pointer surface, hotspot_x and
hotspot_y are _decremented_ by the x and y parameters passed to the
request."
2023-06-07 10:35:49 +03:00
Simon Ser 544c0622fa presentation-time: constify wlr_presentation_feedback_send_presented()
We don't need to mutate the event in this function.
2023-06-06 21:38:07 +00:00
Kirill Primak 25a62a3775 subcompositor: simplify subsurface_consider_map(), call on add
Fixes: 49e9be62ae
2023-06-06 20:38:19 +00:00
Kirill Primak 2acc74a3db Clear input regions if they're ignored 2023-06-06 13:33:31 +03:00
Alexander Orzechowski 9f28366b55 wlr_tablet_v2_tool: Tablet tool surfaces are always mapped 2023-06-06 06:00:31 -04:00
Alexander Orzechowski d700bd2d7c wlr_seat_pointer: cursor surfaces are always mapped 2023-06-06 06:00:21 -04:00
Rose Hudson 9e8947e4d5 add render timer API
Based on five calls:
wlr_render_timer_create - creates a timer which can be reused across
  frames on the same renderer
wlr_renderer_begin_buffer_pass - now takes a timer so that backends can
  record when the rendering starts and finishes
wlr_render_timer_get_time - should be called as late as possible so that
  queries can make their way back from the GPU
wlr_render_timer_destroy - self-explanatory

The timer is exposed as an opaque `struct wlr_render_timer` so that
backends can store whatever they want in there.
2023-06-05 19:50:07 +00:00
Kirill Primak 37b5f8a89e compositor: unmap subsurfaces too on unmap
Similar to 49e9be62ae.
2023-06-05 19:14:35 +00:00
Kenny Levinsen 15f2f6642f gamma-control: Read ramps using pread
read advances the file description offset, and requires the client to
ensure that it is reset appropriately before the next gamma ramp
submission. As there is no event to indicate that wlroots finished
processing the new gamma ramp, this can result in a race between the
client seeking in the file and wlroots reading its content.

Use pread with a fixed offset instead.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3655
2023-06-05 11:55:59 +02:00
Kirill Primak b61d5922f1 compositor: notify subsurfaces about a commit in the rendering order
This is the default order used across wlroots unless the reversed order
specifically is required (e.g. in wlr_surface_surface_at()).
2023-06-03 14:36:41 +00:00
Kirill Primak 49e9be62ae subcompositor: consider mapping on parent map
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3654
2023-06-03 14:36:41 +00:00
Väinö Mäkelä a2f94b500c virtual-keyboard: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä f9f17b6236 virtual-pointer: Handle inert seats
Inert seats are handled like inert outputs, so they work as if the
wanted seat was NULL. The seat argument is only a suggestion, so this
is okay.
2023-06-03 10:43:12 +00:00
Väinö Mäkelä 07e27ba854 xdg-popup: Handle inert seats
According to the protocol text, the popup will be immediately dismissed
when the grab is rejected. Because the grab can't be executed with a
destroyed seat, the popup is dismissed when one is provided.
2023-06-03 10:43:12 +00:00
Väinö Mäkelä 0601813ab6 text-input: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä bcb69b1827 primary-selection: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä 247e86dca9 keyboard-shortcuts-inhibit: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä 16948c7369 input-method: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä 126222884d wlr_idle: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä f988a75a80 tablet: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä 5120addfbb data-control: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä f97f4496de data-device: Handle inert seats 2023-06-03 10:43:12 +00:00
Väinö Mäkelä 0e5f76186e seat: Allow binding to inert seats
If a seat is destroyed while a client is trying to bind it, wlroots
needs to create an inert seat resource instead of crashing.
2023-06-03 10:43:12 +00:00
Simon Ser 52b93f7eb4 output/cursor: fix scale and transform
Many issues here:

- wlr_output_cursor_set_buffer() takes a buffer already scaled for
  the output, not a buffer with scale=1.
- wlr_output_cursor.{width,height,hotspot_x,hotspot_y} are in output
  buffer coordinates.
- render_cursor_buffer() had hardcoded no-ops for scale and
  transform, instead of using the cursor surface's.

Fixes: b64e7e88bf ("output: add output_cursor_set_texture()")
2023-06-02 22:33:40 +00:00
Simon Ser 09c87cec3f cursor: fix wl_pointer.set_cursor hotspot updates
A client might update the cursor with the same wl_surface as
before, but with a different hotspot. Don't ignore such updates.

Fixes: 9c9e3f6263 ("cursor: ignore wlr_cursor_set_surface() with same surface")
2023-06-02 22:33:40 +00:00
Kirill Primak 8c0eeb6a86 session-lock: fix buffer check
If the first commit has no buffer, the unmap hook won't catch it. Check
in the commit hook instead.
2023-06-02 23:26:38 +03:00
Kirill Primak e75407fd4d session-lock: remove unused wlr_session_lock_surface_v1.events.map 2023-06-02 23:20:05 +03:00
Kirill Primak d086ee1b9e compositor: remove wlr_surface_role.precommit
It was previously used to handle unmapping properly but is obsolete now.
2023-06-02 21:04:16 +03:00
Kirill Primak af4181f388 drag: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak 743da5c0ae input-method: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak 229abfae0c session-lock: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak c63f3659c5 layer-shell: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak b0437fc416 xdg-shell: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak c590bb600f subcompositor: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak 6b40e08148 compositor: introduce unified map logic 2023-06-02 17:26:18 +00:00
Simon Ser 6668c822b3 cursor: unset wlr_output_cursor.texture on surface destroy
When the surface is destroyed, its current wlr_texture is about to
get destroyed as well. Reset wlr_output_cursor.texture to prevent
use-after-free.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3652
2023-06-02 16:27:54 +00:00
Simon Ser 9c9e3f6263 cursor: ignore wlr_cursor_set_surface() with same surface
Avoids damaging the output and rendering the cursor again if it
hasn't changed.
2023-06-02 16:27:54 +00:00
Simon Ser 5bcd537ff4 output/cursor: use new rendering API 2023-05-30 16:18:19 +00:00
Simon Ser 93a6acae9f output: add wlr_output_begin_render_pass() 2023-05-30 16:18:19 +00:00
Alexander Orzechowski 95062904c7 wlr_scene: Introduce wlr_scene_buffer_set_opacity 2023-05-30 15:43:29 +00:00
Alexander Orzechowski 2346b90a9f wlr_scene: Make scene_rect_from_node public
This is in an effort to be more consistent with both already public
getters: wlr_scene_buffer_from_node and wlr_scene_tree_from_node
2023-05-30 15:40:41 +00:00
Alexander Orzechowski 88f80c4a7c wlr_scene: Make scene_tree_from_node public
This is to allow for compositors that want to be more implicit about
how their scene is organized. Such a compositor may want to walk up
at a certain scene node to find something such as a surface to focus on.
2023-05-30 15:40:41 +00:00
Simon Ser 2c6aeed7d6 output: use pending render format if any
If a modeset contains a render format change, use that instead of
the current one stored in wlr_output.render_format.

This fixes render_bit_depth configuration not being applied without
a second modeset in Sway.
2023-05-26 16:50:58 +00:00
Alexander Orzechowski d495fb8c04 wlr_{box, fbox}_equal: Consider empty boxes NULL 2023-05-23 17:57:16 +00:00
Simon Ser 96f3f3c92e render/pixel-format: add support for block-based formats
Some formats like sub-sampled YCbCr use a block of bytes to
store the color values for more than one pixel. Update our format
table to be able to handle such formats.
2023-05-21 20:28:45 +00:00
Simon Ser a0ebc401d0 linux-dmabuf-v1: fix wlr_drm_format_set leak in feedback_compile()
Fixes: 43b25fd34e ("dmabuf: Remove assumption that all mods are in fallback tranche")
2023-05-18 11:20:21 +02:00
Austin Shafer 43b25fd34e dmabuf: Remove assumption that all mods are in fallback tranche
According to the spec the compositor should send scanout modifiers in
their respective device tranches, and all other texture modifiers
in the main tranche. Currently wlroots expects all modifiers to be
present in the last (i.e. "fallback") tranche, this removes that assumption
in the feedback compilation stage so that scanout modifiers for secondary
device can be advertised.

"The full-screen feedback parameters have two tranches: one with the
format/modifier pairs supported by the KMS plane, with the scanout flag
set in the tranche_flags event and with tranche_target_device set to the
KMS scan-out device; the other with the rest of the format/modifier
pairs (supported for texturing, but not for scan-out), without the
scanout flag set in the tranche_flags event, an"
2023-05-18 09:08:18 +00:00
Alexander Orzechowski c4bed48fcc output_pick_format: Fail if no format could be chosen 2023-05-18 07:05:30 +00:00
Kirill Primak 75293d5fb0 keyboard: use the new data in wlr_keyboard_set_keymap()
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3647
2023-05-18 08:39:24 +03:00
Simon Ser e2647c5151 keyboard: add support for resetting the keymap 2023-05-17 22:08:34 +00:00
Simon Ser e725f234d7 keyboard: don't change current keymap on wlr_keyboard_set_keymap() error
This function was unsetting the keymap on error. Instead, let's
leave the current keymap untouched on error.
2023-05-17 22:08:34 +00:00
Simon Ser 69aeccddb7 seat/keyboard: allow no keymap 2023-05-17 22:08:34 +00:00
Alexander Orzechowski 300bd80772 wlr_drm_format_set: Store formats on array 2023-05-11 18:25:52 +02:00
Alexander Orzechowski 90d08f8f1c wlr_drm_format: Rework wlr_drm_format_intersect
Now it takes a reference to a destination format
2023-05-11 18:24:43 +02:00
Alexander Orzechowski 340700cb70 wlr_drm_format: Change wlr_drm_format_dup to copy 2023-05-11 18:24:43 +02:00
Alexander Orzechowski e427e019c4 wlr_drm_format: Don't take double pointer in wlr_drm_format_add 2023-05-11 03:51:01 -04:00
Alexander Orzechowski b45396c790 wlr_drm_format: Introduce drm_format_finish 2023-05-11 03:51:01 -04:00
Simon Ser 2a1234a820 wlr-export-dmabuf-v1: handle output destroy
We were storing a wlr_output without listening for the destroy
event.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3646
2023-05-10 20:45:48 +00:00
Alexander Orzechowski 18139f4d87 wlr_cursor: Don't multiply hotspot by scale^2
We are already multiplying in output_cursor_set_texture
2023-05-08 09:17:22 +00:00
Alexander Orzechowski 47a250ae12 wlr_cursor: Consider surface state when setting new cursor surface
Found by inspection
2023-05-06 20:55:11 +00:00
Simon Ser d933f5204b output: drop wlr_output_cursor_set_surface 2023-05-06 13:59:05 -04:00
Simon Ser 78afce5e2d cursor: add surface handling
Only rely on wlr_output_cursor_set_texture(), because
wlr_output_cursor_set_surface() will get dropped.
2023-05-06 17:48:56 +00:00
Simon Ser b64e7e88bf output: add output_cursor_set_texture() 2023-05-06 17:48:56 +00:00
Alexander Orzechowski 1ee75786b4 drm_format_set_union: Require initialized dst and remove assert 2023-05-04 18:19:33 +00:00
Alexander Orzechowski ec796afb6e wlr_compositor: Decide opacity from new has_buffer flag.
`wlr_surface_get_texture` will always return NULL if the compositor was
not given a renderer.
2023-05-04 11:53:26 +02:00
Alexander Orzechowski 394accbe4a wlr_compositer: Keep track if surface has committed a buffer before.
This would break if you are running with a NULL renderer.
2023-05-04 11:53:26 +02:00
Alexander Orzechowski cbe8876050 linux_dmabuf_v1: Use wlr_drm_format_set_union 2023-05-03 12:38:28 -04:00
Simon Ser bf8ae8a036 output/cursor: fix buffer size when nested and scaled
The Wayland, X11 and headless backends don't really care about the
cursor size. We were picking a size identical to the texture size
in that case. This is incorrect for LoDPI cursor textures on HiDPI
outputs: in that case, we need to scale up the cursor texture.

Fixes the cursor being chopped off under the Wayland backend with
scale > 1.
2023-05-03 11:32:51 +02:00
Simon Ser d7fcc1e96f scene: port to wlr_render_pass 2023-04-25 17:26:35 +02:00
Simon Ser 587852056c output: add wlr_output_add_software_cursors_to_render_pass()
Same as wlr_output_render_software_cursors(), but takes a
struct wlr_render_pass.
2023-04-25 17:26:34 +02:00
Simon Ser 44069dfd5e output-layer: add cropping support
Add a src_box state field. Use the SRC_* KMS props in the DRM
backend, reject the layers in the Wayland backend (for now, we can
support it later via viewporter).
2023-04-20 10:39:46 +02:00
Andri Yngvason 00489b11a0 seat: Provide dummy resources for inert seats 2023-04-18 08:29:30 +00:00
Andri Yngvason 3898bb482d seat: Let client manage its own resources
This makes seat_client resources inert when seats and/or input devices are
destroyed, rather than destroying the resources.

When the client calls e.g. wl_keyboard_release(), it's not expecting the
keyboard global to be already destroyed, so this results in an error such
as this:

    wl_display@1: error 0: invalid object 22
2023-04-18 08:29:30 +00:00
Andri Yngvason 1689a3503b wlr_seat: Extract seat_client_create() function 2023-04-18 08:29:30 +00:00
Alexander Orzechowski eac2eaa6a9 wlr_scene: Fix potential use-after-free in wlr_scene_buffer_set_buffer
Fixes: #3636
2023-04-16 14:01:54 +02:00
Alexander Orzechowski 39be67df46 wlr_scene: Send presentation event before direct scanout output commit
We were doing it too late before and surfaces were never getting
the presentation event.
2023-04-14 22:29:24 +02:00
Simon Ser dae2deb3c9 compositor: add wlr_surface_set_preferred_buffer_transform()
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-14 17:07:26 +02:00
Simon Ser 42edd36785 compositor: add wlr_surface_set_preferred_buffer_scale()
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-14 17:07:26 +02:00
Simon Ser 0bb574239d compositor: pass version in wlr_compositor_create
This allows wlroots to support newer versions of the interface
without breaking the API.
2023-04-14 17:07:26 +02:00
Kirill Primak 87e7584dd4 compositor: use defunct_role_object error 2023-04-14 17:04:00 +02:00
Kirill Primak fac7a5cc9d subcompositor: use bad_parent error 2023-04-14 17:00:17 +02:00
Kirill Primak 49435cb27b subcompositor: simplify get_subsurface handler 2023-04-14 16:59:55 +02:00
Alexander Orzechowski b1e38fc7ea output: Drop output_is_direct_scanout 2023-04-06 22:39:08 +02:00
Simon Ser 9ef98452a3 output-damage: drop
Compositors can migrate to wlr_damage_ring.
2023-04-06 20:34:30 +00:00
Simon Ser 7abda952d0 output: drop direct scan-out check in output_basic_test()
wlr_output is not well-suited to checking whether direct scan-out
is happening or not. Compositors may want to use their own external
swapchains, for instance.

Additionally, ab7eabac84 ("output: leverage
wlr_output_configure_primary_swapchain()") makes it so
output_basic_test() is called before the output swapchain is
initialized, resulting in false positives.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3620
2023-04-06 21:46:45 +02:00
Simon Ser ec5135cb09 scene: check wlr_output_is_direct_scanout_allowed() 2023-04-06 21:43:43 +02:00
Simon Ser 079ff9e6fb output: add wlr_output_is_direct_scanout_allowed()
This lets compositors check whether direct scan-out is possible.
Compositors will soon be responsible for manually calling this
function.
2023-04-06 21:42:08 +02:00
Simon Ser 835208db98 output-layer: add support for scaling buffers
This allows callers to set a destination size different from the
buffer size to scale them.

The DRM backend supports this. The Wayland backend doesn't yet
(we'd need to wire up viewporter).
2023-04-04 19:39:38 +02:00
Simon Ser e00c4cd7dc output-layer: cache current state
The will be used by the Wayland backend to figure out whether
updating sub-surface position is necessary.
2023-03-28 22:58:29 +00:00
Kirill Primak a3489f2c64 xdg-shell: improve unmapping logic slightly 2023-03-12 11:09:36 +00:00
Simon Ser 1b6fac4aa6 output-layer: require all layers in wlr_output_state.layers
- Simplifies the backends
- Avoids having two ways to do the same thing: previously one could
  disable a layer by either omitting it from wlr_output_state.layers,
  or by passing a NULL buffer
- We can change our mind in the future: we can allow users to omit
  some layers and define a meaning without breaking the API.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4017#note_1783997
2023-03-10 11:16:01 +00:00
Isaac Freund 87969c1c7c
xdg-decoration: send missing protocol errors 2023-03-10 11:44:20 +01:00
Alexander Orzechowski 9ac94516b8 wlr_scene: Skip direct scanout if there is no damage 2023-03-09 05:38:53 +01:00
Simon Ser 38839ac536 gamma-control-v1: simplify get_gamma_control error handling
Allocate resources only after checking the request.
2023-03-06 13:23:51 +01:00
Simon Ser 9108717d5d gamma-control-v1: fix handling of duplicate control
When a new client comes in and tries to create a
zwlr_gamma_control_v1 object for an output which already has one,
we were destroying the old object and early-returning. The early
return causes the new object to not be set up properly: it's not
inserted in the list and doesn't get the gamma_size event.

Fix this by destroying the new object, and leave the old object
intact, which is what was the intent I think.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3605
2023-03-06 11:40:48 +01:00
Isaac Freund 5ae17de23f
xdg-shell: improve validation of resize edges
The current validation doesn't catch some invalid values such as 3 or 7.
2023-03-02 21:31:51 +01:00
Simon Ser 5079000e49 output: allow modeset with buffer while frame is pending
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3600
2023-02-26 18:42:31 +01:00
Simon Ser ab7eabac84 output: leverage wlr_output_configure_primary_swapchain()
Replace our current logic to setup the primary swapchain with
wlr_output_configure_primary_swapchain().

- Removes some code, reducing duplication
- Stop overwriting wlr_output.swapchain with a yet-to-be-tested
  swapchain: remove the error_destroy_swapchain label.
2023-02-24 18:22:20 +00:00
Simon Ser fef8ab22e3 output: introduce wlr_output_configure_primary_swapchain()
The goal is to simplify wlr_output by moving all of its rendering
API into separate helpers. Here is a first step to sunset
wlr_output_attach_render(). Instead, compositors call
wlr_output_configure_primary_swapchain(), wlr_swapchain_acquire(),
wlr_renderer_begin_with_buffer() and wlr_output_attach_buffer().

Note that compositors can supply a base struct wlr_output_state.
This is useful to allocate a buffer suitable for submission with
a modeset, for instance.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3079
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3197
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3984
2023-02-24 18:22:20 +00:00
Simon Ser b33ab26fe7 render/swapchain: make public
We've had this struct for a while. It'd be useful for compositors
if they want to manage the swap chains themselves instead of being
forced to use wlr_output's. Some compositors might also want to use
a swapchain without an output.
2023-02-21 17:14:31 +01:00
Simon Ser 7215bd1e0f output: expose wlr_output_state_set_buffer() 2023-02-21 09:43:43 +00:00
Simon Ser 4629d0ef40 output: expose wlr_output_state_finish()
Same as the original function, but check for the bitfield before
calling pixman_region32_fini(), because that function expects an
initialized region.
2023-02-21 09:43:43 +00:00
Simon Ser d25ab03326 screencopy-v1: drop unnecessary pixman_region32_t casts
The Pixman API now accepts const parameters.
2023-02-21 09:37:59 +00:00
Alexander Orzechowski 3ef9f91283 wlr_scene: Add dmabuf_feedback helper 2023-02-20 17:21:17 -05:00
Alexander Orzechowski 4ddc20e14c wlr_scene: Extract considering logic for direct scanout 2023-02-20 16:53:59 -05:00
Alexander Orzechowski 323f0b94db wlr_scene: Cleanup header includes
We don't need to pull wlr_compositor.
2023-02-20 16:53:59 -05:00
Simon Ser 849c362ffb linux-dmabuf-v1: add helper for output layer feedback events 2023-02-20 18:38:57 +01:00
Simon Ser e1335a792a output-layer: add feedback event 2023-02-20 18:38:57 +01:00
Simon Ser 3e0ce761ad output: add wlr_output_set_layers() 2023-02-20 18:38:09 +01:00
Simon Ser 2f29b0c438 Add wlr_output_layer
This is based on previous work [1] [2].

This new API allows compositors to display buffers without needing to
perform rendering operations. This API can be implemented on Wayland
using subsurfaces and on DRM using KMS planes.

Compared to [1], this approach leverages wlr_addon_set to let backends
attach their own private state to layers, removes the pending
state (necessary for interop with wlr_output_commit_state()) and
enum wlr_output_layer_state_field.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/1985
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3447
2023-02-20 18:38:09 +01:00
Vasyl Vavrychuk 58067a2084 fullscreen-shell: add release request handler 2023-02-17 10:24:47 +00:00
Kenny Levinsen 1225f81a6a scene: Add fractional scale handling 2023-02-08 16:31:39 +01:00
Kenny Levinsen efb8df8b22 wp-fractional-scale-v1: new protocol implementation
This implements the WIP wp-fractional-scale-v1 protocol.
2023-02-08 16:31:39 +01:00
Simon Ser c6ecbf09b5 linux-dmabuf-v1: fix missing SCANOUT flag
options->scanout_primary_output indicates an output on which scanout is desirable.
Set the missing SCANOUT flag.

Fixes: 0c966f102c ("linux-dmabuf-v1: add wlr_linux_dmabuf_feedback_v1_init_with_options()")
2023-02-07 11:25:10 +01:00
Simon Ser 8c5713bd7a linux-dmabuf-v1: use wlr_linux_dmabuf_feedback_v1_init_with_options() 2023-02-06 19:14:15 +00:00
Simon Ser 0c966f102c linux-dmabuf-v1: add wlr_linux_dmabuf_feedback_v1_init_with_options() 2023-02-06 19:14:15 +00:00
Simon Ser b264ec7767 linux-dmabuf-v1: add basic helpers for feedback 2023-02-06 19:14:15 +00:00
Simon Ser 5cd14dfc91 linux-dmabuf-v1: stop using const in feedback
Instead of using const pointers, use structs owned by the tranche.
This will allow wlroots to expose helpers to build feedback
objects.
2023-02-06 19:14:15 +00:00
Consolatis f6008ffff4 xdg-activation: accept pointer focus for new tokens
This patch allows surfaces without keyboard focus
but with pointer focus to receive valid tokens.

This can be relevant for applications using an older version of
the layershell protocol which only provided the choice between
no keyboard focus and exclusive keyboard focus.
2023-02-06 15:52:02 +01:00
Alexander Orzechowski 7b32c25a4f wlr_scene: Rename wlr_scene_surface_from_buffer
This renames it to wlr_scene_surface_try_from_buffer to be more clear
that this function can return NULL. This is inline with the rest of
wlroots[1].

[1] https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3991
2023-02-04 02:57:42 -05:00
Kirill Primak dc7b5ab21e layer-shell: forbid changing the existing popup parent 2023-02-03 19:29:11 +03:00
Simon Ser 92eedb84c1 output: don't attach buffer on first commit if disabled
In output_ensure_buffer() we create a swapchain and attach an empty
buffer to the output if necessary. We do that during the first commit.
This is fine when the first commit enables the output, however this breaks
when the first commit disables the output. A commit which disables an
output and has a buffer attached is invalid (see output_basic_test()), and
makes the DRM backend crash:

    00:00:00.780 [wlr] [backend/drm/drm.c:622] connector eDP-1: Turning off
    ../subprojects/wlroots/backend/drm/drm.c:652:44: runtime error: member access within null pointer of type 'struct wlr_drm_crtc'
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==2524==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f22e894afc1 bp 0x7ffe1d57c550 sp 0x7ffe1d57c420 T0)
    ==2524==The signal is caused by a READ memory access.
    ==2524==Hint: address points to the zero page.
        #0 0x7f22e894afc1 in drm_connector_commit_state ../subprojects/wlroots/backend/drm/drm.c:652
        #1 0x7f22e894b1f5 in drm_connector_commit ../subprojects/wlroots/backend/drm/drm.c:674
        #2 0x7f22e89e8da9 in wlr_output_commit_state ../subprojects/wlroots/types/output/output.c:756
        #3 0x555ab325624d in apply_output_config ../sway/config/output.c:517
        #4 0x555ab31a1aa1 in handle_new_output ../sway/desktop/output.c:974
        #5 0x7f22e9272f6d in wl_signal_emit_mutable (/usr/lib/libwayland-server.so.0+0x9f6d)
        #6 0x7f22e899b012 in new_output_reemit ../subprojects/wlroots/backend/multi/backend.c:161
        #7 0x7f22e9272f6d in wl_signal_emit_mutable (/usr/lib/libwayland-server.so.0+0x9f6d)
        #8 0x7f22e895a153 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1488
        #9 0x7f22e893c2e4 in backend_start ../subprojects/wlroots/backend/drm/backend.c:24
        #10 0x7f22e892ed00 in wlr_backend_start ../subprojects/wlroots/backend/backend.c:56
        #11 0x7f22e8999b83 in multi_backend_start ../subprojects/wlroots/backend/multi/backend.c:31
        #12 0x7f22e892ed00 in wlr_backend_start ../subprojects/wlroots/backend/backend.c:56
        #13 0x555ab317d5cc in server_start ../sway/server.c:316
        #14 0x555ab317748d in main ../sway/main.c:400
        #15 0x7f22e783c28f  (/usr/lib/libc.so.6+0x2328f)
        #16 0x7f22e783c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
        #17 0x555ab3134c84 in _start (/home/simon/src/sway/build/sway/sway+0x377c84)

Fixes: 3be6658ee7 ("output: allocate swapchain on first commit")
Closes: https://github.com/swaywm/sway/issues/7373
2023-02-02 16:48:35 +00:00
Kirill Primak 911648f430 subcompositor: fix mapped parent check 2023-02-02 17:26:25 +03:00
Simon Ser eb3e8f08a8 subcompositor: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:14:39 +01:00
Simon Ser c5f7f8ab98 ext-session-lock-v1: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:14:12 +01:00
Simon Ser f9bd416d41 layer-shell-v1: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:13:53 +01:00
Simon Ser 49cb85ad72 input-method-v2: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:13:30 +01:00
Simon Ser 711a1a3ed4 xdg-shell: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:12:49 +01:00
Simon Ser 0f24d27e0b xdg-shell: rename wlr_xdg_popup.committed to sent_initial_configure
We made a similar change to wlr_xdg_toplevel.
2023-01-31 16:27:05 +01:00
Simon Ser df0c926a7a xdg-shell: rename wlr_xdg_toplevel.added to sent_initial_configure
This is more descriptive, and avoids the confusion with
wlr_xdg_surface.added.
2023-01-31 16:20:33 +01:00
Simon Ser e1a1dc4be5 xdg-shell: remove unnecessary return
We're at the end of the function anyways.
2023-01-31 16:20:33 +01:00
Simon Ser e69dd909f7 xdg-shell: reset added/committed flag on unmap
When a client attaches a NULL buffer to its wl_surface, it's
unmapped. This resets the xdg_surface in its initial state. An
extra NULL commit makes the compositor send an initial configure
event.

Note, wlr_xdg_toplevel.added is separate from wlr_xdg_surface.added.

Closes: https://github.com/swaywm/sway/issues/7397
2023-01-31 16:20:10 +01:00
Simon Ser 0e54b861e9 seat/keyboard: constify wlr_seat_keyboard_notify_enter() 2023-01-26 15:06:45 +00:00
Simon Ser 695d28c250 seat/keyboard: constify wlr_seat_keyboard_notify_modifiers() 2023-01-26 15:06:45 +00:00
Simon Ser e44834595d seat/keyboard: constify args in wlr_seat_keyboard_enter() 2023-01-26 15:06:45 +00:00
Simon Ser 12e04d8f83 seat/keyboard: constify wlr_seat_keyboard_send_modifiers() 2023-01-26 15:06:45 +00:00
Simon Ser f41dcb3a97 seat/keyboard: skip wl_array allocation
We can just create a wl_array from the array passed by the user.
Here, wl_array is only necessary to make libwayland happy.
2023-01-26 15:06:45 +00:00
Alexander Orzechowski 5007e713b4 wlr_scene: Send intersecting list of scene outputs for outputs_update signal 2023-01-21 16:23:30 -05:00
Kirill Primak 843b874f22 output-layout: improve closest point for no outputs case
Without outputs, all points are equally invalid anyway, but for e.g.
cursor warping it makes more sense to preserve the original position.
2023-01-21 12:48:43 +00:00
Alexander Orzechowski 5f264a7d6c subcompositor: Clean up subsurface_consider_map
check_parent was unecessary: it only served to skip a trivial check
and added more complexity than it was worth.
2023-01-04 04:24:17 -05:00
Alexander Orzechowski 84aee1d708 subcompositor: Clarify comment on subsurface mapped consideration 2023-01-04 04:24:17 -05:00
Isaac Freund 869af1cfbb
session-lock: send more protocol errors
The invalid_destroy and invalid_unlock protocol errors aren't currently
sent by wlroots and instead left up to the compositor. However, we can
handle these as well without much additional complexity.

This also adds a missing wl_resource_destroy() call if the lock is inert
in lock_handle_unlock_and_destroy().
2022-12-23 16:56:42 +01:00
Kirill Primak b28a9afd4b presentation-time: finish surface addon
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3554
2022-12-22 18:35:53 +03:00
bi4k8 790fb93794 cursor: compare to scaled coords 2022-12-20 20:01:56 +00:00
xiliuya 7f6d646e0a keyboard: only update LEDs when changed 2022-12-14 17:51:06 +01:00
Kirill Primak 79248e4961 xdg-shell: use defunct_role_object error 2022-12-07 13:54:31 +00:00
Ronan Pigott f8e70af318 wlr_xdg_activation_v1: add new_token event 2022-12-06 05:45:37 +00:00
Kirill Primak 097ea84cda output-layout: improve API
- wlr_output_layout_add{,_auto}() now return a bool indicating whether
  the function has succeeded.
- wlr_output_layout_move() is removed.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1083
2022-12-05 18:21:04 +00:00
Kirill Primak 27ea18cc33 output-layout: remove wlr_output_layout_output_state
wlroots uses "// private state" comments to denote structure fields
which shouldn't be accessed by compositors, so let's drop
wlr_output_layout_output_state and inline its fields into
wlr_output_layout_output; this also simplifies layout output creation.
2022-12-05 18:21:04 +00:00
Simon Ser 512deebd82 compositor: add wlr_surface.events.precommit 2022-12-05 10:51:46 +01:00
Simon Ser d92f92f2d3 wl-drm: only advertise formats supporting implicit modifiers
With the Vulkan renderer we don't support implicit modifiers.
However wl_drm only supports implicit modifiers.

Stop advertising wl_drm formats when implicit modifiers are
unsupported.
2022-12-02 14:27:07 +00:00
Simon Ser f36a5915da wl-drm: don't store wlr_renderer
Query the formats at init time, then forget about the renderer.
This will allow wl_drm to be created with a list of formats instead
of a renderer, and will behave better after a GPU reset.
2022-12-02 14:27:07 +00:00
Simon Ser c8eb24d30e output: drop enable/mode events
The backend no longer changes the output state behind the
compositor's back. Instead, compositors can listen to the "commit"
event and check for WLR_OUTPUT_STATE_ENABLED/WLR_OUTPUT_STATE_MODE.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2300
2022-12-01 20:05:04 +00:00
Simon Ser 4287f70dc3 output-layout: stop listening for output mode events
These will go away.
2022-12-01 20:05:04 +00:00
Simon Ser 19dfe99496 output-damage: stop listening for output mode events
These will go away.
2022-12-01 20:05:04 +00:00
Simon Ser fecbaa2bd6 scene: stop listening for output enable/mode events
These will go away.
2022-12-01 20:05:04 +00:00
Alexander Orzechowski fe891ebd4e output_init_render: Allow re-initialization
This lets the compositor call this function after the fact to replace
the renderer/allocator after a renderer context lost.
2022-12-01 10:01:35 +00:00
Simon Ser f103dc74d8 linux-dmabuf-v1: introduce wlr_linux_dmabuf_v1_create()
Some compositors may want to use the linux-dmabuf-v1 implementation
with a completely custom renderer. Add a function to create the
global with a default feedback.
2022-11-30 14:19:46 +01:00
Simon Ser 9c04fd2496 linux-dmabuf-v1: drop wlr_renderer field
This isn't used anymore.
2022-11-30 14:19:46 +01:00
Simon Ser 88493d1f7c linux-dmabuf-v1: don't use wlr_renderer to send legacy format list
The wlr_renderer field will go away in a subsequent commit.

Build the legacy device list from the default feedback instead.
2022-11-30 14:19:46 +01:00
Simon Ser d45cffb865 linux-dmabuf-v1: don't use wlr_renderer to sanity check DMA-BUFs
The wlr_renderer field will go away in a subsequent commit.

Instead of trying to create a texture, try to import the DMA-BUF
into the DRM device FD.
2022-11-30 14:14:07 +01:00
Simon Ser c99c60090c linux-dmabuf-v1: add version arg to create()
To be able to add support for newer versions without breaking
changes.
2022-11-30 14:14:04 +01:00
Simon Ser 444d94ef89 linux-dmabuf-v1: add "_with_renderer" suffix to create() function
Make it clear this is a helper consuming a wlr_renderer. We'll
add a lower-level create() function which doesn't take it in the
next commit.
2022-11-30 14:14:02 +01:00
Simon Zeni 0611c10909 types/wlr_seat: finish keyboard_state during wlr_seat_destroy 2022-11-29 15:21:18 -05:00
Johan Malm 338e0a3976 scene/layer_shell_v1.c: remove redundant comment 2022-11-29 18:01:57 +00:00
Johan Malm 8e80432a72 scene/layer_shell_v1.c: set exclusive zone correctly
...when only one edge is anchored.

The layer-shell protocol specifies that a positive exclusive-zone value is
'meaningful' if the surface is anchored to either:

1. one edge
2. one edge and both perpendicular edges.

For example, if you wish to position a layer-shell client along the top
edge and make it exclusive, you should be able to either set anchor=TOP or
anchor=TOP|LEFT|RIGHT. It appears that many panels/bars use the latter
approach (anchor to an edge and also both perpendicular edges) which is
probably why this has not been reported previously.

This patch adds support for the first case and thereby makes exclusive
zone behaviour consistent with the protocol and also with sway's extant
layer-shell implementation.
2022-11-29 18:01:57 +00:00
Alexander Orzechowski 32d00984e1 wlr_scene: Expand damage cull region with fractional scales 2022-11-29 07:43:39 +00:00
Alexander Orzechowski fe21fc6920 wlr_scene: Don't cull the entire output when entering direct scanout
We don't need to.
2022-11-29 07:43:39 +00:00
Kirill Primak 5477ad7d90 scene: fix output damage expansion condition
Now, it is checked whether an output pixel corresponds to an integer
number of buffer pixels; if it doesn't, the region is altered to take
this into account.
2022-11-28 23:54:29 +00:00
Simon Ser 35a0d9c85d scene: set output damage during direct scan-out
This allows the backend to have access to the frame damage, as
reported by the scanned-out client. Some KMS drivers can make use
of it (e.g. for PSR, or optimized USB transfers in the GUD driver),
and the Wayland/X11 backends forward it to the parent compositor.
2022-11-26 10:06:56 +01:00
Simon Ser ce089498cc scene: use wlr_output_state for direct scanout
Avoids polluting wlr_output.pending with temporary state. Removes
the need to call wlr_output_rollback() in error codepaths.
2022-11-26 09:52:49 +01:00
Simon Ser 76b3687739 shm: add create() function without a wlr_renderer
This allows compositors which don't use wlr_renderer to still use
wlroots' wl_shm implementation.
2022-11-25 15:16:42 +00:00
Kirill Primak 060df4c6c0 scene: introduce wlr_scene_buffer.events.outputs_update
This event is useful for e.g. sending the preferred buffer scale to the
client.
2022-11-24 22:28:13 +00:00
Simon Ser 42016fa262 compositor: make renderer optional
This is a first step towards moving texture uploading out of
wlr_compositor.

This commit allows compositors to opt-out of the texture uploading
by passing a NULL wlr_renderer. An immediate user of this is
gamescope, which currently implements a stub wlr_renderer just to
make wlr_compositor happy.
2022-11-24 21:55:24 +00:00
Simon Ser 1978a91717 compositor: release current buffer after commit event
Some compositors may want to access the original buffer in their
commit handler.
2022-11-24 21:55:24 +00:00
Guido Günther 8a56490229 seat/pointer: Initialize low_res_value
Fixes

    In file included from /usr/include/wayland-server-core.h:32,
                     from ../types/seat/wlr_seat_pointer.c:6:
    In function 'wl_fixed_from_double',
        inlined from 'wlr_seat_pointer_send_axis' at ../types/seat/wlr_seat_pointer.c:367:6:
    /usr/include/wayland-util.h:641:17: error: 'low_res_value' may be used uninitialized [-Werror=maybe-uninitialized]
      641 |         u.d = d + (3LL << (51 - 8));
          |               ~~^~~~~~~~~~~~~~~~~~~
    ../types/seat/wlr_seat_pointer.c: In function 'wlr_seat_pointer_send_axis':
    ../types/seat/wlr_seat_pointer.c:329:16: note: 'low_res_value' was declared here
      329 |         double low_res_value;
          |                ^~~~~~~~~~~~~
2022-11-24 22:37:52 +01:00
Simon Ser f84f7c7710 wl-drm: use resource interface
Instead of hardcoding builtin resource types in
wlr_buffer_from_resource(), use the modular resource interface.
2022-11-17 19:55:19 +00:00
Simon Ser 772066a174 linux-dmabuf-v1: use resource interface
Instead of hardcoding builtin resource types in
wlr_buffer_from_resource(), use the modular resource interface.
2022-11-17 19:55:19 +00:00
Kirill Primak c2fb5289c2 xdg-shell: send invalid_size errors 2022-11-17 10:03:52 +00:00
Simon Ser 6c3d6be74b output: drop wlr_output_damage_whole()
This function is not used anymore. Backends have no good reason to
damage outputs.
2022-11-17 09:17:32 +00:00
Simon Ser ef5e2cc5e3 output: call wlr_output_update_enabled() after commit
Backends no longer need to manually call wlr_output_update_enabled()
in their commit hook: wlr_output will take care of that.
2022-11-17 09:12:25 +00:00
bi4k8 8b12037cad wlr_seat: clear `drag->seat_client` when destroyed
This was previously a use-after-free in `wlr_drag.c`.
2022-11-16 01:56:18 +00:00
Alexander Orzechowski 265439600e output: Initialize request_state 2022-11-15 12:00:47 -05:00
Simon Ser 270b8dd342 shm: allow accessing multiple shm mapping concurrently
Use a basic linked list to store the currently active mappings.

Note that we don't actually need to implement a full lock-free
atomic linked list here. The signal handler will never write to
the list, it will only read it. Only the main thread will write.
We need to always expose a consistent view of the list to the
signal handler (the main thread might be interrupted at any point
by the signal handler).
2022-11-15 16:30:00 +00:00
Simon Ser 6c277e3c39 buffer: drop wlr_shm_client_buffer
It's been superseded by wlr_shm.
2022-11-15 16:30:00 +00:00
Simon Ser 0ae3c7b1a2 Introduce wlr_shm
This is a re-implementation of wl_shm. The motivations for using
this over the one shipped in libwayland are:

- Properly handle SIGBUS when accessing a wl_buffer's underlying
  data after the wl_buffer protocol object has been destroyed.
  With the current code, we just crash if the client does that
  and then shrinks the backing file.
- No need to fight the wl_shm_buffer API anymore. This was awkward
  because we weren't notified when clients created a wl_shm buffer,
  and this doesn't play well with our wlr_buffer abstraction.
- Access to the underlying FD. This makes it possible to forward
  the wl_shm buffer to a parent compositor with the Wayland/X11
  backends.
- Better stride checks. We can use our format table to ensure that
  the stride is consistent with the bpp and width.
2022-11-15 16:30:00 +00:00
Simon Ser 48541d2f2e scene: check wlr_renderer_begin return value 2022-11-15 15:50:19 +00:00
Simon Ser 45159f8708 output: check wlr_renderer_begin return value 2022-11-15 15:50:19 +00:00
Simon Ser bf623ec782 content-type-v1: add version param to wlr_content_type_manager_v1_create() 2022-11-15 16:43:04 +01:00
Simon Ser ff55663906 output: introduce request_state event
This allows backends to request the compositor to change the state
of an output.

References: https://github.com/swaywm/wlroots/issues/2300#issuecomment-761819673
2022-11-15 15:39:55 +00:00
Simon Ser 024627e872 content-type-v1: new protocol implementation
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/150
2022-11-15 15:36:09 +00:00
Simon Ser 258bf9be1e compositor: drop wlr_surface.{sx,sy}
The concept of a persistent accumulated surface offset is wrong
from a protocol point-of-view. wl_surface.offset is tied to a
commit, its interpretation depends on the surface role.

For example, with the following sequence:

    wl_surface@1.offset(1, 1)
    wl_surface@1.commit()
    wl_pointer@2.set_cursor(wl_surface@1, 42, 42)

The final cursor hotspot is (42, 42): the commit which happened
before the set_cursor request has no impact on the hotspot
computation.

The wlr_output_cursor logic already uses wlr_surface.current.{dx,dy}.
wlr_scene's drag icon doesn't, update it accordingly.
2022-11-15 13:41:09 +00:00
Alexander Orzechowski c8a5dfcc87 wlr_scene: Add drag icon helper 2022-11-14 15:44:43 +00:00
Simon Ser 9f793d3503 layer-shell-v1: specify version in constructor
This allows compositors to indicate which features they support,
and is required to eventually make this API stable.

References: https://github.com/swaywm/sway/issues/7260
2022-11-14 09:52:13 +01:00
Simon Ser 2b22a10478 scene: constify region APIs 2022-11-11 23:11:17 +00:00
Simon Ser c5d79bfb26 region: constify 2022-11-11 23:11:17 +00:00
Simon Ser fe4225d5de output: constify damage APIs 2022-11-11 23:11:17 +00:00
Simon Ser 9e10e9af7f output-damage: constify wlr_output_damage_add() 2022-11-11 23:11:17 +00:00
Simon Ser fb7bd920a6 damage-ring: constify wlr_damage_ring_add() 2022-11-11 23:11:17 +00:00
Simon Ser 93597952aa buffer: constify wlr_client_buffer_apply_damage() 2022-11-11 23:11:17 +00:00
Alexander Orzechowski c58ad0f171 wlr_scene: Remove duplicate buffer check when submitting a new buffer
wlr_buffer allows mutation during its lifetime. This happens for
wlr_client_buffer which fixes damage tracking issues.
2022-11-11 15:37:22 +00:00
Alexander Orzechowski ea40ba4f6a wlr_scene: Fix texture reuse
Add private interface to ignore a buffer that's locking a client_buffer
for damage tracking. This should eventually be replaced by wlr_raster.
2022-11-11 00:08:04 +00:00
Simon Ser 440d7fa072 scene: destroy addons before cleaning up internal state
This allows addons to access wlr_scene_node/wlr_scene_surface
fields to clean up themselves.
2022-11-08 16:47:59 +00:00
Simon Ser 24c149fefb scene: fix whitespace 2022-11-08 16:47:59 +00:00
Kirill Primak 123a08b448 scene: fix output damage expansion
This fixes e.g. `weston-simple-damage --use-viewport` which technically
renders at the buffer scale of 0.5.
2022-11-08 06:37:42 +00:00
Kirill Primak 388de59df3 compositor: use the correct input region 2022-11-07 21:06:12 +00:00
Kirill Primak c09d3450d4 compositor: enforce surface destruction order 2022-11-06 17:00:00 +03:00
Kirill Primak 099b9de752 compositor: drop role object NULL checks in handlers
Instead, move the check to the caller.
2022-11-06 17:00:00 +03:00
Kirill Primak acd5a64fd1 xdg-shell: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 92fbfda2ca drag-icon: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 75af6a0a39 input-method: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak bcf6b2bbf8 session-lock: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 2518ace573 subcompositor: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 3da2cf3eb3 layer-shell: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 756260ac05 compositor: introduce wlr_surface_destroy_role_object() 2022-11-06 14:16:05 +03:00
Kirill Primak 1243a855d4 xdg-shell: fix geometry types 2022-11-05 18:30:09 +00:00
Kirill Primak 92e3c5b798 scene: fix buffer source box transforming 2022-11-05 14:44:57 +03:00
Isaac Freund a773231c42 wlr-output-management: implement adaptive sync
Version 4 of the protocol adds support for reporting/setting adaptive
sync state of outputs. Implement these new requests/events in wlroots.
2022-10-24 16:19:25 +00:00
Alexander Orzechowski c2d2773df5 wlr_scene: Handle fractional scaling better
Try to alleviate scaling inaccuracies by implementing a fudge factor.
2022-10-22 19:13:21 +00:00
Simon Ser f0ee563416 output: try to use fixed mode in wlr_output_set_custom_mode()
If a fixed mode matching the user requirements is available, use
that. This avoids generating the mode with GTF or CVT in the DRM
backend, and instead uses mode timings advertised by the output.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3514
2022-10-20 09:49:16 +02:00
Alexander Orzechowski c07424411a wlr_scene: Destroy the texture when setting a new buffer.
Fixes: https://github.com/labwc/labwc/issues/587
Fixes: f0e31e806f (wlr_scene: Fix not updating the scene node when setting a new buffer)
2022-10-14 20:11:28 +00:00
Simon Ser 3a949ea8eb idle-notify-v1: new protocol implementation
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/29
2022-10-14 13:36:15 +00:00
Kirill Primak a049d66dd7 xdg-toplevel: send invalid_parent error 2022-10-14 10:57:49 +00:00
Alexander Orzechowski 5ba6cf517b wlr_scene: use wl_container_of() instead of casts 2022-10-13 16:36:05 +00:00
Simon Ser 650f955507 output: fix crash in output_test_with_back_buffer()
The output->impl->test check has been removed, but
output_test_with_back_buffer() hasn't been updated accordingly.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3506
Fixes: 3be6658ee7 ("output: allocate swapchain on first commit")
2022-10-10 12:08:06 +02:00
Alexander Orzechowski 99f55303aa wlr_scene: Apply source box translation 2022-10-10 08:09:55 +00:00
Alexander Orzechowski ceff381747 wlr_scene: Ignore disabled outputs 2022-10-10 08:09:55 +00:00
Alexander Orzechowski f0e31e806f wlr_scene: Fix not updating the scene node when setting a new buffer
If a new buffer is set for a buffer node, we must update the entire
node unconditionally if the buffer size changes, or the buffer is given
a buffer where it was previously NULL.

While we're here, let's avoid calling scene_node_update on just damage
updates. If the caller hasn't given us a damage region we just assume
the whole buffer.
2022-10-10 08:09:55 +00:00
Alexander Orzechowski dd9cfd3e2f wlr_scene: Be resilient against overflow conditions
If the area calculations for output overlap overflow a signed int, we
may not consider it to be a primary output. Turn this into an unsigned
type so this happens less frequently.
Additionally, it is possible the overflow would produce 0, we can handle
this by simply changing the comparison to more than or equal.

While we're here, let's assert that we always assign a primary output
if there are any intersecting outputs.
2022-10-10 08:09:55 +00:00
Simon Ser 5b0719b17c drm-lease-v1: reject the lease request by default
If the compositor didn't call wlr_drm_lease_request_v1_grant() nor
wlr_drm_lease_request_v1_reject(), then reject the lease.
2022-10-07 19:49:28 +00:00
Simon Ser 11d073ab09 drm-lease-v1: send finished event on failure in submit request
If the "submit" request handler fails, send a "finished" event
so that the client doesn't stall forever.
2022-10-07 19:49:28 +00:00
Simon Ser 5c382f6344 drm-lease-v1: fix error codepath
We were crashing in the error codepath [1] when
wlr_drm_create_lease() fails.

To fix this, delay the creation of the wlr_drm_lease_v1 until the
request is granted. Previously we were allocating that struct early
without populating the drm_lease field. However that means we ended
up with a half-constructed struct in the error codepath which is
annoying to handle.

[1]: https://github.com/swaywm/sway/issues/7204#issuecomment-1269797356
2022-10-07 19:49:28 +00:00
Simon Ser 3be6658ee7 output: allocate swapchain on first commit
On first commit, require a new buffer if the compositor called a
mode-setting function, even if the mode won't change. This makes it
so the swapchain is created now.

Stop trying to check whether the backend supports buffer-less modesets
because that makes everything more complicated. For instance, the
DRM backend doesn't need a new buffer if the previous DRM master left
the output enabled.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3499
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3502
2022-10-07 19:21:20 +00:00
Simon Ser e92b272616 output/render: make output_ensure_buffer() no-op when missing renderer
Some compositors want to have full control over the buffers attached
to the output, and don't want to use the internal swapchain. Such
compositors include KWinFT (allocates its buffers on its own) and
gamescope (uses a headless output without any buffers).

Let's just make output_ensure_buffer() a no-op in that case.
2022-10-07 19:21:20 +00:00
Simon Ser 7d8284ec10 output/render: early return in output_ensure_buffer()
Slightly simplify the logic here.
2022-10-07 19:21:20 +00:00
Kirill Primak 7eedbde878 tablet-v2: fix event parameters 2022-10-07 20:19:41 +03:00
Kirill Primak ff9c52801f output: add a swapchain NULL check in wlr_output_commit_state()
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3504
2022-10-07 15:12:53 +00:00
Kirill Primak dd0665d822 output-damage: drop precommit listener 2022-10-07 17:43:50 +03:00
Kirill Primak b9155c5b80 output-damage: fix setting pending_attach_render 2022-10-07 17:42:32 +03:00
Simon Ser 6832ae14aa render: drop wlr_renderer_read_pixels() flags
These are unused.
2022-10-04 09:15:19 +02:00
Simon Ser 50cc1ef4d3 screencopy-v1: simplify frame_dma_copy() error path
Unify success and error code-paths.
2022-10-03 17:06:38 +00:00
Simon Ser 0af4affd0b screencopy-v1: fix frame_shm_copy() error path
Don't call wlr_renderer_end() if wlr_renderer_begin_with_buffer()
failed. This will result in an abort().
2022-10-03 17:06:38 +00:00
Kirill Primak b7e2a2584e foreign-toplevel-management: fix indentation 2022-10-01 19:57:32 +00:00
Simon Ser e40d492b78 output: fix typo in error message 2022-10-01 16:52:31 +02:00
Simon Ser a0345f2854 output: add wlr_output_state.allow_artifacts
When starting up, the compositor might call wlr_output_set_mode()
with a mode which is already the current one. wlroots will detect
this and make the wlr_output_set_mode() call a no-op. During the
next wlr_output_commit() call, wlroots will perform an atomic
commit without the ALLOW_MODESET flag.

This is an issue, because some drivers need ALLOW_MODESET even if
the mode is the same. For instance, if the FB stride or modifier
changed, some drivers require a modeset.

Add a new flag "allow_artifacts" which is set when the compositor
calls mode-setting functions. Use this flag to figure out whether
we want to perform atomic commits with ALLOW_MODESET.

(The name "allow_artifacts" is picked because ALLOW_MODESET is a
misnomer, see [1].)

[1]: https://patchwork.freedesktop.org/patch/505107/

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3499
2022-09-30 10:58:17 +00:00
Simon Ser c153ae3c5d screencopy-v1: use wlr_buffer APIs
Instead of using low-level wl_shm_buffer and wlr_dmabuf_v1_buffer
APIs, use the unified wlr_buffer APIs. That way it doesn't matter
what the exact wlr_buffer implementation is used, any which provides
the necessary capabilities (data_ptr or dmabuf) would work.

Simplifies the logic a bit, and will make the transition to wlr_shm
easier.
2022-09-22 18:01:52 +00:00
Simon Ser f03da48491 screencopy-v1: rename wlr_screencopy_frame_v1.stride
Make it clear it's only about shm, not about DMA-BUFs.
2022-09-22 18:01:52 +00:00
Simon Ser 77b829e15f screencopy-v1: use DRM format code for shm buffers
Will allow us to simplify common shm/DMA-BUF logic later on.
2022-09-22 18:01:52 +00:00
Simon Ser 4885c08f38 screencopy-v1: rename wlr_screencopy_frame_v1.{format,fourcc}
Make it clear that one is for shm buffers only, and the other is
for DMA-BUF buffers only.
2022-09-22 18:01:52 +00:00
John Lindgren 68c8cef38e cursor: Don't warp to (0,0) when last output is disconnected
There doesn't appear to be any good reason to warp the cursor to
the top-left corner when all outputs are disconnected; it's no more
valid than any other (x,y) point in that case.

The real-world case here is a user with a single external monitor
turning it off (which apparently counts as disconnected depending
on the connection type/hardware).  For that user, it's desirable to
have the cursor remain in its original location when the monitor
is turned back on.
2022-09-21 14:25:09 -04:00
John Lindgren 5417a182e5 cursor: Add a more general check for infinite/NaN cursor position
It should be considered a bug if a compositor sets a non-finite
cursor position, so fail loudly (in debug builds) if that happens.

The existing check in wlr_cursor_warp_closest() is now redundant,
and would silently hide such bugs, so remove it.
2022-09-21 14:25:09 -04:00
Simon Ser 8e8b9a7217 output: fix back buffer checks
The back buffer is no longer set at commit time since 0556aa0c59
("output: rejigger attach/clear for back buffer").

Instead, check whether the buffer belongs to the output swapchain.
This is more robust.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3496
2022-09-21 16:18:16 +02:00
Simon Ser 0556aa0c59 output: rejigger attach/clear for back buffer
In wlr_output_attach_render(), stop setting
wlr_output.pending.buffer. This removes one footgun: using the
wlr_buffer at that stage is invalid, because rendering operations
haven't been flushed to the GPU yet. We need to wait until
output_clear_back_buffer() for the wlr_buffer to be used safely.

Instead, set wlr_output.pending.buffer in wlr_output_test() and
wlr_output_commit().

Additionally, move the output_clear_back_buffer() from
wlr_output_commit_state() to wlr_output_commit(). This reduces the
number of calls in the failure path.
2022-09-19 10:46:26 +00:00