Commit Graph

1562 Commits

Author SHA1 Message Date
Simon Ser 3415e3718f tablet-v2: fix pad and tool object versions
These were hardcoded to 1. Instead, create the resource with the
version of the parent object.

(cherry picked from commit ea585dba0f)
2021-07-07 19:24:47 +02:00
Simon Ser 6d742464bb output-damage: fix output swapchain handling
When wlr_output.swapchain is used instead of the backend's, the
buffer_type will be set to SCANOUT even if wlr_output_attach_render
has been called. This tricks wlr_output_damage into thinking the
whole output needs to be repainted.

Workaround this issue by forcing buffer_type to RENDER when the
output has a back-buffer set.

Will clean all of that up when removing the precommit event handler
altogether.

This commit fixes damage tracking on the Wayland, X11 and headless
backends.

(cherry picked from commit a48e569d38)
2021-07-07 19:24:47 +02:00
Simon Ser 2a6dc0059f output: detach buffer from renderer before commit
Right now we rely entirely on implicit sync for synchronizing
access to GPU buffers. Implicit sync works by setting
synchronization points on the buffer in writers, and letting
readers wait on these sync points before accessing the buffer.

With OpenGL, sync points are created using functions such as
eglSwapBuffers or glFlush. If none of these special functions
are called, no sync point will be created and readers will
potentially access a buffer that hasn't finished rendering yet.

In the context of wlroots, OpenGL is the writer and the backend
(KMS or parent Wayland/X11 session) is the reader. After we're
done rendering a frame, and before passing that frame to the
backend, we need to call glFlush.

glFlush is called when the buffer is detached from the renderer.
This is a task done by output_clear_back_buffer. So let's call
this function before invoking the impl->commit hook, instead of
calling it after.

All of this is maybe a little tricky to get right with the
current renderer_bind_buffer API. The new
wlr_renderer_begin_with_buffer API is much better, because glFlush
is called on wlr_renderer_end, so it's more intuitive.

Closes: https://github.com/swaywm/wlroots/issues/3020
(cherry picked from commit c2bd63c186)
2021-07-07 19:24:47 +02:00
Simon Ser 75f476c01e surface: allow locking pending state in commit handler
We were bumping the pending sequence number after emitting the
commit event, so commit handlers were seeing inconsistent state
where current.seq == pending.seq. This prevents commit handlers
from immediately locking the pending state.

Fix this by bumping the pending sequence number before firing the
commit event.

(cherry picked from commit c7018a45b7)
2021-07-07 19:24:47 +02:00
Simon Ser 4b2ef3dff9 surface: accept commits with buffer size not divisible by scale
There are still many situations where the buffer scale is not
divisible by scale. The fix will require a tad more work, so
let's just log the client error for now and continue handling
the surface commit as usual.

Closes: https://github.com/swaywm/sway/issues/6352
(cherry picked from commit 1c4b5bcab3)
2021-07-07 19:22:57 +02:00
Simon Ser 103edde481 xdg-activation-v1: fix wlr_xdg_activation_v1_create error path 2021-06-17 14:48:28 +02:00
Simon Ser 6259fd23fb output: reset back buffer on failed commit
On commit failure, we need to unbind the back buffer from the
renderer.

This fixes assertions triggered on commits following a failed commit
where the compositor called wlr_output_attach_render.
2021-06-13 13:17:30 +02:00
Simon Ser b2f6db3533 render: drop wlr_ prefix from wlr_renderer_bind_buffer
Make it clear this function is a private wlroots API and will stay
that way.
2021-06-09 10:26:09 +02:00
Simon Ser fbadadf36f output: use wlr_renderer_begin_with_buffer for cursor 2021-06-09 10:26:09 +02:00
Simon Ser a667175ec7 screencopy-v1: use wlr_renderer_begin_with_buffer 2021-06-09 10:26:09 +02:00
Simon Ser 1a06ea7750 output: make attach_render and rollback_render optional
If these aren't provided by the backend, allocate a swapchain for the
output.
2021-06-07 15:42:38 +02:00
Simon Ser 233a2617cf output: split output_pick_cursor_format
Introduce output_pick_format that can be re-used for the primary
buffer too.
2021-06-07 15:42:38 +02:00
Simon Ser 534615cd55 buffer: use wlr_texture_from_buffer for wl_shm_buffer 2021-06-07 09:22:56 -04:00
Simon Ser 7c26345826 buffer: introduce wlr_shm_client_buffer
Introduce wlr_shm_client_buffer, which provides a wlr_buffer wrapper
around wl_shm_buffer.

Because the client can destroy the wl_buffer while we still are using
it, we need to do some libwayland tricks to still be able to continue
accessing its underlying storage. We need to reference the wl_shm_pool
and save the data pointer.
2021-06-07 09:22:56 -04:00
Simon Ser 38ba5881a0 buffer: replace get_data_ptr with {begin,end}_data_ptr_access
This new API allows buffer implementations to know when a user is
actively accessing the buffer's underlying storage. This is
important for the upcoming client-backed wlr_buffer implementation.
2021-06-07 09:22:56 -04:00
Simon Ser 9e58301df7 surface: allow placing subsurfaces below parent
Prior to this commit, subsurfaces could only be placed above their
parent. Any place_{above,below} request involving the parent would
fail with a protocol error.

However the Wayland protocol allows using the parent surface in the
place_{above,below} requests, and allows subsurfaces to be placed
below their parent.

Weston's implementation adds a dummy wl_list node in the subsurface
list. However this is potentially dangerous: iterating the list
requires making sure the dummy wl_list node is checked for, otherwise
memory corruption will happen.

Instead, split the list in two: one for subsurfaces above the parent,
the other for subsurfaces below.

Tested with wleird's subsurfaces demo client.

Closes: https://github.com/swaywm/wlroots/issues/1865
2021-06-03 14:04:07 +02:00
zccrs 11040d4942 Make the xdg_popup_get_position to public
Rename the xdg_popup_get_position to
wlr_xdg_popup_get_position
2021-06-03 09:50:54 +02:00
Simon Ser 76f51a949f xdg-activation-v1: add token timeout
There isn't always a good time to prune old tokens. Compositors
which only implement a "give focus on activation" logic can prune
tokens on focus change. However other compositors might want to
implement other semantics, e.g. "mark urgent on activation". In this
case a focus change shouldn't invalidate other tokens.

Additionally, some tokens aren't necessarily tied to a seat.

To avoid ending up with an ever-growing list of tokens, add a timeout.
2021-06-02 11:18:25 +02:00
Simon Ser 8ff435831f xdg-activation-v1: new protocol implementation
This implements the new xdg-activation-v1 protocol [1].

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/50
2021-06-02 11:18:25 +02:00
Simon Ser 2b0a1aeed5 output: take a wlr_buffer in set_cursor
Instead of passing a wlr_texture to the backend, directly pass a
wlr_buffer. Use get_cursor_size and get_cursor_formats to create
a wlr_buffer that can be used as a cursor.

We don't want to pass a wlr_texture because we want to remove as
many rendering bits from the backend as possible.
2021-06-02 11:08:52 +02:00
Simon Ser a8d7c2d4ea screencopy-v1: stop using wlr_client_buffer
We can just use the wlr_dmabuf_v1_buffer directly, no need to wrap
it in a wlr_client_buffer.
2021-05-17 16:22:43 +02:00
Simon Ser 68758e8c21 buffer: use wlr_texture_from_buffer for DMA-BUFs 2021-05-17 16:22:43 +02:00
Simon Ser 6f39574ff5 linux-dmabuf-v1: implement wlr_buffer
This allows the DMA-BUF wl_buffer objects to be used directly as
wlr_buffers, without having to use wlr_client_buffer_import.
2021-05-17 16:22:43 +02:00
Yuya Nishihara 8008d21f5b virtual_keyboard: Emulate key release events on destroy
According to libinput, release events are generated when device is unplugged,
and libinput copies this behavior for device removal. Let's do the same for
our virtual keyboard.

8f846a41fa

This is another attempt to fix #2034 and the following sway issue:

https://github.com/swaywm/sway/issues/6254

Note that we have other key repeating issues in sway, which aren't addressed
by this patch. Since the virtual keyboard itself isn't destroyed when the
keyboard grab is destroyed, we'll probably need some trick to reset the state
of the corresponding virtual keyboard when the grab is released.

https://github.com/swaywm/sway/issues/6095
https://github.com/swaywm/sway/issues/6193
2021-05-07 11:18:19 +02:00
Simon Ser 24fde77c62 buffer: add format param to get_data_ptr
Allow wlr_buffer_impl.get_data_ptr to return a format.

This allows the Pixman renderer to not care about get_dmabuf/get_shm,
and only care about get_data_ptr. This will also help with [1], because
client wl_shm buffers can't implement get_shm.

[1]: https://github.com/swaywm/wlroots/pull/2892

References: https://github.com/swaywm/wlroots/issues/2864
2021-04-27 20:36:03 +02:00
Simon Zeni ccbce0f0a6 types/wlr_screencopy_v1: log error on read pixels failure 2021-04-27 18:28:41 +02:00
Simon Ser 6622cd3277 output: correctly handle outputs without a test() impl
This fixes a crash when calling wlr_output_test() on a headless
output.

Closes: https://github.com/swaywm/sway/issues/6213
2021-04-21 08:52:50 +02:00
Simon Ser e8df7c367a linux-dmabuf-v1: split params and buffer
Previously, the same struct was used for linux-dmabuf-v1 params
and buffer. This made the whole logic a little bit awkward, because
a wlr_dmabuf_v1_buffer could either be still being constructed, or
be a complete buffer.

Introduce a separate wlr_linux_buffer_params_v1 struct for buffer
params still being constructed. Once the params are complete (ie.
once the create request is sent), the params struct is destroyed
and the buffer struct is created.

This will help with [1] as well.

[1]: https://github.com/swaywm/wlroots/issues/2664
2021-04-19 18:09:13 +02:00
Simon Ser f64ed60c7b linux-dmabuf-v1: drop some from_resource helpers
Drop wlr_dmabuf_v1_buffer_from_params_resource and
wlr_linux_dmabuf_v1_from_resource. Contrary to wl_buffer, these
resources are internal linux-dmabuf-v1 implementation details and
should not be shared with other interfaces.
2021-04-19 18:09:13 +02:00
Simon Ser 6c61de996c buffer: introduce wlr_buffer_get_shm
References: https://github.com/swaywm/wlroots/issues/2399#issuecomment-769408708
2021-04-17 09:54:39 +02:00
Simon Zeni 0b9288ec0b buffer: introduce wlr_buffer_get_data_ptr
The function has been place in an internal header for API stability
reasons.
2021-04-17 09:54:39 +02:00
Ryan Farley b29ac8fbac util/uuid: replace with util/token, remove libuuid
Use 128-bit hexadecimal string tokens generated with /dev/urandom
instead of UUIDs for xdg-foreign handles, removing the libuuid
dependency. Update readme and CI. Closes #2830.

build: remove xdg-foreign feature

With no external dependencies required, there's no reason not to always
build it. Remove WLR_HAS_XDG_FOREIGN as well.
2021-04-11 19:09:36 +02:00
Isaac Freund 78befa59f9 gtk-primary-selection: drop support
The standard primary-selection protocol is now widely supported.
2021-04-08 09:50:18 +02:00
Simon Ser a9e5df44d8 surface: remove resource_list arg from surface_create
This is never used.
2021-04-06 14:57:44 +02:00
Simon Ser c430cd7d53 surface: make wlr_surface_create private
This is not meant to be exposed in the public API, just like
wlr_region_create [1].

[1]: https://github.com/swaywm/wlroots/pull/2662
2021-04-06 14:57:44 +02:00
Kenny Levinsen 741da702bc xdg_shell: Fix invert_y of top right anchor 2021-03-26 23:20:09 +01:00
Simon Ser 80dbb9ba71 subsurface: immediately unlock cached state in set_desync
set_desync takes effect immediately without waiting for the next
wl_surface.commit request.
2021-03-25 19:34:47 +01:00
Simon Ser 8ecc557ab0 subsurface: use cached surface state 2021-03-25 19:34:47 +01:00
Simon Ser e0258f4506 surface: introduce cached states
Cached states allow a surface commit to be delayed. They are useful for:

- Subsurfaces
- The upcoming transactions protocol [1]
- Explicit synchronization

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/26
2021-03-25 19:34:47 +01:00
Simon Ser 7ac76aba8a surface: introduce commit sequence numbers
Very similar to output commit sequence numbers. Can be useful to
reference a specific commit.
2021-03-25 19:34:47 +01:00
Simon Zeni 50d2985607 Move render/shm_format functions to render/pixel_format 2021-03-25 10:55:54 +01:00
Simon Ser d9cae04ffc linux-dmabuf-v1: always advertise support for implicit modifiers
Some clients (like Xwayland) will fallback to wl_drm if the compositor
doesn't explicitly advertise support for implicit modifiers, even when
the compositor supports explicit modifiers. This behavior sounds correct
from a protocol point of view.
2021-03-23 23:32:44 +01:00
Simon Ser c740fccc9d Fix buffer blit matrices
There was a missing wlr_matrix_scale call, so we ended up with black
frames.

Closes: https://github.com/swaywm/wlroots/issues/2780
2021-03-16 17:57:51 +01:00
Simon Ser 7720dde74d screencopy: stop using wlr_renderer_blit_dmabuf
The original motivation is the following crash:

    #0  0x00007f0ddeddeef5 in raise () at /usr/lib/libc.so.6
    #1  0x00007f0ddedc8862 in abort () at /usr/lib/libc.so.6
    #2  0x00007f0ddedc8747 in _nl_load_domain.cold () at /usr/lib/libc.so.6
    #3  0x00007f0ddedd7646 in  () at /usr/lib/libc.so.6
    #4  0x00007f0de033f8de in gles2_get_renderer_in_context (wlr_renderer=0x612000003640) at ../subprojects/wlroots/render/gles2/renderer.c:38
    #5  0x00007f0de0341675 in gles2_begin (wlr_renderer=0x612000003640, width=3840, height=2160) at ../subprojects/wlroots/render/gles2/renderer.c:186
    #6  0x00007f0de033b100 in wlr_renderer_begin (r=0x612000003640, width=3840, height=2160) at ../subprojects/wlroots/render/wlr_renderer.c:56
    #7  0x00007f0de03466ed in gles2_blit_dmabuf (wlr_renderer=0x612000003640, dst_attr=0x60b000150148, src_attr=0x7fff9f9bfde0) at ../subprojects/wlroots/render/gles2/renderer.c:591
    #8  0x00007f0de033d717 in wlr_renderer_blit_dmabuf (r=0x612000003640, dst=0x60b000150148, src=0x7fff9f9bfde0) at ../subprojects/wlroots/render/wlr_renderer.c:210
    #9  0x00007f0de04cbc3b in frame_handle_output_commit (listener=0x611000220bc8, data=0x7fff9f9c0050) at ../subprojects/wlroots/types/wlr_screencopy_v1.c:303

The GLES2 renderer assumes it'll have a wlr_buffer to render to.

Instead of accomodating for the edge-case of rendering without a
wlr_buffer, drop wlr_renderer_blit_dmabuf calls and instead use
wlr_renderer_bind_buffer just like the rest of the wlr_renderer users.
wlr_renderer_blit_dmabuf is now unused in wlroots.

The upside is that the new blit_dmabuf function in screencopy is
renderer-agnostic.
2021-03-16 17:57:51 +01:00
Simon Ser 44fa2c4b49 output: fix transform matrix for 90/270 rotations
We need to adjust the second translation depending on the transform
we applied.

Fixes: 9601a2abf0 ("output: improve transform matrix calculation"
Closes: https://github.com/swaywm/wlroots/issues/2774
2021-03-11 22:52:38 +01:00
Simon Zeni 9601a2abf0 output: improve transform matrix calculation
Compute only the transform matrix in the output. The projection matrix
will be calculated inside the gles2 renderer when we start rendering.

The goal is to help the pixman rendering process.
2021-03-10 15:33:36 +01:00
Kenny Levinsen 46d2f80c38 wlr_seat_pointer: Remove log on notify_button 2021-03-07 11:01:38 +01:00
Simon Ser 675bc39658 Fix wl_shm_format passed to wlr_texture_from_pixels
Fixes: 27fba3df43 ("render: use DRM formats in wlr_texture_from_pixels")
2021-02-23 17:36:32 +01:00
Simon Ser c2815fd44d buffer: add missing convert_wl_shm_format_to_drm call
Fixes: 27fba3df43 ("render: use DRM formats in wlr_texture_from_pixels")
Closes: https://github.com/swaywm/wlroots/issues/2757
2021-02-23 17:33:08 +01:00
Simon Ser b54ef3372d render: use DRM formats in wlr_renderer_read_pixels 2021-02-23 16:09:26 +01:00