[move-to-master] common/macros: change WLR_VERSION macro to runtime evaluation

This commit is contained in:
Consolatis 2026-04-04 16:58:05 +02:00
parent c9b4da2ce2
commit 379f06b1e8
3 changed files with 15 additions and 2 deletions

View file

@ -62,7 +62,11 @@
#define BOUNDED_INT(a) ((a) < INT_MAX && (a) > INT_MIN) #define BOUNDED_INT(a) ((a) < INT_MAX && (a) > INT_MIN)
#endif #endif
#define LAB_WLR_VERSION_AT_LEAST(major, minor, micro) \ #define _LAB_CALC_WLR_VERSION_NUM(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro))
(WLR_VERSION_NUM >= (((major) << 16) | ((minor) << 8) | (micro)))
#define LAB_WLR_VERSION_AT_LEAST(major, minor, micro) ( \
server.wlr_version >= _LAB_CALC_WLR_VERSION_NUM(major, minor, micro))
#define LAB_WLR_VERSION_LOWER(major, minor, micro) (!LAB_WLR_VERSION_AT_LEAST(major, minor, micro))
#endif /* LABWC_MACROS_H */ #endif /* LABWC_MACROS_H */

View file

@ -148,6 +148,8 @@ struct seat {
}; };
struct server { struct server {
uint32_t wlr_version;
struct wl_display *wl_display; struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop; /* Can be used for timer events */ struct wl_event_loop *wl_event_loop; /* Can be used for timer events */
struct wlr_renderer *renderer; struct wlr_renderer *renderer;

View file

@ -6,6 +6,7 @@
#include <unistd.h> #include <unistd.h>
#include "common/fd-util.h" #include "common/fd-util.h"
#include "common/font.h" #include "common/font.h"
#include "common/macros.h"
#include "common/spawn.h" #include "common/spawn.h"
#include "config/rcxml.h" #include "config/rcxml.h"
#include "config/session.h" #include "config/session.h"
@ -164,6 +165,12 @@ main(int argc, char *argv[])
char *primary_client = NULL; char *primary_client = NULL;
enum wlr_log_importance verbosity = WLR_ERROR; enum wlr_log_importance verbosity = WLR_ERROR;
server.wlr_version = _LAB_CALC_WLR_VERSION_NUM(
wlr_version_get_major(),
wlr_version_get_minor(),
wlr_version_get_micro()
);
int c; int c;
while (1) { while (1) {
int index = 0; int index = 0;