Commit Graph

416 Commits

Author SHA1 Message Date
Simon Ser 756ecf8ee9 backend/wayland: use request_state when toplevel is resized 2022-11-15 15:39:55 +00:00
Simon Ser feb5691240 backend: remove const casts for pixman_region32_t
Pixman 0.42.0 has constified APIs for pixman_region32_t. We no longer
need the casts.
2022-11-11 23:11:17 +00:00
Simon Ser a28caf08e3 backend: use global output name counters
The output names must be globally unique per the Wayland spec, even
if the compositor creates multiple backends of the same kind.
2022-10-13 13:12:43 +02:00
Simon Ser 4cc5bdc4d1 backend/wayland: drop output_set_custom_mode()
It's an unnecessary wrapper.
2022-09-08 14:18:40 +02:00
Isaac Freund 2ec27d23e0 backend/wayland: report adaptive sync as enabled
Adaptive sync is effectively always enabled when using the Wayland
backend. This is not something we have control over, so we set the
state to enabled on creating the output and never allow changing it.
2022-08-30 17:53:50 +00:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Simon Ser 8c3c6987db backend/wayland: fix touch device not added on startup
We were firing the new_input signal on backend initialization,
before the compositor had the chance to add a listener for it.

Mimick what's done for wl_keyboard: if the backend hasn't been
started, delay wl_touch initialization.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3473
2022-08-11 09:13:08 +02:00
José Expósito 11f49b6b6a backend/wayland: handle high-res scroll events
Receive high-resolution scroll events from the parent compositor using
a Wayland listiner and emit the appropiate wlr_pointer signal.
2022-07-11 11:01:35 +02:00
José Expósito 65c436407f pointer: transform low-res to high-res axis events
Currently, the "wlr_event_pointer_axis" event stores low-resolution
values in its "delta_discrete" field. Low-resolution values are always
multiples of one, i.e., 1 for one wheel detent, 2 for two wheel
detents, etc.

In order to simplify internal handling of events, always transform in
the backend from the low-resolution value into the high-resolution
value.

The transformation is performed by multiplying by 120. The 120 magic
number is used by the kernel and it is exposed to clients in the
"WLR_POINTER_AXIS_DISCRETE_STEP" constant.
2022-07-11 11:01:35 +02:00
Isaac Freund 91943a68a6 wlr_input_device: remove anon union field
This union is unnecessary since the recent input device refactor and can
now be replaced by wlr_*_from_input_device() functions.
2022-06-21 18:42:07 +00:00
Simon Ser 25dd3cc0cd output: pass wlr_output_state to backend
Groundwork for the following commits. The goal is to allow users
to specify their own wlr_output_state instead of wlr_output.pending.
2022-05-30 11:34:57 +02:00
Simon Ser be86145322 output: turn make/model/serial into char *
This allows the make/model/serial to be NULL when unset, and allows
them to be longer than the hardcoded array length.

This is a breaking change: compositors need to handle the new NULL
case, and we stop setting make/model to useless "headless" or
"wayland" strings.
2022-05-26 13:36:06 +00:00
Kirill Primak bc4350c976 backend/wayland: reset active pointer on destroy 2022-04-29 21:55:04 +03:00
Simon Ser a1e1e9aba8 Revert "backend/wayland: zero out finished input devices"
This reverts commit 03c88b07ba.

init functions now zero out the structs.
2022-04-28 10:09:50 +02:00
Kirill Primak 03c88b07ba backend/wayland: zero out finished input devices 2022-04-22 17:51:24 +00:00
Kirill Primak a43d105a50 backend/wayland/pointer: fix indentation 2022-04-22 17:51:24 +00:00
Alexander Orzechowski 2ce0305483 seat: Don't finish wlr_keyboard if server was never started 2022-04-22 01:49:58 +00:00
Simon Zeni aaf787ee56 types/wlr_touch: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni e732c5c895 types/wlr_tablet_tool: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni d1f543a9d8 types/wlr_tablet_pad: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni 9a17200446 types/wlr_keyboard: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni bd6c000d14 types/wlr_pointer: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni a92e5f8d46 types/wlr_input_device: move output_name field to wlr_pointer and wlr_touch 2022-03-17 13:44:18 -04:00
Simon Zeni 2001441a37 backend/wayland: remove wl_seat_listener from public API 2022-03-17 17:16:47 +00:00
Simon Zeni b7e9ad7989 backend/wayland: remove wlr_wl_input_device 2022-03-17 17:16:47 +00:00
Simon Zeni 56f7c000b5 backend/wayland/tablet_v2: give wlr_tablet_* ownership to wlr_wl_seat 2022-03-17 17:16:47 +00:00
Simon Zeni d3fb44314c backend/wayland: give wlr_touch ownership to wlr_wl_seat 2022-03-17 17:16:47 +00:00
Simon Zeni e723dd928b backend/wayland: drop wlr_switch support 2022-03-17 17:16:47 +00:00
Simon Zeni be8527bd36 backend/wayland: give wlr_pointer ownership to wlr_wl_seat
All the code logic related to the pointer has been moved to its own file.

The seat is responsible for the lifetime of its wlr_wl_pointer(s), and assigning
them to the relevant wlr_wl_output. The wlr_wl_pointer becomes a simple helper
to manager the wlr_pointer associated to the seat's wl_pointer and its lifetime.
2022-03-17 17:16:47 +00:00
Simon Zeni f9b6aa3079 backend/wayland: give wlr_keyboard ownership to wlr_wl_seat 2022-03-17 17:16:47 +00:00
David96 7a2c96dcbd types/wlr_tablet_tool: remove name ambiguity
It wasn't clear in the backend whether to use name or base.name, change
it so base.name has to be used.

Fixes https://github.com/swaywm/sway/issues/6884
2022-03-11 11:49:41 +01:00
Simon Zeni cfed039c9a types/wlr_input_device: move init and finish function to private API 2022-03-07 16:37:41 +00:00
Simon Zeni 1bb2631c5c types/wlr_input_device: remove wlr_input_device_destroy 2022-03-07 16:37:41 +00:00
Simon Zeni 10cbb9fbe1 interface/wlr_touch: rework destroy sequence
The destroy callback in wlr_touch_impl has been removed. The function
`wlr_touch_finish` has been introduced to clean up the resources owned by a
wlr_touch.

`wlr_input_device_destroy` no longer destroys the wlr_touch, attempting to
destroy a wlr_touch will result in a no-op.

The field `name` has been added to the wlr_touch_impl to be able to identify
a given wlr_touch device.
2022-03-07 16:37:41 +00:00
Simon Zeni 8d3cb94b41 interface/wlr_tablet_tool: rework destroy sequence
The destroy callback in wlr_tablet_tool_impl has been removed. The function
`wlr_tablet_tool_finish` has been introduced to clean up the resources owned by
a wlr_tablet_tool.

`wlr_input_device_destroy` no longer destroys the wlr_tablet_tool, attempting to
destroy a wlr_tablet_tool will result in a no-op.

The field `name` has been added to the wlr_tablet_tool_impl to be able to
identify a given wlr_tablet_tool device.
2022-03-07 16:37:41 +00:00
Simon Zeni a5b032cb1e interface/wlr_tablet_pad: rework destroy sequence
The destroy callback in wlr_tablet_pad_impl has been removed. The function
`wlr_tablet_pad_finish` has been introduced to clean up the resources owned by a
wlr_tablet_pad.

`wlr_input_device_destroy` no longer destroys the wlr_tablet_pad, attempting to
destroy a wlr_tablet_pad will result in a no-op.

The field `name` has been added to the wlr_tablet_pad_impl to be able to identify
a given wlr_tablet_pad device.
2022-03-07 16:37:41 +00:00
Simon Zeni 0d2be496a8 interface/wlr_switch: rework destroy sequence
The destroy callback in wlr_switch_impl has been removed. The function
`wlr_switch_finish` has been introduced to clean up the resources owned by a
wlr_switch.

`wlr_input_device_destroy` no longer destroys the wlr_switch, attempting to
destroy a wlr_switch will result in a no-op.

The field `name` has been added to the wlr_switch_impl to be able to identify
a given wlr_switch device.
2022-03-07 16:37:41 +00:00
Simon Zeni 51cd3c0726 interface/wlr_pointer: rework destroy sequence
The destroy callback in wlr_pointer_impl has been removed. The function
`wlr_pointer_finish` has been introduced to clean up the resources owned by a
wlr_pointer.

`wlr_input_device_destroy` no longer destroys the wlr_pointer, attempting to
destroy a wlr_pointer will result in a no-op.

The field `name` has been added to the wlr_pointer_impl to be able to identify
a given wlr_pointer device.
2022-03-07 16:37:41 +00:00
Simon Zeni 7dc4a3ecd7 interface/wlr_keyboard: rework destroy sequence
The destroy member in wlr_keyboard_impl has been removed. The function
`wlr_keyboard_finish` has been introduce to clean up the resources owned by a
wlr_keyboard.

`wlr_input_device_destroy` no longer destroys the wlr_keyboard, attempting to
destroy a wlr_keyboard will result in a no-op.

The field `name` has been added to the wlr_keyboard_impl to be able to identify
a given wlr_keyboard device.
2022-03-07 16:37:41 +00:00
Simon Zeni e279266f71 interfaces: remove wlr_input_device_impl 2022-02-22 14:23:46 -05:00
Simon Zeni 887516d004 backend/wayland: remove wlr_input_device_impl 2022-02-21 16:48:43 -05:00
Simon Zeni edfb332b24 types/wlr_touch: add base wlr_input_device
wlr_touch now owns its wlr_input_device. It will be initialized when the
tablet tool is initialized, and finished when the touch is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni 7dfee50350 types/wlr_tablet_tool: add base wlr_input_device
wlr_tablet_tool owns its wlr_input_device. It will be initialized when the
tablet tool is initialized, and finished when the tablet tool is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni a662743610 types/wlr_tablet_pad: add base wlr_input_device
wlr_tablet_pad owns its wlr_input_device. It will be initialized when the
tablet pad is initialized, and finished when the tablet pad is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni d5480efc7a types/wlr_pointer: add base wlr_input_device
wlr_pointer owns its wlr_input_device. It will be initialized when the
pointer is initialized, and finished when the pointer is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni a1978b1299 types/wlr_keyboard: add base wlr_input_device
wlr_keyboard owns its base wlr_input_device. It will be initialized when the
keyboard is initialized, and finished when the keyboard is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni 71577e351e types/wlr_input_device: default vendor and product id to 0
vendor and product id are set when needed by the libinput backend
2022-02-21 17:11:32 +00:00
Simon Ser b5a019d575 build: simplify Meson subproject fallbacks
All of these projects use meson.override_dependency() so we can
stop referencing their internal variable name to grab the
depndencies we need.
2021-12-19 18:12:16 +00:00
Simon Ser 9f41627aa1 backend/wayland: add basic linux-dmabuf feedback support
This patch makes it so we bind to zwp_linux_dmabuf_v1 version 4 and
we use it to grab the main device. v4 sends supported formats via a
table so we need to handle this as well.

v4 allows wlroots to remove the requirement for Mesa's internal
wl_drm interface.
2021-12-15 14:34:08 +00:00
Simon Ser 818fc4a87b Fix incorrect %zd formatting directives
%zd is for ssize_t. For size_t we should use %zu.
2021-12-09 16:42:04 +01:00
Simon Ser 36a2b19485 output: introduce wlr_output_set_name
wlroots picks names for all outputs, but it might be desirable for
compositor to override it.

For instance, Sway will use a headless output as a fallback in
case no outputs are connected. Sway wants to clearly label the
fallback output as such and label "real" headless outputs starting
from HEADLESS-1.
2021-12-09 15:46:46 +01:00
Simon Ser ad28490cf4 build: move wayland-client dep to backend/wayland/
wayland-client isn't really used by wlroots core, so let's move the
dep to where it's needed in the Wayland backend.
2021-12-07 16:11:29 +01:00
Quantum 812ab2e716 Fix uninitialized variable errors in release mode
When using `meson --buildtype=release`, `-Wextra -Werror` is passed.
This includes `-Werror=maybe-uninitialized`, which complains about
the instances fixed in this commit.
2021-12-01 02:39:14 -05:00
Moon Sungjoon 611b9ca843 backend/wayland: improve wayland input device name
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3332
This makes input device names include it's type name
2021-11-30 22:06:14 +00:00
Simon Ser 1d9c1bcea6 input-device: remove wlr_input_device.link
This field's ownership is unclear: it's in wlr_input_device, but
it's not managed by the common code, it's up to each individual
backend to use it and clean it up.

Since this is a backend implementation detail, move it to the
backend-specific structs.
2021-11-23 14:14:18 +00:00
Simon Ser 3b93da70a0 backend/wayland: report parent presentation clock
There's no guarantee that the parent Wayland compositor uses
CLOCK_MONOTONIC for reporting presentation timestamps, they could
be using e.g. CLOCK_MONOTONIC_RAW or another system-specific clock.

Forward the value via wlr_backend_impl.get_presentation_clock.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3254#note_1143061
2021-11-22 19:31:59 +01:00
Simon Ser a04cfca4da Remove support for DMA-BUF flags
They are never used in practice, which makes all of our flag
handling effectively dead code. Also, APIs such as KMS don't
provide a good way to deal with the flags. Let's just fail the
DMA-BUF import when clients provide flags.
2021-11-17 16:12:59 +00:00
Ronan Pigott 8e225261f0 backend/wayland: use xdga client activation 2021-10-31 10:33:14 +01:00
Kirill Primak 2af8cc769a output: add presented flag to presentation event 2021-10-15 09:38:58 +02:00
Kirill Primak 1089b7b8d6 output: disallow NULL event for wlr_output_send_present() 2021-10-15 09:38:58 +02:00
Simon Ser 3d0848daae backend: create renderer and allocator in wlr_backend_autocreate
Instead of ensuring the renderer and allocator are initialized in each
backend, do it in wlr_backend_autocreate. This allows compositors to
create backends without any renderer/allocator if they side-step
wlr_backend_autocreate.

Since the wlr_backend_get_renderer and backend_get_allocator end up
calling wlr_renderer_autocreate and wlr_allocator_autocreate, it sounds
like a good idea to centralize all of the opimionated bits in one place.
2021-09-30 08:50:43 -06:00
José Expósito 62e62b6942 backend/wayland: send hold gesture events
Receive hold gesture events using a Wayland listiner and emit the
appropiate wlr_pointer signal.
2021-09-27 15:30:31 +02:00
Simon Ser 3ce2ea9e16 Move allocator stuff into new directory
Add render/allocator/ and include/render/allocator/ to hold
everything allocator-related.
2021-08-25 09:57:20 -04:00
Simon Ser 18c2dce65e backend: unify startup messages 2021-08-19 20:47:36 +02:00
Simon Ser 3132c0ab10 output: drop wlr_output_state.buffer_type
This is now unconditionally set to WLR_OUTPUT_STATE_BUFFER_SCANOUT.
2021-07-29 09:48:33 -04:00
Simon Ser a47f89cf7c backend/wayland: properly cleanup wlr_wl_pointer
We were missing destroy calls for gestures, and we were only
destroying the relative pointer on output destroy.
2021-07-13 09:20:25 -04:00
Simon Ser 8eef6a8843 backend/wayland: send touch frame events 2021-07-08 09:12:17 +02:00
Simon Ser a38baec1f8 buffer: make enum wlr_buffer_cap public
Custom backends and renderers need to implement
wlr_backend_impl.get_buffer_caps and
wlr_renderer_impl.get_render_buffer_caps. They can't if enum
wlr_buffer_cap isn't made public.
2021-07-01 16:40:19 -04:00
Simon Ser 5888c96da8 tablet: stop using wlr_list 2021-07-01 10:35:39 -04:00
Simon Ser 2f615468b6 backend: add output state allow-lists
Right now, when a new output state field is added, all backends by
default won't reject it. This means we need to add new checks to
each and every backend when we introduce a new state field.

Instead, introduce a bitmask of supported output state fields in
each backend, and error out if the user has submitted an unknown
field.

Some fields don't need any backend involvment to work. These are
listed in WLR_OUTPUT_STATE_BACKEND_OPTIONAL as a convenience.
2021-06-20 23:17:08 +02:00
Simon Ser 543f5b35d0 backend/wayland: remove swapchain
Rely on wlr_output's generic swapchain handling.
2021-06-07 15:42:38 +02:00
Simon Ser 5f8092b045 backend/wayland: implement get_dmabuf_primary_formats 2021-06-07 15:42:38 +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 de51df2770 backend/wayland: implement get_cursor_formats 2021-06-02 11:08:52 +02:00
Simon Ser ce3e819b33 backend: stop using renderer to get the buffer type
When picking a format, the backend needs to know whether the
buffers allocated by the allocator will be DMA-BUFs or shared
memory. So far, the backend used the renderer's supported
buffer types to guess this information.

This is pretty fragile: renderers in general don't care about the
SHM cap (they only care about the DATA_PTR one). Additionally,
nothing stops a renderer from supporting both DMA-BUFs and shared
memory, but this would break the backend's guess.

Instead, use wlr_allocator.buffer_caps. This is more reliable since
the buffers created with the allocator are guaranteed to have these
caps.
2021-05-31 15:50:13 -04:00
Simon Ser 349553d011 backend/wayland: use common renderer and allocator
Instead of managing our own renderer and allocator, let the common
code do it.
2021-05-21 22:13:54 +02:00
Simon Ser 7ec5bf6b10 backend: introduce wlr_backend_finish
This new functions cleans up the common backend state. While this
currently only emits the destroy signal, this will also clean up
the renderer and allocator in upcoming patches.
2021-05-21 22:13:54 +02:00
Simon Zeni cc1b66364c backend: use wlr_allocator_autocreate 2021-04-28 20:55:57 +02:00
Simon Zeni 144189674e backend: introduce backend_get_buffer_caps 2021-04-28 20:55:57 +02:00
Simon Zeni a8c91fbac9 render/shm_allocator: make wlr_shm_allocator_create return a wlr_allocator 2021-04-28 20:55:57 +02:00
Simon Zeni c75aa71816 render/gbm_allocator: make wlr_gbm_allocator_create return a wlr_allocator 2021-04-28 20:55:57 +02:00
Simon Ser 5c699f09cb Log drmGetDevices2 error code 2021-04-26 16:27:24 +02:00
Simon Ser 9de93a866f backend/wayland: fallback to wl_shm on missing render node 2021-04-17 09:54:39 +02:00
Simon Ser 80865351bd backend/wayland: add support for wl_shm buffers 2021-04-17 09:54:39 +02:00
Simon Zeni 84dea55b20 render: rename get_dmabuf_render_formats into get_render_formats 2021-04-15 17:10:06 +02:00
Simon Ser b89bcffea4 render/egl, backend/wayland: add workaround for split render/display setups
Split render/display setups have two separate devices: one display-only
with a primary node, and one render-only with a render node. However
in these cases the EGL implementation and the Wayland compositor will
advertise the display device instead of the render device [1]. The EGL
implementation will magically open the render device when the display
device is passed in.

So just pass the display device as if it were a render device. Maybe in
the future Mesa will advertise the render device instead and we'll be
able to remove this workaround.

[1]: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4178
2021-03-27 11:23:32 +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
Simon Ser f3758d1d0a backend: add error messages in attach_render impls 2021-02-18 22:14:19 +01:00
Manuel Stoeckl a290d7a78d Make implementation function lists static const
This requires a change to the type of `struct wlr_tablet` and
`wlr_tablet_init` signature, both of which are part of the unstable API.
2021-02-05 10:04:20 +01:00
Simon Ser 8e27418dd3 backend/wayland: flush remote display
It turns out wl_event_source_check is not enough to guarantee that the
remote wl_display will be flushed after we queue requests. We need to
explicitly flush, just like we do in our X11 code.

References: https://gitlab.freedesktop.org/wayland/wayland/-/issues/187
2021-02-03 15:22:36 +01:00
Simon Ser 7b50f5d324 backend/wayland: remove unnecessary cast 2021-01-29 12:12:47 +01:00
Simon Ser afdf4dc890 render/gles2: make EGL context current in bind_buffer
Instead of requiring callers to manually make the EGL context current
before binding a buffer and unsetting it after unbinding a buffer, do
it inside wlr_renderer_bind_buffer.

This hides renderer-specific implementation details inside the
wlr_renderer interface. Non-GLES2 renderers may not use EGL.
This removes all EGL dependencies from the backends.

References: https://github.com/swaywm/wlroots/issues/2618
References: https://github.com/swaywm/wlroots/pull/2615#issuecomment-756687006
2021-01-16 09:06:17 +01:00
Simon Zeni 08a4c62aac render: remove egl include from wlr_renderer 2021-01-16 08:57:42 +01:00
Simon Zeni e128e6c08d render: drop egl parameters from wlr_renderer_autocreate 2021-01-16 08:57:42 +01:00
Simon Ser 400f4e7f27 backend/wayland: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser a6a0568316
backend: remove unnecessary GLES2 includes 2021-01-14 12:36:49 +01:00
Simon Ser 3f7e0cf5f0 render/egl: remove surface and buffer age args from make_current
These aren't used anymore.
2021-01-12 11:31:04 +01:00
Simon Ser 098094c5cb backend/wayland: use the EGL GBM platform
Just like other backends, use the EGL GBM platform. This will make it
easier to move the allocator and renderer initialization out of the
backends.
2021-01-10 11:32:00 +01:00
Simon Zeni 9192c0480a remove unnecessary egl includes 2021-01-07 17:11:22 +01:00