Commit Graph

2207 Commits

Author SHA1 Message Date
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