mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Use #if instead of #ifdef for wlroots config data
This prevents some annoying issues when e.g. not including wlr/config.h or making a typo in the guard name.
This commit is contained in:
parent
3181c4bec0
commit
51bfdd620e
25 changed files with 69 additions and 61 deletions
|
|
@ -17,8 +17,7 @@
|
|||
#include <wlr/util/log.h>
|
||||
#include "backend/multi.h"
|
||||
|
||||
/* WLR_HAS_X11_BACKEND needs to be after wlr/config.h */
|
||||
#ifdef WLR_HAS_X11_BACKEND
|
||||
#if WLR_HAS_X11_BACKEND
|
||||
#include <wlr/backend/x11.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -102,7 +101,7 @@ static struct wlr_backend *attempt_wl_backend(struct wl_display *display,
|
|||
return backend;
|
||||
}
|
||||
|
||||
#ifdef WLR_HAS_X11_BACKEND
|
||||
#if WLR_HAS_X11_BACKEND
|
||||
static struct wlr_backend *attempt_x11_backend(struct wl_display *display,
|
||||
const char *x11_display, wlr_renderer_create_func_t create_renderer_func) {
|
||||
struct wlr_backend *backend = wlr_x11_backend_create(display, x11_display, create_renderer_func);
|
||||
|
|
@ -165,7 +164,7 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
|
|||
const char *name, wlr_renderer_create_func_t create_renderer_func) {
|
||||
if (strcmp(name, "wayland") == 0) {
|
||||
return attempt_wl_backend(display, create_renderer_func);
|
||||
#ifdef WLR_HAS_X11_BACKEND
|
||||
#if WLR_HAS_X11_BACKEND
|
||||
} else if (strcmp(name, "x11") == 0) {
|
||||
return attempt_x11_backend(display, NULL, create_renderer_func);
|
||||
#endif
|
||||
|
|
@ -248,7 +247,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef WLR_HAS_X11_BACKEND
|
||||
#if WLR_HAS_X11_BACKEND
|
||||
const char *x11_display = getenv("DISPLAY");
|
||||
if (x11_display) {
|
||||
struct wlr_backend *x11_backend =
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
enum { DRM_MAJOR = 226 };
|
||||
|
||||
#ifdef WLR_HAS_LIBCAP
|
||||
#if WLR_HAS_LIBCAP
|
||||
#include <sys/capability.h>
|
||||
|
||||
static bool have_permissions(void) {
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@
|
|||
#include <wlr/util/log.h>
|
||||
#include "util/signal.h"
|
||||
|
||||
#ifdef WLR_HAS_SYSTEMD
|
||||
#if WLR_HAS_SYSTEMD
|
||||
#include <systemd/sd-bus.h>
|
||||
#include <systemd/sd-login.h>
|
||||
#elif defined(WLR_HAS_ELOGIND)
|
||||
#elif WLR_HAS_ELOGIND
|
||||
#include <elogind/sd-bus.h>
|
||||
#include <elogind/sd-login.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ extern const struct session_impl session_logind;
|
|||
extern const struct session_impl session_direct;
|
||||
|
||||
static const struct session_impl *impls[] = {
|
||||
#if defined(WLR_HAS_SYSTEMD) || defined(WLR_HAS_ELOGIND)
|
||||
#if WLR_HAS_SYSTEMD || WLR_HAS_ELOGIND
|
||||
&session_logind,
|
||||
#endif
|
||||
&session_direct,
|
||||
|
|
@ -70,7 +70,7 @@ struct wlr_session *wlr_session_create(struct wl_display *disp) {
|
|||
const char *env_wlr_session = getenv("WLR_SESSION");
|
||||
if (env_wlr_session) {
|
||||
if (!strcmp(env_wlr_session, "logind") || !strcmp(env_wlr_session, "systemd")) {
|
||||
#if defined(WLR_HAS_SYSTEMD) || defined(WLR_HAS_ELOGIND)
|
||||
#if WLR_HAS_SYSTEMD || WLR_HAS_ELOGIND
|
||||
session = session_logind.create(disp);
|
||||
#else
|
||||
wlr_log(WLR_ERROR, "wlroots is not compiled with logind support");
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include <wlr/util/log.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
#include <xcb/xcb.h>
|
||||
#ifdef WLR_HAS_XCB_XKB
|
||||
#if WLR_HAS_XCB_XKB
|
||||
#include <xcb/xkb.h>
|
||||
#endif
|
||||
#include "backend/x11.h"
|
||||
|
|
@ -148,7 +148,7 @@ static bool backend_start(struct wlr_backend *backend) {
|
|||
0, 0);
|
||||
xcb_free_pixmap(x11->xcb_conn, pix);
|
||||
|
||||
#ifdef WLR_HAS_XCB_XKB
|
||||
#if WLR_HAS_XCB_XKB
|
||||
const xcb_query_extension_reply_t *reply =
|
||||
xcb_get_extension_data(x11->xcb_conn, &xcb_xkb_id);
|
||||
if (reply != NULL && reply->present) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#elif __FreeBSD__
|
||||
#include <dev/evdev/input-event-codes.h>
|
||||
#endif
|
||||
#ifdef WLR_HAS_XCB_XKB
|
||||
#if WLR_HAS_XCB_XKB
|
||||
#include <xcb/xkb.h>
|
||||
#endif
|
||||
#include "backend/x11.h"
|
||||
|
|
@ -124,7 +124,7 @@ void handle_x11_input_event(struct wlr_x11_backend *x11,
|
|||
return;
|
||||
}
|
||||
default:
|
||||
#ifdef WLR_HAS_XCB_XKB
|
||||
#if WLR_HAS_XCB_XKB
|
||||
if (x11->xkb_supported && event->response_type == x11->xkb_base_event) {
|
||||
xcb_xkb_state_notify_event_t *ev =
|
||||
(xcb_xkb_state_notify_event_t *)event;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ foreach lib : x11_optional
|
|||
dep = dependency(lib, required: get_option(lib))
|
||||
if dep.found()
|
||||
x11_libs += dep
|
||||
conf_data.set('WLR_HAS_' + lib.underscorify().to_upper(), true)
|
||||
conf_data.set10('WLR_HAS_' + lib.underscorify().to_upper(), true)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
|
|
@ -41,4 +41,4 @@ lib_wlr_backend_x11 = static_library(
|
|||
)
|
||||
|
||||
backend_parts += lib_wlr_backend_x11
|
||||
conf_data.set('WLR_HAS_X11_BACKEND', true)
|
||||
conf_data.set10('WLR_HAS_X11_BACKEND', true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue