static XIA *xia = NULL;
static XCP *xcp = NULL;
+#ifdef _GNU_SOURCE
+ /* load the function pointer with RTLD_NEXT
+ * this might be the real X function or another
+ * preloaded intercept
+ */
+ if (!lib_xlib)
+ lib_xlib = RTLD_NEXT;
+#else
/* find the real Xlib and the real X function */
if (!lib_xlib)
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
- if (!xia)
+#endif
+ if (lib_xlib && !xia)
xia = (XIA *) dlsym(lib_xlib, "XInternAtom");
- if (!xcp)
+ if (lib_xlib && !xcp)
xcp = (XCP *) dlsym(lib_xlib, "XChangeProperty");
+ if (!xia || !xcp) {
+ fprintf(stderr, "libswmhack.so: ERROR: %s\n", dlerror());
+ return;
+ }
/* Try to update the window's workspace property */
atom = (*xia)(dpy, name, False);
char *env;
Window id;
+#ifdef _GNU_SOURCE
+ /* load the function pointer with RTLD_NEXT
+ * this might be the real X function or another
+ * preloaded intercept
+ */
+ if (!lib_xlib)
+ lib_xlib = RTLD_NEXT;
+#else
/* find the real Xlib and the real X function */
if (!lib_xlib)
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
- if (!func) {
+#endif
+ if (lib_xlib && !func) {
func = (CWF *) dlsym(lib_xlib, "XCreateWindow");
display = dpy;
}
+ if (!func) {
+ fprintf(stderr, "libswmhack.so: ERROR: %s\n", dlerror());
+ return BadImplementation;
+ }
if (parent == DefaultRootWindow(dpy))
parent = MyRoot(dpy);
char *env;
Window id;
+#ifdef _GNU_SOURCE
+ /* load the function pointer with RTLD_NEXT
+ * this might be the real X function or another
+ * preloaded intercept
+ */
+ if (!lib_xlib)
+ lib_xlib = RTLD_NEXT;
+#else
/* find the real Xlib and the real X function */
if (!lib_xlib)
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
- if (!func)
+#endif
+ if (lib_xlib && !func)
func = (CSWF *) dlsym(lib_xlib, "XCreateSimpleWindow");
+ if (!func) {
+ fprintf(stderr, "libswmhack.so: ERROR: %s\n", dlerror());
+ return BadImplementation;
+ }
if (parent == DefaultRootWindow(dpy))
parent = MyRoot(dpy);
{
static RWF *func = NULL;
+#ifdef _GNU_SOURCE
+ /* load the function pointer with RTLD_NEXT
+ * this might be the real X function or another
+ * preloaded intercept
+ */
+ if (!lib_xlib)
+ lib_xlib = RTLD_NEXT;
+#else
/* find the real Xlib and the real X function */
if (!lib_xlib)
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
- if (!func)
+#endif
+ if (lib_xlib && !func)
func = (RWF *) dlsym(lib_xlib, "XReparentWindow");
+ if (!func) {
+ fprintf(stderr, "libswmhack.so: ERROR: %s\n", dlerror());
+ return BadImplementation;
+ }
if (parent == DefaultRootWindow(dpy))
parent = MyRoot(dpy);
static ANEF *func = NULL;
static KeyCode kp_add = 0, kp_subtract = 0;
+#ifdef _GNU_SOURCE
+ /* load the function pointer with RTLD_NEXT
+ * this might be the real X function or another
+ * preloaded intercept
+ */
+ if (!lib_xtlib)
+ lib_xtlib = RTLD_NEXT;
+#else
/* find the real Xlib and the real X function */
if (!lib_xtlib)
lib_xtlib = dlopen("libXt.so", RTLD_GLOBAL | RTLD_LAZY);
- if (!func) {
+#endif
+ if (lib_xtlib && !func) {
func = (ANEF *) dlsym(lib_xtlib, "XtAppNextEvent");
if (display != NULL) {
kp_add = XKeysymToKeycode(display, XK_KP_Add);
kp_subtract = XKeysymToKeycode(display, XK_KP_Subtract);
}
}
+ if (!func) {
+ fprintf(stderr, "libswmhack.so: ERROR: %s\n", dlerror());
+ return;
+ }
(*func) (app_context, event_return);