-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathx11.c
53 lines (44 loc) · 1.19 KB
/
x11.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <dlfcn.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "wth.h"
typedef int (*XChangeProperty_func_type)(
Display *display,
Window w,
Atom property,
Atom type,
int format,
int mode,
const unsigned char *data,
int nelements
);
static struct wth_once once = WTH_ONCE_INITIALIZER;
static const char *new_title;
static XChangeProperty_func_type XChangeProperty_orig;
static Atom _NET_WM_NAME;
static void init_once(void *user_arg)
{
/* Cache original function pointer */
XChangeProperty_orig = dlsym(RTLD_NEXT, "XChangeProperty");
new_title = wth_get_title();
Display *display = user_arg;
_NET_WM_NAME = XInternAtom(display, "_NET_WM_NAME", 0);
}
int XChangeProperty(
Display *display,
Window w,
Atom property,
Atom type,
int format,
int mode,
const unsigned char *data,
int nelements
) {
wth_init_once(&once, init_once, display);
if (property == XA_WM_NAME || property == _NET_WM_NAME) {
data = (const unsigned char *)new_title;
nelements = (int)strlen(new_title);
}
return XChangeProperty_orig(display, w, property, type, format, mode, data, nelements);
}