2 * Copyright (C) 2005-2007 Carsten Haitzler
3 * Copyright (C) 2006-2007 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Basic hack mechanism (dlopen etc.) taken from e_hack.c in e17.
36 /* dlopened xlib so we can find the symbols in the real xlib to call them */
37 static void *lib_xlib = NULL;
39 static Window root = None;
41 /* Find our root window */
50 root = DefaultRootWindow(dpy);
52 s = getenv("ENL_WM_ROOT");
56 sscanf(s, "%lx", &root);
60 typedef Window(CWF) (Display * _display, Window _parent, int _x,
61 int _y, unsigned int _width,
63 unsigned int _border_width, int _depth,
64 unsigned int _class, Visual * _visual,
65 unsigned long _valuemask,
66 XSetWindowAttributes * _attributes);
68 /* XCreateWindow intercept hack */
70 XCreateWindow(Display * display, Window parent, int x, int y,
71 unsigned int width, unsigned int height,
72 unsigned int border_width,
73 int depth, unsigned int clss, Visual * visual,
74 unsigned long valuemask, XSetWindowAttributes * attributes)
76 static CWF *func = NULL;
78 /* find the real Xlib and the real X function */
80 lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
82 func = (CWF *) dlsym(lib_xlib, "XCreateWindow");
84 if (parent == DefaultRootWindow(display))
85 parent = MyRoot(display);
87 return (*func) (display, parent, x, y, width, height, border_width, depth,
88 clss, visual, valuemask, attributes);
91 typedef Window(CSWF) (Display * _display, Window _parent, int _x,
92 int _y, unsigned int _width,
94 unsigned int _border_width,
95 unsigned long _border,
96 unsigned long _background);
98 /* XCreateSimpleWindow intercept hack */
100 XCreateSimpleWindow(Display * display, Window parent, int x, int y,
101 unsigned int width, unsigned int height,
102 unsigned int border_width,
103 unsigned long border, unsigned long background)
105 static CSWF *func = NULL;
107 /* find the real Xlib and the real X function */
109 lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
111 func = (CSWF *) dlsym(lib_xlib, "XCreateSimpleWindow");
113 if (parent == DefaultRootWindow(display))
114 parent = MyRoot(display);
116 return (*func) (display, parent, x, y, width, height,
117 border_width, border, background);
120 typedef int (RWF) (Display * _display, Window _window, Window _parent,
123 /* XReparentWindow intercept hack */
125 XReparentWindow(Display * display, Window window, Window parent, int x, int y)
127 static RWF *func = NULL;
129 /* find the real Xlib and the real X function */
131 lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
133 func = (RWF *) dlsym(lib_xlib, "XReparentWindow");
135 if (parent == DefaultRootWindow(display))
136 parent = MyRoot(display);
138 return (*func) (display, window, parent, x, y);