diff --git a/Xext/namespace/config.c b/Xext/namespace/config.c new file mode 100644 index 000000000..424b9c1f1 --- /dev/null +++ b/Xext/namespace/config.c @@ -0,0 +1,39 @@ +#include + +#include +#include + +#include "namespace.h" + +struct Xnamespace ns_root = { + .builtin = TRUE, + .name = NS_NAME_ROOT, + .refcnt = 1, + .superPower = TRUE, +}; + +struct Xnamespace ns_anon = { + .builtin = TRUE, + .name = NS_NAME_ANONYMOUS, + .refcnt = 1, +}; + +struct xorg_list ns_list = { 0 }; + +Bool XnsLoadConfig(void) +{ + xorg_list_init(&ns_list); + xorg_list_add(&ns_root.entry, &ns_list); + xorg_list_add(&ns_anon.entry, &ns_list); + + return TRUE; +} + +struct Xnamespace *XnsFindByName(const char* name) { + struct Xnamespace *walk; + xorg_list_for_each_entry(walk, &ns_list, entry) { + if (strcmp(walk->name, name)==0) + return walk; + } + return NULL; +} diff --git a/Xext/namespace/meson.build b/Xext/namespace/meson.build index f8ce18fe8..78dd9f1cb 100644 --- a/Xext/namespace/meson.build +++ b/Xext/namespace/meson.build @@ -1,6 +1,7 @@ libxserver_namespace = static_library( 'libxserver_namespace', [ + 'config.c', 'namespace.c', ], include_directories: inc, diff --git a/Xext/namespace/namespace.c b/Xext/namespace/namespace.c index 21fe72e88..82c4db3db 100644 --- a/Xext/namespace/namespace.c +++ b/Xext/namespace/namespace.c @@ -1,5 +1,6 @@ #include +#include #include #include "include/extinit_priv.h" @@ -13,4 +14,10 @@ void NamespaceExtensionInit(void) { XNS_LOG("initializing namespace extension ...\n"); + + /* load configuration */ + if (!XnsLoadConfig()) { + XNS_LOG("No config file. disabling Xns extension\n"); + return; + } } diff --git a/Xext/namespace/namespace.h b/Xext/namespace/namespace.h index 96a307bb4..8100ad139 100644 --- a/Xext/namespace/namespace.h +++ b/Xext/namespace/namespace.h @@ -4,6 +4,27 @@ #include #include +#include "include/list.h" +#include "include/window.h" + +struct Xnamespace { + struct xorg_list entry; + const char *name; + Bool builtin; + Bool superPower; + size_t refcnt; +}; + +extern struct xorg_list ns_list; +extern struct Xnamespace ns_root; +extern struct Xnamespace ns_anon; + +#define NS_NAME_ROOT "root" +#define NS_NAME_ANONYMOUS "anon" + +Bool XnsLoadConfig(void); +struct Xnamespace *XnsFindByName(const char* name); + #define XNS_LOG(...) do { printf("XNS "); printf(__VA_ARGS__); } while (0) static inline Bool streq(const char *a, const char *b)