enlightenment/lib/e_hack.c

207 lines
6.3 KiB
C
Raw Normal View History

Sorry guys.. I had to revert a bunch of changes.. that's life.. but READ the following (it's in the README now) ------------------------------------------------------------------------------- Enlightenment 0.17.0 CVS Code.... ------------------------------------------------------------------------------- The Rasterman - raster@valinux.com, raster@rasterman.com ******************************************************************************* **************** READ THIS! It is of the UTMOST IMPORTANCE! ******************* ******************************************************************************* This is the source code for Enlightenment 0.17 - If you got this you got it from Enlightenment's CVS repository - or from someone who took it out of the CVS repository. The CVS repository is full of code *IN DEVELOPMENT* - that often means it's in the middle of being worked on and may install strange things in strange places, make a mess, and may not even be compatible with a final release. If you at all use this code, you are HEAVILY URGED, when it is finally released, to remove all traces of anything this CVS code base has installed on your system (it is COMPLETELY up to you to keep track of that - do NOT expect any help), and then install the full release on a cleaned system. Don't come asking "can I just keep using CVS" oonce things are released - thqat is the reason I pu this paragraph here - so you don't ask. The asnwer is the same as above - if there is a proper final release use that. CVS is really only for those havily hacking on the code. Now we have that warning over and done with. How to build and install from CVS? $ ./autogen.sh && make $ su Password: <- as root -> # make install You should be able to use the binary of enlightenment as a window manager. you might be advised for cleanliness to do $ ./autogen.sh --prefix=/usr/local/e-17 so it installs relative to the /usr/local/e-17 directory and keeps all the e-17 development code and data in that tree so it is easily removed when the time codes. NOTES: Read these carefully! Enlightenment does not check for previously running Window Managers right now - so you need to make sure no other WM is running - E will not do that for you. Enlightenment has no menus or keybindings or any way of launching applications right now - you'll have to figure out an alternative way of doing it. Enlightenment only handles a small subset of ICCCM and thus will have bugs - some applications will not behave correctly and may apear in odd spots or not resize or place themselves properly etc. Expect this - it's code being worked on. Just be happy it does as much as it already does. Enlightenment RELIES on lots of libraires that have been written. Ecore, Ebits, Evas, Edb, Imlib2 just to mention a few. Especially Ebits, Ecore and Evas change in CVS often - you will need the absolute latest of these if you wish Enlightenment 0.17 code to run properly or compile. If you update Enlightenment from CVS update these too to get any changes they have in their trees. If you plan on working on the code... STOP! don't rush in and work on it - even if you have CVS commit access - EXPECT me (Raster) to revert any changes you make if you do this - regardless of the changes and how much work you put into them. First read the code well and LEARN it. If you have questions about some of the more obscure hidden program flow - ASK - but don't go tampering with it - Enlightenment 0.17's code is much more complex and intricate than E 0.16 - but at the same time it's much cleaner and more object oriented. Learn it well first. Some parts of E 0.17 are "hacked" with hard-coded stuff, just so, for now, it works. They will be virtualized and imporved over time. If you have plans - tell me about them first - discuss them before you go impliment them. I know I already have a lot of the components of E 0.17's code planned in my head - but I won't get to them for a while - and if people go impliment or hack bad stuff in, it means I have to spend lots of time fixing something that is bad in the first place, or we end up doing duplicate work. There *IS* a plan - believe it or not - but to be honest - it's more complex and large than I can just write down in a README, so talk about your ideas first. I'm going to be ruthless in keeping the code neat, clean and free of nasty hacks (except ones I put in as temporary stop-gap measures to make the thing work - since I know where those are and what I need to do to do it right). If you can't find me or I don't reply to your e-mail - don't get impatient - just wait. I currently have no network access at home, so I'm doing a chunk of code offline. I'll get to your mail and queries as time allows. If you have problems with the code or bugs to report, kindly forward them to /dev/null (the code is in now way or form ready for bug reports - I don't want crap filling my mailbox). I hope that clears things up for now. SVN revision: 3976
2000-12-11 12:08:38 -08:00
#include "config.h"
#include "e_hack.h"
/* prototypes */
static void __e_hack_set_properties(Display *display, Window window);
/* dlopened xlib so we can find the symbols in the real xlib to call them */
static void *lib_xlib = NULL;
/* the function that actually sets the properties on toplevel window */
static void
__e_hack_set_properties(Display *display, Window window)
{
static Atom a_launch_id = 0;
static Atom a_launch_path = 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;
char *env = NULL;
if (!a_launch_id) a_launch_id = XInternAtom(display, "_E_HACK_LAUNCH_ID", False);
if (!a_launch_path) a_launch_path = XInternAtom(display, "_E_HACK_LAUNCH_PATH", 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 ((env = getenv("E_HACK_LAUNCH_ID")))
XChangeProperty(display, window, a_launch_id, XA_STRING, 8, PropModeReplace, env, strlen(env));
if ((env = getenv("E_HACK_LAUNCH_PATH")))
XChangeProperty(display, window, a_launch_path, XA_STRING, 8, PropModeReplace, env, strlen(env));
{
uid_t uid;
pid_t pid, ppid;
struct utsname ubuf;
char buf[4096];
uid = getuid();
pid = getpid();
ppid = getppid();
snprintf(buf, sizeof(buf), "%i", uid);
XChangeProperty(display, window, a_user_id, XA_STRING, 8, PropModeReplace, buf, strlen(buf));
snprintf(buf, sizeof(buf), "%i", pid);
XChangeProperty(display, window, a_process_id, XA_STRING, 8, PropModeReplace, buf, strlen(buf));
snprintf(buf, sizeof(buf), "%i", ppid);
XChangeProperty(display, window, a_p_process_id, XA_STRING, 8, PropModeReplace, buf, strlen(buf));
if (!uname(&ubuf))
{
snprintf(buf, sizeof(buf), "%s", ubuf.nodename);
XChangeProperty(display, window, a_machine_name, XA_STRING, 8, PropModeReplace, buf, strlen(buf));
}
else
XChangeProperty(display, window, a_machine_name, XA_STRING, 8, PropModeReplace, " ", 1);
}
if ((env = getenv("USER")))
XChangeProperty(display, window, a_user_name, XA_STRING, 8, PropModeReplace, env, strlen(env));
}
/* XCreateWindow intercept hack */
Window
XCreateWindow(
Display *display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
int depth,
unsigned int class,
Visual *visual,
unsigned long valuemask,
XSetWindowAttributes *attributes
)
{
static Window (*func)
(
Display *display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
int depth,
unsigned int class,
Visual *visual,
unsigned long valuemask,
XSetWindowAttributes *attributes
) = NULL;
int i;
/* find the real Xlib and the real X function */
if (!lib_xlib) lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
if (!func) func = dlsym (lib_xlib, "XCreateWindow");
/* multihead screen handling loop */
for (i = 0; i < ScreenCount(display); i++)
{
/* if the window is created as a toplevel window */
if (parent == RootWindow(display, i))
{
Window window;
/* create it */
window = (*func) (display, parent, x, y, width, height,
border_width, depth, class, visual, valuemask,
attributes);
/* set properties */
__e_hack_set_properties(display, window);
/* return it */
return window;
}
}
/* normal child window - create as usual */
return (*func) (display, parent, x, y, width, height, border_width, depth,
class, visual, valuemask, attributes);
}
/* XCreateSimpleWindow intercept hack */
Window
XCreateSimpleWindow(
Display *display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
unsigned long border,
unsigned long background
)
{
static Window (*func)
(
Display *display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
unsigned long border,
unsigned long background
) = NULL;
int i;
/* find the real Xlib and the real X function */
if (!lib_xlib) lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
if (!func) func = dlsym (lib_xlib, "XCreateSimpleWindow");
/* multihead screen handling loop */
for (i = 0; i < ScreenCount(display); i++)
{
/* if the window is created as a toplevel window */
if (parent == RootWindow(display, i))
{
Window window;
/* create it */
window = (*func) (display, parent, x, y, width, height,
border_width, border, background);
/* set properties */
__e_hack_set_properties(display, window);
/* return it */
return window;
}
}
/* normal child window - create as usual */
return (*func) (display, parent, x, y, width, height,
border_width, border, background);
}
/* XReparentWindow intercept hack */
int
XReparentWindow(
Display *display,
Window window,
Window parent,
int x, int y
)
{
static int (*func)
(
Display *display,
Window window,
Window parent,
int x, int y
) = NULL;
int i;
/* find the real Xlib and the real X function */
if (!lib_xlib) lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
if (!func) func = dlsym (lib_xlib, "XReparentWindow");
/* multihead screen handling loop */
for (i = 0; i < ScreenCount(display); i++)
{
/* if the window is created as a toplevel window */
if (parent == RootWindow(display, i))
{
/* set properties */
__e_hack_set_properties(display, window);
/* reparent it */
return (*func) (display, window, parent, x, y);
}
}
/* normal child window reparenting - reparent as usual */
return (*func) (display, window, parent, x, y);
}