X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=lib%2Fswm_hack.c;h=e6df1b080af3747f20f174789ee459bb482350dd;hb=63341d669cd6c063547eb381add1178da7828a95;hp=5d60d617b584f0635db47bc492b68575351de84f;hpb=bbb499e87a8c905214478e1badd67465701fc5cb;p=spectrwm.git diff --git a/lib/swm_hack.c b/lib/swm_hack.c index 5d60d61..e6df1b0 100644 --- a/lib/swm_hack.c +++ b/lib/swm_hack.c @@ -1,4 +1,3 @@ -/* $scrotwm$ */ /* * Copyright (c) 2009 Marco Peereboom * Copyright (c) 2009 Ryan McBride @@ -77,19 +76,38 @@ MyRoot(Display * dpy) return root; } + +typedef Atom (XIA) (Display *display, char *atom_name, Bool + only_if_exists); + +typedef int (XCP) (Display *display, Window w, Atom property, + Atom type, int format, int mode, unsigned char *data, + int nelements); + #define SWM_PROPLEN (16) void set_property(Display *dpy, Window id, char *name, char *val) { Atom atom = 0; char prop[SWM_PROPLEN]; + static XIA *xia = NULL; + static XCP *xcp = NULL; + + /* find the real Xlib and the real X function */ + if (!lib_xlib) + lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY); + if (!xia) + xia = (XIA *) dlsym(lib_xlib, "XInternAtom"); + if (!xcp) + xcp = (XCP *) dlsym(lib_xlib, "XChangeProperty"); /* Try to update the window's workspace property */ - atom = XInternAtom(dpy, name, False); - if (atom) + atom = (*xia)(dpy, name, False); + if (atom) if (snprintf(prop, SWM_PROPLEN, "%s", val) < SWM_PROPLEN) - XChangeProperty(dpy, id, atom, XA_STRING, - 8, PropModeReplace, prop, SWM_PROPLEN); + (*xcp)(dpy, id, atom, XA_STRING, + 8, PropModeReplace, (unsigned char *)prop, + strlen((char *)prop)); } typedef Window(CWF) (Display * _display, Window _parent, int _x,