Commit graph

125 commits

Author SHA1 Message Date
Simon Ser
d1b39b5843 backend: take wl_event_loop instead of wl_display in wlr_backend_autocreate() 2024-01-25 15:05:36 +00:00
Simon Ser
f27808b8d9 backend/multi: take wl_event_loop instead of wl_display 2024-01-25 15:05:36 +00:00
Simon Ser
54f9944b48 backend/drm: drop wl_display argument
We can grab the event loop from the wlr_session instead.
2024-01-25 15:05:36 +00:00
Simon Ser
b62ac611c8 backend/x11: take wl_event_loop instead of wl_display 2024-01-25 15:05:36 +00:00
Simon Ser
ed0bba581b backend/wayland: take wl_event_loop instead of wl_display 2024-01-25 15:05:36 +00:00
Simon Ser
f5e8fa48f3 backend/libinput: drop wl_display argument
We can grab the event loop from the wlr_session instead.
2024-01-25 15:05:36 +00:00
Simon Ser
682dbf36e5 backend/headless: take wl_event_loop instead of wl_display 2024-01-25 15:05:36 +00:00
Simon Ser
4ad6e6c298 backend: destroy multi backend when primary backend is
This makes it easy for compositors to handle situations where the
DRM or libinput backend becomes unavailable. Compositors can listen
the destroy event of the multi backend returned by
wlr_backend_autocreate() and decide what to do.
2024-01-25 14:58:00 +03:00
Simon Ser
be0b7845f7 backend: make attempt_drm_backend() return the primary backend
We'll need this in the next commit.
2024-01-25 12:12:13 +01:00
Simon Ser
63792b38e4 backend/session: take wl_event_loop instead of wl_display
wl_display holds a lot more than wlr_session needs: wlr_session
only needs to wait for a FD to become readable, but wl_display
provides full access to the Wayland client and protocol objects.

Switch to wl_event_loop to better reflect the above.
2023-11-23 11:15:07 +00:00
Simon Ser
1c24b1182b backend: drop wlr_backend_get_presentation_clock()
We can just assume CLOCK_MONOTONIC everywhere.

Simplifies the backend API, and fixes clock mismatches when multiple
backends are used together with different clocks.
2023-10-30 18:39:39 +01:00
Simon Ser
7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Simon Ser
bec94cc040 backend: move #ifdefs to nested functions
Instead of littering #ifdefs everywhere, move them to the dedicated
attempt_XXX_backend() functions. This makes the logic in
wlr_backend_autocreate() more readable, and provides better error
messages when the X11/Wayland backends are disabled at compile-time,
or when WLR_BACKENDS contains a backend disabled at compile-time.
2023-02-27 11:33:52 +01:00
Simon Ser
8acaabcbab backend: make wlr_backend_autocreate() fail when DRM is missing
When we change the required dependencies for the DRM backend,
Meson might auto-disable the backend for users missing the new
requirements. This results in confused users [1] because they don't
notice the "drm-backend: NO" line burried in the Meson logs, and
then get a black screen when starting the compositor.

Update wlr_backend_autocreate() to refuse to create a backend with
only libinput (without DRM).

Users really wanting to start their compositor with a libinput
backend and without a DRM backend can manually set WLR_BACKENDS.

[1]: https://github.com/swaywm/sway/issues/7457
2023-02-27 11:18:58 +01:00
Simon Ser
c667e64892 backend: disable DRM backend monitor when WLR_DRM_DEVICES is used
WLR_DRM_DEVICES specifies a static list of DRM devices to open
at startup.

Do not create DRM backends for hotplugged DRM devices when it's
set.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3595
2023-02-21 12:55:26 +01:00
Simon Ser
7303e13808 backend: avoid adding NULL backend in attempt_backend_by_name() 2023-02-21 12:52:20 +01:00
Simon Ser
2849712356 backend: create DRM backend monitor when WLR_BACKENDS is used 2023-02-21 12:51:46 +01:00
Simon Ser
f0375eed24 backend/session: make optional
Some compositors are not interested in wlr_session, for instance
nested compositors.

Disabling wlr_session removes the udev dependency.
2022-11-25 16:15:29 +00:00
Simon Ser
21254737bf backend: use time helpers to implement timeouts
Instead of hand-rolling get_current_time_msec(), let's just re-use
the helper we already have in "util/time.h".
2022-11-25 16:15:29 +00:00
Simon Ser
fb4fb3bac2 backend: error out when missing DRM and libinput in wlr_backend_autocreate()
Instead of returning an empty multi backend, fail with a clear
error when both the DRM and libinput backends are disabled.
2022-11-25 16:15:29 +00:00
Simon Ser
77d9fc0848 backend: rename backend to multi in wlr_backend_autocreate()
This function deals with multiple kinds of backends. Make it more
obvious that this variable holds the multi backend which is returned
to the user.
2022-11-15 21:16:25 +00:00
Simon Ser
e7c556fcf6 backend: drop wlr_backend_get_session()
This no longer has purpose.
2022-11-15 21:16:25 +00:00
Simon Ser
41b7acbab7 backend: return wlr_session in wlr_backend_autocreate() call
Up until now, wlr_backend_autocreate() created the wlr_session and
then stuffed it into struct wlr_multi_backend so that compositors
can grab it later.

This is an abuse of wlr_multi_backend and the wlr_backend API:
wlr_backend_get_session() and wlr_multi_backend.session only exist
to accomodate the needs of wlr_backend_autocreate(). What's more,
the DRM and libinput backends don't implement
wlr_backend_impl.get_session.

Instead, return the struct wlr_session to the compositor in the
wlr_backend_autocreate() call. wlr_backend_get_session() will be
removed in the next commit.
2022-11-15 21:16:25 +00:00
Alexander Orzechowski
8bd7170fd9 Use env helpers 2022-08-22 10:18:52 -04:00
Alexander Orzechowski
ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Simon Ser
6c350799b2 Zero-initialize structs in init functions
Ensures there is no field left to its previous undefined value after
calling an init function.
2022-04-28 10:09:50 +02:00
Simon Ser
ec28457508 backend: error out in autocreate without libinput support
The libinput backend is now optional. However, this means that a
user building wlroots without the correct libinput dependencies
will end up with a compositor which doesn't respond to input events.

wlr_backend_autocreate is supposed to return a sensible setup, so in
this case let's just error out and explain what happened. Users can
suppress the check by setting WLR_LIBINPUT_NO_DEVICES=1 (already used
to suppress the zero input device case inside the libinput backend).

Compositors which really want to create a bare DRM backend can easily
create it manually instead of using wlr_backend_autocreate.
2021-12-20 13:56:09 +00:00
Chris Chamberlain
d8ca494558 backend/drm: add wlr_drm_backend_monitor
This helper is responsible for listening for new DRM devices and
create new child DRM backends as necessary.
2021-12-13 14:55:16 +01:00
Chris Chamberlain
f6d3efbf4b backend: fix return value of attempt_drm_backend
The multi backend was returned instead of the primary DRM backend.
2021-12-13 14:53:41 +01:00
Simon Zeni
1d3dd7fc08 backend: remove noop backend 2021-11-25 16:49:05 +00:00
Simon Zeni
c0fd60be63 backend: fix attempt_backend_by_name multi backend self insertion 2021-11-19 10:44:51 -05:00
Simon Zeni
fdf3169b41 backend: remove wlr_backend_get_renderer 2021-11-18 09:37:57 -05:00
Simon Zeni
6dc6af1534 backend: remove backend_get_allocator 2021-11-18 09:37:57 -05:00
Simon Zeni
0c76aef202 backend: remove backend ensure renderer and allocator check 2021-11-18 09:37:57 -05:00
MarkusVolk
ebe3cfaceb backend.c: do not try to explicitly clean up the libinput backend
Since libinput is an optional dependency the libinput backend is possibly undeclared.
wlr_backend_destroy(backend) below will clean up the child libinput backend if any.
2021-10-27 14:54:01 +02:00
Anthony Super
e22a386319 Add error handling to backend creation
This commit adds two error-handling cases to the function
attempt_dmr_backend. Specifically:

- In the case where the number of found GPUs is zero, we now
  print a log message indicating this and return a NULL pointer
- In the case where we could not successfully create a backend
  on any GPU, we now log a message indicating this and return
  a NULL pointer

This allows us to provide more descriptive error messages,
as well as avoid a SEGFAULT (the function
`ensure_primary_backend_renderer_and_allocator` dereferences the pointer
given, which could be NULL until this patch) when these cases arise.
2021-10-18 14:36:04 +02:00
Jan Beich
31af2b67b0 backend: drop unconditional and unused <libinput.h>
After 70fb21c35b made libinput optional the include prevents
building without libinput package installed.

backend/backend.c:4:10: fatal error: 'libinput.h' file not found
 #include <libinput.h>
          ^~~~~~~~~~~~
2021-10-05 09:11:44 +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
muradm
35f0a0d570 backend: wait for session to become active 2021-09-07 20:28:02 +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
c74dc45bb6 backend/drm: drop get_renderer implementation
We can now just rely on the common code for this.
2021-07-28 22:52:35 +02:00
ayaka
70fb21c35b backend: make DRM and libinput backends optional
Co-authored-by: Simon Ser <contact@emersion.fr>
2021-07-22 09:56:38 -04:00
Simon Ser
4dae12890f backend: automatically create allocator
Introduce a new backend_get_allocator function that automatically
creates an allocator for the backend if the backend has a renderer.
2021-05-21 22:13:54 +02:00
Simon Ser
bcabe34a2e backend: automatically create renderer
If a backend accepts buffers (as indicated by get_buffer_caps) but
doesn't implement get_renderer, automatically create a renderer.
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 Ser
1c1ef69326 Log when WLR_BACKENDS/WLR_RENDERER is set
Makes it easier to figure out why a backend/renderer is picked.
2021-04-28 21:06:41 +02:00
Simon Zeni
144189674e backend: introduce backend_get_buffer_caps 2021-04-28 20:55:57 +02:00
Roman Gilg
b36af22c94 backend: move get_drm_fd to public interface
The get_drm_fd was made available in an internal header with a53ab146f. Move it
now to the public header so consumers opting in to the unstable interfaces can
make use of it.
2021-04-12 11:43:56 +02:00
Simon Ser
a53ab146fe backend: add get_drm_fd to interface
This function allows backends to return the DRM FD they are using. This
will allow the allocator and the renderer to use the right device.
2021-01-16 08:57:42 +01:00
Simon Ser
e8d56ca415 backend/session: allow wlr_session_find_gpus to return an error
Sometimes wlr_session_find_gpus will encounter an error. This is
different from finding zero GPUs.

On error, wlr_session_find_gpus already returns -1. However, this is
casted to size_t, so callers uncorrectly assume this is a success.

Instead, make wlr_session_find_gpus return a ssize_t and allow callers
to handle the error accordingly.
2021-01-04 19:46:44 +01:00