Commit Graph

416 Commits

Author SHA1 Message Date
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
Simon Zeni b899a412e3 backend: remove wlr_egl from all backends 2021-01-07 17:11:22 +01:00
Simon Ser 07d75c99db render: remove EGL config and visual from wlr_renderer_autocreate
This isn't used anymore by any backend.

Some examples still provide an EGL config to wlr_egl_init, so we can't
drop it yet there.
2021-01-06 12:05:51 +01:00
Simon Ser 3721dbfddb
backend/wayland: remove unnecessary flags from event source
wl_event_loop_add_fd only accepts READABLE and WRITABLE. ERROR and
HANGUP are always implicitly enabled.
2021-01-05 19:54:20 +01:00
Kenny Levinsen d3047011d0 backend/wayland: Avoid uninitialized read
keyboard_handle_leave would always process 1 keycode more than was
pending, which meant reading uninitialized memory from the "pressed"
array.

Found by valgrind.
2021-01-05 12:26:00 +01:00
Simon Ser 7febdc7334 backend/wayland: re-use cursor wl_buffers
We were importing cursor buffers as wl_buffers over and over again.
Instead, only import these once.
2021-01-04 13:48:28 +01:00
Simon Ser 4b03bdc3ab Remove wlr_create_renderer_func_t
This callback allowed compositors to customize the EGL config used by
the renderer. However with renderer v6 EGL configs aren't used anymore.
Instead, buffers are allocated via GBM and GL FBOs are rendered to. So
customizing the EGL config is a no-op.
2020-12-30 17:09:40 +01:00
Simon Ser b9460ab724
Stop using wlr_texture_get_size
Just use wlr_texture.{width,height} directly.
2020-12-25 12:21:29 +01:00
Simon Ser defcd9b025 backend/wayland: re-use wl_buffers
Instead of re-importing a buffer each time we submit a new frame, re-use
the wl_buffer objects if possible.
2020-12-21 16:30:47 +01:00
Simon Ser de896caceb backend/wayland: remove EGL config
We don't use EGLSurface anymore, so we don't need to choose an EGL
config anymore.
2020-12-19 21:11:01 +01:00
Simon Ser 87bd718de5
backend: use fcntl(F_DUPFD_CLOEXEC) instead of dup
This makes sure the CLOEXEC flag is set on the dup'ed FD.
2020-12-15 20:52:53 +01:00
Simon Ser 16a51bbab2 backend/wayland: query render formats 2020-12-13 12:16:28 +01:00
Simon Ser 441bac139f backend/wayland: use wlr_swapchain for cursor surface 2020-12-13 12:16:28 +01:00
Simon Ser 3923ff005d backend/wayland: use wlr_swapchain for main surface
The cursor surface still uses a wl_egl_window.

References: https://github.com/swaywm/wlroots/issues/1352
2020-12-13 12:16:28 +01:00
Simon Ser 038285d496 backend/wayland: stop rendering black frame on init
Instead of rendering a black frame, schedule a frame event to ask the
compositor to render a proper frame.
2020-12-13 12:16:28 +01:00
Simon Ser 768131e488 output: stop assuming a frame is pending in init
- The DRM backend initially doesn't have a frame scheduled initially.
  However the compositor is expected to set a mode to start the
  rendering loop (frame_pending is set to true in drm_crtc_pageflip).
- The headless and X11 backends have a timer to schedule frames, so they
  ignore this hint completely.
- The Wayland backend renders a fake frame to start the rendering loop.
  It's the only case where a frame is pending on init, move the
  assumption there.
2020-12-13 12:16:28 +01:00
Simon Ser 6485fadc16
backend/wayland: don't set EGL visual
The Wayland platform doesn't have visuals. By chance,
WL_SHM_FORMAT_ARGB8888 is zero, which means egl_get_config was ignoring
it and everything worked fine.
2020-11-25 13:52:05 +01:00
Mykola Orliuk 2eae9ec7c8 backend/wayland: Set cursor indivdualy per output 2020-11-12 12:31:32 +01:00
Mykola Orliuk 44531e16e0 backend/wayland: Add active pointer per host seat
Every host seat with pointer capability propagates events to one of
sub-pointer depending which output window we entered.
active_pointer tracks reference to sub-pointer on enter/leave events to
avoid lookup for it on every move events.

Fixes swaywm/wlroots#1499
2020-11-12 12:31:32 +01:00
Mykola Orliuk ce8855ca2a backend/wayland: Bind pointer listener to seat 2020-11-12 12:31:32 +01:00
Mykola Orliuk 07e2e0f60c backend/wayland: Listen to pointers from all seats
This effectively gets swaywm/wlroots#1499 to the point where
functionality somewhat preserved and no crash happens.
We still can have only one cursor, but we can control it from multiple
seats in time-sharing manner by entering/leaving output.
2020-11-12 12:31:32 +01:00
Mykola Orliuk 44c4773d58 backend/wayland: Use seat name in input names 2020-11-12 12:31:32 +01:00
Mykola Orliuk 70ffda3ea3 backend/wayland: Add registering multiple seats 2020-11-12 12:31:32 +01:00
Mykola Orliuk 85b0872650 backend/wayland: Link input devices with seats 2020-11-12 12:31:32 +01:00
Mykola Orliuk 40bfd9f8f7 backend/wayland: Bind seat listener to wlr_wl_seat 2020-11-12 12:31:32 +01:00
Isaac Freund 7693f61d81 Replace wlr_key_state with wl_keyboard_key_state
There's no reason to have duplicate enums
2020-11-11 10:58:38 +01:00
Mykola Orliuk 31aa7f4c95 backend/wayland: fix some keyboard/touch leaks 2020-10-18 21:25:25 +02:00
Mykola Orliuk 009cd634a2 backend/wayland: fix input creation error handling 2020-10-18 21:25:25 +02:00
Mykola Orliuk 41bf1c6871 backend/wayland: add error flow in create_wl_seat 2020-10-18 21:25:25 +02:00
Mykola Orliuk 1ac5257357 backend/wayland: factor out wlr_wl_seat 2020-10-18 16:28:12 +02:00
Mykola Orliuk df417b7e95 backend/wayland: manage cursor for current pointer 2020-10-18 16:28:12 +02:00
Ilia Bozhinov b98522b38f
backend/wayland: add touch support to the wayland backend
Goal currently is to get support working for a single output, thus there is only one touch device created.

Multi-output support is left for later.
2020-10-18 15:33:03 +02:00
Ilia Bozhinov efe6414640 wayland: emit relative pointer events only for current pointer 2020-09-04 10:13:35 +02:00
Simon Ser 297354f847 Remove unnecessary wl_display_dispatch calls
wl_display_roundtrip already takes care of dispatching the display.
2020-08-24 07:55:35 -06:00
Ilia Bozhinov 9feeb2738d
backend/wayland: destroy relative pointer when output is disconnected
Fixes #2243
Fixes #2106
2020-08-17 11:33:57 +02:00
Antonin Décimo d9bb792794 Fix incorrect format parameters 2020-07-27 10:49:19 +02:00
Simon Ser bf93d2e67c output: rename impl->rollback to rollback_render
The output backend API is now mostly state-less thanks to the atomic
hooks (commit and test). There is one exception though: attach_render.
This function makes the rendering context current. However sometimes the
compositor might decide not to render after attach_render (e.g. when
there's nothing new to render to the back buffer). Thus
wlr_output_rollback has been introduced to revert the pending state.

Because the output backend API is mostly state-less, the only thing
wlr_output_impl.rollback needs to do is revert the current rendering
context. Rename the function to rollback_render to make this clear. Add
a check in the common wlr_output code to only call rollback_render when
attach_buffer has been previously called.

On the long term, we'll be able to remove attach_render and
rollback_render together.
2020-06-19 11:50:42 -06:00
Tudor Brindus dc13bb827d util: fix and move `get_current_time_msec` into a util file
This commit makes `get_current_time_msec` correctly return milliseconds
as opposed to microseconds. It also considers the value of `tv_sec`, so
we don't lose occasionally go back in time by one second. Finally, the
function is moved into `util/time.cc` so that it can be reused elsewhere
without having to consider these pitfalls.
2020-06-06 00:09:19 +02:00
Simon Ser 019fe8bb7e backend/wayland: fix spurious eglSwapBuffers failures
This was introduced in [1]. However after reverting that PR I still
can't reproduce the bug the PR aimed to fix [2].

Since there's no good explanation why we would need to swap buffers
before resizing, let's just revert the PR.

[1]: https://github.com/swaywm/wlroots/pull/1486
[2]: https://github.com/swaywm/wlroots/issues/1371

Closes: https://github.com/swaywm/wlroots/issues/1768
2020-06-02 14:14:08 -06:00
Tudor Brindus 47a30957d1 backend/wayland: scale tablet tool position into [0, 1] range
Fixes #2233.
2020-06-01 22:36:46 +02:00
Simon Ser 1a23c1425f Add comments for missing tablet tool entries
And stop using default cases, so that we know which parts of the code
need an update when adding a new enum entry.

Closes: https://github.com/swaywm/wlroots/issues/2208
2020-05-28 15:13:05 +02:00
Simon Ser af2f69e6c1 render/egl: unset current context after swapping buffers
After swapping buffers, it doesn't make sense to perform more rendering
operations. Unset the context to reflect this.

This commit makes it so the context is always only current between
wlr_egl_make_current and wlr_egl_swap_buffers.

This is an alternative to [1].

[1]: https://github.com/swaywm/wlroots/pull/2212
2020-05-20 17:39:34 +02:00
Simon Ser 1edc42157b render/egl: introduce wlr_egl_unset_current
This function can be called after wlr_egl_make_current to cleanup the
EGL context. This avoids having lingering EGL contexts that make things
work by chance.

Closes: https://github.com/swaywm/wlroots/issues/2197
2020-05-19 14:56:20 +02:00
Simon Ser 781ed1ff02 Fix -Wreturn-type warnings
When calling assert(0) instead of returning a value, -Wreturn-type
warnings are triggered because assertions can be disabled. Replace these
assertions with abort().
2020-05-19 14:54:02 +02:00
Tudor Brindus 6357e166f9 backend/wayland: emit tablet tool axis events to the axis handler 2020-05-04 21:53:52 +02:00
Simon Ser ab4f642153 build: use dicts instead of get_variable
Closes: https://github.com/swaywm/wlroots/issues/1963
2020-04-21 15:26:45 +02:00
Simon Ser 83c1ba7783 backend/wayland: check scan-out buffer is compatible in output_test
If the buffer doesn't have a supported format/modifier, make the test
fail.
2020-04-10 15:52:20 +02:00
Simon Ser 50ade3671f output: check for buffer size compatibility in common code
Instead of checking for buffer size compatibility in each backend,
centralize the check in wlr_output itself.
2020-04-10 15:52:20 +02:00
Simon Ser 5f092c55d1 output: fix blurred hw cursors with fractional scaling
The scaling factor was being implicitly cast to an int.

Closes: https://github.com/swaywm/sway/issues/4927
2020-04-10 15:10:12 +02:00
Simon Ser 9acca4fc73 backend: set EGL_RENDERABLE_TYPE and EGL_SURFACE_TYPE
Ensure these are set to the correct value.
2020-04-09 00:15:25 +00:00
Simon Ser 507d9bc19e Add wlr_output_impl.rollback
Most of the pending output state is not forwarded to the backend prior
to an output commit. For instance, wlr_output_set_mode just stashes the
mode without calling any wlr_output_impl function.
wlr_output_impl.commit is responsible for applying the pending mode.

However, there are exceptions to this rule. The first one is
wlr_output_attach_render. It won't go away before renderer v6 is
complete, because it needs to set the current EGL surface.

The second one is wlr_output_attach_buffer.
wlr_output_impl.attach_buffer is removed in [1].

When wlr_output_rollback is called, all pending state is supposed to be
cleared. This works for all the state except the two exceptions
mentionned above. To fix this, introduce wlr_output_impl.rollback.

Right now, the backend resets the current EGL surface. This prevents GL
commands from affecting the output after wlr_output_rollback.

This patch is required for FBO-based outputs to work properly. The
compositor might be using FBOs for its own purposes [2], having leftover
FBO state can have bad consequences.

[1]: https://github.com/swaywm/wlroots/pull/2097
[2]: https://github.com/swaywm/wlroots/pull/2063#issuecomment-597614312
2020-04-08 17:33:00 +02:00
Simon Ser d3bd5f2a7b backend: reset EGL surface after buffer swap
This prevents GL commands to affect a previously current EGL surface
after a buffer swap.
2020-04-08 17:33:00 +02:00
Simon Ser 6977f3a843 output: check buffer in wlr_output_test
Check that buffer can be scanned out in wlr_output_test instead of
wlr_output_attach_buffer. This allows the backend to have access to the
whole pending state when performing the check.

This brings the wlr_output API more in line with the KMS API.

This removes the need for wlr_output_attach_buffer to return a value,
and for wlr_output_impl.attach_buffer.
2020-04-08 16:31:21 +02:00
Simon Ser e041158988 output: introduce wlr_output_test 2020-04-08 16:31:21 +02:00
Simon Ser 6595db6409 buffer: add a release event
Consumers call wlr_buffer_lock. Once all consumers are done with the
buffer, only the producer should have a reference to the buffer. In this
case, we can release the buffer (and let the producer re-use it).
2020-04-02 15:03:43 +02:00
Simon Ser b614ded3fc backend/wayland: close keymap FD
We don't actually need the keymap. We need to close the FD or we will
run out of FDs.
2020-03-17 13:37:53 +01:00
Simon Ser a3c699eee5 backend/wayland: fix seat caps handling
Previously, each time a wl_seat.capabilities event was received the
Wayland backend created new input devices. It now only does so the first
time.

Input devices are now destroyed when the cap is removed.

Closes: https://github.com/swaywm/sway/issues/5055
2020-03-04 09:57:10 +01:00
Simon Ser 348f52b5fc output: remove wlr_output_impl.schedule_frame
This function allowed backends to provide a custom function for frame
scheduling. Before resuming the rendering loop, the DRM and Wayland
backends would wait for vsync.

There isn't a clear benefit of doing this. The only upside is that we
get more stable timings: the delay between two repaints doesn't change too
much and is close to a mutliple of the refresh rate.

However this introduces latency, especially when a client misses a
frame. For instance a fullscreen game missing vblank will need to wait
more than a whole frame before being able to display new content. This
worst case scenario happens as follows:

- Client is still rendering its frame and cannot submit it in time
- Deadline is reached
- Compositor decides to stop the rendering loop since nothing changed on
  screen
- Client finally manages to render its frame, submits it
- Compositor calls wlr_output_schedule_frame
- DRM backend waits for next vblank
- The wlr_output frame event is fired, compositor draws new content on screen
- On the second next vblank, the new content reaches the screen

With this patch, the wlr_output frame event is fired immediately when
the client submits its late frame.

This change also makes it easier to support variable refresh rate, since
VRR is all about being able to present too-late frames earlier.

References: https://github.com/swaywm/wlroots/issues/1925
2020-03-04 03:22:19 +01:00
Simon Ser 613f9c6f8d backend/wayland: rename wl_seat.c to seat.c
I never got why we have a wl_ prefix here.
2020-03-04 03:21:40 +01:00
Scott Anderson 70a084c119 meson: Fix protocol includes for compositor examples 2020-01-24 09:10:28 +00:00
Simon Ser 802ef9da8a backend/wayland: handle display errors more gracefully
Previously, an error on the remote Wayland display would result in an
infinite loop priting:

    2020-01-09 13:39:03 - [wayland] Source dispatch function returned negative value!
    2020-01-09 13:39:03 - [wayland] This would previously accidentally suppress a follow-up dispatch

This happens when the remote compositor disconnects the client because
of a protocol error, for instance.

Handle wl_display_dispatch and wl_display_dispatch_pending returning -1
by terminating the local display and printing an error.
2020-01-09 07:48:30 -07:00
Simon Ser e6fd880686 backend/wayland: listen to wl_buffer.release events
Previously, we just assumed submitting a new frame would make the
compositor release the current one. This isn't always the case, for
instance Sway retains old buffers when a transaction is pending. This
resulted in synchronization issues with clients writing in
front-buffers.

Fix this by un-referencing a wlr_buffer when the parent compositor sends
wl_buffer.release.

Tested by running a fullscreen mpv instance in Sway with the Wayland
backend.
2020-01-09 07:41:50 -07:00
Simon Ser 5bbb44482b backend/wayland: fix frame callback not registered
This got removed in [1]. I probably messed up the rebase.

[1]: https://github.com/swaywm/wlroots/pull/1797/files#diff-3065f86e6de87d143d4a7673a8ee3a2d

Fixes: 5d1ba0f446 ("output: re-introduce atomic mode, enabled, scale and transform")
2020-01-02 12:44:28 -07:00
Simon Ser 5d1ba0f446 output: re-introduce atomic mode, enabled, scale and transform
This reverts commit 01f903874b and re-applies
commit ee5f98ad49.

Updates: https://github.com/swaywm/wlroots/issues/1640 (Atomic output updates issue)
See also: https://github.com/swaywm/wlroots/pull/1762 (Atomic output updates original PR)
See also: https://github.com/swaywm/wlroots/issues/1780 (Issue caused by atomic output updates)
See also: https://github.com/swaywm/sway/issues/4419 (Issue caused by atomic output updates)
See also: https://github.com/swaywm/wlroots/pull/1781 (Revert PR)
2019-12-30 11:21:11 -07:00
Simon Ser 4da4a15d6b output: add description
wlr_output.description is a string containing a human-readable string
identifying the output. Compositors can customise it via
wlr_output_set_description, for instance to make the name more
user-friendly.

References: https://github.com/swaywm/wlroots/issues/1623
2019-12-29 12:35:22 -05:00
Scott Anderson cff1c2f740 meson: Various improvements
Bumps minimum version to 0.51.0

- Remove all intermediate static libraries.
  They serve no purpose and are just add a bunch of boilerplate for
  managing dependencies and options. It's now managed as a list of
  files which are compiled into libwlroots directly.

- Use install_subdir instead of installing headers individually.
  I've changed my mind since I did that. Listing them out is annoying as
  hell, and it's easy to forget to do it.

- Add not_found_message for all of our optional dependencies that have a
  meson option. It gives some hints about what option to pass and what
  the optional dependency is for.

- Move all backend subdirectories into their own meson.build. This
keeps some of the backend-specific build logic (especially rdp and
session) more neatly separated off.

- Don't overlink example clients with code they're not using.
  This was done by merging the protocol dictionaries and setting some
  variables containing the code and client header file.
  Example clients now explicitly mention what extension protocols they
  want to link to.

- Split compositor example logic from client example logic.

- Minor formatting changes
2019-12-23 07:48:29 -05:00
Simon Ser e959b882d5 backend/wayland: add support for presentation-time 2019-11-21 11:32:30 -05:00
Simon Ser 16e5e9541b Add -Wmissing-prototypes
This requires functions without a prototype definition to be static.
This allows to detect dead code, export less symbols and put shared
functions in headers.
2019-11-20 02:05:03 +00:00
Simon Ser cde544de81 backend/wayland: expose remote objects
Expose the remote wl_display, wl_surface and wl_seat used by the Wayland
backend.

This allows compositors to customize the Wayland backend and to have
more freedom. For instance a compositor might want to handle clipboard
and drag-and-drop from the remote Wayland compositor. Another compositor
might want to setup pointer constraints.
2019-11-13 10:15:28 -05:00
Simon Ser 1e568d84df backend/wayland: add support for relative-pointer-unstable-v1
We just send relative motion events alongside absolute motion events.
Compositors can figure out how absolute and relative events are related
(e.g. whether they have been triggered by the same logical event) with
the frame event.
2019-11-13 10:15:19 -05:00
Simon Ser 5bddb5a909 backend/wayland: add support for direct scan-out
Closes: https://github.com/swaywm/wlroots/issues/1830
2019-10-16 09:40:26 -04:00
Markus Ongyerth ebeef0fbe8 Clean up wayland backend tablet support
Mostly address feedback from emersion on PR #1694
Remove const qualifier from char *name, to allow free() call
2019-09-26 19:41:19 +03:00
Markus Ongyerth 2285e36b0c Add zwp-tablet-unstable-v2 client support
This allows wlroots based compositors to properly use graphic tablets
with the wayland backend.
This should be a decent quality of life improvement when working on
tablet related features.
2019-09-26 19:41:19 +03:00
Antonin Décimo e7f1aa30dd backend/wayland: check if zxdg_toplevel_decoration_v1 is not NULL 2019-08-12 09:37:21 +09:00
Rouven Czerwinski 01f903874b Revert "output: atomic mode"
This reverts commit ee5f98ad49.

This intoduced problems where outputs could not be turned off because
they had flips pending.
2019-08-07 16:22:11 +09:00
Simon Ser ee5f98ad49 output: atomic mode, enabled, scale and transform
This commit makes more output properties (mode, enabled, scale and transform)
atomic. This means that they are double-buffered and only applied on commit.

Compositors now need to call wlr_output_commit after setting any of those
properties.

Internally, backends still apply properties sequentially. The behaviour should
be exactly the same as before. Future commits will update some backends to take
advantage of the atomic interface. Some backends are non-atomic by design, e.g.
the X11 backend or the legacy DRM backend.

Updates: https://github.com/swaywm/wlroots/issues/1640
2019-08-02 10:01:29 -04:00
Simon Ser ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
Greg V d80acadfd8 Support pointer-gestures on Wayland backend 2019-06-21 14:43:28 -04:00
Simon Ser ce3f4c3fe1 output: remove wlr_output_impl.transform
The backend doesn't need to handle transform changes, since everything is done
in software. In fact, all of the implementations were all identical and just
set the transform.

We could add support for hardware transforms, but:

- This would require a different field (something like hardware_transform)
- Not all combinations are possible because there often are hardware
  limitations
- The Wayland protocol isn't ready for this (in particular xdg-output, see [1])

This belongs to a different patch series anyway.

[1]: https://patchwork.freedesktop.org/series/52324/
2019-06-16 10:51:49 -04:00
Simon Ser 947d5ff481 backend/wayland: remove wl_shm
We bind to it but never use it.
2019-05-06 20:51:57 +03:00
Simon Ser 292d20e4c1 backend/wayland: use xdg-decoration-unstable-v1
This allows the toplevel to have proper decorations on compositors that support
xdg-decoration-unstable-v1.
2019-05-06 10:34:41 -06:00
Simon Ser 933208837d backend/wayland: fix wlr_wl_pointer use-after-free 2019-04-23 14:36:12 -06:00
Simon Ser 9a0f8a194c output: refactor backend API
This updates the backend part of the output API. This is mostly renaming:
make_current becomes attach_render and swap_buffers becomes commit.

This also fixes the RDP backend to support NULL damage.
2019-04-23 14:34:30 -06:00
Alyssa Ross 95b22619e0 Fix missing headers when building without X11
The deleted includes are redundant, because other headers will include
the necessary files. Additionally, they cause build failures, because
including EGL/egl.h or EGL/eglext.h directly, instead of through
wlr/render/egl.h or wlr/render/interface.h, will mean that
MESA_EGL_NO_X11_HEADERS will not have been defined, and so the EGL
headers will attempt to pull in unnecessary X11 headers that may not
exist on the system.

For the headers produced by glgen.sh, the includes couldn't simply be
deleted, because no other header would include the EGL headers. Neither
wlr/render/egl.h or wlr/render/interface.h felt appropriate to include,
so I opted instead to copy the MESA_EGL_NO_X11_HEADERS definition before
the EGL includes.
2019-04-22 00:04:08 +03:00
Jan Beich b6d0de177a backend: unbreak on 32-bit architectures
backend/headless/output.c:132:3: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++backend->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
backend/noop/output.c:72:3: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++backend->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
backend/wayland/output.c:294:3: error: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++backend->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
backend/x11/output.c:150:3: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++x11->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~
2019-04-08 14:03:15 -06:00
Brian Ashworth 67523fb228 backend/wayland: improve output number handling
This improves the way the output numbers are handled for the wayland
backend. Instead of using the number of active outputs plus one, the
last used number is stored and new outputs will increment it. This
fixes the situation where you start with one output, create a second,
close the first, and create a third. Without this, both outputs will be
`WL-2`, which causes an issue since the identifier will also be
identical. With this, the last output is `WL-3` and the outputs can be
distinguished.
2019-03-15 09:43:40 +02:00
emersion 5445d8aad0 meson: enable more compiler warnings 2019-03-01 09:20:23 +01:00
emersion b45fc24b18
backend/wayland: handle wl_pointer.axis_stop 2019-01-26 11:18:47 +01:00
emersion 5de26ad8ed
pointer: add a frame event
Frame events group logically connected pointer events. It makes sense to make
the backend responsible for sending frame events, since once the events are
split (ie. once the frame events are stripped) it's not easy to figure out
which events belongs to which frame again.

This is also how Weston handles frame events.

Fixes https://github.com/swaywm/wlroots/issues/1468
2019-01-26 11:04:05 +01:00
Jente Hidskes 85d84a1a04
backend/x11 & backend/wayland: make set_title NULL-safe
Set the default "wlroots - " title when the title argument to the
set_title functions is NULL. Otherwise, for at least the Wayland
backend, we'd crash because xdg_toplevel_set_title doesn't handle a NULL
pointer.
2019-01-24 15:18:28 +01:00
Brian Ashworth 88ee102992 backend/wayland: fix resizing
Before resizing the egl window, the buffers must be swapped
2019-01-22 21:19:34 +01:00
Drew DeVault d3d1437bc4 Add wlr_wl_output_set_title 2019-01-10 21:53:32 -05:00
Drew DeVault 97af2464b7 Update Wayland backend to xdg-shell stable 2019-01-10 09:17:14 -05:00
Timidger 9af0c5338f
Standardize the wlr_box input paramaters
Fixes #1094
2018-12-21 13:56:10 -05:00
emersion 408e2a77e9
backend/wayland: fix zero-length VLA 2018-11-27 23:18:12 +01:00
emersion 180151ed09
backend/wayland: handle WL_EVENT_WRITABLE for Wayland socket
We need to flush when the connection is writable again. This is important in
case the write buffer becomes full. This is also what Weston does [1].

[1]: https://gitlab.freedesktop.org/wayland/weston/blob/master/libweston/compositor-wayland.c#L2593
2018-11-11 21:14:15 +01:00
Scott Anderson aaff4b8c00 backend/wayland: Make header order consistent 2018-11-11 22:29:35 +13:00
Scott Anderson bbce92a923 backend/wayland: Move initilisation code earlier
The renderer redesign is going to need the render fd before the backend
is fully started, so we have to move the wl registry code to when the
backend is created instead of when it is started.

We also need to stash the wl_keyboard and emit it to library users
later, once they've added their listeners and started the backend.
2018-11-11 18:11:56 +13:00
Scott Anderson 47545cf550 backend/wayland: Use specific wl_global versions
Explicitly use the version we support instead of accepting the
compositor's version.
2018-11-11 18:11:56 +13:00
Scott Anderson 4e03802057 backend/wayland: Move registry into backend
Registry was a very small file, and is heavily related to the backend,
so there is not point in keeping them separate.
2018-11-11 18:11:56 +13:00
emersion 68362b37a8
backend/drm: fix frame scheduling on secondary GPUs
There was a missing copy_drm_surface_mgpu call in drm_connector_schedule_frame
so we asked for a pageflip with an unknown BO, resulting in ENOENT.

Additionally, this commit makes schedule_frame return a bool indicating
failures. This allows schedule_frame_handle_idle_timer to only set
frame_pending to true if a frame has been successfully scheduled. Thus, if a
pageflip fails, rendering won't be blocked forever anymore.

In case a pageflip is already pending, true is returned because a frame has
already been scheduled and will be sent sometime soon.
2018-10-29 20:38:57 +01:00