aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorAlexander Orzechowski <orzechowski.alexander@gmail.com>2022-08-19 10:10:52 -0400
committerAlexander Orzechowski <orzechowski.alexander@gmail.com>2022-08-22 10:18:52 -0400
commit8bd7170fd95aa0753dc859457808d7f7f81d560d (patch)
treeb51d0586fae5ab51af9728616bbc9c2c91662d5f /backend
parent31a9fc1fb60f8001f43186d36e3fbb5fce584d91 (diff)
Use env helpers
Diffstat (limited to 'backend')
-rw-r--r--backend/backend.c4
-rw-r--r--backend/drm/drm.c7
-rw-r--r--backend/libinput/backend.c10
3 files changed, 8 insertions, 13 deletions
diff --git a/backend/backend.c b/backend/backend.c
index 32ddca97..4c886af6 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -17,6 +17,7 @@
#include "backend/backend.h"
#include "backend/multi.h"
#include "render/allocator/allocator.h"
+#include "util/env.h"
#if WLR_HAS_DRM_BACKEND
#include <wlr/backend/drm.h>
@@ -364,8 +365,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
}
wlr_multi_backend_add(backend, libinput);
#else
- const char *no_devs = getenv("WLR_LIBINPUT_NO_DEVICES");
- if (no_devs && strcmp(no_devs, "1") == 0) {
+ if (env_parse_bool("WLR_LIBINPUT_NO_DEVICES")) {
wlr_log(WLR_INFO, "WLR_LIBINPUT_NO_DEVICES is set, "
"starting without libinput backend");
} else {
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 9acb4175..94dd7023 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -29,6 +29,7 @@
#include "render/drm_format_set.h"
#include "render/swapchain.h"
#include "render/wlr_renderer.h"
+#include "util/env.h"
// Output state which needs a KMS commit to be applied
static const uint32_t COMMIT_OUTPUT_STATE =
@@ -74,8 +75,7 @@ bool check_drm_features(struct wlr_drm_backend *drm) {
return false;
}
- const char *no_atomic = getenv("WLR_DRM_NO_ATOMIC");
- if (no_atomic && strcmp(no_atomic, "1") == 0) {
+ if (env_parse_bool("WLR_DRM_NO_ATOMIC")) {
wlr_log(WLR_DEBUG,
"WLR_DRM_NO_ATOMIC set, forcing legacy DRM interface");
drm->iface = &legacy_iface;
@@ -91,8 +91,7 @@ bool check_drm_features(struct wlr_drm_backend *drm) {
int ret = drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap);
drm->clock = (ret == 0 && cap == 1) ? CLOCK_MONOTONIC : CLOCK_REALTIME;
- const char *no_modifiers = getenv("WLR_DRM_NO_MODIFIERS");
- if (no_modifiers != NULL && strcmp(no_modifiers, "1") == 0) {
+ if (env_parse_bool("WLR_DRM_NO_MODIFIERS")) {
wlr_log(WLR_DEBUG, "WLR_DRM_NO_MODIFIERS set, disabling modifiers");
} else {
ret = drmGetCap(drm->fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c
index 02c2f64b..688fae5d 100644
--- a/backend/libinput/backend.c
+++ b/backend/libinput/backend.c
@@ -6,6 +6,7 @@
#include <wlr/backend/session.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
+#include "util/env.h"
static struct wlr_libinput_backend *get_libinput_backend_from_backend(
struct wlr_backend *wlr_backend) {
@@ -103,13 +104,8 @@ static bool backend_start(struct wlr_backend *wlr_backend) {
libinput_log_set_priority(backend->libinput_context, LIBINPUT_LOG_PRIORITY_ERROR);
int libinput_fd = libinput_get_fd(backend->libinput_context);
- char *no_devs = getenv("WLR_LIBINPUT_NO_DEVICES");
- if (no_devs) {
- if (strcmp(no_devs, "1") != 0) {
- no_devs = NULL;
- }
- }
- if (!no_devs && wl_list_empty(&backend->devices)) {
+
+ if (!env_parse_bool("WLR_LIBINPUT_NO_DEVICES") && wl_list_empty(&backend->devices)) {
handle_libinput_readable(libinput_fd, WL_EVENT_READABLE, backend);
if (wl_list_empty(&backend->devices)) {
wlr_log(WLR_ERROR, "libinput initialization failed, no input devices");