5 * * gnome-terminal does this funky thing where a new gnome-temrinal process
6 * tries to message an existing one asking it to create a new terminal. this
7 * means none of these properties ever end up on a new term window - in fact
8 * only the ones that are on the first term process. we need a way of knowing
9 * this, OR making sure no new iwndows other than the first appear with these
10 * properties. this also leads to handling splash windows - we might want then
11 * the first 2 or 3 windows with it.
13 * we need to discuss this... it's an interesting hack that solves a LOT of
14 * things (and that we can maybe in future expand to hacking away at gtk and
17 * anyway - for now this is fairly harmless and just adds a property to all
18 * top-level app windows
22 static void __e_hack_set_properties(Display *display, Window window);
24 /* dlopened xlib so we can find the symbols in the real xlib to call them */
25 static void *lib_xlib = NULL;
27 /* the function that actually sets the properties on toplevel window */
29 __e_hack_set_properties(Display *display, Window window)
31 static Atom a_hack = 0;
39 if (!a_hack) a_hack = XInternAtom(display, "__E_HACK", False);
41 buf[sizeof(buf) - 1] = 0;
43 snprintf(buf2, sizeof(buf2), "uid: %i\n", uid);
44 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
46 snprintf(buf2, sizeof(buf2), "pid: %i\n", pid);
47 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
49 snprintf(buf2, sizeof(buf2), "ppid: %i\n", ppid);
50 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
53 snprintf(buf2, sizeof(buf2), "machine_name: %s\n", ubuf.nodename);
54 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
56 if ((env = getenv("E_LAUNCH_ID")))
58 snprintf(buf2, sizeof(buf2), "launch_id: %s\n", env);
59 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
61 if ((env = getenv("USER")))
63 snprintf(buf2, sizeof(buf2), "username: %s\n", env);
64 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
66 if ((env = getenv("E_DESK")))
68 snprintf(buf2, sizeof(buf2), "e_desk: %s\n", env);
69 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
71 if ((env = getenv("E_ZONE")))
73 snprintf(buf2, sizeof(buf2), "e_zone: %s\n", env);
74 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
76 if ((env = getenv("E_CONTAINER")))
78 snprintf(buf2, sizeof(buf2), "e_container: %s\n", env);
79 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
81 if ((env = getenv("E_MANAGER")))
83 snprintf(buf2, sizeof(buf2), "e_manager: %s\n", env);
84 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
86 XChangeProperty(display, window, a_hack, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
89 /* XCreateWindow intercept hack */
95 unsigned int width, unsigned int height,
96 unsigned int border_width,
100 unsigned long valuemask,
101 XSetWindowAttributes *attributes
104 static Window (*func)
109 unsigned int width, unsigned int height,
110 unsigned int border_width,
114 unsigned long valuemask,
115 XSetWindowAttributes *attributes
119 /* find the real Xlib and the real X function */
120 if (!lib_xlib) lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
121 if (!func) func = dlsym (lib_xlib, "XCreateWindow");
123 /* multihead screen handling loop */
124 for (i = 0; i < ScreenCount(display); i++)
126 /* if the window is created as a toplevel window */
127 if (parent == RootWindow(display, i))
132 window = (*func) (display, parent, x, y, width, height,
133 border_width, depth, class, visual, valuemask,
136 __e_hack_set_properties(display, window);
141 /* normal child window - create as usual */
142 return (*func) (display, parent, x, y, width, height, border_width, depth,
143 class, visual, valuemask, attributes);
146 /* XCreateSimpleWindow intercept hack */
152 unsigned int width, unsigned int height,
153 unsigned int border_width,
154 unsigned long border,
155 unsigned long background
158 static Window (*func)
163 unsigned int width, unsigned int height,
164 unsigned int border_width,
165 unsigned long border,
166 unsigned long background
170 /* find the real Xlib and the real X function */
171 if (!lib_xlib) lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
172 if (!func) func = dlsym (lib_xlib, "XCreateSimpleWindow");
174 /* multihead screen handling loop */
175 for (i = 0; i < ScreenCount(display); i++)
177 /* if the window is created as a toplevel window */
178 if (parent == RootWindow(display, i))
183 window = (*func) (display, parent, x, y, width, height,
184 border_width, border, background);
186 __e_hack_set_properties(display, window);
191 /* normal child window - create as usual */
192 return (*func) (display, parent, x, y, width, height,
193 border_width, border, background);
196 /* XReparentWindow intercept hack */
214 /* find the real Xlib and the real X function */
215 if (!lib_xlib) lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
216 if (!func) func = dlsym (lib_xlib, "XReparentWindow");
218 /* multihead screen handling loop */
219 for (i = 0; i < ScreenCount(display); i++)
221 /* if the window is created as a toplevel window */
222 if (parent == RootWindow(display, i))
225 __e_hack_set_properties(display, window);
227 return (*func) (display, window, parent, x, y);
230 /* normal child window reparenting - reparent as usual */
231 return (*func) (display, window, parent, x, y);