diff --git a/.builds/alpine.yml b/.builds/alpine.yml index 3caed3453..5427f2759 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -7,7 +7,6 @@ packages: - mesa-dev - meson - pixman-dev - - util-linux-dev - wayland-dev - wayland-protocols - xcb-util-image-dev diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index 7806b72cb..4262feed4 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -10,7 +10,6 @@ packages: - graphics/png - graphics/wayland - graphics/wayland-protocols - - misc/e2fsprogs-libuuid - multimedia/ffmpeg - x11/libX11 - x11/libinput diff --git a/README.md b/README.md index 83d818c65..f8f9583b0 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,6 @@ Install dependencies: * udev * pixman * libseat (optional, for (e)logind and seatd support) -* libuuid (optional, for xdg-foreign support) If you choose to enable X11 support: diff --git a/include/meson.build b/include/meson.build index c72eada54..747e59840 100644 --- a/include/meson.build +++ b/include/meson.build @@ -9,13 +9,6 @@ if not features.get('xwayland') else subdir('xwayland') endif -if not features.get('xdg-foreign') - exclude_files += [ - 'types/wlr_xdg_foreign_v1.h', - 'types/wlr_xdg_foreign_v2.h', - 'types/wlr_xdg_foreign_registry.h', - ] -endif install_subdir('wlr', install_dir: get_option('includedir'), diff --git a/include/util/token.h b/include/util/token.h new file mode 100644 index 000000000..bdfdaf45a --- /dev/null +++ b/include/util/token.h @@ -0,0 +1,9 @@ +#ifndef UTIL_TOKEN_H +#define UTIL_TOKEN_H + +#include + +#define TOKEN_STRLEN 33 +bool generate_token(char out[static TOKEN_STRLEN]); + +#endif diff --git a/include/util/uuid.h b/include/util/uuid.h deleted file mode 100644 index 2fecb4077..000000000 --- a/include/util/uuid.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef UTIL_UUID_H -#define UTIL_UUID_H - -#include - -bool generate_uuid(char out[static 37]); - -#endif diff --git a/include/wlr/config.h.in b/include/wlr/config.h.in index 15aacbfe4..bcea55a1f 100644 --- a/include/wlr/config.h.in +++ b/include/wlr/config.h.in @@ -7,6 +7,4 @@ #mesondefine WLR_HAS_XWAYLAND -#mesondefine WLR_HAS_XDG_FOREIGN - #endif diff --git a/meson.build b/meson.build index afa9c86ae..84e1a5213 100644 --- a/meson.build +++ b/meson.build @@ -84,7 +84,6 @@ features = { 'libseat': false, 'x11-backend': false, 'xwayland': false, - 'xdg-foreign': false, } internal_features = { 'xcb-errors': false, @@ -104,16 +103,6 @@ pixman = dependency('pixman-1') math = cc.find_library('m') rt = cc.find_library('rt') -if not get_option('xdg-foreign').disabled() - uuid = dependency('uuid', required: false) - uuid_create = cc.has_function('uuid_create') - if uuid.found() or uuid_create - features += { 'xdg-foreign': true } - elif get_option('xdg-foreign').enabled() - error('Missing dependency uuid and uuid_create function not available ' + - 'cannot build with xdg-foreign support') - endif -endif wlr_files = [] wlr_deps = [ diff --git a/meson_options.txt b/meson_options.txt index 770f604d9..033019ccc 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,4 +4,3 @@ option('xwayland', type: 'feature', value: 'auto', yield: true, description: 'En option('x11-backend', type: 'feature', value: 'auto', description: 'Enable X11 backend') option('examples', type: 'boolean', value: true, description: 'Build example applications') option('icon_directory', description: 'Location used to look for cursors (default: ${datadir}/icons)', type: 'string', value: '') -option('xdg-foreign', type: 'feature', value: 'auto', description: 'Enable xdg-foreign protocol') diff --git a/types/meson.build b/types/meson.build index d7b1bc5d6..47431429b 100644 --- a/types/meson.build +++ b/types/meson.build @@ -63,13 +63,9 @@ wlr_files += files( 'wlr_virtual_pointer_v1.c', 'wlr_xcursor_manager.c', 'wlr_xdg_decoration_v1.c', + 'wlr_xdg_foreign_v1.c', + 'wlr_xdg_foreign_v2.c', + 'wlr_xdg_foreign_registry.c', 'wlr_xdg_output_v1.c', ) -if features.get('xdg-foreign') - wlr_files += files( - 'wlr_xdg_foreign_v1.c', - 'wlr_xdg_foreign_v2.c', - 'wlr_xdg_foreign_registry.c', - ) -endif diff --git a/types/wlr_xdg_foreign_registry.c b/types/wlr_xdg_foreign_registry.c index 7af137b5f..0b75e5932 100644 --- a/types/wlr_xdg_foreign_registry.c +++ b/types/wlr_xdg_foreign_registry.c @@ -1,6 +1,6 @@ #include #include "util/signal.h" -#include "util/uuid.h" +#include "util/token.h" #include #include #include @@ -9,7 +9,7 @@ bool wlr_xdg_foreign_exported_init( struct wlr_xdg_foreign_exported *exported, struct wlr_xdg_foreign_registry *registry) { do { - if (!generate_uuid(exported->handle)) { + if (!generate_token(exported->handle)) { return false; } } while (wlr_xdg_foreign_registry_find_by_handle(registry, exported->handle) != NULL); diff --git a/util/meson.build b/util/meson.build index 9d3f15872..5e31cbbe4 100644 --- a/util/meson.build +++ b/util/meson.build @@ -6,11 +6,6 @@ wlr_files += files( 'shm.c', 'signal.c', 'time.c', + 'token.c', ) - -if features.get('xdg-foreign') - add_project_arguments('-DHAS_LIBUUID=@0@'.format(uuid.found().to_int()), language: 'c') - wlr_deps += uuid - wlr_files += files('uuid.c') -endif diff --git a/util/token.c b/util/token.c new file mode 100644 index 000000000..cf6034a32 --- /dev/null +++ b/util/token.c @@ -0,0 +1,29 @@ +#include "util/token.h" +#include "wlr/util/log.h" + +#include +#include +#include +#include + +bool generate_token(char out[static TOKEN_STRLEN]) { + static FILE *urandom = NULL; + uint64_t data[2]; + + if (!urandom) { + if (!(urandom = fopen("/dev/urandom", "r"))) { + wlr_log_errno(WLR_ERROR, "Failed to open random device"); + return false; + } + } + if (fread(data, sizeof(data), 1, urandom) != 1) { + wlr_log_errno(WLR_ERROR, "Failed to read from random device"); + return false; + } + if (snprintf(out, TOKEN_STRLEN, "%016" PRIx64 "%016" PRIx64, data[0], data[1]) != TOKEN_STRLEN - 1) { + wlr_log_errno(WLR_ERROR, "Failed to format hex string token"); + return false; + } + return true; +} + diff --git a/util/uuid.c b/util/uuid.c deleted file mode 100644 index 82e310b94..000000000 --- a/util/uuid.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include "util/uuid.h" - -#if HAS_LIBUUID -bool generate_uuid(char out[static 37]) { - uuid_t uuid; - uuid_generate_random(uuid); - uuid_unparse(uuid, out); - return true; -} -#else -#include -#include -#include - -bool generate_uuid(char out[static 37]) { - uuid_t uuid; - uint32_t status; - uuid_create(&uuid, &status); - if (status != uuid_s_ok) { - return false; - } - char *str; - uuid_to_string(&uuid, &str, &status); - if (status != uuid_s_ok) { - return false; - } - - assert(strlen(str) + 1 == 37); - memcpy(out, str, 37); - free(str); - return true; -} -#endif