summaryrefslogtreecommitdiff
path: root/src/preload
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-06-04 09:01:13 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-06-04 09:01:13 +0000
commit6468e0cef066dcaaa38c387dcea9491d3393b501 (patch)
treed6f62b8613e5629d3a280f48e03592c3852dbe96 /src/preload
parent7a7f286d44ccd8f0f776b98553cb3774472098e0 (diff)
make it a single property - have to parse it now tho.
SVN revision: 15116
Diffstat (limited to 'src/preload')
-rw-r--r--src/preload/e_hack.c112
1 files changed, 63 insertions, 49 deletions
diff --git a/src/preload/e_hack.c b/src/preload/e_hack.c
index 357df1410..6562d807e 100644
--- a/src/preload/e_hack.c
+++ b/src/preload/e_hack.c
@@ -1,6 +1,23 @@
1#include "config.h" 1#include "config.h"
2#include "e_hack.h" 2#include "e_hack.h"
3 3
4/* FIXME:
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.
12 *
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
15 * qt directly)
16 *
17 * anyway - for now this is fairly harmless and just adds a property to all
18 * top-level app windows
19 */
20
4/* prototypes */ 21/* prototypes */
5static void __e_hack_set_properties(Display *display, Window window); 22static void __e_hack_set_properties(Display *display, Window window);
6 23
@@ -11,65 +28,62 @@ static void *lib_xlib = NULL;
11static void 28static void
12__e_hack_set_properties(Display *display, Window window) 29__e_hack_set_properties(Display *display, Window window)
13{ 30{
14 static Atom a_launch_id = 0; 31 static Atom a_hack = 0;
15 static Atom a_user_id = 0;
16 static Atom a_process_id = 0;
17 static Atom a_p_process_id = 0;
18 static Atom a_machine_name = 0;
19 static Atom a_user_name = 0;
20 static Atom a_desk = 0;
21 static Atom a_zone = 0;
22 static Atom a_container = 0;
23 static Atom a_manager = 0;
24 char *env = NULL; 32 char *env = NULL;
33 char buf[4096];
34 char buf2[4096];
35 uid_t uid;
36 pid_t pid, ppid;
37 struct utsname ubuf;
25 38
26 if (!a_launch_id) a_launch_id = XInternAtom(display, "_E_HACK_LAUNCH_ID", False); 39 if (!a_hack) a_hack = XInternAtom(display, "__E_HACK", False);
27 if (!a_user_id) a_user_id = XInternAtom(display, "_E_HACK_USER_ID", False); 40 buf[0] = 0;
28 if (!a_process_id) a_process_id = XInternAtom(display, "_E_HACK_PROCESS_ID", False); 41 buf[sizeof(buf) - 1] = 0;
29 if (!a_p_process_id) a_p_process_id = XInternAtom(display, "_E_HACK_PARENT_PROCESS_ID", False); 42 uid = getuid();
30 if (!a_machine_name) a_machine_name = XInternAtom(display, "_E_HACK_MACHINE_NAME", False); 43 snprintf(buf2, sizeof(buf2), "uid: %i\n", uid);
31 if (!a_user_name) a_user_name = XInternAtom(display, "_E_HACK_USER_NAME", False); 44 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
32 if (!a_desk) a_desk = XInternAtom(display, "_E_HACK_DESK", False); 45 pid = getpid();
33 if (!a_zone) a_zone = XInternAtom(display, "_E_HACK_ZONE", False); 46 snprintf(buf2, sizeof(buf2), "pid: %i\n", pid);
34 if (!a_container) a_container = XInternAtom(display, "_E_HACK_CONTAINER", False); 47 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
35 if (!a_manager) a_manager = XInternAtom(display, "_E_HACK_MANAGER", False); 48 ppid = getppid();
36 49 snprintf(buf2, sizeof(buf2), "ppid: %i\n", ppid);
50 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
51 if (!uname(&ubuf))
52 {
53 snprintf(buf2, sizeof(buf2), "machine_name: %s\n", ubuf.nodename);
54 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
55 }
37 if ((env = getenv("E_LAUNCH_ID"))) 56 if ((env = getenv("E_LAUNCH_ID")))
38 XChangeProperty(display, window, a_launch_id, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env));
39 { 57 {
40 uid_t uid; 58 snprintf(buf2, sizeof(buf2), "launch_id: %s\n", env);
41 pid_t pid, ppid; 59 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
42 struct utsname ubuf;
43 char buf[4096];
44
45 uid = getuid();
46 pid = getpid();
47 ppid = getppid();
48
49 snprintf(buf, sizeof(buf), "%i", uid);
50 XChangeProperty(display, window, a_user_id, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
51 snprintf(buf, sizeof(buf), "%i", pid);
52 XChangeProperty(display, window, a_process_id, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
53 snprintf(buf, sizeof(buf), "%i", ppid);
54 XChangeProperty(display, window, a_p_process_id, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
55 if (!uname(&ubuf))
56 {
57 snprintf(buf, sizeof(buf), "%s", ubuf.nodename);
58 XChangeProperty(display, window, a_machine_name, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
59 }
60 else
61 XChangeProperty(display, window, a_machine_name, XA_STRING, 8, PropModeReplace, (unsigned char *)" ", 1);
62 } 60 }
63 if ((env = getenv("USER"))) 61 if ((env = getenv("USER")))
64 XChangeProperty(display, window, a_user_name, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env)); 62 {
63 snprintf(buf2, sizeof(buf2), "username: %s\n", env);
64 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
65 }
65 if ((env = getenv("E_DESK"))) 66 if ((env = getenv("E_DESK")))
66 XChangeProperty(display, window, a_desk, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env)); 67 {
68 snprintf(buf2, sizeof(buf2), "e_desk: %s\n", env);
69 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
70 }
67 if ((env = getenv("E_ZONE"))) 71 if ((env = getenv("E_ZONE")))
68 XChangeProperty(display, window, a_zone, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env)); 72 {
73 snprintf(buf2, sizeof(buf2), "e_zone: %s\n", env);
74 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
75 }
69 if ((env = getenv("E_CONTAINER"))) 76 if ((env = getenv("E_CONTAINER")))
70 XChangeProperty(display, window, a_container, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env)); 77 {
78 snprintf(buf2, sizeof(buf2), "e_container: %s\n", env);
79 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
80 }
71 if ((env = getenv("E_MANAGER"))) 81 if ((env = getenv("E_MANAGER")))
72 XChangeProperty(display, window, a_manager, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env)); 82 {
83 snprintf(buf2, sizeof(buf2), "e_manager: %s\n", env);
84 strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
85 }
86 XChangeProperty(display, window, a_hack, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
73} 87}
74 88
75/* XCreateWindow intercept hack */ 89/* XCreateWindow intercept hack */