mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-06 21:45:58 +01:00
Use env helpers
This commit is contained in:
parent
31a9fc1fb6
commit
8bd7170fd9
7 changed files with 70 additions and 96 deletions
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wlr/util/region.h>
|
||||
#include <xf86drm.h>
|
||||
#include "render/egl.h"
|
||||
#include "util/env.h"
|
||||
|
||||
static enum wlr_log_importance egl_log_importance_to_wlr(EGLint type) {
|
||||
switch (type) {
|
||||
|
@ -284,8 +285,7 @@ static bool egl_init_display(struct wlr_egl *egl, EGLDisplay *display) {
|
|||
}
|
||||
|
||||
if (check_egl_ext(device_exts_str, "EGL_MESA_device_software")) {
|
||||
const char *allow_software = getenv("WLR_RENDERER_ALLOW_SOFTWARE");
|
||||
if (allow_software != NULL && strcmp(allow_software, "1") == 0) {
|
||||
if (env_parse_bool("WLR_RENDERER_ALLOW_SOFTWARE")) {
|
||||
wlr_log(WLR_INFO, "Using software rendering");
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Software rendering detected, please use "
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "backend/backend.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
#include "util/env.h"
|
||||
|
||||
void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||
const struct wlr_renderer_impl *impl) {
|
||||
|
@ -266,54 +267,65 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
|
|||
return true;
|
||||
}
|
||||
|
||||
struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd) {
|
||||
const char *name = getenv("WLR_RENDERER");
|
||||
if (name) {
|
||||
wlr_log(WLR_INFO, "Loading user-specified renderer due to WLR_RENDERER: %s",
|
||||
name);
|
||||
static void log_creation_failure(bool is_auto, const char *msg) {
|
||||
wlr_log(is_auto ? WLR_DEBUG : WLR_ERROR, "%s%s", msg, is_auto ? ". Skipping!" : "");
|
||||
}
|
||||
|
||||
struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd) {
|
||||
const char *renderer_options[] = {
|
||||
"auto",
|
||||
#if WLR_HAS_GLES2_RENDERER
|
||||
if (strcmp(name, "gles2") == 0) {
|
||||
if (drm_fd < 0) {
|
||||
wlr_log(WLR_ERROR, "Cannot create GLES2 renderer: "
|
||||
"no DRM FD available");
|
||||
return NULL;
|
||||
}
|
||||
return wlr_gles2_renderer_create_with_drm_fd(drm_fd);
|
||||
}
|
||||
"gles2",
|
||||
#endif
|
||||
#if WLR_HAS_VULKAN_RENDERER
|
||||
if (strcmp(name, "vulkan") == 0) {
|
||||
return wlr_vk_renderer_create_with_drm_fd(drm_fd);
|
||||
}
|
||||
"vulkan",
|
||||
#endif
|
||||
if (strcmp(name, "pixman") == 0) {
|
||||
return wlr_pixman_renderer_create();
|
||||
}
|
||||
|
||||
wlr_log(WLR_ERROR, "Invalid WLR_RENDERER value: '%s'", name);
|
||||
return NULL;
|
||||
}
|
||||
"pixman",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *renderer_name = renderer_options[env_parse_switch("WLR_RENDERER", renderer_options)];
|
||||
bool is_auto = strcmp(renderer_name, "auto") == 0;
|
||||
struct wlr_renderer *renderer = NULL;
|
||||
|
||||
#if WLR_HAS_GLES2_RENDERER
|
||||
if (drm_fd >= 0) {
|
||||
if ((renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd)) != NULL) {
|
||||
return renderer;
|
||||
if (!renderer && (is_auto || strcmp(renderer_name, "gles2") == 0)) {
|
||||
if (drm_fd < 0) {
|
||||
log_creation_failure(is_auto, "Cannot create GLES2 renderer: no DRM FD available");
|
||||
} else {
|
||||
renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd);
|
||||
if (!renderer) {
|
||||
log_creation_failure(is_auto, "Failed to create a GLES2 renderer");
|
||||
}
|
||||
}
|
||||
wlr_log(WLR_DEBUG, "Failed to create GLES2 renderer");
|
||||
} else {
|
||||
wlr_log(WLR_DEBUG, "Skipping GLES2 renderer: no DRM FD available");
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((renderer = wlr_pixman_renderer_create()) != NULL) {
|
||||
return renderer;
|
||||
#if WLR_HAS_VULKAN_RENDERER
|
||||
if (!renderer && (is_auto || strcmp(renderer_name, "vulkan") == 0)) {
|
||||
if (drm_fd < 0) {
|
||||
log_creation_failure(is_auto, "Cannot create Vulkan renderer: no DRM FD available");
|
||||
} else {
|
||||
renderer = wlr_vk_renderer_create_with_drm_fd(drm_fd);
|
||||
if (!renderer) {
|
||||
log_creation_failure(is_auto, "Failed to create a Vulkan renderer");
|
||||
}
|
||||
}
|
||||
}
|
||||
wlr_log(WLR_DEBUG, "Failed to create pixman renderer");
|
||||
#endif
|
||||
|
||||
wlr_log(WLR_ERROR, "Could not initialize renderer");
|
||||
return NULL;
|
||||
if (!renderer && (is_auto || strcmp(renderer_name, "pixman") == 0)) {
|
||||
renderer = wlr_pixman_renderer_create();
|
||||
if (!renderer) {
|
||||
log_creation_failure(is_auto, "Failed to create a pixman renderer");
|
||||
}
|
||||
}
|
||||
|
||||
if (!renderer) {
|
||||
wlr_log(WLR_ERROR, "Could not initialize renderer");
|
||||
}
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static int open_drm_render_node(void) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "render/allocator/allocator.h"
|
||||
#include "render/swapchain.h"
|
||||
#include "types/wlr_output.h"
|
||||
#include "util/env.h"
|
||||
#include "util/global.h"
|
||||
|
||||
#define OUTPUT_VERSION 4
|
||||
|
@ -366,11 +367,9 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
|||
wl_signal_init(&output->events.destroy);
|
||||
output_state_init(&output->pending);
|
||||
|
||||
const char *no_hardware_cursors = getenv("WLR_NO_HARDWARE_CURSORS");
|
||||
if (no_hardware_cursors != NULL && strcmp(no_hardware_cursors, "1") == 0) {
|
||||
wlr_log(WLR_DEBUG,
|
||||
"WLR_NO_HARDWARE_CURSORS set, forcing software cursors");
|
||||
output->software_cursor_locks = 1;
|
||||
output->software_cursor_locks = env_parse_bool("WLR_NO_HARDWARE_CURSORS");
|
||||
if (output->software_cursor_locks) {
|
||||
wlr_log(WLR_DEBUG, "WLR_NO_HARDWARE_CURSORS set, forcing software cursors");
|
||||
}
|
||||
|
||||
wlr_addon_set_init(&output->addons);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "types/wlr_buffer.h"
|
||||
#include "types/wlr_scene.h"
|
||||
#include "util/array.h"
|
||||
#include "util/env.h"
|
||||
#include "util/time.h"
|
||||
|
||||
#define HIGHLIGHT_DAMAGE_FADEOUT_TIME 250
|
||||
|
@ -150,49 +151,16 @@ struct wlr_scene *wlr_scene_create(void) {
|
|||
wl_list_init(&scene->outputs);
|
||||
wl_list_init(&scene->presentation_destroy.link);
|
||||
|
||||
char *debug_damage = getenv("WLR_SCENE_DEBUG_DAMAGE");
|
||||
if (debug_damage) {
|
||||
wlr_log(WLR_INFO, "Loading WLR_SCENE_DEBUG_DAMAGE option: %s", debug_damage);
|
||||
}
|
||||
const char *debug_damage_options[] = {
|
||||
"none",
|
||||
"rerender",
|
||||
"highlight",
|
||||
NULL
|
||||
};
|
||||
|
||||
if (!debug_damage || strcmp(debug_damage, "none") == 0) {
|
||||
scene->debug_damage_option = WLR_SCENE_DEBUG_DAMAGE_NONE;
|
||||
} else if (strcmp(debug_damage, "rerender") == 0) {
|
||||
scene->debug_damage_option = WLR_SCENE_DEBUG_DAMAGE_RERENDER;
|
||||
} else if (strcmp(debug_damage, "highlight") == 0) {
|
||||
scene->debug_damage_option = WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Unknown WLR_SCENE_DEBUG_DAMAGE option: %s", debug_damage);
|
||||
scene->debug_damage_option = WLR_SCENE_DEBUG_DAMAGE_NONE;
|
||||
}
|
||||
|
||||
char *disable_direct_scanout = getenv("WLR_SCENE_DISABLE_DIRECT_SCANOUT");
|
||||
if (disable_direct_scanout) {
|
||||
wlr_log(WLR_INFO, "Loading WLR_SCENE_DISABLE_DIRECT_SCANOUT option: %s", disable_direct_scanout);
|
||||
}
|
||||
|
||||
if (!disable_direct_scanout || strcmp(disable_direct_scanout, "0") == 0) {
|
||||
scene->direct_scanout = true;
|
||||
} else if (strcmp(disable_direct_scanout, "1") == 0) {
|
||||
scene->direct_scanout = false;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Unknown WLR_SCENE_DISABLE_DIRECT_SCANOUT option: %s", disable_direct_scanout);
|
||||
scene->direct_scanout = true;
|
||||
}
|
||||
|
||||
char *visibility_disabled = getenv("WLR_SCENE_DISABLE_VISIBILITY");
|
||||
if (visibility_disabled) {
|
||||
wlr_log(WLR_INFO, "Loading WLR_SCENE_DISABLE_VISIBILITY option: %s", visibility_disabled);
|
||||
}
|
||||
|
||||
if (!visibility_disabled || strcmp(visibility_disabled, "0") == 0) {
|
||||
scene->calculate_visibility = true;
|
||||
} else if (strcmp(visibility_disabled, "1") == 0) {
|
||||
scene->calculate_visibility = false;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Unknown WLR_SCENE_DISABLE_VISIBILITY option: %s", visibility_disabled);
|
||||
scene->calculate_visibility = true;
|
||||
}
|
||||
scene->debug_damage_option = env_parse_switch("WLR_SCENE_DEBUG_DAMAGE", debug_damage_options);
|
||||
scene->direct_scanout = !env_parse_bool("WLR_SCENE_DISABLE_DIRECT_SCANOUT");
|
||||
scene->calculate_visibility = !env_parse_bool("WLR_SCENE_DISABLE_VISIBILITY");
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue