From 81a7d915fd36a33fdb93cb4019a325a01a59d645 Mon Sep 17 00:00:00 2001 From: PekingSpades <180665176+PekingSpades@users.noreply.github.com> Date: Mon, 17 Nov 2025 16:52:09 +0800 Subject: [PATCH] linux: avoid 5s wait on init failure and fallback to libx11.so.6 --- clipboard_linux.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/clipboard_linux.c b/clipboard_linux.c index d23934b..7a9a13f 100644 --- a/clipboard_linux.c +++ b/clipboard_linux.c @@ -39,10 +39,15 @@ int initX11() { return 1; } libX11 = dlopen("libX11.so", RTLD_LAZY); - if (!libX11) { - return 0; - } - P_XOpenDisplay = (Display* (*)(int)) dlsym(libX11, "XOpenDisplay"); + if (!libX11) + { + libX11 = dlopen("libX11.so.6", RTLD_LAZY); + if (!libX11) + { + return 0; + } + } + P_XOpenDisplay = (Display* (*)(int)) dlsym(libX11, "XOpenDisplay"); P_XCloseDisplay = (void (*)(Display*)) dlsym(libX11, "XCloseDisplay"); P_XDefaultRootWindow = (Window (*)(Display*)) dlsym(libX11, "XDefaultRootWindow"); P_XCreateSimpleWindow = (Window (*)(Display*, Window, int, int, int, int, int, int, int)) dlsym(libX11, "XCreateSimpleWindow"); @@ -84,6 +89,7 @@ int clipboard_test() { // if the write is availiable for reading. int clipboard_write(char *typ, unsigned char *buf, size_t n, uintptr_t handle) { if (!initX11()) { + syncStatus(handle, -1); return -1; }