forked from enlightenment/enlightenment
parent
1cdf725b70
commit
5923846e24
9 changed files with 4 additions and 696 deletions
@ -1,2 +1,2 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
SUBDIRS = bin modules preload
|
||||
SUBDIRS = bin modules
|
||||
|
@ -1,25 +0,0 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)src/preload \
|
||||
@e_cflags@
|
||||
|
||||
pkgdir = $(libdir)/enlightenment/preload
|
||||
|
||||
#pkg_LTLIBRARIES = e_hack.la e_precache.la
|
||||
pkg_LTLIBRARIES = e_precache.la
|
||||
|
||||
#e_hack_la_SOURCES = \
|
||||
#e_hack.c \
|
||||
#e_hack.h
|
||||
#e_hack_la_LIBADD = @dlopen_libs@
|
||||
#e_hack_la_LDFLAGS = -module -avoid-version
|
||||
#e_hack_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
e_precache_la_SOURCES = \
|
||||
e_precache.c \ |
||||
e_precache.h |
||||
e_precache_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
e_precache_la_LDFLAGS = -module -avoid-version
|
||||
e_precache_la_DEPENDENCIES = $(top_builddir)/config.h
|
@ -1,232 +0,0 @@ |
||||
#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); |
||||
|
||||
/* 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_hack = 0; |
||||
char *env = NULL; |
||||
char buf[4096]; |
||||
char buf2[4096]; |
||||
uid_t uid; |
||||
pid_t pid, ppid; |
||||
struct utsname ubuf; |
||||
|
||||
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(buf2, sizeof(buf2), "ppid: %i\n", ppid); |
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1); |
||||
if (!uname(&ubuf)) |
||||
{ |
||||
snprintf(buf2, sizeof(buf2), "machine_name: %s\n", ubuf.nodename); |
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 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"))) |
||||
{ |
||||
snprintf(buf2, sizeof(buf2), "username: %s\n", env); |
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1); |
||||
} |
||||
if ((env = getenv("E_DESK"))) |
||||
{ |
||||
snprintf(buf2, sizeof(buf2), "e_desk: %s\n", env); |
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1); |
||||
} |
||||
if ((env = getenv("E_ZONE"))) |
||||
{ |
||||
snprintf(buf2, sizeof(buf2), "e_zone: %s\n", env); |
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1); |
||||
} |
||||
if ((env = getenv("E_CONTAINER"))) |
||||
{ |
||||
snprintf(buf2, sizeof(buf2), "e_container: %s\n", env); |
||||
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1); |
||||
} |
||||
if ((env = getenv("E_MANAGER"))) |
||||
{ |
||||
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 */ |
||||
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); |
||||
} |
@ -1,12 +0,0 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <stdarg.h> |
||||
#include <string.h> |
||||
#include <dlfcn.h> |
||||
#include <unistd.h> |
||||
#include <sys/types.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/utsname.h> |
||||
#include <X11/Xlib.h> |
||||
#include <X11/X.h> |
||||
#include <X11/Xatom.h> |
@ -1,280 +0,0 @@ |
||||
#include "config.h" |
||||
#include "e_precache.h" |
||||
|
||||
static void *lib_eina = NULL; |
||||
static void *lib_ecore = NULL; |
||||
static void *lib_ecore_file = NULL; |
||||
static void *lib_ecore_x = NULL; |
||||
static void *lib_evas = NULL; |
||||
static void *lib_edje = NULL; |
||||
static void *lib_eet = NULL; |
||||
|
||||
static int *e_precache_end = NULL; |
||||
|
||||
/* internal calls */ |
||||
static int log_fd = -1; |
||||
static int do_log = 0; |
||||
|
||||
static void |
||||
log_open(void) |
||||
{ |
||||
char buf[4096] = "DUMMY", *home; |
||||
|
||||
if (log_fd != -1) return; |
||||
if (!e_precache_end) |
||||
{ |
||||
#ifdef HAVE_UNSETENV |
||||
unsetenv("LD_PRELOAD"); |
||||
#else |
||||
if (getenv("LD_PRELOAD")) putenv("LD_PRELOAD"); |
||||
#endif |
||||
e_precache_end = dlsym(NULL, "e_precache_end"); |
||||
} |
||||
if (!e_precache_end) return; |
||||
if (*e_precache_end) return; |
||||
|
||||
home = getenv("HOME"); |
||||
if (home) |
||||
snprintf(buf, sizeof(buf), "%s/.e-precache", home); |
||||
else |
||||
snprintf(buf, sizeof(buf), "/tmp/.e-precache"); |
||||
log_fd = open(buf, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); |
||||
if (log_fd) do_log = 1; |
||||
} |
||||
|
||||
static void |
||||
log_close(void) |
||||
{ |
||||
if (log_fd >= 0) |
||||
{ |
||||
close(log_fd); |
||||
log_fd = -1; |
||||
} |
||||
do_log = 0; |
||||
} |
||||
|
||||
static void |
||||
log_write(const char *type, const char *file) |
||||
{ |
||||
static Eina_Hash *s_hash = NULL; |
||||
static Eina_Hash *o_hash = NULL; |
||||
static Eina_Hash *d_hash = NULL; |
||||
char buf[2]; |
||||
|
||||
if ((e_precache_end) && (*e_precache_end)) |
||||
{ |
||||
log_close(); |
||||
return; |
||||
} |
||||
if (type[0] == 's') |
||||
{ |
||||
if (eina_hash_find(s_hash, file)) return; |
||||
if (!s_hash) s_hash = eina_hash_string_superfast_new(NULL); |
||||
eina_hash_add(s_hash, file, (void *)1); |
||||
} |
||||
else if (type[0] == 'o') |
||||
{ |
||||
if (eina_hash_find(o_hash, file)) return; |
||||
if (!o_hash) o_hash = eina_hash_string_superfast_new(NULL); |
||||
eina_hash_add(o_hash, file, (void *)1); |
||||
} |
||||
else if (type[0] == 'd') |
||||
{ |
||||
if (eina_hash_find(d_hash, file)) return; |
||||
if (!d_hash) d_hash = eina_hash_string_superfast_new(NULL); |
||||
eina_hash_add(d_hash, file, (void *)1); |
||||
} |
||||
buf[0] = type[0]; buf[1] = ' '; |
||||
write(log_fd, buf, 2); |
||||
write(log_fd, file, strlen(file)); |
||||
write(log_fd, "\n", 1); |
||||
} |
||||
|
||||
static void * |
||||
lib_func(const char *lib1, const char *lib2, const char *fname, const char *libname, void **lib) |
||||
{ |
||||
void *func; |
||||
|
||||
if (!*lib) *lib = dlopen(lib1, RTLD_GLOBAL | RTLD_LAZY); |
||||
if (!*lib) *lib = dlopen(lib2, RTLD_GLOBAL | RTLD_LAZY); |
||||
func = dlsym(*lib, fname); |
||||
if (!func) |
||||
{ |
||||
printf("ABORT: Can't find %s() in %s or %s (%s = %p)\n", |
||||
fname, lib1, lib2, libname, *lib); |
||||
abort(); |
||||
} |
||||
log_open(); |
||||
return func; |
||||
} |
||||
|
||||
/* intercepts */ |
||||
Eina_Module * |
||||
eina_module_find(const Eina_Array *array, const char *module)
|
||||
{ |
||||
static Eina_Module *(*func) (const Eina_Array *array, const char *module) = NULL; |
||||
|
||||
if (!func)
|
||||
func = lib_func("libeina.so", "libeina.so.1",
|
||||
"eina_module_find", "lib_eina", &lib_eina); |
||||
if (do_log) log_write("o", module); |
||||
return (*func) (array, module); |
||||
} |
||||
|
||||
void
|
||||
ecore_app_args_set(int argc, const char **argv) |
||||
{ |
||||
static void (*func) (int argc, const char **argv) = NULL; |
||||
|
||||
if (!func)
|
||||
func = lib_func("libecore.so", "libecore.so.1",
|
||||
"ecore_app_args_set", "lib_ecore", &lib_ecore); |
||||
if (do_log) log_write("o", (const char *)argv); |
||||
(*func) (argc, argv); |
||||
} |
||||
|
||||
long long |
||||
ecore_file_mod_time(const char *file) |
||||
{ |
||||
static long long (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_mod_time", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("s", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
long long |
||||
ecore_file_size(const char *file) |
||||
{ |
||||
static int (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_size", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("s", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
Eina_Bool |
||||
ecore_file_exists(const char *file) |
||||
{ |
||||
static int (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_exists", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("s", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
Eina_Bool |
||||
ecore_file_is_dir(const char *file) |
||||
{ |
||||
static int (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_is_dir", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("s", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
Eina_Bool |
||||
ecore_file_can_read(const char *file) |
||||
{ |
||||
static int (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_can_read", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("s", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
Eina_Bool |
||||
ecore_file_can_write(const char *file) |
||||
{ |
||||
static int (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_can_write", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("s", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
Eina_Bool |
||||
ecore_file_can_exec(const char *file) |
||||
{ |
||||
static int (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_can_exec", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("s", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
Eina_List * |
||||
ecore_file_ls(const char *file) |
||||
{ |
||||
static Eina_List * (*func) (const char *file) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
||||
"ecore_file_ls", "lib_ecore_file", &lib_ecore_file); |
||||
if (do_log) log_write("d", file); |
||||
return (*func) (file); |
||||
} |
||||
|
||||
int
|
||||
ecore_x_init(const char *name)
|
||||
{ |
||||
static int (*func) (const char *name) = NULL; |
||||
|
||||
if (!func)
|
||||
func = lib_func("libecore_x.so", "libecore_x.so.1",
|
||||
"ecore_x_init", "lib_ecore_x", &lib_ecore_x); |
||||
if (do_log) log_write("o", name); |
||||
return (*func) (name); |
||||
} |
||||
|
||||
void |
||||
evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key) |
||||
{ |
||||
static void (*func) (Evas_Object *obj, const char *file, const char *key) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libevas.so", "libevas.so.1",
|
||||
"evas_object_image_file_set", "lib_evas", &lib_evas); |
||||
if (do_log) log_write("o", file); |
||||
(*func) (obj, file, key); |
||||
} |
||||
|
||||
/* edje */ |
||||
Eina_Bool
|
||||
edje_object_file_set(Evas_Object *obj, const char *file, const char *group)
|
||||
{ |
||||
static Eina_Bool (*func) (Evas_Object *obj, const char *file, const char *group) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libedje.so", "libedje.so.1",
|
||||
"edje_object_file_set", "lib_edje", &lib_edje); |
||||
if (do_log) log_write("o", file); |
||||
return (*func) (obj, file, group); |
||||
} |
||||
|
||||
Eet_File * |
||||
eet_open(const char *file, Eet_File_Mode mode) |
||||
{ |
||||
static Eet_File * (*func) (const char *file, Eet_File_Mode mode) = NULL; |
||||
|
||||
if (!func) |
||||
func = lib_func("libeet.so", "libeet.so.0",
|
||||
"eet_open", "lib_eet", &lib_eet); |
||||
if (do_log) log_write("o", file); |
||||
return (*func) (file, mode); |
||||
} |
||||
|
@ -1,18 +0,0 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <stdarg.h> |
||||
#include <string.h> |
||||
#include <dlfcn.h> |
||||
#include <unistd.h> |
||||
#include <sys/types.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/utsname.h> |
||||
#include <fcntl.h> |
||||
#ifdef HAVE_ALLOCA_H |
||||
#include <alloca.h> |
||||
#endif |
||||
#include <Eina.h> |
||||
#include <Evas.h> |
||||
#include <Ecore.h> |
||||
#include <Ecore_File.h> |
||||
#include <Eet.h> |
Loading…
Reference in new issue