Commit Graph

2201 Commits

Author SHA1 Message Date
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
Simon Ser 0213da60bb output: drop back_buffer variable in wlr_output_commit_state()
We can just use pending.buffer instead. It's completely fine to
call wlr_swapchain_set_buffer_submitted() with a buffer which
doesn't come from the swapchain, in which case it's a no-op.
2022-09-19 10:46:26 +00:00
Simon Ser 679d5ba699 output: inline output_attach_render()
No need to have a separate function for this. It's only used once.
2022-09-19 10:46:26 +00:00
Simon Ser 2ad25b1460 output: fix wlr_output_set_gamma() with zero size
This is documented to reset the gamma LUT, but we don't handle this
properly.

While at it, make sure we leave wlr_output.pending in a good state
on allocation failure.
2022-09-18 15:20:39 +02:00
Kirill Primak ebd4c83cd6 xdg-toplevel: validate resize_edge 2022-09-17 08:20:24 +00:00
Simon Ser 69c47717c2 buffer: split into multiple files
wlr_buffer.c is difficult to read because it contains a mixed bag
of unrelated things: base buffer type, buffer implementations,
buffer resource factory, and client buffer.

Split each of these into their own file.
2022-09-16 18:32:22 +02:00
John Lindgren 1facdeabe5 wlr_drm_lease_v1: Fix use-after-free in backend_destroy()
valgrind said (on exit from labwc):

    Invalid write of size 8
       at 0x487DEAF: wl_list_remove (wayland-util.c:56)
       by 0x487DF80: wl_signal_emit_mutable (wayland-server.c:2182)
       by 0x48CD6B7: backend_destroy.part.0.lto_priv.0 (backend.c:41)
       by 0x48DC19D: multi_backend_destroy (backend.c:58)
       by 0x4880286: UnknownInlinedFun (wayland-server.c:2315)
       by 0x4880286: wl_display_destroy (wayland-server.c:1170)
       by 0x112491: UnknownInlinedFun (server.c:485)
       by 0x112491: main (main.c:110)
     Address 0x1f9d0210 is 112 bytes inside a block of size 136 free'd
       at 0x484426F: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x487DF6D: wl_signal_emit_mutable (wayland-server.c:2179)
       by 0x48CD6B7: backend_destroy.part.0.lto_priv.0 (backend.c:41)
       by 0x48DC19D: multi_backend_destroy (backend.c:58)
       by 0x4880286: UnknownInlinedFun (wayland-server.c:2315)
       by 0x4880286: wl_display_destroy (wayland-server.c:1170)
       by 0x112491: UnknownInlinedFun (server.c:485)
       by 0x112491: main (main.c:110)
     Block was alloc'd at
       at 0x4846A73: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x4918D4E: drm_lease_device_v1_create (wlr_drm_lease_v1.c:639)
       by 0x48D3B00: wlr_multi_for_each_backend (backend.c:249)
       by 0x49191D2: wlr_drm_lease_v1_manager_create (wlr_drm_lease_v1.c:706)
       by 0x111EE9: UnknownInlinedFun (server.c:384)
       by 0x111EE9: main (main.c:92)
2022-09-15 21:24:05 -04:00
Simon Ser 7d9c595f19 output/cursor: downgrade error messages
When the output doesn't support hardware cursors, these errors
will be printed. However, these errors are expected and we have a
proper fallback.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3457
2022-09-15 09:33:30 +02:00
Simon Ser b5a474189e output/render: log human-readable format 2022-09-14 12:13:17 +02:00
Kirill Primak 42ae1e75aa subcompositor: consider mapping after adding
ec8b49c93f calls subsurface_consider_map()
too early. Instead, call it after emitting new_subsurface signal to let
compositors receive a map event.
2022-09-12 18:44:36 +00:00
Kirill Primak 3abedaf211 subcompositor: move+rename subsurface_parent_commit() 2022-09-12 18:44:36 +00:00
Kirill Primak 4cc3abb966 xdg-foreign-v2: s/unmap/destroy
Same as the previous commit.
2022-09-11 09:20:08 +03:00
Kirill Primak ba7bbab3ab xdg-foreign-v1: s/unmap/destroy
dac040f87f mistakenly renamed
xdg_surface_destroy listener, which was listening to *unmap* events, to
xdg_surface_unmap. The actual fix, however, is to listen to destroy
events. This fixes various crashes.
2022-09-11 09:20:08 +03:00
Simon Ser d8ef9a95de xdg-foreign-v2: return wlr_xdg_toplevel in verify_is_toplevel()
This makes it clearer that the wlr_xdg_toplevel cannot be NULL.
2022-09-11 09:20:08 +03:00
Simon Ser 053bb42a6d xdg-foreign-v1: return wlr_xdg_toplevel in verify_is_toplevel()
This makes it clearer that the wlr_xdg_toplevel cannot be NULL.
2022-09-11 09:20:08 +03:00
Consolatis 0cff058f38 wlr_virtual_pointer_v1: fix discrete scrolling
It seems it was forgotten to adjust when implementing
	!3461 High-resolution scroll wheel support
2022-09-08 05:33:28 +02:00
Alexander Orzechowski 2e06ff5688 wlr_scene: Clarify surface commit frame events 2022-09-05 08:24:50 +00:00
Alexander Orzechowski 35d94d779c wlr_scene: Consider screen position when culling background 2022-09-03 18:42:17 -04:00
Kirill Primak 26e1812ab3 output-layout: improve wlr_output_layout_output_in_direction()
Now the function checks if the reference output belongs to the layout,
and returns NULL if it doesn't.
2022-08-30 19:26:23 +03:00
Kirill Primak 2ea80eb115 output-layout: avoid uninitialized wlr_box fields 2022-08-30 19:26:23 +03:00
Kirill Primak 4462f5dcb3 cursor: avoid uninitialized wlr_box fields 2022-08-30 19:26:20 +03:00
Alexander Orzechowski 138d21464d wlr_compositor: Don't leak region32 when calculating opaque region 2022-08-30 03:03:21 -04:00
Alexander Orzechowski 78cf39b6bd wlr_scene: Don't leak a region32 when texture failed to upload 2022-08-29 16:19:30 +00:00
Alexander Orzechowski fe9e193ab5 wlr_scene: More sanity checking
The render list should neither contain scene trees or null buffers.
2022-08-29 16:19:30 +00:00
Kirill Primak 7333a4602a util/set: overhaul 2022-08-29 13:48:42 +00:00
Kirill Primak 20c208d46a util/array: unclutter 2022-08-29 13:48:42 +00:00
Isaac Freund d94d1bf0ea
output: clean up after modifierless test failure
If the first test in output_ensure_buffer() fails with modifiers we
replace the swapchain with a modifierless swapchain and try again.
However if that fails as well the output is currently stuck without
modifiers until the next modeset.

To fix this, destroy the modifierless swapchain if the test using it
fails. The next output_attach_back_buffer() call will create a swapchain
that allows modifiers when needed.
2022-08-28 16:04:22 +02:00
Alexander Orzechowski fa7d2cb8d6 wlr_scene: Only consider visible parts of the node when culling background
Originally, I thought that we could safely subtract opaque regions
from the background even if the black rect optimization was kicking in.
This is wrong because a scene node that isn't fully occluded will still
appear in the render list even if its partially under a black rect. We
need to make sure that while culling the background, we only consider
opaque regions that are also visible. This will fix the black rect
optimization with the background.
2022-08-26 19:07:52 -04:00
yiqiang 6a11256cd0 scene/wlr_scene:fix judgment of invisible node 2022-08-26 22:19:22 +00:00
Alexander Orzechowski 525506559a wlr_compositor: Use wlr_fbox_equal 2022-08-25 19:00:13 -04:00
Isaac Freund d452a729cb
wlr-output-management: fix broken asserts
These asserts were broken in 4c1afb12 as new implementations were added
without updating the wl_resource_instance_of() calls.
2022-08-25 00:51:32 +02:00
Isaac Freund 4c1afb126b wlr-output-management: Implement version 3 release requests
Head/mode resources older than version 3 and lacking a release request
are intentionally leaked as this is the only way to fix the race.

Implements: https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/merge_requests/114
2022-08-24 14:10:23 +00:00
Alexander Orzechowski d3cb6b73a2 wlr_scene: Initialize region32 before trying to use it 2022-08-22 14:46:41 -04:00
Alexander Orzechowski 8bd7170fd9 Use env helpers 2022-08-22 10:18:52 -04:00
Alexander Orzechowski e7477c7114 wlr_scene: Improve awkward code style 2022-08-22 10:18:00 -04:00
Alexander Orzechowski 9bba4284e4 wlr_scene: Cull background
We don't need to worry about the black rect optimization here (that
always assumes that there will be a black background) because the
background is culled based on the render list. That means if a black rect
is removed, the visibility will reach all the way to the bottom forcing
the renderer to clear the area not breaking the assumption.
2022-08-22 10:17:59 -04:00
Alexander Orzechowski 6d1b8b376d wlr_scene: Only enable black rect optimization if culling is enabled
If culling is not enabled, there is no longer any guarantee that the
elements behind the rect won't be rendered. We must render the black rect
in all circumstances to cover up anything rendered.

This fixes the WLR_SCENE_DISABLE_VISIBILTY option.
2022-08-19 16:18:46 -04:00
Alexander Orzechowski 4d4f823263 wlr_scene: Simplify calculate_visibilty option 2022-08-19 16:18:11 -04:00
Kenny Levinsen 7c575922c0 wlr_scene: Convert render_list to wl_array
This simplifies some of the growth logic, but uses array_realloc to shrink the
array if needed.
2022-08-19 19:38:33 +02:00
Mark Bolhuis 9ab819684d types/wlr_xdg_output_v1: Fix wl_output.done bug.
If the client binds to version 3 of zxdg_output_v1 and version 1 of
wl_output no wl_output.done or zxdg_output_v1.done event is
emitted [1].

Also no wl_output.done event is emitted when version 2 or lower of
zxdg_output_v1 is bound to.

Add a version check to output_manager_handle_get_xdg_output so that no
wl_output.done event is emitted when using version 1 of wl_output and
version 2 or lower of zxdg_output_v1.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/81
2022-08-19 14:22:23 +00:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
yiqiang 3621c14b82 wlr_scene: fix color value when filtering black boxes
Signed-off-by: yiqiang <yiqiang@kylinos.cn>
2022-08-16 10:52:03 +08:00
Alexander Orzechowski bea4bd43e3 wlr_scene: Use wlr_box_equal 2022-08-15 07:37:09 -04:00
Alexander Orzechowski bcf7a79357 wlr_scene: Use wlr_fbox_equals 2022-08-15 06:14:59 -04:00
Alexander Orzechowski 919e67da7d wlr_scene: Account for occlusion by other scene nodes when calculating visibility 2022-08-14 02:38:51 -04:00
Alexander Orzechowski ce57485e6a wlr_scene: Calculate output intersections based on node visibility
This has a few benefits one of them crucial for proper operation:
 - The primary output will be based on the largest area that is actually
 visible to the user. Presentation and frame done events are based on
 this state. This is important to do since we cull frame done events.
 If we happen to be in a situation where a surface sits mostly on output
 A and some on output B but is completely obstructed by for instance a
 fullscreen surface on output A we will erroneously send frame_done
 events based on output A. If we base things as they are in reality
 (visibility) the primary output will instead be output B and things will
 work properly.
 - The primary output will be NULL if the surface is completely hidden.
 Due to quirks with wayland, on a surface commit, frame done events are
 required to be sent. Therefore, a new frame will be submitted for rendering
 on the primary output. We can improve adaptive sync on completely hidden
 but enabled surfaces if we null out the primary output in this state.
 - The client will be more likely to choose better metadata to use
 for rendering to an output's optimal rendering characteristics.
2022-08-14 02:38:51 -04:00
Alexander Orzechowski 342830e99c wlr_scene/surface: Hook through opaque metadata 2022-08-14 02:38:50 -04:00
Alexander Orzechowski 18417026be wlr_scene: Introduce buffer opaque region metadata 2022-08-14 02:38:50 -04:00
Alexander Orzechowski 0a9a941ba3 wlr_scene: Rewrite direct scan out logic to rely on visibility
Also make the regular rendering logic use the introduced
render list.
2022-08-14 02:38:50 -04:00
Alexander Orzechowski 14f4cfffba wlr_scene: Don't render non visible parts of textures/rects
We can also get rid of the intersection checks in the rendering functions
because we are guaranteed to already be in the node do to the prior
intersection checking of the node visibility.
2022-08-14 02:38:50 -04:00
Alexander Orzechowski d16d341381 wlr_scene: Only send frame done events for visible buffers 2022-08-14 02:38:50 -04:00
Alexander Orzechowski 6d62300324 wlr_scene_set_buffer_with_damage: Only damage the visible parts of the node 2022-08-14 02:38:50 -04:00
Alexander Orzechowski c6246272fd wlr_scene: Rework damage handling
Simplify damage handling by using our cached visibility state.
Damaging can happen in one step because since we can use the old visibility
state which represent what portions of the screen the scene node was. This
way we can damage everything in one step after the fact.
2022-08-14 02:38:50 -04:00
Alexander Orzechowski 028606512d wlr_scene: Add per scene node visibility 2022-08-14 01:39:20 -04:00
Alexander Orzechowski f411ca040e wlr_scene: Damage scene on node destroy by disabling node
This removes one trivial call of scene_node_damage_whole. It's easier
to disable the node later than it is to do the damage dance later.
2022-08-14 01:39:20 -04:00
Alexander Orzechowski 7f17774d18 wlr_scene: Introduce scene_nodes_in_box
Will query the scene for all nodes that appear in the given wlr_box.
The nodes will be sent to the iterator from closest to farthest from the
eye.

Refactor wlr_scene_node_at to use this new function.
2022-08-14 01:39:20 -04:00
Simon Ser c2359d0321 surface: implement wl_surface.offset
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/123
2022-08-12 11:27:33 +02:00
Simon Ser 42d68d7532 surface: add WLR_SURFACE_STATE_OFFSET
This indicates whether the surface offset has changed.
2022-08-12 11:20:44 +02:00
Simon Ser 98cf38601f render: replace wlr_texture_write_pixels with update_from_buffer
This lets the renderer handle the wlr_buffer directly, just like it
does in texture_from_buffer. This also allows the renderer to batch
the rectangle updates, and update more than the damage region if
desirable (e.g. too many rects), so can be more efficient.
2022-08-12 08:41:32 +00:00
Alexander Orzechowski f72aeacd6e wlr_scene: Add option to disable direct scanout
Closes: #3405
Supersedes: !3562

Co-authored-by: Xiao YaoBing <xiaoyaobing@qq.com>
2022-08-08 00:40:21 -04:00
Kenny Levinsen 3baf2a6bcf scene/layer_shell: Ignore unmapped exclusion zone
Only the exclusion zone for mapped layer shell surfaces should be respected. In
particular, a layer shell surface that was mapped with an exclusion zone but is
now unmapped should not adjust the usable area.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3471
2022-08-06 00:23:44 +02:00
Kenny Levinsen 7abe8352db xdg_shell: Destroy popups after unmap event
This aligns with wlr_layer_shell_v1, and better matches how we normally use
teardown signals.
2022-08-06 00:20:42 +02:00
Kenny Levinsen 668b2740ff Set mapped before firing map/unmap events
This allows whatever the user calls from the signal handlers to react to observe
the new state rather than the old, e.g. that a surface is no longer mapped in
the unmap handler.
2022-08-06 00:19:38 +02:00
Simon Ser b24b50ec0c single-pixel-buffer-v1: new protocol implementation
This implements the single-pixel-buffer-v1 protocol [1], to allow clients
to create 1x1 buffers with a single color.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/104
2022-08-03 10:35:23 +00:00
Simon Ser f1e05a6493 xdg-shell: add support for v5
This version adds a wm_capabilities event.
2022-08-01 18:50:16 +02:00
Quantum 30bf8a4303 seat/pointer: fix uninitialized variable warning
This results in the following warning, which in release mode causes an
error due to -Werror:

../types/seat/wlr_seat_pointer.c: In function ‘wlr_seat_pointer_send_axis’:
../types/seat/wlr_seat_pointer.c:344:25: error: ‘low_res_value_discrete’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  343 |   if (version < WL_POINTER_AXIS_VALUE120_SINCE_VERSION &&
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  344 |     value_discrete != 0 && low_res_value_discrete == 0) {
      |     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
2022-07-28 02:25:31 -04:00
Kirill Primak 7298c42139 seat/pointer: rework sending axis events
This commit fixes:
- sending discrete scrolling events to multiple pointer resources
- sending events to clients which don't support wl_pointer.axis_discrete
2022-07-27 14:26:56 +00:00
José Expósito add44b3e2e seat: support low-resolution clients
When the client doesn't support high-resolution scroll, accumulate
deltas until we can notify a discrete event.

Some mice have a free spinning wheel, making possible to lock the wheel
when the accumulator value is not 0. To avoid synchronization issues
between the mouse wheel and the accumulators, store the last delta and
when the scroll direction changes, reset the accumulator.
2022-07-11 11:01:35 +02:00