aboutsummaryrefslogtreecommitdiff
path: root/backend/backend.c
AgeCommit message (Collapse)Author
2024-02-15Define _POSIX_C_SOURCE globallySimon Ser
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead, require POSIX.1-2008 globally. A lot of core source files depend on that already. Some care must be taken on a few select files where we need a bit more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and some files need BSD extensions (_DEFAULT_SOURCE). In both cases, these feature test macros imply _POSIX_C_SOURCE. Make sure to not define both these macros and _POSIX_C_SOURCE explicitly to avoid POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001 but _XOPEN_SOURCE says POSIX.1-2008). Additionally, there is one special case in render/vulkan/vulkan.c. That file needs major()/minor(), and these are system-specific. On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need to make sure it's not defined for this file. On Linux, we can explicitly include <sys/sysmacros.h> and ensure that apart from symbols defined there the file only uses POSIX toys.
2024-01-25backend: take wl_event_loop instead of wl_display in wlr_backend_autocreate()Simon Ser
2024-01-25backend/multi: take wl_event_loop instead of wl_displaySimon Ser
2024-01-25backend/drm: drop wl_display argumentSimon Ser
We can grab the event loop from the wlr_session instead.
2024-01-25backend/x11: take wl_event_loop instead of wl_displaySimon Ser
2024-01-25backend/wayland: take wl_event_loop instead of wl_displaySimon Ser
2024-01-25backend/libinput: drop wl_display argumentSimon Ser
We can grab the event loop from the wlr_session instead.
2024-01-25backend/headless: take wl_event_loop instead of wl_displaySimon Ser
2024-01-25backend: destroy multi backend when primary backend isSimon Ser
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-25backend: make attempt_drm_backend() return the primary backendSimon Ser
We'll need this in the next commit.
2023-11-23backend/session: take wl_event_loop instead of wl_displaySimon Ser
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-10-30backend: drop wlr_backend_get_presentation_clock()Simon Ser
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-07-07Use struct initializers instead of memset()Simon Ser
This is a bit more type-safe.
2023-02-27backend: move #ifdefs to nested functionsSimon Ser
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-27backend: make wlr_backend_autocreate() fail when DRM is missingSimon Ser
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-21backend: disable DRM backend monitor when WLR_DRM_DEVICES is usedSimon Ser
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-21backend: avoid adding NULL backend in attempt_backend_by_name()Simon Ser
2023-02-21backend: create DRM backend monitor when WLR_BACKENDS is usedSimon Ser
2022-11-25backend/session: make optionalSimon Ser
Some compositors are not interested in wlr_session, for instance nested compositors. Disabling wlr_session removes the udev dependency.
2022-11-25backend: use time helpers to implement timeoutsSimon Ser
Instead of hand-rolling get_current_time_msec(), let's just re-use the helper we already have in "util/time.h".
2022-11-25backend: error out when missing DRM and libinput in wlr_backend_autocreate()Simon Ser
Instead of returning an empty multi backend, fail with a clear error when both the DRM and libinput backends are disabled.
2022-11-15backend: rename backend to multi in wlr_backend_autocreate()Simon Ser
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-15backend: drop wlr_backend_get_session()Simon Ser
This no longer has purpose.
2022-11-15backend: return wlr_session in wlr_backend_autocreate() callSimon Ser
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-08-22Use env helpersAlexander Orzechowski
2022-08-18Use wl_signal_emit_mutableAlexander Orzechowski
2022-04-28Zero-initialize structs in init functionsSimon Ser
Ensures there is no field left to its previous undefined value after calling an init function.
2021-12-20backend: error out in autocreate without libinput supportSimon Ser
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-13backend/drm: add wlr_drm_backend_monitorChris Chamberlain
This helper is responsible for listening for new DRM devices and create new child DRM backends as necessary.
2021-12-13backend: fix return value of attempt_drm_backendChris Chamberlain
The multi backend was returned instead of the primary DRM backend.
2021-11-25backend: remove noop backendSimon Zeni
2021-11-19backend: fix attempt_backend_by_name multi backend self insertionSimon Zeni
2021-11-18backend: remove wlr_backend_get_rendererSimon Zeni
2021-11-18backend: remove backend_get_allocatorSimon Zeni
2021-11-18backend: remove backend ensure renderer and allocator checkSimon Zeni
2021-10-27backend.c: do not try to explicitly clean up the libinput backendMarkusVolk
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-18Add error handling to backend creationAnthony Super
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-05backend: drop unconditional and unused <libinput.h>Jan Beich
After 70fb21c35ba4 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-09-30backend: create renderer and allocator in wlr_backend_autocreateSimon Ser
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-07backend: wait for session to become activemuradm
2021-08-25Move allocator stuff into new directorySimon Ser
Add render/allocator/ and include/render/allocator/ to hold everything allocator-related.
2021-07-28backend/drm: drop get_renderer implementationSimon Ser
We can now just rely on the common code for this.
2021-07-22backend: make DRM and libinput backends optionalayaka
Co-authored-by: Simon Ser <contact@emersion.fr>
2021-05-21backend: automatically create allocatorSimon Ser
Introduce a new backend_get_allocator function that automatically creates an allocator for the backend if the backend has a renderer.
2021-05-21backend: automatically create rendererSimon Ser
If a backend accepts buffers (as indicated by get_buffer_caps) but doesn't implement get_renderer, automatically create a renderer.
2021-05-21backend: introduce wlr_backend_finishSimon Ser
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-04-28Log when WLR_BACKENDS/WLR_RENDERER is setSimon Ser
Makes it easier to figure out why a backend/renderer is picked.
2021-04-28backend: introduce backend_get_buffer_capsSimon Zeni
2021-04-12backend: move get_drm_fd to public interfaceRoman Gilg
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-01-16backend: add get_drm_fd to interfaceSimon Ser
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.