forked from enlightenment/enlightenment
make it a single property - have to parse it now tho.
SVN revision: 15116
This commit is contained in:
parent
7a7f286d44
commit
6468e0cef0
|
@ -1,6 +1,23 @@
|
|||
#include "config.h"
|
||||
#include "e_hack.h"
|
||||
|
||||
/* FIXME:
|
||||
* * gnome-terminal does this funky thing where a new gnome-temrinal process
|
||||
* tries to message an existing one asking it to create a new terminal. this
|
||||
* means none of these properties ever end up on a new term window - in fact
|
||||
* only the ones that are on the first term process. we need a way of knowing
|
||||
* this, OR making sure no new iwndows other than the first appear with these
|
||||
* properties. this also leads to handling splash windows - we might want then
|
||||
* the first 2 or 3 windows with it.
|
||||
*
|
||||
* we need to discuss this... it's an interesting hack that solves a LOT of
|
||||
* things (and that we can maybe in future expand to hacking away at gtk and
|
||||
* qt directly)
|
||||
*
|
||||
* anyway - for now this is fairly harmless and just adds a property to all
|
||||
* top-level app windows
|
||||
*/
|
||||
|
||||
/* prototypes */
|
||||
static void __e_hack_set_properties(Display *display, Window window);
|
||||
|
||||
|
@ -11,65 +28,62 @@ static void *lib_xlib = NULL;
|
|||
static void
|
||||
__e_hack_set_properties(Display *display, Window window)
|
||||
{
|
||||
static Atom a_launch_id = 0;
|
||||
static Atom a_user_id = 0;
|
||||
static Atom a_process_id = 0;
|
||||
static Atom a_p_process_id = 0;
|
||||
static Atom a_machine_name = 0;
|
||||
static Atom a_user_name = 0;
|
||||
static Atom a_desk = 0;
|
||||
static Atom a_zone = 0;
|
||||
static Atom a_container = 0;
|
||||
static Atom a_manager = 0;
|
||||
static Atom a_hack = 0;
|
||||
char *env = NULL;
|
||||
|
||||
if (!a_launch_id) a_launch_id = XInternAtom(display, "_E_HACK_LAUNCH_ID", False);
|
||||
if (!a_user_id) a_user_id = XInternAtom(display, "_E_HACK_USER_ID", False);
|
||||
if (!a_process_id) a_process_id = XInternAtom(display, "_E_HACK_PROCESS_ID", False);
|
||||
if (!a_p_process_id) a_p_process_id = XInternAtom(display, "_E_HACK_PARENT_PROCESS_ID", False);
|
||||
if (!a_machine_name) a_machine_name = XInternAtom(display, "_E_HACK_MACHINE_NAME", False);
|
||||
if (!a_user_name) a_user_name = XInternAtom(display, "_E_HACK_USER_NAME", False);
|
||||
if (!a_desk) a_desk = XInternAtom(display, "_E_HACK_DESK", False);
|
||||
if (!a_zone) a_zone = XInternAtom(display, "_E_HACK_ZONE", False);
|
||||
if (!a_container) a_container = XInternAtom(display, "_E_HACK_CONTAINER", False);
|
||||
if (!a_manager) a_manager = XInternAtom(display, "_E_HACK_MANAGER", False);
|
||||
|
||||
if ((env = getenv("E_LAUNCH_ID")))
|
||||
XChangeProperty(display, window, a_launch_id, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env));
|
||||
{
|
||||
char buf[4096];
|
||||
char buf2[4096];
|
||||
uid_t uid;
|
||||
pid_t pid, ppid;
|
||||
struct utsname ubuf;
|
||||
char buf[4096];
|
||||
|
||||
if (!a_hack) a_hack = XInternAtom(display, "__E_HACK", False);
|
||||
buf[0] = 0;
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
uid = getuid();
|
||||
snprintf(buf2, sizeof(buf2), "uid: %i\n", uid);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
pid = getpid();
|
||||
snprintf(buf2, sizeof(buf2), "pid: %i\n", pid);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
ppid = getppid();
|
||||
|
||||
snprintf(buf, sizeof(buf), "%i", uid);
|
||||
XChangeProperty(display, window, a_user_id, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
|
||||
snprintf(buf, sizeof(buf), "%i", pid);
|
||||
XChangeProperty(display, window, a_process_id, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
|
||||
snprintf(buf, sizeof(buf), "%i", ppid);
|
||||
XChangeProperty(display, window, a_p_process_id, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
|
||||
snprintf(buf2, sizeof(buf2), "ppid: %i\n", ppid);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
if (!uname(&ubuf))
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s", ubuf.nodename);
|
||||
XChangeProperty(display, window, a_machine_name, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
|
||||
snprintf(buf2, sizeof(buf2), "machine_name: %s\n", ubuf.nodename);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
else
|
||||
XChangeProperty(display, window, a_machine_name, XA_STRING, 8, PropModeReplace, (unsigned char *)" ", 1);
|
||||
if ((env = getenv("E_LAUNCH_ID")))
|
||||
{
|
||||
snprintf(buf2, sizeof(buf2), "launch_id: %s\n", env);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
if ((env = getenv("USER")))
|
||||
XChangeProperty(display, window, a_user_name, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env));
|
||||
{
|
||||
snprintf(buf2, sizeof(buf2), "username: %s\n", env);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
if ((env = getenv("E_DESK")))
|
||||
XChangeProperty(display, window, a_desk, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env));
|
||||
{
|
||||
snprintf(buf2, sizeof(buf2), "e_desk: %s\n", env);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
if ((env = getenv("E_ZONE")))
|
||||
XChangeProperty(display, window, a_zone, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env));
|
||||
{
|
||||
snprintf(buf2, sizeof(buf2), "e_zone: %s\n", env);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
if ((env = getenv("E_CONTAINER")))
|
||||
XChangeProperty(display, window, a_container, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env));
|
||||
{
|
||||
snprintf(buf2, sizeof(buf2), "e_container: %s\n", env);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
if ((env = getenv("E_MANAGER")))
|
||||
XChangeProperty(display, window, a_manager, XA_STRING, 8, PropModeReplace, (unsigned char *)env, strlen(env));
|
||||
{
|
||||
snprintf(buf2, sizeof(buf2), "e_manager: %s\n", env);
|
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
XChangeProperty(display, window, a_hack, XA_STRING, 8, PropModeReplace, (unsigned char *)buf, strlen(buf));
|
||||
}
|
||||
|
||||
/* XCreateWindow intercept hack */
|
||||
|
|
Loading…
Reference in New Issue