From 1a13f8c26f67c2a13c1dffdb60b4577a5e3e704d Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Mon, 25 Jul 2011 09:40:18 +0000 Subject: [PATCH] E: Make E work with the new XCB stuffs. This breaks out e_alert into it's own utility (as per raster's request/idea). Remove explicit x_clags in Makefile.am(s) as they are no longer needed. NB: I added some additional libs to the precache stuffs (even tho it's not used right now). Also a newer e_main (more optimized). NB: IF you are brave and want to test this, build evas w/ xcb, build ecore w/ xcb, then rebuild E. Also, disable building opengl in both evas & ecore (it's not ready for public consumption when paired w/ xcb). SVN revision: 61680 --- configure.ac | 64 +- src/bin/Makefile.am | 14 +- src/bin/e.h | 334 ++--- src/bin/e_alert.c | 253 +--- src/bin/e_alert.h | 11 +- src/bin/e_alert_main.c | 615 ++++++++ src/bin/e_config.c | 22 +- src/bin/e_fm/Makefile.am | 2 - src/bin/e_ipc.c | 141 +- src/bin/e_ipc.h | 1 + src/bin/e_main.c | 2532 +++++++++++++++++---------------- src/bin/e_signals.c | 90 +- src/bin/e_start_main.c | 33 +- src/bin/e_utils.c | 5 - src/modules/comp/e_mod_comp.c | 4 +- src/preload/Makefile.am | 3 +- src/preload/e_precache.c | 82 +- 17 files changed, 2356 insertions(+), 1850 deletions(-) create mode 100644 src/bin/e_alert_main.c diff --git a/configure.ac b/configure.ac index fed543ecd..e8c81f319 100644 --- a/configure.ac +++ b/configure.ac @@ -77,7 +77,7 @@ EFL_CHECK_PATH_MAX AC_CHECK_FUNCS(setenv) AC_CHECK_FUNCS(unsetenv) -AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find X11/extensions/shape.h. Make sure your CFLAGS environment variable contains include lines for the location of this file])) +dnl AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find X11/extensions/shape.h. Make sure your CFLAGS environment variable contains include lines for the location of this file])) AC_CHECK_HEADERS(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file])) @@ -160,25 +160,25 @@ AC_ARG_ENABLE(simple-x11, [ want_evas_simple_x11=$enableval ] ) -x_dir="" -x_cflags="" -x_libs="" -AC_PATH_XTRA -AC_CHECK_HEADER(X11/X.h, - [ - if test "x$want_evas_simple_x11" = "xyes"; then - x_libs="${x_libs} -lX11 -lXext" - else - x_dir=${x_dir:-/usr/X11R6} - x_cflags=${x_cflags:--I${x_includes:-$x_dir/include}} - x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext" - fi - ],[ - AC_MSG_ERROR([Cannot find X headers and libraries.]) - ] -) -AC_SUBST(x_cflags) -AC_SUBST(x_libs) +dnl x_dir="" +dnl x_cflags="" +dnl x_libs="" +dnl AC_PATH_XTRA +dnl AC_CHECK_HEADER(X11/X.h, +dnl [ +dnl if test "x$want_evas_simple_x11" = "xyes"; then +dnl x_libs="${x_libs} -lX11 -lXext" +dnl else +dnl x_dir=${x_dir:-/usr/X11R6} +dnl x_cflags=${x_cflags:--I${x_includes:-$x_dir/include}} +dnl x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext" +dnl fi +dnl ],[ +dnl AC_MSG_ERROR([Cannot find X headers and libraries.]) +dnl ] +dnl ) +dnl AC_SUBST(x_cflags) +dnl AC_SUBST(x_libs) cf_cflags="" cf_libs="" @@ -372,12 +372,16 @@ eeze_mount= EEZE_MOUNT_CONFIG=0 if test "x$e_cv_want_mount_eeze" != "xno" ; then AC_CHECK_LIB([eeze], [eeze_disk_function], +## [ +## eeze_mount="eeze >= 1.1.0" +## EEZE_MOUNT_CONFIG=1 +## AC_DEFINE_UNQUOTED([HAVE_EEZE_MOUNT], [1], [enable eeze mounting]) +## AC_MSG_NOTICE([eeze mounting enabled]) +## ], [ - eeze_mount="eeze >= 1.0.99 ecore-con >= 1.0.999" - EEZE_MOUNT_CONFIG=1 - AC_DEFINE_UNQUOTED([HAVE_EEZE_MOUNT], [1], [enable eeze mounting]) - AC_MSG_NOTICE([eeze mounting enabled]) - ], + AC_MSG_NOTICE([eeze mounting disabled]) + e_cv_want_mount_eeze=no + ] ) else AC_MSG_NOTICE([eeze mounting disabled]) @@ -390,7 +394,7 @@ AM_CONDITIONAL([HAVE_EEZE_MOUNT], [false]) test -n "$hal_mount" && AC_DEFINE_UNQUOTED([HAVE_HAL_MOUNT], [1], [enable HAL mounting]) test -n "$udisks_mount" && AC_DEFINE_UNQUOTED([HAVE_UDISKS_MOUNT], [1], [enable Udisks mounting]) AM_CONDITIONAL([HAVE_UDISKS_MOUNT], [test -n "$udisks_mount"]) -AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test -n "$eeze_mount"]) +##AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test -n "$eeze_mount"]) # doxygen program for documentation building @@ -442,6 +446,7 @@ PKG_CHECK_MODULES(E_FM_OP, [ PKG_CHECK_MODULES(E_FM_OPEN, [ ecore >= 1.0.999 ecore-ipc >= 1.0.999 + ecore-con >= 1.0.999 eet >= 1.4.0 eina >= 1.0.999 ]) @@ -460,6 +465,13 @@ PKG_CHECK_MODULES(E_INIT, [ eina >= 1.0.999 ]) +PKG_CHECK_MODULES(E_ALERT, [ + xcb + eina >= 1.0.999 + ecore >= 1.0.999 + ecore-ipc >= 1.0.999 +]) + PKG_CHECK_MODULES(E, [ evas >= 1.0.999 ecore >= 1.0.999 diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index c0db26efe..145786ab4 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -9,7 +9,6 @@ INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/src/bin \ @e_cflags@ \ -@x_cflags@ \ @cf_cflags@ \ @VALGRIND_CFLAGS@ \ @EDJE_DEF@ \ @@ -30,7 +29,8 @@ enlightenment_fm_op \ enlightenment_init \ enlightenment_sys \ enlightenment_thumb \ -enlightenment_backlight +enlightenment_backlight \ +enlightenment_alert ENLIGHTENMENTHEADERS = \ e_about.h \ @@ -184,8 +184,8 @@ e_zone.h enlightenment_src = \ e_about.c \ e_acpi.c \ -e_actions.c \ e_alert.c \ +e_actions.c \ e_atoms.c \ e_backlight.c \ e_bg.c \ @@ -331,7 +331,7 @@ e_main.c \ $(enlightenment_src) enlightenment_LDFLAGS = -export-dynamic -enlightenment_LDADD = @e_libs@ @x_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm +enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm enlightenment_imc_SOURCES = \ e.h \ @@ -375,6 +375,12 @@ e_xinerama.c enlightenment_init_LDADD = @E_INIT_LIBS@ +enlightenment_alert_SOURCES = \ +e_alert_main.c + +enlightenment_alert_LDADD = @E_ALERT_LIBS@ +enlightenment_alert_CFLAGS = @E_ALERT_CFLAGS@ + # HACK! why install-data-hook? install-exec-hook is run after bin_PROGRAMS # and before internal_bin_PROGRAMS are installed. install-data-hook is # run after both diff --git a/src/bin/e.h b/src/bin/e.h index f385f8f4f..052754bea 100644 --- a/src/bin/e.h +++ b/src/bin/e.h @@ -1,169 +1,173 @@ #ifndef E_H -#define E_H +# define E_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define USE_IPC -#if 0 -#define OBJECT_PARANOIA_CHECK -#define OBJECT_CHECK -#endif - -#ifndef _FILE_OFFSET_BITS -#define _FILE_OFFSET_BITS 64 -#endif - -#ifdef HAVE_ALLOCA_H -# include -#elif defined __GNUC__ -# define alloca __builtin_alloca -#elif defined _AIX -# define alloca __alloca -#elif defined _MSC_VER -# include -# define alloca _alloca -#else -# include -# ifdef __cplusplus -extern "C" +# ifdef HAVE_CONFIG_H +# include "config.h" # endif -void *alloca (size_t); -#endif +# define USE_IPC +# if 0 +# define OBJECT_PARANOIA_CHECK +# define OBJECT_CHECK +# endif -#ifdef __linux__ -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +# ifndef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 +# endif -#ifdef HAVE_GETTEXT -# include -#endif - -#ifndef _POSIX_HOST_NAME_MAX -#define _POSIX_HOST_NAME_MAX 255 -#endif - -#ifdef HAVE_VALGRIND -# include -#endif - -#ifdef __GLIBC__ -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef EAPI -#undef EAPI -#endif -#ifdef WIN32 -# ifdef BUILDING_DLL -# define EAPI __declspec(dllexport) +# ifdef HAVE_ALLOCA_H +# include +# elif defined __GNUC__ +# define alloca __builtin_alloca +# elif defined _AIX +# define alloca __alloca +# elif defined _MSC_VER +# include +# define alloca _alloca # else -# define EAPI __declspec(dllimport) +# include +# ifdef __cplusplus +extern "C" +# endif +void *alloca (size_t); # endif -#else -# ifdef __GNUC__ -# if __GNUC__ >= 4 + +# ifdef __linux__ +# include +# endif + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# ifdef HAVE_GETTEXT +# include +# endif + +# ifndef _POSIX_HOST_NAME_MAX +# define _POSIX_HOST_NAME_MAX 255 +# endif + +# ifdef HAVE_VALGRIND +# include +# endif + +# ifdef __GLIBC__ +# include +# include +# endif + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# ifdef EAPI +# undef EAPI +# endif +# ifdef WIN32 +# ifdef BUILDING_DLL +# define EAPI __declspec(dllexport) +# else +# define EAPI __declspec(dllimport) +# endif +# else +# ifdef __GNUC__ +# if __GNUC__ >= 4 /* BROKEN in gcc 4 on amd64 */ -#if 0 -# pragma GCC visibility push(hidden) -#endif -# define EAPI __attribute__ ((visibility("default"))) +# if 0 +# pragma GCC visibility push(hidden) +# endif +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif # else # define EAPI # endif -# else -# define EAPI # endif -#endif -#ifdef EINTERN -#undef EINTERN -#endif -#ifdef __GNUC__ -# if __GNUC__ >= 4 -# define EINTERN __attribute__ ((visibility("hidden"))) +# ifdef EINTERN +# undef EINTERN +# endif +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EINTERN __attribute__ ((visibility("hidden"))) +# else +# define EINTERN +# endif # else # define EINTERN # endif -#else -# define EINTERN -#endif typedef struct _E_Before_Idler E_Before_Idler; typedef struct _E_Rect E_Rect; /* convenience macro to compress code and avoid typos */ -#define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; } -#define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy))) -#define E_INSIDE(x, y, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy))) -#define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) (((xx) >= (x)) && (((x) + (w)) >= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) >= ((yy) + (hh)))) -#define E_SPANS_COMMON(x1, w1, x2, w2) (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) -#define E_REALLOC(p, s, n) p = (s *)realloc(p, sizeof(s) * n) -#define E_NEW(s, n) (s *)calloc(n, sizeof(s)) -#define E_NEW_RAW(s, n) (s *)malloc(n * sizeof(s)) -#define E_FREE(p) do { free(p); p = NULL; } while (0) -#define E_FREE_LIST(list, free) \ - do \ - { \ - if (list) \ - { \ - void *data; \ - EINA_LIST_FREE(list, data) \ - { \ - free(data); \ - } \ - list = NULL; \ - } \ - } \ - while (0) +# define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; } +# define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) \ + (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy))) +# define E_INSIDE(x, y, xx, yy, ww, hh) \ + (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy))) +# define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) \ + (((xx) >= (x)) && (((x) + (w)) >= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) >= ((yy) + (hh)))) +# define E_SPANS_COMMON(x1, w1, x2, w2) \ + (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) +# define E_REALLOC(p, s, n) p = (s *)realloc(p, sizeof(s) * n) +# define E_NEW(s, n) (s *)calloc(n, sizeof(s)) +# define E_NEW_RAW(s, n) (s *)malloc(n * sizeof(s)) +# define E_FREE(p) do { free(p); p = NULL; } while (0) +# define E_FREE_LIST(list, free) \ + do \ + { \ + if (list) \ + { \ + void *data; \ + EINA_LIST_FREE(list, data) \ + { \ + free(data); \ + } \ + list = NULL; \ + } \ + } \ + while (0) -#define E_CLAMP(x, min, max) (x < min ? min : (x > max ? max : x)) -#define E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \ +# define E_CLAMP(x, min, max) (x < min ? min : (x > max ? max : x)) +# define E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \ { \ if (E_INTERSECTS(_x, _y, _w, _h, _cx, _cy, _cw, _ch)) \ { \ @@ -190,28 +194,27 @@ typedef struct _E_Rect E_Rect; } \ } -#define E_REMOTE_OPTIONS 1 -#define E_REMOTE_OUT 2 -#define E_WM_IN 3 -#define E_REMOTE_IN 4 -#define E_ENUM 5 -#define E_LIB_IN 6 +# define E_REMOTE_OPTIONS 1 +# define E_REMOTE_OUT 2 +# define E_WM_IN 3 +# define E_REMOTE_IN 4 +# define E_ENUM 5 +# define E_LIB_IN 6 -#define E_TYPEDEFS 1 -#include "e_includes.h" -#undef E_TYPEDEFS -#include "e_includes.h" +# define E_TYPEDEFS 1 +# include "e_includes.h" +# undef E_TYPEDEFS +# include "e_includes.h" EAPI E_Before_Idler *e_main_idler_before_add(int (*func) (void *data), void *data, int once); -EAPI void e_main_idler_before_del(E_Before_Idler *eb); - +EAPI void e_main_idler_before_del(E_Before_Idler *eb); struct _E_Before_Idler { - int (*func) (void *data); - void *data; - unsigned char once : 1; - unsigned char delete_me : 1; + int (*func) (void *data); + void *data; + Eina_Bool once : 1; + Eina_Bool delete_me : 1; }; struct _E_Rect @@ -227,14 +230,15 @@ extern EAPI E_Path *path_icons; extern EAPI E_Path *path_modules; extern EAPI E_Path *path_backgrounds; extern EAPI E_Path *path_messages; -extern EAPI int restart; -extern EAPI int good; -extern EAPI int evil; -extern EAPI int starting; -extern EAPI int stopping; +extern EAPI Eina_Bool good; +extern EAPI Eina_Bool evil; +extern EAPI Eina_Bool starting; +extern EAPI Eina_Bool stopping; +extern EAPI Eina_Bool restart; +extern EAPI Eina_Bool e_precache_end; extern EAPI Eina_Bool x_fatal; -extern EAPI unsigned long e_alert_composite_win; +//extern EAPI unsigned long e_alert_composite_win; #endif diff --git a/src/bin/e_alert.c b/src/bin/e_alert.c index 62846ec0c..9bb78f456 100644 --- a/src/bin/e_alert.c +++ b/src/bin/e_alert.c @@ -1,229 +1,60 @@ #include "e.h" -#include "e_alert.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +/* local function prototypes */ +static Eina_Bool _e_alert_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event); -/* local subsystem functions */ +/* local variables */ +static Ecore_Exe *alert_exe = NULL; +static Ecore_Event_Handler *alert_exe_hdl = NULL; -/* local subsystem globals */ -static Display *dd = NULL; -static char *title = NULL, *str1 = NULL, *str2 = NULL; -static Font font = 0; -static XFontStruct *fs = NULL; -static GC gc = 0; -static Window win = 0, b1 = 0, b2 = 0; -static int ww = 320, hh = 240, wx = 20, wy = 20; - -EAPI unsigned long e_alert_composite_win = 0; - -/* externally accessible functions */ -EINTERN int -e_alert_init(const char *disp) +EINTERN int +e_alert_init(void) { - XGCValues gcv; - int wid, hih, mask; - XSetWindowAttributes att; - - dd = XOpenDisplay(disp); - if (!dd) return 0; - font = XLoadFont(dd, "fixed"); - fs = XQueryFont(dd, font); - - /* dont i18n this - i dont want gettext doing anything as this is called - from a segv */ - title = "Enlightenment Error"; - str1 = "(F1) Recover"; - str2 = "(F2) Exit"; - - wid = DisplayWidth(dd, DefaultScreen(dd)); - hih = DisplayHeight(dd, DefaultScreen(dd)); - att.background_pixel = WhitePixel(dd, DefaultScreen(dd)); - att.border_pixel = BlackPixel(dd, DefaultScreen(dd)); - att.override_redirect = True; - mask = CWBackPixel | CWBorderPixel | CWOverrideRedirect; - - wx = (wid - ww) / 2; - wy = (hih - hh) / 2; - - win = XCreateWindow(dd, DefaultRootWindow(dd), - wx, wy, ww, hh, 0, - CopyFromParent, InputOutput, - CopyFromParent, mask, &att); - - b1 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, - InputOutput, CopyFromParent, mask, &att); - b2 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, - InputOutput, CopyFromParent, mask, &att); - XMapWindow(dd, b1); - XMapWindow(dd, b2); - - gc = XCreateGC(dd, win, 0, &gcv); - XSetForeground(dd, gc, att.border_pixel); - XSelectInput(dd, win, KeyPressMask | KeyReleaseMask | ExposureMask); + alert_exe_hdl = + ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_alert_cb_exe_del, NULL); return 1; } -EINTERN int -e_alert_shutdown(void) +EINTERN int +e_alert_shutdown(void) { - if (!x_fatal) - { - XDestroyWindow(dd, win); - XFreeGC(dd, gc); - XFreeFont(dd, fs); - XCloseDisplay(dd); - } - title = NULL; - str1 = NULL; - str2 = NULL; - dd = NULL; - font = 0; - fs = NULL; - gc = 0; + e_alert_hide(); + + if (alert_exe_hdl) ecore_event_handler_del(alert_exe_hdl); + alert_exe_hdl = NULL; + return 1; } -EAPI void -e_alert_show(const char *text) +EAPI void +e_alert_show(int sig) { - int w, i, j, k; - char line[1024]; - XEvent ev; - int fw, fh, mh; - KeyCode key; - int button; + char buf[8192]; - if (!text) return; + snprintf(buf, sizeof(buf), + "%s/enlightenment/utils/enlightenment_alert %d %d", + e_prefix_lib_get(), sig, getpid()); - if ((!dd) || (!fs)) - { - fputs(text, stderr); - fflush(stderr); - exit(1); - } - - fh = fs->ascent + fs->descent; - mh = ((ww - 20) / 2) - 20; - - /* fixed size... */ - w = 20; - XMoveResizeWindow(dd, b1, w, hh - 15 - fh, mh + 10, fh + 10); - XSelectInput(dd, b1, ButtonPressMask | ButtonReleaseMask | ExposureMask); - w = ww - 20 - mh; - XMoveResizeWindow(dd, b2, w, hh - 15 - fh, mh + 10, fh + 10); - XSelectInput(dd, b2, ButtonPressMask | ButtonReleaseMask | ExposureMask); - - if (e_alert_composite_win) - { -#ifdef ShapeInput - XRectangle rect; - - rect.x = wx; - rect.y = wy; - rect.width = ww; - rect.height = hh; - XShapeCombineRectangles(dd, e_alert_composite_win, ShapeInput, - 0, 0, &rect, 1, ShapeSet, Unsorted); -#endif - XReparentWindow(dd, win, e_alert_composite_win, wx, wy); - } - XMapRaised(dd, win); - XGrabPointer(dd, win, True, ButtonPressMask | ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, None, None, CurrentTime); - XGrabKeyboard(dd, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); - XSetInputFocus(dd, win, RevertToPointerRoot, CurrentTime); - XSync(dd, False); - - button = 0; - while (button == 0) - { - XNextEvent(dd, &ev); - switch (ev.type) - { - case KeyPress: - key = XKeysymToKeycode(dd, XStringToKeysym("F1")); - if (key == ev.xkey.keycode) - { - button = 1; - break; - } - key = XKeysymToKeycode(dd, XStringToKeysym("F2")); - if (key == ev.xkey.keycode) - { - button = 2; - break; - } - break; - case ButtonPress: - if (ev.xbutton.window == b1) - button = 1; - else if (ev.xbutton.window == b2) - button = 2; - break; - case Expose: - while (XCheckTypedWindowEvent(dd, ev.xexpose.window, Expose, &ev)); - - /* outline */ - XDrawRectangle(dd, win, gc, 0, 0, ww - 1, hh - 1); - - XDrawRectangle(dd, win, gc, 2, 2, ww - 4 - 1, fh + 4 - 1); - - fw = XTextWidth(fs, title, strlen(title)); - XDrawString(dd, win, gc, 2 + 2 + ((ww - 4 - 4 - fw) / 2) , 2 + 2 + fs->ascent, title, strlen(title)); - - i = 0; - j = 0; - k = 2 + fh + 4 + 2; - while (text[i]) - { - line[j++] = text[i++]; - if (line[j - 1] == '\n') - { - line[j - 1] = 0; - j = 0; - XDrawString(dd, win, gc, 4, k + fs->ascent, line, strlen(line)); - k += fh + 2; - } - } - fw = XTextWidth(fs, str1, strlen(str1)); - XDrawRectangle(dd, b1, gc, 0, 0, mh - 1, fh + 10 - 1); - XDrawString(dd, b1, gc, 5 + ((mh - fw) / 2), 5 + fs->ascent, str1, strlen(str1)); - - fw = XTextWidth(fs, str2, strlen(str2)); - XDrawRectangle(dd, b2, gc, 0, 0, mh - 1, fh + 10 - 1); - XDrawString(dd, b2, gc, 5 + ((mh - fw) / 2), 5 + fs->ascent, str2, strlen(str2)); - - XSync(dd, False); - break; - - default: - break; - } - } - XDestroyWindow(dd, win); - XSync(dd, False); - - switch (button) - { - case 1: - ecore_app_restart(); - break; - case 2: - exit(-11); - break; - default: - break; - } + alert_exe = ecore_exe_run(buf, NULL); + pause(); } -/* local subsystem functions */ +EAPI void +e_alert_hide(void) +{ + if (alert_exe) ecore_exe_terminate(alert_exe); +} + +/* local functions */ +static Eina_Bool +_e_alert_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event) +{ + Ecore_Exe_Event_Del *ev; + + ev = event; + if (!alert_exe) return ECORE_CALLBACK_RENEW; + if (ev->exe == alert_exe) alert_exe = NULL; + + return ECORE_CALLBACK_RENEW; +} diff --git a/src/bin/e_alert.h b/src/bin/e_alert.h index 7c821dda6..0e93adad9 100644 --- a/src/bin/e_alert.h +++ b/src/bin/e_alert.h @@ -1,13 +1,20 @@ #ifdef E_TYPEDEFS +typedef enum _E_Alert_Op_Type +{ + E_ALERT_OP_RESTART = 0, + E_ALERT_OP_EXIT +} E_Alert_Op_Type; + #else #ifndef E_ALERT_H #define E_ALERT_H -EINTERN int e_alert_init(const char *disp); +EINTERN int e_alert_init(void); EINTERN int e_alert_shutdown(void); -void e_alert_show(const char *text); +EAPI void e_alert_show(int sig); +EAPI void e_alert_hide(void); #endif #endif diff --git a/src/bin/e_alert_main.c b/src/bin/e_alert_main.c new file mode 100644 index 000000000..aa2bde598 --- /dev/null +++ b/src/bin/e_alert_main.c @@ -0,0 +1,615 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WINDOW_WIDTH 320 +#define WINDOW_HEIGHT 240 + +/* local function prototypes */ +static int _e_alert_ipc_init(void); +static Eina_Bool _e_alert_ipc_server_add(void *data, int type, void *event); +static int _e_alert_connect(void); +static void _e_alert_create(void); +static void _e_alert_display(void); +static void _e_alert_button_move_resize(xcb_window_t btn, int x, int y, int w, int h); +static void _e_alert_window_raise(xcb_window_t win); +static void _e_alert_sync(void); +static void _e_alert_shutdown(void); +static void _e_alert_run(void); +static void _e_alert_draw(void); +static int _e_alert_handle_key_press(xcb_generic_event_t *event); +static int _e_alert_handle_button_press(xcb_generic_event_t *event); +static xcb_char2b_t *_e_alert_build_string(const char *str); +static void _e_alert_draw_outline(void); +static void _e_alert_draw_title_outline(void); +static void _e_alert_draw_title(void); +static void _e_alert_draw_text(void); +static void _e_alert_draw_button_outlines(void); +static void _e_alert_draw_button_text(void); +static void _e_alert_restart_e(void); +static void _e_alert_exit_e(void); + +/* local variables */ +static Ecore_Ipc_Server *_ipc_server = NULL; +static Ecore_Ipc_Server *_server = NULL; +static xcb_connection_t *conn = NULL; +static xcb_screen_t *screen = NULL; +static xcb_window_t win = 0; +static xcb_window_t btn1 = 0; +static xcb_window_t btn2 = 0; +static xcb_font_t font = 0; +static xcb_gcontext_t gc = 0; +static int sw = 0, sh = 0; +static int fa = 0, fh = 0, fw = 0; +static const char *title = NULL, *str1 = NULL, *str2 = NULL; +static int ret = 0, sig = 0; +static pid_t pid; + +int +main(int argc, char **argv) +{ + int i = 0; + + for (i = 1; i < argc; i++) + { + if ((!strcmp(argv[i], "-h")) || + (!strcmp(argv[i], "-help")) || + (!strcmp(argv[i], "--help"))) + { + printf("This is an internal tool for Enlightenment.\n" + "do not use it.\n"); + exit(0); + } + else if ((i == 1)) + sig = atoi(argv[i]); // signal + else if ((i == 2)) + pid = atoi(argv[i]); // E's pid + } + + if (!ecore_init()) return EXIT_FAILURE; + if (!ecore_ipc_init()) + { + ecore_shutdown(); + return EXIT_FAILURE; + } + + if (!_e_alert_connect()) + { + printf("FAILED TO INIT ALERT SYSTEM!!!\n"); + ecore_ipc_shutdown(); + ecore_shutdown(); + return EXIT_FAILURE; + } + + if (!_e_alert_ipc_init()) + { + printf("Failed to Connect to Enlightenment!!!\n"); + ecore_ipc_shutdown(); + ecore_shutdown(); + return EXIT_FAILURE; + } + + title = "Enlightenment Error"; + str1 = "(F1) Recover"; + str2 = "(F2) Exit"; + + _e_alert_create(); + _e_alert_display(); + _e_alert_run(); + _e_alert_shutdown(); + + if (ret == 1) + _e_alert_restart_e(); + else if (ret == 2) + _e_alert_exit_e(); + + if (_ipc_server) + ecore_ipc_server_del(_ipc_server); + + ecore_ipc_shutdown(); + ecore_shutdown(); + + return EXIT_SUCCESS; +} + +/* local functions */ +static int +_e_alert_ipc_init(void) +{ + char *edir = NULL; + + if (!(edir = getenv("E_IPC_SOCKET"))) return 0; + _ipc_server = + ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, edir, 0, NULL); + if (!_ipc_server) return 0; + + ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, + _e_alert_ipc_server_add, NULL); + return 1; +} + +static Eina_Bool +_e_alert_ipc_server_add(void *data, int type, void *event) +{ + Ecore_Ipc_Event_Server_Add *e; + + e = event; + _server = e->server; + return ECORE_CALLBACK_PASS_ON; +} + +static int +_e_alert_connect(void) +{ + conn = xcb_connect(NULL, NULL); + if ((!conn) || (xcb_connection_has_error(conn))) + { + printf("E_Alert_Main: Error Trying to Connect!!\n"); + return 0; + } + + /* grab default screen */ + screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data; + sw = screen->width_in_pixels; + sh = screen->height_in_pixels; + + return 1; +} + +static void +_e_alert_create(void) +{ + uint32_t mask, mask_list[4]; + int wx = 0, wy = 0; + + wx = ((sw - WINDOW_WIDTH) / 2); + wy = ((sh - WINDOW_HEIGHT) / 2); + + font = xcb_generate_id(conn); + xcb_open_font(conn, font, strlen("fixed"), "fixed"); + + /* create main window */ + mask = (XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | + XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK); + mask_list[0] = screen->white_pixel; + mask_list[1] = screen->black_pixel; + mask_list[2] = 1; + mask_list[3] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | + XCB_EVENT_MASK_EXPOSURE); + + win = xcb_generate_id(conn); + xcb_create_window(conn, XCB_COPY_FROM_PARENT, win, screen->root, + wx, wy, WINDOW_WIDTH, WINDOW_HEIGHT, 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + XCB_COPY_FROM_PARENT, mask, mask_list); + + /* create button 1 */ + mask_list[3] = (XCB_EVENT_MASK_BUTTON_PRESS | + XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_EXPOSURE); + + btn1 = xcb_generate_id(conn); + xcb_create_window(conn, XCB_COPY_FROM_PARENT, btn1, win, + -100, -100, 1, 1, 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + XCB_COPY_FROM_PARENT, mask, mask_list); + xcb_map_window(conn, btn1); + + /* create button 2 */ + btn2 = xcb_generate_id(conn); + xcb_create_window(conn, XCB_COPY_FROM_PARENT, btn2, win, + -100, -100, 1, 1, 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + XCB_COPY_FROM_PARENT, mask, mask_list); + xcb_map_window(conn, btn2); + + /* create drawing gc */ + mask = (XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT); + mask_list[0] = screen->black_pixel; + mask_list[1] = screen->white_pixel; + mask_list[2] = font; + + gc = xcb_generate_id(conn); + xcb_create_gc(conn, gc, win, mask, mask_list); +} + +static void +_e_alert_display(void) +{ + xcb_char2b_t *str = NULL; + xcb_query_text_extents_cookie_t cookie; + xcb_query_text_extents_reply_t *reply; + int x = 0, w = 0; + + str = _e_alert_build_string(title); + + cookie = + xcb_query_text_extents_unchecked(conn, font, strlen(title), str); + reply = xcb_query_text_extents_reply(conn, cookie, NULL); + if (reply) + { + fa = reply->font_ascent; + fh = (fa + reply->font_descent); + fw = reply->overall_width; + free(reply); + } + free(str); + + /* move buttons */ + x = 20; + w = (WINDOW_WIDTH / 2) - 40; + _e_alert_button_move_resize(btn1, x, WINDOW_HEIGHT - 20 - (fh + 20), + w, (fh + 20)); + + x = ((WINDOW_WIDTH / 2) + 20); + _e_alert_button_move_resize(btn2, x, WINDOW_HEIGHT - 20 - (fh + 20), + w, (fh + 20)); + + /* FIXME: May need e_alert_composite_win here and checks for shapedinput */ + /* if (e_alert_composite_win) */ + /* { */ +/* #ifdef ShapeInput */ + /* XRectangle rect; */ + + /* rect.x = wx; */ + /* rect.y = wy; */ + /* rect.width = ww; */ + /* rect.height = hh; */ + /* XShapeCombineRectangles(dd, e_alert_composite_win, ShapeInput, */ + /* 0, 0, &rect, 1, ShapeSet, Unsorted); */ +/* #endif */ + /* XReparentWindow(dd, win, e_alert_composite_win, wx, wy); */ + /* } */ + + /* map and raise main window */ + xcb_map_window(conn, win); + _e_alert_window_raise(win); + + /* grab pointer & keyboard */ + xcb_grab_pointer_unchecked(conn, 0, win, + (XCB_EVENT_MASK_BUTTON_PRESS | + XCB_EVENT_MASK_BUTTON_RELEASE), + XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, + XCB_NONE, XCB_NONE, XCB_CURRENT_TIME); + xcb_grab_keyboard_unchecked(conn, 0, win, XCB_CURRENT_TIME, + XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); + xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, + win, XCB_CURRENT_TIME); + + /* flush screen */ + xcb_flush(conn); + + /* sync */ + _e_alert_sync(); +} + +static void +_e_alert_button_move_resize(xcb_window_t btn, int x, int y, int w, int h) +{ + uint32_t list[4], mask; + + if (!btn) return; + + mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | + XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT); + list[0] = x; + list[1] = y; + list[2] = w; + list[3] = h; + + xcb_configure_window(conn, btn, mask, (const uint32_t *)&list); +} + +static void +_e_alert_window_raise(xcb_window_t win) +{ + uint32_t list[] = { XCB_STACK_MODE_ABOVE }; + + if (!win) return; + xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, list); +} + +static void +_e_alert_sync(void) +{ + xcb_flush(conn); + free(xcb_get_input_focus_reply(conn, + xcb_get_input_focus(conn), NULL)); +} + +static void +_e_alert_shutdown(void) +{ + xcb_close_font(conn, font); + xcb_destroy_window(conn, btn1); + xcb_destroy_window(conn, btn2); + xcb_destroy_window(conn, win); + xcb_free_gc(conn, gc); + xcb_disconnect(conn); +} + +static void +_e_alert_run(void) +{ + xcb_generic_event_t *event = NULL; + + xcb_flush(conn); + while ((event = xcb_wait_for_event(conn))) + { + switch (event->response_type & ~0x80) + { + case XCB_BUTTON_PRESS: + ret = _e_alert_handle_button_press(event); + break; + case XCB_KEY_PRESS: + ret = _e_alert_handle_key_press(event); + break; + case XCB_EXPOSE: + { + xcb_expose_event_t *ev; + + ev = (xcb_expose_event_t *)event; + if (ev->window != win) break; + + _e_alert_draw(); + _e_alert_sync(); + + break; + } + default: + break; + } + free(event); + if (ret > 0) break; + } +} + +static void +_e_alert_draw(void) +{ + _e_alert_draw_outline(); + _e_alert_draw_title_outline(); + _e_alert_draw_title(); + _e_alert_draw_text(); + _e_alert_draw_button_outlines(); + _e_alert_draw_button_text(); + + xcb_flush(conn); +} + +static int +_e_alert_handle_key_press(xcb_generic_event_t *event) +{ + xcb_key_press_event_t *ev; + + ev = (xcb_key_press_event_t *)event; + if (ev->detail == 67) // F1 + return 1; + else if (ev->detail == 68) // F2 + return 2; + else + return 0; +} + +static int +_e_alert_handle_button_press(xcb_generic_event_t *event) +{ + xcb_button_press_event_t *ev; + + ev = (xcb_button_press_event_t *)event; + if (ev->child == btn1) + return 1; + else if (ev->child == btn2) + return 2; + else + return 0; +} + +static xcb_char2b_t * +_e_alert_build_string(const char *str) +{ + unsigned int i = 0; + xcb_char2b_t *ret = NULL; + + if (!(ret = malloc(strlen(str) * sizeof(xcb_char2b_t)))) + return NULL; + + for (i = 0; i < strlen(str); i++) + { + ret[i].byte1 = 0; + ret[i].byte2 = str[i]; + } + + return ret; +} + +static void +_e_alert_draw_outline(void) +{ + xcb_rectangle_t rect; + + /* draw outline */ + rect.x = 0; + rect.y = 0; + rect.width = (WINDOW_WIDTH - 1); + rect.height = (WINDOW_HEIGHT - 1); + xcb_poly_rectangle(conn, win, gc, 1, &rect); +} + +static void +_e_alert_draw_title_outline(void) +{ + xcb_rectangle_t rect; + + /* draw title box */ + rect.x = 2; + rect.y = 2; + rect.width = (WINDOW_WIDTH - 4 - 1); + rect.height = (fh + 4 + 2); + xcb_poly_rectangle(conn, win, gc, 1, &rect); +} + +static void +_e_alert_draw_title(void) +{ + xcb_void_cookie_t cookie; + int x = 0, y = 0; + + /* draw title */ + x = (2 + 2 + ((WINDOW_WIDTH - 4 - 4 - fw) / 2)); + y = (2 + 2 + fh); + + cookie = + xcb_image_text_8(conn, strlen(title), win, gc, x, y, title); +} + +static void +_e_alert_draw_text(void) +{ + xcb_void_cookie_t cookie; + char warn[1024], msg[PATH_MAX], line[1024]; + int i = 0, j = 0, k = 0; + + snprintf(msg, sizeof(msg), + "This is not meant to happen and is likely a sign of \n" + "a bug in Enlightenment or the libraries it relies \n" + "on. You can gdb attach to this process (%d) now \n" + "to try debug it or you could exit, or just hit \n" + "restart to try and get your desktop back the way \n" + "it was.\n" + "\n" + "Please compile everything with -g in your CFLAGS.", pid); + + switch (sig) + { + case SIGSEGV: + snprintf(warn, sizeof(warn), + "This is very bad. Enlightenment SEGV'd."); + break; + case SIGILL: + snprintf(warn, sizeof(warn), + "This is very bad. Enlightenment SIGILL'd."); + break; + case SIGFPE: + snprintf(warn, sizeof(warn), + "This is very bad. Enlightenment SIGFPE'd."); + break; + case SIGBUS: + snprintf(warn, sizeof(warn), + "This is very bad. Enlightenment SIGBUS'd."); + break; + case SIGABRT: + snprintf(warn, sizeof(warn), + "This is very bad. Enlightenment SIGABRT'd."); + break; + default: + break; + } + + /* draw text */ + k = (fh + 12); + cookie = + xcb_image_text_8(conn, strlen(warn), win, gc, + 4, (k + fa), warn); + k += (2 * (fh + 2)); + while (msg[i]) + { + line[j++] = msg[i++]; + if (line[j - 1] == '\n') + { + line[j - 1] = 0; + j = 0; + cookie = + xcb_image_text_8(conn, strlen(line), win, gc, + 4, (k + fa), line); + k += (fh + 2); + } + } +} + +static void +_e_alert_draw_button_outlines(void) +{ + xcb_rectangle_t rect; + + rect.x = 0; + rect.y = 0; + rect.width = (WINDOW_WIDTH / 2) - 40 - 1; + rect.height = (fh + 20) - 1; + + /* draw button outlines */ + xcb_poly_rectangle(conn, btn1, gc, 1, &rect); + xcb_poly_rectangle(conn, btn2, gc, 1, &rect); +} + +static void +_e_alert_draw_button_text(void) +{ + xcb_void_cookie_t dcookie; + xcb_char2b_t *str = NULL; + xcb_query_text_extents_cookie_t cookie; + xcb_query_text_extents_reply_t *reply; + int x = 0, w = 0, bw = 0; + + bw = (WINDOW_WIDTH / 2) - 40 - 1; + + /* draw button1 text */ + str = _e_alert_build_string(str1); + + cookie = + xcb_query_text_extents_unchecked(conn, font, strlen(str1), str); + reply = xcb_query_text_extents_reply(conn, cookie, NULL); + if (reply) + { + w = reply->overall_width; + free(reply); + } + free(str); + + x = (5 + ((bw - w) / 2)); + + dcookie = + xcb_image_text_8(conn, strlen(str1), btn1, gc, x, (10 + fa), str1); + + /* draw button2 text */ + str = _e_alert_build_string(str2); + + cookie = + xcb_query_text_extents_unchecked(conn, font, strlen(str2), str); + reply = xcb_query_text_extents_reply(conn, cookie, NULL); + if (reply) + { + w = reply->overall_width; + free(reply); + } + free(str); + + x = (5 + ((bw - w) / 2)); + + dcookie = + xcb_image_text_8(conn, strlen(str2), btn2, gc, x, (10 + fa), str2); +} + +static void +_e_alert_restart_e(void) +{ + kill(getppid(), SIGUSR2); + ecore_ipc_server_send(_server, 8, 0, 0, 0, 0, NULL, 0); + ecore_ipc_server_flush(_server); +} + +static void +_e_alert_exit_e(void) +{ + kill(getppid(), SIGUSR2); + ecore_ipc_server_send(_server, 8, 1, 0, 0, 0, NULL, 0); + ecore_ipc_server_flush(_server); +} diff --git a/src/bin/e_config.c b/src/bin/e_config.c index 5071475e7..f81303769 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -903,9 +903,9 @@ e_config_init(void) E_CONFIG_VAL(D, T, exec.show_exit_dialog, UCHAR); E_CONFIG_VAL(D, T, null_container_win, UCHAR); - + E_CONFIG_LIST(D, T, env_vars, _e_config_env_var_edd); - + E_CONFIG_VAL(D, T, backlight.normal, DOUBLE); E_CONFIG_VAL(D, T, backlight.dim, DOUBLE); E_CONFIG_VAL(D, T, backlight.transition, DOUBLE); @@ -914,7 +914,7 @@ e_config_init(void) E_CONFIG_VAL(D, T, deskenv.load_xmodmap, UCHAR); E_CONFIG_VAL(D, T, deskenv.load_gnome, UCHAR); E_CONFIG_VAL(D, T, deskenv.load_kde, UCHAR); - + e_config_load(); e_config_save_queue(); @@ -1021,15 +1021,13 @@ e_config_load(void) { printf("EEEK! no config of any sort! abort abort abort!\n"); fprintf(stderr, "EEEK! no config of any sort! abort abort abort!\n"); - e_alert_show("Enlightenment was started without any configuration\n" - "files available for the given profile (normally\n" - "default or the last profile used or provided on the\n" - "command-line with -profile etc.)\n" - "\n" - "Cannot contiue without configuration to work with.\n" - "Please ensure you have system or user configuration\n" - "for the profile you are using before proceeeding." - ); + e_error_message_show("Enlightenment was started without any configuration\n" + "files available for the given profile (normally\n" + "default or the last profile used or provided on the\n" + "command-line with -profile etc.)\n\n" + "Cannot contiue without configuration to work with.\n" + "Please ensure you have system or user configuration\n" + "for the profile you are using before proceeeding."); abort(); } if (e_config->config_version < E_CONFIG_FILE_VERSION) diff --git a/src/bin/e_fm/Makefile.am b/src/bin/e_fm/Makefile.am index a27dd9a75..a0ef6a0d3 100644 --- a/src/bin/e_fm/Makefile.am +++ b/src/bin/e_fm/Makefile.am @@ -6,7 +6,6 @@ AM_CFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/src/bin \ @e_cflags@ \ -@x_cflags@ \ @cf_cflags@ \ @VALGRIND_CFLAGS@ \ @EDJE_DEF@ \ @@ -61,4 +60,3 @@ $(eeze_s) \ ../e_sha1.c enlightenment_fm_LDADD = @E_FM_LIBS@ - diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c index 4f6f4d850..de443295d 100644 --- a/src/bin/e_ipc.c +++ b/src/bin/e_ipc.c @@ -2,15 +2,9 @@ #ifdef USE_IPC /* local subsystem functions */ -static Eina_Bool _e_ipc_cb_client_add(void *data __UNUSED__, - int type __UNUSED__, - void *event); -static Eina_Bool _e_ipc_cb_client_del(void *data __UNUSED__, - int type __UNUSED__, - void *event); -static Eina_Bool _e_ipc_cb_client_data(void *data __UNUSED__, - int type __UNUSED__, - void *event); +static Eina_Bool _e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event); +static Eina_Bool _e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event); +static Eina_Bool _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event); /* local subsystem globals */ static Ecore_Ipc_Server *_e_ipc_server = NULL; @@ -42,8 +36,7 @@ e_ipc_init(void) if (stat(buf, &st) == 0) { - if ((st.st_uid == - getuid()) && + if ((st.st_uid == getuid()) && ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) == (S_IRWXU | S_IFDIR))) { @@ -68,15 +61,19 @@ e_ipc_init(void) return 0; } } - snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i", tmp, user, disp, pid); + snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i", + tmp, user, disp, pid); _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, buf, 0, NULL); e_util_env_set("E_IPC_SOCKET", ""); if (!_e_ipc_server) return 0; e_util_env_set("E_IPC_SOCKET", buf); printf("INFO: E_IPC_SOCKET=%s\n", buf); - ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _e_ipc_cb_client_add, NULL); - ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _e_ipc_cb_client_del, NULL); - ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _e_ipc_cb_client_data, NULL); + ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, + _e_ipc_cb_client_add, NULL); + ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, + _e_ipc_cb_client_del, NULL); + ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, + _e_ipc_cb_client_data, NULL); e_ipc_codec_init(); #endif @@ -100,26 +97,24 @@ e_ipc_shutdown(void) #ifdef USE_IPC /* local subsystem globals */ static Eina_Bool -_e_ipc_cb_client_add(void *data __UNUSED__, - int type __UNUSED__, - void *event) +_e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event) { Ecore_Ipc_Event_Client_Add *e; e = event; - if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return ECORE_CALLBACK_PASS_ON; + if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) + return ECORE_CALLBACK_PASS_ON; return ECORE_CALLBACK_PASS_ON; } static Eina_Bool -_e_ipc_cb_client_del(void *data __UNUSED__, - int type __UNUSED__, - void *event) +_e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event) { Ecore_Ipc_Event_Client_Del *e; e = event; - if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return ECORE_CALLBACK_PASS_ON; + if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) + return ECORE_CALLBACK_PASS_ON; /* delete client sruct */ e_thumb_client_del(e); e_fm2_client_del(e); @@ -129,14 +124,13 @@ _e_ipc_cb_client_del(void *data __UNUSED__, } static Eina_Bool -_e_ipc_cb_client_data(void *data __UNUSED__, - int type __UNUSED__, - void *event) +_e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event) { Ecore_Ipc_Event_Client_Data *e; e = event; - if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return ECORE_CALLBACK_PASS_ON; + if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) + return ECORE_CALLBACK_PASS_ON; switch (e->major) { case E_IPC_DOMAIN_SETUP: @@ -146,50 +140,50 @@ _e_ipc_cb_client_data(void *data __UNUSED__, switch (e->minor) { case E_IPC_OP_EXEC_ACTION: - { - E_Ipc_2Str *req = NULL; + { + E_Ipc_2Str *req = NULL; - if (e_ipc_codec_2str_dec(e->data, e->size, &req)) - { - Eina_List *m = e_manager_list(); - int len, ok = 0; - void *d; + if (e_ipc_codec_2str_dec(e->data, e->size, &req)) + { + Eina_List *m = e_manager_list(); + int len, ok = 0; + void *d; - if (m) - { - E_Manager *man = eina_list_data_get(m); + if (m) + { + E_Manager *man = eina_list_data_get(m); - if (man) - { - E_Action *act = e_action_find(req->str1); + if (man) + { + E_Action *act = e_action_find(req->str1); - if (act && act->func.go) - { - act->func.go(E_OBJECT(man), req->str2); - ok = 1; - } - } - } + if ((act) && (act->func.go)) + { + act->func.go(E_OBJECT(man), req->str2); + ok = 1; + } + } + } - d = e_ipc_codec_int_enc(ok, &len); - if (d) - { - ecore_ipc_client_send(e->client, - E_IPC_DOMAIN_REPLY, - E_IPC_OP_EXEC_ACTION_REPLY, - 0, 0, 0, d, len); - free(d); - } + d = e_ipc_codec_int_enc(ok, &len); + if (d) + { + ecore_ipc_client_send(e->client, + E_IPC_DOMAIN_REPLY, + E_IPC_OP_EXEC_ACTION_REPLY, + 0, 0, 0, d, len); + free(d); + } - if (req) - { - E_FREE(req->str1); - E_FREE(req->str2); - E_FREE(req); - } - } - } - break; + if (req) + { + E_FREE(req->str1); + E_FREE(req->str2); + E_FREE(req); + } + } + } + break; default: break; @@ -208,6 +202,23 @@ _e_ipc_cb_client_data(void *data __UNUSED__, e_init_client_data(e); break; + case E_IPC_DOMAIN_ALERT: + { + E_Action *a = NULL; + + switch (e->minor) + { + case E_ALERT_OP_RESTART: + a = e_action_find("restart"); + break; + case E_ALERT_OP_EXIT: + a = e_action_find("exit"); + break; + } + if ((a) && (a->func.go)) a->func.go(NULL, NULL); + break; + } + default: break; } diff --git a/src/bin/e_ipc.h b/src/bin/e_ipc.h index 85ac7be8d..760c58886 100644 --- a/src/bin/e_ipc.h +++ b/src/bin/e_ipc.h @@ -15,6 +15,7 @@ typedef enum _E_Ipc_Domain E_IPC_DOMAIN_THUMB, E_IPC_DOMAIN_FM, E_IPC_DOMAIN_INIT, + E_IPC_DOMAIN_ALERT, E_IPC_DOMAIN_LAST } E_Ipc_Domain; diff --git a/src/bin/e_main.c b/src/bin/e_main.c index c5d5f948c..7228e8300 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -1,15 +1,22 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "e.h" - #ifdef HAVE_ECORE_IMF -#include +# include #endif -#include -#include +#define MAX_LEVEL 55 + +#define TS_DO +#ifdef TS_DO +#define TS(x) \ + { \ + t1 = ecore_time_unix_get(); \ + printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \ + t2 = t1; \ + } +static double t0, t1, t2; +#else +# define TS(x) +#endif /* * i need to make more use of these when i'm baffled as to when something is @@ -59,111 +66,75 @@ my_free_hook(void *p, const void *caller) } */ -EAPI int e_precache_end = 0; -EAPI Eina_Bool x_fatal = EINA_FALSE; - -static int really_know = 0; - -/* local subsystem functions */ +/* local function prototypes */ +static void _e_main_shutdown(int errcode); static void _e_main_shutdown_push(int (*func)(void)); -static void _e_main_shutdown(int errorcode); - -static int _e_main_x_shutdown(void); -static int _e_main_dirs_init(void); -static int _e_main_dirs_shutdown(void); -static int _e_main_screens_init(void); -static int _e_main_screens_shutdown(void); -static void _e_main_manage_all(void); -static int _e_main_path_init(void); -static int _e_main_path_shutdown(void); - +static void _e_main_parse_arguments(int argc, char **argv); static void _e_main_cb_x_fatal(void *data __UNUSED__); static Eina_Bool _e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__); static Eina_Bool _e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__); static Eina_Bool _e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev); -static Eina_Bool _e_main_cb_x_flusher(void *data __UNUSED__); -static Eina_Bool _e_main_cb_idler_before(void *data __UNUSED__); -static Eina_Bool _e_main_cb_idler_after(void *data __UNUSED__); -static Eina_Bool _e_main_cb_eet_cacheburst_end(void *data __UNUSED__); -static Eina_Bool _e_main_cb_startup_fake_end(void *data __UNUSED__); +static int _e_main_x_shutdown(void); +static int _e_main_dirs_init(void); +static int _e_main_dirs_shutdown(void); +static int _e_main_path_init(void); +static int _e_main_path_shutdown(void); +static void _e_main_test_formats(void); +static int _e_main_screens_init(void); +static int _e_main_screens_shutdown(void); static void _e_main_desk_save(void); static void _e_main_desk_restore(E_Manager *man, E_Container *con); +static void _e_main_efreet_paths_init(void); +static void _e_main_modules_load(Eina_Bool safe_mode); +static void _e_main_manage_all(void); +static Eina_Bool _e_main_cb_x_flusher(void *data __UNUSED__); +static Eina_Bool _e_main_cb_idle_before(void *data __UNUSED__); +static Eina_Bool _e_main_cb_idle_after(void *data __UNUSED__); +static Eina_Bool _e_main_cb_startup_fake_end(void *data __UNUSED__); -/* local subsystem globals */ -#define MAX_LEVEL 64 -static int (*_e_main_shutdown_func[MAX_LEVEL]) (void); -static int _e_main_level = 0; -static int _e_cacheburst = 0; +/* local variables */ +static Eina_Bool really_know = EINA_FALSE; static Eina_Bool locked = EINA_FALSE; - -static jmp_buf x_fatal_buf; static Eina_Bool inloop = EINA_FALSE; +static jmp_buf x_fatal_buff; -static Eina_List *_e_main_idler_before_list = NULL; +static int _e_main_lvl = 0; +static int (*_e_main_shutdown_func[MAX_LEVEL])(void); -static Ecore_Idle_Enterer *_e_main_idle_enterer_before = NULL; -static Ecore_Idle_Enterer *_e_main_idle_enterer_after = NULL; -static Ecore_Idle_Enterer *_e_main_idle_enterer_flusher = NULL; +static Eina_List *_idle_before_list = NULL; +static Ecore_Idle_Enterer *_idle_before = NULL; +static Ecore_Idle_Enterer *_idle_after = NULL; +static Ecore_Idle_Enterer *_idle_flush = NULL; -#define TS_DO - -#ifdef TS_DO -#define TS(x) \ - { \ - t1 = ecore_time_unix_get(); \ - printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \ - t2 = t1; \ - } -static double t0, t1, t2; -#else -#define TS(x) -#endif - -#undef DBG_EINA_STRINGSHARE - -#ifdef DBG_EINA_STRINGSHARE -static Eina_Bool -stdbg(void *data __UNUSED__) -{ -// enable to debug eina stringshare usage - eina_stringshare_dump(); - return ECORE_CALLBACK_CANCEL; -} -#endif +/* external variables */ +EAPI Eina_Bool e_precache_end = EINA_FALSE; +EAPI Eina_Bool x_fatal = EINA_FALSE; +EAPI Eina_Bool good = EINA_FALSE; +EAPI Eina_Bool evil = EINA_FALSE; +EAPI Eina_Bool starting = EINA_TRUE; +EAPI Eina_Bool stopping = EINA_FALSE; +EAPI Eina_Bool restart = EINA_FALSE; /* externally accessible functions */ -int -main(int argc, char **argv) +int +main(int argc, char **argv) { - int i; - int nostartup = 0; - int after_restart = 0; - int safe_mode = 0; - char buf[PATH_MAX]; - char *s; + Eina_Bool nostartup = EINA_FALSE; + Eina_Bool safe_mode = EINA_FALSE; + Eina_Bool after_restart = EINA_FALSE; + double t = 0.0, tstart = 0.0; + char *s = NULL, buff[PATH_MAX]; struct sigaction action; - double t, tstart; - #ifdef TS_DO t0 = t1 = t2 = ecore_time_unix_get(); #endif - TS("begin"); - -#if 0 - { - stack_t ss; - ss.ss_sp = malloc(8 * 1024); - ss.ss_size = 8 * 1024; - ss.ss_flags = 0; - sigaltstack(&ss, NULL); - } -#endif + TS("Begin Startup"); /* trap deadly bug signals and allow some form of sane recovery */ /* or ability to gdb attach and debug at this point - better than your */ /* wm/desktop vanishing and not knowing what happened */ - + TS("Signal Trap"); action.sa_sigaction = e_sigseg_act; action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO; sigemptyset(&action.sa_mask); @@ -188,57 +159,858 @@ main(int argc, char **argv) action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO; sigemptyset(&action.sa_mask); sigaction(SIGABRT, &action, NULL); - - TS("signals done"); + TS("Signal Trap Done"); t = ecore_time_unix_get(); s = getenv("E_START_TIME"); - if ((s) && (!getenv("E_RESTART_OK"))) + if ((s) && (!getenv("E_RESTART_OK"))) { - tstart = atof(s); - if ((t - tstart) < 5.0) safe_mode = 1; + tstart = atof(s); + if ((t - tstart) < 5.0) safe_mode = EINA_TRUE; } - tstart = t; - snprintf(buf, sizeof(buf), "%1.1f", tstart); - e_util_env_set("E_START_TIME", buf); + snprintf(buff, sizeof(buff), "%1.1f", tstart); + e_util_env_set("E_START_TIME", buff); - TS("eina init"); - eina_init(); + TS("Eina Init"); + if (!eina_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Eina!\n")); + _e_main_shutdown(-1); + } + TS("Eina Init Done"); _e_main_shutdown_push(eina_shutdown); - TS("determine prefix"); - if (!e_prefix_determine(argv[0])) + TS("Determine Prefix"); + if (!e_prefix_determine(argv[0])) { - fprintf(stderr, - "ERROR: Enlightenment cannot determine its installed\n" - " prefix from the system or argv[0].\n" - " This is because it is not on Linux AND has been\n" - " Executed strangely. This is unusual.\n" - ); + fprintf(stderr, + "ERROR: Enlightenment cannot determine it's installed\n" + " prefix from the system or argv[0].\n" + " This is because it is not on Linux AND has been\n" + " executed strangely. This is unusual.\n"); } - TS("prefix done"); + TS("Determine Prefix Done"); /* for debugging by redirecting stdout of e to a log file to tail */ setvbuf(stdout, NULL, _IONBF, 0); - if (getenv("E_RESTART")) after_restart = 1; - - if (getenv("DESKTOP_STARTUP_ID")) + TS("Environment Variables"); + if (getenv("E_RESTART")) after_restart = EINA_TRUE; + if (getenv("DESKTOP_STARTUP_ID")) e_util_env_set("DESKTOP_STARTUP_ID", NULL); - e_util_env_set("E_RESTART_OK", NULL); e_util_env_set("E_RESTART", "1"); - - /* envrionment varabiles so you know E is running/launched you */ e_util_env_set("PANTS", "ON"); e_util_env_set("DESKTOP", "Enlightenment-0.17.0"); + TS("Environment Variables Done"); - TS("intl init"); - e_intl_init(); + TS("Parse Arguments"); + _e_main_parse_arguments(argc, argv); + TS("Parse Arguments Done"); + + /*** Initialize Core EFL Libraries We Need ***/ + + TS("Eet Init"); + if (!eet_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Eet!\n")); + _e_main_shutdown(-1); + } + TS("Eet Init Done"); + _e_main_shutdown_push(eet_shutdown); + + TS("Ecore Init"); + if (!ecore_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Ecore!\n")); + _e_main_shutdown(-1); + } + TS("Ecore Init Done"); + _e_main_shutdown_push(ecore_shutdown); + + ecore_app_args_set(argc, (const char **)argv); + + TS("Ecore Event Handlers"); + if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, + _e_main_cb_signal_exit, NULL)) + { + e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n" + "Perhaps you are out of memory?")); + _e_main_shutdown(-1); + } + if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, + _e_main_cb_signal_hup, NULL)) + { + e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n" + "Perhaps you are out of memory?")); + _e_main_shutdown(-1); + } + if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, + _e_main_cb_signal_user, NULL)) + { + e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n" + "Perhaps you are out of memory?")); + _e_main_shutdown(-1); + } + TS("Ecore Event Handlers Done"); + +#ifdef HAVE_ECORE_IMF + TS("Ecore_IMF Init"); + if (!ecore_imf_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Ecore_IMF!\n")); + _e_main_shutdown(-1); + } + TS("Ecore_IMF Init Done"); + _e_main_shutdown_push(ecore_imf_shutdown); +#endif + + TS("Ecore_File Init"); + if (!ecore_file_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n")); + _e_main_shutdown(-1); + } + TS("Ecore_File Init Done"); + _e_main_shutdown_push(ecore_file_shutdown); + + TS("Ecore_Con Init"); + if (!ecore_con_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Ecore_Con!\n")); + _e_main_shutdown(-1); + } + TS("Ecore_Con Init Done"); + _e_main_shutdown_push(ecore_con_shutdown); + + TS("Ecore_Ipc Init"); + if (!ecore_ipc_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Ecore_Ipc!\n")); + _e_main_shutdown(-1); + } + TS("Ecore_Ipc Init Done"); + _e_main_shutdown_push(ecore_ipc_shutdown); + + _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL); + + TS("Ecore_X Init"); + if (!ecore_x_init(NULL)) + { + e_error_message_show(_("Enlightenment cannot initialize Ecore_X!\n")); + _e_main_shutdown(-1); + } + TS("Ecore_X Init Done"); + _e_main_shutdown_push(_e_main_x_shutdown); + + ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL); + + TS("Ecore_Evas Init"); + if (!ecore_evas_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n")); + _e_main_shutdown(-1); + } + TS("Ecore_Evas Init Done"); +// _e_main_shutdown_push(ecore_evas_shutdown); + + /* e doesn't sync to compositor - it should be one */ + ecore_evas_app_comp_sync_set(0); + + TS("Ecore_Evas Engine Check"); + if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB)) + { + if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB)) + { + e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n" + "rendering in Evas. Please check your installation of Evas and\n" + "Ecore and check they support the Software X11 rendering engine.")); + _e_main_shutdown(-1); + } + } + if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER)) + { + e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n" + "rendering in Evas. Please check your installation of Evas and\n" + "Ecore and check they support the Software Buffer rendering engine.")); + _e_main_shutdown(-1); + } + TS("Ecore_Evas Engine Check Done"); + + TS("Efreet Init"); + if (!efreet_init()) + { + e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n" + "Perhaps you lack permissions on ~/.cache/efreet or are\n" + "out of memory or disk space?")); + _e_main_shutdown(-1); + } + TS("Efreet Init Done"); + _e_main_shutdown_push(efreet_shutdown); + + TS("Edje Init"); + if (!edje_init()) + { + e_error_message_show(_("Enlightenment cannot initialize Edje!\n")); + _e_main_shutdown(-1); + } + TS("Edje Init Done"); + _e_main_shutdown_push(edje_shutdown); + edje_freeze(); + + /*** Initialize E Subsystems We Need ***/ + + TS("E Intl Init"); + if (!e_intl_init()) + { + e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n")); + _e_main_shutdown(-1); + } + TS("E Intl Init Done"); _e_main_shutdown_push(e_intl_shutdown); - TS("parse args"); + /* init white box of death alert */ + TS("E_Alert Init"); + if (!e_alert_init()) + { + e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n" + "Have you set your DISPLAY variable?")); + _e_main_shutdown(-1); + } + TS("E_Alert Init Done"); + _e_main_shutdown_push(e_alert_shutdown); + + TS("E_Xinerama Init"); + if (!e_xinerama_init()) + { + e_error_message_show(_("Enlightenment cannot initialize E_Xinerama!\n")); + _e_main_shutdown(-1); + } + TS("E_Xinerama Init Done"); + _e_main_shutdown_push(e_xinerama_shutdown); + + TS("E_Randr Init"); + if (!e_randr_init()) + { + e_error_message_show(_("Enlightenment cannot initialize E_Randr!\n")); + _e_main_shutdown(-1); + } + TS("E_Randr Init Done"); + _e_main_shutdown_push(e_randr_shutdown); + + TS("E_Hints Init"); + e_hints_init(); + TS("E_Hints Init Done"); + + TS("E_Configure Init"); + e_configure_init(); + TS("E_Configure Init Done"); + + TS("E Directories Init"); + /* setup directories we will be using for configurations storage etc. */ + if (!_e_main_dirs_init()) + { + e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n" + "Perhaps you have no home directory or the disk is full?")); + _e_main_shutdown(-1); + } + TS("E Directories Init Done"); + _e_main_shutdown_push(_e_main_dirs_shutdown); + + TS("E_Filereg Init"); + if (!e_filereg_init()) + { + e_error_message_show(_("Enlightenment cannot set up its file registry system.")); + _e_main_shutdown(-1); + } + TS("E_Filereg Init Done"); + _e_main_shutdown_push(e_filereg_shutdown); + + TS("E_Config Init"); + if (!e_config_init()) + { + e_error_message_show(_("Enlightenment cannot set up its config system.")); + _e_main_shutdown(-1); + } + TS("E_Config Init Done"); + _e_main_shutdown_push(e_config_shutdown); + + /* fix for FOOLS that keep cp'ing default.edj into ~/.e/e/themes */ + e_user_dir_concat_static(buff, "themes/default.edj"); + if (ecore_file_exists(buff)) ecore_file_unlink(buff); + + TS("E_Env Init"); + if (!e_env_init()) + { + e_error_message_show(_("Enlightenment cannot set up its environment.")); + _e_main_shutdown(-1); + } + TS("E_Env Init Done"); + _e_main_shutdown_push(e_env_shutdown); + + e_util_env_set("E_ICON_THEME", e_config->icon_theme); + ecore_exe_run_priority_set(e_config->priority); + locked |= e_config->desklock_start_locked; + + TS("E_Scale Init"); + if (!e_scale_init()) + { + e_error_message_show(_("Enlightenment cannot set up its scale system.")); + _e_main_shutdown(-1); + } + TS("E_Scale Init Done"); + _e_main_shutdown_push(e_scale_shutdown); + + TS("E_Pointer Init"); + if (!e_pointer_init()) + { + e_error_message_show(_("Enlightenment cannot set up its pointer system.")); + _e_main_shutdown(-1); + } + TS("E_Pointer Init Done"); + _e_main_shutdown_push(e_pointer_shutdown); + + TS("E Paths Init"); + if (!_e_main_path_init()) + { + e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n" + "Perhaps you are out of memory?")); + _e_main_shutdown(-1); + } + TS("E Paths Init Done"); + _e_main_shutdown_push(_e_main_path_shutdown); + + TS("E_Ipc Init"); + if (!e_ipc_init()) _e_main_shutdown(-1); + TS("E_Ipc Init Done"); + _e_main_shutdown_push(e_ipc_shutdown); + + edje_frametime_set(1.0 / e_config->framerate); + + TS("E_Font Init"); + if (!e_font_init()) + { + e_error_message_show(_("Enlightenment cannot set up its font system.")); + _e_main_shutdown(-1); + } + TS("E_Font Init Done"); + _e_main_shutdown_push(e_font_shutdown); + + TS("E_Font Apply"); + e_font_apply(); + TS("E_Font Apply Done"); + + TS("E_Canvas Recache"); + e_canvas_recache(); + TS("E_Canvas Recache Done"); + + TS("E_Theme Init"); + if (!e_theme_init()) + { + e_error_message_show(_("Enlightenment cannot set up its theme system.")); + _e_main_shutdown(-1); + } + TS("E_Theme Init Done"); + _e_main_shutdown_push(e_theme_shutdown); + + TS("E_Moveresize Init"); + e_moveresize_init(); + TS("E_Moveresize Init Done"); + _e_main_shutdown_push(e_moveresize_shutdown); + + if (e_config->show_splash) + { + TS("E_Splash Init"); + if (!e_init_init()) + { + e_error_message_show(_("Enlightenment cannot set up its init screen.")); + _e_main_shutdown(-1); + } + TS("E_Splash Init Done"); + _e_main_shutdown_push(e_init_shutdown); + } + if (!((!e_config->show_splash) || (after_restart))) + { + e_init_title_set(_("Enlightenment")); + e_init_version_set(VERSION); + e_init_show(); + pause(); + } + + if (e_config->show_splash) + e_init_status_set(_("Starting International Support")); + TS("E_Intl Post Init"); + if (!e_intl_post_init()) + { + e_error_message_show(_("Enlightenment cannot set up its intl system.")); + _e_main_shutdown(-1); + } + TS("E_Intl Post Init Done"); + _e_main_shutdown_push(e_intl_post_shutdown); + + if (!really_know) + { + TS("Test File Format Support"); + _e_main_test_formats(); + TS("Test File Format Support Done"); + } + else + { + efreet_icon_extension_add(".svg"); + efreet_icon_extension_add(".jpg"); + efreet_icon_extension_add(".png"); + efreet_icon_extension_add(".edj"); + } + + if (e_config->show_splash) + e_init_status_set(_("Setup Screens")); + TS("Screens Init"); + if (!_e_main_screens_init()) + { + e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n" + "failed. Perhaps another window manager is running?\n")); + _e_main_shutdown(-1); + } + TS("Screens Init Done"); + _e_main_shutdown_push(_e_main_screens_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup ACPI")); + TS("E_Acpi Init"); + e_acpi_init(); + TS("E_Acpi Init Done"); + _e_main_shutdown_push(e_acpi_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Backlight")); + TS("E_Backlight Init"); + if (!e_backlight_init()) + { + e_error_message_show(_("Enlightenment cannot configure the backlight.")); + _e_main_shutdown(-1); + } + TS("E_Backlight Init Done"); + _e_main_shutdown_push(e_backlight_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup DPMS")); + TS("E_Dpms Init"); + if (!e_dpms_init()) + { + e_error_message_show(_("Enlightenment cannot configure the DPMS settings.")); + _e_main_shutdown(-1); + } + TS("E_Dpms Init Done"); + _e_main_shutdown_push(e_dpms_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Screensaver")); + TS("E_Screensaver Init"); + if (!e_screensaver_init()) + { + e_error_message_show(_("Enlightenment cannot configure the X screensaver.")); + _e_main_shutdown(-1); + } + TS("E_Screensaver Init Done"); + _e_main_shutdown_push(e_screensaver_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Powersave Modes")); + TS("E_Powersave Init"); + if (!e_powersave_init()) + { + e_error_message_show(_("Enlightenment cannot set up its powersave modes.")); + _e_main_shutdown(-1); + } + TS("E_Powersave Init Done"); + _e_main_shutdown_push(e_powersave_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Desklock")); + TS("E_Desklock Init"); + if (!e_desklock_init()) + { + e_error_message_show(_("Enlightenment cannot set up its desk locking system.")); + _e_main_shutdown(-1); + } + TS("E_Desklock Init Done"); + _e_main_shutdown_push(e_desklock_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Popups")); + TS("E_Popups Init"); + if (!e_popup_init()) + { + e_error_message_show(_("Enlightenment cannot set up its popup system.")); + _e_main_shutdown(-1); + } + TS("E_Popups Init Done"); + _e_main_shutdown_push(e_popup_shutdown); + + if ((locked) && ((!e_config->show_splash) && (!after_restart))) + e_desklock_show(); + + if (e_config->show_splash) + e_init_status_set(_("Setup Message Bus")); + TS("E_Msgbus Init"); + if (e_msgbus_init()) + _e_main_shutdown_push(e_msgbus_shutdown); + TS("E_Msgbus Init Done"); + + if (e_config->show_splash) + e_init_status_set(_("Setup Paths")); + TS("Efreet Paths"); + _e_main_efreet_paths_init(); + TS("Efreet Paths Done"); + + if (e_config->show_splash) + e_init_status_set(_("Setup System Controls")); + TS("E_Sys Init"); + if (!e_sys_init()) + { + e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n")); + _e_main_shutdown(-1); + } + TS("E_Sys Init Done"); + _e_main_shutdown_push(e_sys_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Actions")); + TS("E_Actions Init"); + if (!e_actions_init()) + { + e_error_message_show(_("Enlightenment cannot set up its actions system.")); + _e_main_shutdown(-1); + } + TS("E_Actions Init Done"); + _e_main_shutdown_push(e_actions_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Execution System")); + TS("E_Exec Init"); + if (!e_exec_init()) + { + e_error_message_show(_("Enlightenment cannot set up its exec system.")); + _e_main_shutdown(-1); + } + TS("E_Exec Init Done"); + _e_main_shutdown_push(e_exec_shutdown); + + TS("E_Container Freeze"); + e_container_all_freeze(); + TS("E_Container Freeze Done"); + + if (e_config->show_splash) + e_init_status_set(_("Setup Filemanager")); + TS("E_Fm2 Init"); + if (!e_fm2_init()) + { + e_error_message_show(_("Enlightenment cannot initialize the File manager.\n")); + _e_main_shutdown(-1); + } + TS("E_Fm2 Init Done"); + _e_main_shutdown_push(e_fm2_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Message System")); + TS("E_Msg Init"); + if (!e_msg_init()) + { + e_error_message_show(_("Enlightenment cannot set up its msg system.")); + _e_main_shutdown(-1); + } + TS("E_Msg Init Done"); + _e_main_shutdown_push(e_msg_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup DND")); + TS("E_Dnd Init"); + if (!e_dnd_init()) + { + e_error_message_show(_("Enlightenment cannot set up its dnd system.")); + _e_main_shutdown(-1); + } + TS("E_Dnd Init Done"); + _e_main_shutdown_push(e_dnd_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Grab Input Handling")); + TS("E_Grabinput Init"); + if (!e_grabinput_init()) + { + e_error_message_show(_("Enlightenment cannot set up its grab input handling system.")); + _e_main_shutdown(-1); + } + TS("E_Grabinput Init Done"); + _e_main_shutdown_push(e_grabinput_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Modules")); + TS("E_Module Init"); + if (!e_module_init()) + { + e_error_message_show(_("Enlightenment cannot set up its module system.")); + _e_main_shutdown(-1); + } + TS("E_Module Init Done"); + _e_main_shutdown_push(e_module_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Remembers")); + TS("E_Remember Init"); + if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START)) + { + e_error_message_show(_("Enlightenment cannot setup remember settings.")); + _e_main_shutdown(-1); + } + TS("E_Remember Init Done"); + _e_main_shutdown_push(e_remember_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Color Classes")); + TS("E_Color_Class Init"); + if (!e_color_class_init()) + { + e_error_message_show(_("Enlightenment cannot set up its color class system.")); + _e_main_shutdown(-1); + } + TS("E_Color_Class Init Done"); + _e_main_shutdown_push(e_color_class_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Gadcon")); + TS("E_Gadcon Init"); + if (!e_gadcon_init()) + { + e_error_message_show(_("Enlightenment cannot set up its gadget control system.")); + _e_main_shutdown(-1); + } + TS("E_Gadcon Init Done"); + _e_main_shutdown_push(e_gadcon_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Wallpaper")); + TS("E_Bg Init"); + if (!e_bg_init()) + { + e_error_message_show(_("Enlightenment cannot set up its desktop background system.")); + _e_main_shutdown(-1); + } + TS("E_Bg Init Done"); + _e_main_shutdown_push(e_bg_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Mouse")); + TS("E_Mouse Init"); + if (!e_mouse_update()) + { + e_error_message_show(_("Enlightenment cannot configure the mouse settings.")); + _e_main_shutdown(-1); + } + TS("E_Mouse Init Done"); + + if (e_config->show_splash) + e_init_status_set(_("Setup Bindings")); + TS("E_Bindings Init"); + if (!e_bindings_init()) + { + e_error_message_show(_("Enlightenment cannot set up its bindings system.")); + _e_main_shutdown(-1); + } + TS("E_Bindings Init Done"); + _e_main_shutdown_push(e_bindings_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Shelves")); + TS("E_Shelf Init"); + if (!e_shelf_init()) + { + e_error_message_show(_("Enlightenment cannot set up its module system.")); + _e_main_shutdown(-1); + } + TS("E_Shelf Init Done"); + _e_main_shutdown_push(e_shelf_shutdown); + + if (e_config->show_splash) + e_init_status_set(_("Setup Thumbnailer")); + TS("E_Thumb Init"); + if (!e_thumb_init()) + { + e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n")); + _e_main_shutdown(-1); + } + TS("E_Thumb Init Done"); + _e_main_shutdown_push(e_thumb_shutdown); + + if (!after_restart) + { + if (e_config->show_splash) + e_init_status_set(_("Setup Desktop Environment")); + TS("E_Deskenv Init"); + if (!e_deskenv_init()) + { + e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n")); + _e_main_shutdown(-1); + } + TS("E_Deskenv Init Done"); + _e_main_shutdown_push(e_deskenv_shutdown); + } + + if (e_config->show_splash) + e_init_status_set(_("Setup File Ordering")); + TS("E_Order Init"); + if (!e_order_init()) + { + e_error_message_show(_("Enlightenment cannot set up its order file system.")); + _e_main_shutdown(-1); + } + TS("E_Order Init Done"); + _e_main_shutdown_push(e_order_shutdown); + + TS("Add Idler For X Flush"); + _idle_flush = ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL); + TS("Add Idler For X Flush Done"); + + TS("E_Manager Keys Grab"); + e_managers_keys_grab(); + TS("E_Manager Keys Grab Done"); + + if (e_config->show_splash) + e_init_status_set(_("Load Modules")); + TS("Load Modules"); + _e_main_modules_load(safe_mode); + TS("Load Modules Done"); + + TS("Run Startup Apps"); + if (!nostartup) + { + if (after_restart) + e_startup(E_STARTUP_RESTART); + else + e_startup(E_STARTUP_START); + } + TS("Run Startup Apps Done"); + + if (!((!e_config->show_splash) || (after_restart))) + { + ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL); + if (locked) e_desklock_show(); + } + + TS("E_Container Thaw"); + e_container_all_thaw(); + TS("E_Container Thaw Done"); + + TS("E_Test Init"); + e_test(); + TS("E_Test Done"); + + if (e_config->show_splash) + e_init_status_set(_("Configure Shelves")); + TS("E_Shelf Config Update"); + e_shelf_config_update(); + TS("E_Shelf Config Update Done"); + + TS("Manage all windows"); + _e_main_manage_all(); + + _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL); + + if (e_config->show_splash) + e_init_status_set(_("Almost Done")); + + starting = EINA_FALSE; + inloop = EINA_TRUE; + + TS("MAIN LOOP AT LAST"); + if (!setjmp(x_fatal_buff)) + ecore_main_loop_begin(); + else + printf("FATAL: X Died. Connection gone. Abbreviated Shutdown\n"); + + inloop = EINA_FALSE; + stopping = EINA_TRUE; + + if (!x_fatal) e_canvas_idle_flush(); + + e_config_save_flush(); + _e_main_desk_save(); + e_remember_internal_save(); + + _e_main_shutdown(0); + + if (restart) + { + e_util_env_set("E_RESTART_OK", "1"); + ecore_app_restart(); + } + + e_prefix_shutdown(); + + return 0; +} + +/* FIXME: make safe to delete within a callback */ +EAPI E_Before_Idler * +e_main_idler_before_add(int (*func) (void *data), void *data, int once) +{ + E_Before_Idler *eb; + + eb = calloc(1, sizeof(E_Before_Idler)); + eb->func = func; + eb->data = data; + eb->once = once; + _idle_before_list = eina_list_append(_idle_before_list, eb); + return eb; +} + +EAPI void +e_main_idler_before_del(E_Before_Idler *eb) +{ + eb->delete_me = 1; +} + +/* local functions */ +static void +_e_main_shutdown(int errcode) +{ + int i = 0; + + printf("E17: Begin Shutdown Procedure!\n"); + + if (_idle_before) ecore_idle_enterer_del(_idle_before); + _idle_before = NULL; + if (_idle_after) ecore_idle_enterer_del(_idle_after); + _idle_after = NULL; + if (_idle_flush) ecore_idle_enterer_del(_idle_flush); + _idle_flush = NULL; + + for (i = (_e_main_lvl - 1); i >= 0; i--) + (*_e_main_shutdown_func[i])(); + if (errcode < 0) exit(errcode); +} + +static void +_e_main_shutdown_push(int (*func)(void)) +{ + _e_main_lvl++; + if (_e_main_lvl > MAX_LEVEL) + { + _e_main_lvl--; + e_error_message_show("WARNING: too many init levels. MAX = %i", + MAX_LEVEL); + return; + } + _e_main_shutdown_func[_e_main_lvl - 1] = func; +} + +static void +_e_main_parse_arguments(int argc, char **argv) +{ + char *s = NULL; + int i = 0; + /* handle some command-line parameters */ for (i = 1; i < argc; i++) { @@ -252,26 +1024,25 @@ main(int argc, char **argv) int x, y, w, h; i++; - /* WWxHH+XX+YY */ if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4) e_xinerama_fake_screen_add(x, y, w, h); } else if (!strcmp(argv[i], "-good")) { - good = 1; - evil = 0; + good = EINA_TRUE; + evil = EINA_FALSE; printf("LA LA LA\n"); } else if (!strcmp(argv[i], "-evil")) { - good = 0; - evil = 1; + good = EINA_FALSE; + evil = EINA_TRUE; printf("MUHAHAHAHHAHAHAHAHA\n"); } else if (!strcmp(argv[i], "-psychotic")) { - good = 1; - evil = 1; + good = EINA_TRUE; + evil = EINA_TRUE; printf("MUHAHALALALALALALALA\n"); } else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1))) @@ -281,14 +1052,9 @@ main(int argc, char **argv) e_util_env_set("E_CONF_PROFILE", argv[i]); } else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it")) - { - really_know = 1; - } + really_know = EINA_TRUE; else if (!strcmp(argv[i], "-locked")) - { - locked = EINA_TRUE; - puts("enlightenment will start with desklock on."); - } + locked = EINA_TRUE; else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--help"))) @@ -327,1092 +1093,136 @@ main(int argc, char **argv) s = getenv("DISPLAY"); if (s) { - char *p; + char *p, buff[PATH_MAX]; - p = strrchr(s, ':'); - if (!p) + if (!(p = strrchr(s, ':'))) { - snprintf(buf, sizeof(buf), "%s:0.0", s); - e_util_env_set("DISPLAY", buf); + snprintf(buff, sizeof(buff), "%s:0.0", s); + e_util_env_set("DISPLAY", buff); } else { - p = strrchr(p, '.'); - if (!p) + if (!(p = strrchr(p, '.'))) { - snprintf(buf, sizeof(buf), "%s.0", s); - e_util_env_set("DISPLAY", buf); + snprintf(buff, sizeof(buff), "%s.0", s); + e_util_env_set("DISPLAY", buff); } } } - TS("arg parse done"); - /* fixes for FOOLS that keep cp'ing default.edj into ~/.e/e/themes */ - { - e_user_dir_concat_static(buf, "themes/default.edj"); - if (ecore_file_exists(buf)) ecore_file_unlink(buf); - } - - TS("ecore init"); - /* basic ecore init */ - if (!ecore_init()) - { - e_error_message_show(_("Enlightenment cannot Initialize Ecore!\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } -#ifdef HAVE_ECORE_IMF - ecore_imf_init(); - _e_main_shutdown_push(ecore_imf_shutdown); -#endif -// FIXME: SEGV's on shutdown if fm2 windows up - disable for now. => is it history ? - _e_main_shutdown_push(ecore_shutdown); - - /* init edje and set it up in frozen mode */ - edje_init(); - edje_freeze(); - _e_main_shutdown_push(edje_shutdown); - - _e_cacheburst++; -/* eet_cacheburst(_e_cacheburst); */ - ecore_timer_add(5.0, _e_main_cb_eet_cacheburst_end, NULL); - - TS("ecore_file init"); - /* init the file system */ - if (!ecore_file_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the File system.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(ecore_file_shutdown); - - TS("more ecore"); - /* setup my args */ - ecore_app_args_set(argc, (const char **)argv); - - /* setup a handler for when e is asked to exit via a system signal */ - if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _e_main_cb_signal_exit, NULL)) - { - e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } - if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, _e_main_cb_signal_hup, NULL)) - { - e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } - if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, _e_main_cb_signal_user, NULL)) - { - e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } - - /* an idle enterer to be called before all others */ - _e_main_idle_enterer_before = ecore_idle_enterer_before_add(_e_main_cb_idler_before, NULL); - - TS("x connect"); - /* init x */ - if (!ecore_x_init(NULL)) - { - e_error_message_show(_("Enlightenment cannot initialize its X connection.\n" - "Have you set your DISPLAY variable?")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(_e_main_x_shutdown); - /* init white box of death alert */ - if (!e_alert_init(NULL)) - { - e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n" - "Have you set your DISPLAY variable?")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_alert_shutdown); - /* we want to have been launched by enlightenment_start. there is a very */ /* good reason we want to have been launched this way, thus check */ if (!getenv("E_START")) { - e_alert_show("You are executing enlightenment directly. This is\n" - "bad. Please do not execute the \"enlightenment\"\n" - "binary. Use the \"enlightenment_start\" launcher. It\n" - "will handle setting up environment variables, paths,\n" - "and launching any other required services etc.\n" - "before enlightenment itself begins running.\n"); + e_error_message_show(_("You are executing enlightenment directly. This is\n" + "bad. Please do not execute the \"enlightenment\"\n" + "binary. Use the \"enlightenment_start\" launcher. It\n" + "will handle setting up environment variables, paths,\n" + "and launching any other required services etc.\n" + "before enlightenment itself begins running.\n")); _e_main_shutdown(-1); } +} - TS("ecore_con"); - /* init generic communications */ - if (!ecore_con_init()) +static void +_e_main_cb_x_fatal(void *data __UNUSED__) +{ + e_error_message_show("Lost X Connection."); + ecore_main_loop_quit(); + if (!x_fatal) { - e_error_message_show(_("Enlightenment cannot initialize the connections system.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); + x_fatal = EINA_TRUE; + if (inloop) longjmp(x_fatal_buff, -99); } - _e_main_shutdown_push(ecore_con_shutdown); - /* init ipc */ - if (!ecore_ipc_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the IPC system.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(ecore_ipc_shutdown); +} - TS("xinerama"); - if (!e_xinerama_init()) - { - e_error_message_show(_("Enlightenment cannot setup xinerama wrapping.\n" - "This should not happen.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_xinerama_shutdown); +static Eina_Bool +_e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__) +{ + /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */ + e_sys_action_do(E_SYS_EXIT, NULL); + return ECORE_CALLBACK_RENEW; +} - TS("randr"); - if (!e_randr_init()) - { - e_error_message_show(_("Enlightenment cannot setup randr wrapping.\n" - "This should not happen.")); - } - else - { - _e_main_shutdown_push(e_randr_shutdown); - } +static Eina_Bool +_e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__) +{ + e_sys_action_do(E_SYS_RESTART, NULL); + return ECORE_CALLBACK_RENEW; +} -/* ecore_x_grab(); */ - - ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL); - - TS("x hints"); - /* Init window manager hints */ - e_hints_init(); - TS("x hints done"); - - TS("ecore_evas init"); - /* init the evas wrapper */ - if (!ecore_evas_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the Evas system.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } - ecore_evas_app_comp_sync_set(0); /* e doesn't sync to compositor - it should be one */ - if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB)) - { - e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n" - "rendering in Evas. Please check your installation of Evas and\n" - "Ecore and check they support the Software X11 rendering engine.")); - _e_main_shutdown(-1); - } - if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER)) - { - e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n" - "rendering in Evas. Please check your installation of Evas and\n" - "Ecore and check they support the Software Buffer rendering engine.")); - _e_main_shutdown(-1); - } -// ecore_evas closes evas - deletes objs - deletes fm widgets which tries to -// ipc to slave to stop monitoring - but ipc has been shut down. dont shut -// down. -// _e_main_shutdown_push(ecore_evas_shutdown); - TS("test done"); - - /*** Finished loading subsystems, Loading WM Specifics ***/ - TS("configure"); - e_configure_init(); - - TS("dirs"); - /* setup directories we will be using for configurations storage etc. */ - if (!_e_main_dirs_init()) - { - e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n" - "Perhaps you have no home directory or the disk is full?")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(_e_main_dirs_shutdown); - - TS("filereg"); - /* setup file registry */ - if (!e_filereg_init()) - { - e_error_message_show(_("Enlightenment cannot set up its file registry system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_filereg_shutdown); - - TS("config"); - /* init config system */ - if (!e_config_init()) - { - e_error_message_show(_("Enlightenment cannot set up its config system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_config_shutdown); - - TS("env"); - /* init config system */ - if (!e_env_init()) - { - e_error_message_show(_("Enlightenment cannot set up its environment.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_env_shutdown); - - e_util_env_set("E_ICON_THEME", e_config->icon_theme); - - locked |= e_config->desklock_start_locked; - - /* set all execced stuff to configured priority */ - ecore_exe_run_priority_set(e_config->priority); - - TS("scale"); - /* init config system */ - if (!e_scale_init()) - { - e_error_message_show(_("Enlightenment cannot set up its scale system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_scale_shutdown); - - TS("pointer"); - if (!e_pointer_init()) - { - e_error_message_show(_("Enlightenment cannot set up the pointer system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_pointer_shutdown); - - TS("path"); - /* setup paths for finding things */ - if (!_e_main_path_init()) - { - e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(_e_main_path_shutdown); - - TS("ipc"); - /* setup e ipc service */ - if (e_ipc_init()) - _e_main_shutdown_push(e_ipc_shutdown); - - /* setup edje to animate @ e_config->framerate frames per sec. */ - edje_frametime_set(1.0 / e_config->framerate); - - TS("font"); - /* init font system */ - if (!e_font_init()) - { - e_error_message_show(_("Enlightenment cannot set up its font system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_font_shutdown); - e_font_apply(); - e_canvas_recache(); - - TS("theme"); - /* init theme system */ - if (!e_theme_init()) - { - e_error_message_show(_("Enlightenment cannot set up its theme system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_theme_shutdown); - - TS("move/resize info"); - /* init move resize popup */ - e_moveresize_init(); - _e_main_shutdown_push(e_moveresize_shutdown); +static Eina_Bool +_e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) +{ + Ecore_Event_Signal_User *e = ev; - TS("splash"); - /* setup init status window/screen */ - if (!e_init_init()) + if (e->number == 1) { - e_error_message_show(_("Enlightenment cannot set up init screen.\n" - "Perhaps you are out of memory?")); - _e_main_shutdown(-1); + E_Action *a = e_action_find("configuration"); + if ((a) && (a->func.go)) a->func.go(NULL, NULL); } - _e_main_shutdown_push(e_init_shutdown); - if (!((!e_config->show_splash) || (after_restart))) + else if (e->number == 2) { - e_init_title_set(_("Enlightenment")); - e_init_version_set(VERSION); - e_init_show(); - pause(); + // comp module has its own handler for this for enabling/disabling fps debug } - - e_init_status_set(_("Starting International Support")); - TS("intl post"); - /* init intl system */ - if (!e_intl_post_init()) - { - e_error_message_show(_("Enlightenment cannot set up its intl system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_intl_post_shutdown); - - TS("efreet"); - /* init FDO desktop */ - if (!efreet_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n" - "Perhaps you lack permissions on ~/.cache/efreet or are\n" - "out of memory or disk space?")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(efreet_shutdown); - TS("efreet done"); - - if (!really_know) - { - e_init_status_set(_("Testing Format Support")); - TS("test file format support"); - { - Ecore_Evas *ee; - Evas_Object *im, *txt; - char buf[PATH_MAX]; - Evas_Coord tw, th; - - ee = ecore_evas_buffer_new(1, 1); - if (!ee) - { - e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n" - "Evas has Software Buffer engine support.\n")); - _e_main_shutdown(-1); - } - e_canvas_add(ee); - im = evas_object_image_add(ecore_evas_get(ee)); - - e_prefix_data_concat_static(buf, "data/images/test.png"); - evas_object_image_file_set(im, buf, NULL); - if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) - { - e_error_message_show(_("Enlightenment found Evas can't load PNG files. Check Evas has PNG\n" - "loader support.\n")); - _e_main_shutdown(-1); - } - - e_prefix_data_concat_static(buf, "data/images/test.jpg"); - evas_object_image_file_set(im, buf, NULL); - if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) - { - e_error_message_show(_("Enlightenment found Evas can't load JPEG files. Check Evas has JPEG\n" - "loader support.\n")); - _e_main_shutdown(-1); - } - - e_prefix_data_concat_static(buf, "data/images/test.edj"); - evas_object_image_file_set(im, buf, "images/0"); - if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) - { - e_error_message_show(_("Enlightenment found Evas can't load EET files. Check Evas has EET\n" - "loader support.\n")); - _e_main_shutdown(-1); - } - evas_object_del(im); - txt = evas_object_text_add(ecore_evas_get(ee)); - evas_object_text_font_set(txt, "Sans", 10); - evas_object_text_text_set(txt, "Hello"); - evas_object_geometry_get(txt, NULL, NULL, &tw, &th); - if ((tw <= 0) && (th <= 0)) - { - e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n" - "support and system fontconfig defines a 'Sans' font.\n")); - _e_main_shutdown(-1); - } - evas_object_del(txt); - e_canvas_del(ee); - ecore_evas_free(ee); - } - } - - e_init_status_set(_("Check SVG Support")); - TS("svg"); - { - Ecore_Evas *ee; - Evas_Object *im; - char buf[PATH_MAX]; - - ee = ecore_evas_buffer_new(1, 1); - if (!ee) - { - e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n" - "Evas has Software Buffer engine support.\n")); - _e_main_shutdown(-1); - } - e_canvas_add(ee); - im = evas_object_image_add(ecore_evas_get(ee)); - - e_prefix_data_concat_static(buf, "data/images/test.svg"); - evas_object_image_file_set(im, buf, NULL); - if (evas_object_image_load_error_get(im) == EVAS_LOAD_ERROR_NONE) - { - efreet_icon_extension_add(".svg"); - /* prefer png over svg */ - efreet_icon_extension_add(".png"); - } - evas_object_del(im); - e_canvas_del(ee); - ecore_evas_free(ee); - } - - e_init_status_set(_("Setup Screens")); - TS("screens"); - /* manage the root window */ - if (!_e_main_screens_init()) - { - e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n" - "failed. Perhaps another window manager is running?\n")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(_e_main_screens_shutdown); - - e_init_status_set(_("Setup Screensaver")); - TS("screensaver"); - /* setup screensaver */ - if (!e_screensaver_init()) - { - e_error_message_show(_("Enlightenment cannot configure the X screensaver.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_screensaver_shutdown); - - e_init_status_set(_("Setup Desklock")); - TS("desklock"); - /* setup desklock */ - if (!e_desklock_init()) - { - e_error_message_show(_("Enlightenment cannot set up its desk locking system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_desklock_shutdown); - - e_init_status_set(_("Setup Popups")); - TS("popup"); - /* init popup system */ - if (!e_popup_init()) - { - e_error_message_show(_("Enlightenment cannot set up its popup system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_popup_shutdown); - - if ((locked) && ((!e_config->show_splash) && (!after_restart))) - e_desklock_show(); - - TS("msgbus"); - /* setup e msgbus (DBUS) service */ - if (e_msgbus_init()) - _e_main_shutdown_push(e_msgbus_shutdown); - - e_init_status_set(_("Setup Paths")); - TS("efreet paths"); - { - Eina_List **list; - - list = efreet_icon_extra_list_get(); - if (list) - { - e_user_dir_concat_static(buf, "icons"); - *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf)); - e_prefix_data_concat_static(buf, "data/icons"); - *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf)); - } - } - efreet_icon_extension_add(".edj"); - TS("efreet paths done"); - - e_init_status_set(_("Setup System Controls")); - TS("sys init"); - /* init the enlightenment sys command system */ - if (!e_sys_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_sys_shutdown); - - e_init_status_set(_("Setup Actions")); - TS("actions"); - /* init actions system */ - if (!e_actions_init()) - { - e_error_message_show(_("Enlightenment cannot set up its actions system.")); - _e_main_shutdown(-1); - } - - e_init_status_set(_("Setup Execution System")); - TS("exec"); - /* init app system */ - if (!e_exec_init()) - { - e_error_message_show(_("Enlightenment cannot set up its exec system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_exec_shutdown); - - TS("container freeze"); - e_container_all_freeze(); - - e_init_status_set(_("Setup FM")); - TS("fm2"); - /* init the enlightenment file manager */ - if (!e_fm2_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the File manager.\n")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_fm2_shutdown); - - /* - TS("fwin"); - if (!e_fwin_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the File manager.\n")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_fwin_shutdown); - */ - - e_init_status_set(_("Setup Message System")); - TS("msg"); - /* setup generic msg handling etc */ - if (!e_msg_init()) - { - e_error_message_show(_("Enlightenment cannot set up its msg system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_msg_shutdown); - - e_init_status_set(_("Setup DND")); - TS("dnd"); - /* setup dnd */ - if (!e_dnd_init()) - { - e_error_message_show(_("Enlightenment cannot set up its dnd system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_dnd_shutdown); - - e_init_status_set(_("Setup Grab Input Handling")); - TS("grabinput"); - /* setup input grabbing co-operation system */ - if (!e_grabinput_init()) - { - e_error_message_show(_("Enlightenment cannot set up its input grab handling system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_grabinput_shutdown); - - e_init_status_set(_("Setup Modules")); - TS("modules"); - /* setup module loading etc */ - if (!e_module_init()) - { - e_error_message_show(_("Enlightenment cannot set up its module system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_module_shutdown); - - e_init_status_set(_("Setup Remembers")); - TS("remember"); - /* do remember stuff */ - if (!e_remember_init(after_restart ? E_STARTUP_RESTART: E_STARTUP_START)) - { - e_error_message_show(_("Enlightenment cannot setup remember settings.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_remember_shutdown); - - e_init_status_set(_("Setup Color Classes")); - TS("colorclasses"); - /* setup color_class */ - if (!e_color_class_init()) - { - e_error_message_show(_("Enlightenment cannot set up its color class system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_color_class_shutdown); - - e_init_status_set(_("Setup Gadcon")); - TS("gadcon"); - /* setup gadcon */ - if (!e_gadcon_init()) - { - e_error_message_show(_("Enlightenment cannot set up its gadget control system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_gadcon_shutdown); - - e_init_status_set(_("Setup ACPI")); - TS("acpi"); - /* acpi init will never fail. It always returns one even if acpid - * is not running, so no need to trap the return */ - e_acpi_init(); - _e_main_shutdown_push(e_acpi_shutdown); - - e_init_status_set(_("Setup Backlight")); - TS("backlight"); - /* setup dpms */ - if (!e_backlight_init()) - { - e_error_message_show(_("Enlightenment cannot configure the backlight.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_backlight_shutdown); - - e_init_status_set(_("Setup DPMS")); - TS("dpms"); - /* setup dpms */ - if (!e_dpms_init()) - { - e_error_message_show(_("Enlightenment cannot configure the DPMS settings.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_dpms_shutdown); - - e_init_status_set(_("Setup Powersave modes")); - TS("powersave"); - if (!e_powersave_init()) - { - e_error_message_show(_("Enlightenment cannot set up its powersave modes.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_powersave_shutdown); - - e_init_status_set(_("Setup Wallpaper")); - TS("bg"); - /* init desktop background system */ - if (!e_bg_init()) - { - e_error_message_show(_("Enlightenment cannot set up its desktop background system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_bg_shutdown); - - e_init_status_set(_("Setup Mouse")); - TS("mouse"); - /* setup mouse accel */ - if (!e_mouse_update()) - { - e_error_message_show(_("Enlightenment cannot configure the mouse settings.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_actions_shutdown); - - e_init_status_set(_("Setup Bindings")); - TS("bindings"); - /* init bindings system */ - if (!e_bindings_init()) - { - e_error_message_show(_("Enlightenment cannot set up its bindings system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_bindings_shutdown); - - e_init_status_set(_("Setup Shelves")); - TS("shelves"); - /* setup shelves */ - if (!e_shelf_init()) - { - e_error_message_show(_("Enlightenment cannot set up its shelf system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_shelf_shutdown); - - e_init_status_set(_("Setup Thumbnailer")); - TS("thumb init"); - /* init the enlightenment thumbnailing system */ - if (!e_thumb_init()) - { - e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_thumb_shutdown); - - if (!after_restart) - { - TS("deskenv"); - /* init deskenv system */ - if (!e_deskenv_init()) - { - e_error_message_show(_("Enlightenment cannot set up its desktop environment system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_deskenv_shutdown); - } - - e_init_status_set(_("Setup File Ordering")); - TS("order"); - if (!e_order_init()) - { - e_error_message_show(_("Enlightenment cannot set up its order file system.")); - _e_main_shutdown(-1); - } - _e_main_shutdown_push(e_order_shutdown); - - TS("add idle enterers"); - /* add in a handler that just before we go idle we flush x - will happen after ecore_evas's idle rendering as it's after ecore_evas_init() */ - _e_main_idle_enterer_flusher = - ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL); - - e_managers_keys_grab(); - - /* ecore_x_ungrab(); */ - - /* load modules */ - e_init_status_set(_("Load Modules")); - TS("load modules"); - if (safe_mode) - { - E_Module *m; - char *crashmodule; - - crashmodule = getenv("E_MODULE_LOAD"); - if (crashmodule) m = e_module_new(crashmodule); - - if ((crashmodule) && (m)) - { - e_module_disable(m); - e_object_del(E_OBJECT(m)); - - e_int_config_modules(e_container_current_get(e_manager_current_get()), NULL); - e_error_message_show - (_("Enlightenment crashed early on start and has
" - "been restarted. There was an error loading
" - "module named: %s. This module has been disabled
" - "and will not be loaded."), crashmodule); - e_util_dialog_show - (_("Enlightenment crashed early on start and has been restarted"), - _("Enlightenment crashed early on start and has been restarted.
" - "There was an error loading module named: %s

" - "This module has been disabled and will not be loaded."), crashmodule); - e_module_all_load(); - } - else - { - e_int_config_modules(e_container_current_get(e_manager_current_get()), NULL); - e_error_message_show - (_("Enlightenment crashed early on start and has
" - "been restarted. All modules have been disabled
" - "and will not be loaded to help remove any problem
" - "modules from your configuration. The module
" - "configuration dialog should let you select your
" - "modules again.")); - e_util_dialog_show - (_("Enlightenment crashed early on start and has been restarted"), - _("Enlightenment crashed early on start and has been restarted.
" - "All modules have been disabled and will not be loaded to help
" - "remove any problem modules from your configuration.

" - "The module configuration dialog should let you select your
" - "modules again.")); - } - } - else - e_module_all_load(); - - TS("init properites"); - if (!nostartup) - { - if (after_restart) e_startup(E_STARTUP_RESTART); - else e_startup(E_STARTUP_START); - } - - if (!((!e_config->show_splash) || (after_restart))) - { - ecore_timer_add(16.0, _e_main_cb_startup_fake_end, NULL); - if (locked) e_desklock_show(); - } - - e_container_all_thaw(); - - TS("test code"); - /* run any testing code now we are set up */ - e_test(); - - e_init_status_set(_("Configure Shelves")); - TS("shelf config update"); - e_shelf_config_update(); - - TS("manage all windows"); - _e_main_manage_all(); - - /* an idle enterer to be called after all others */ - _e_main_idle_enterer_after = - ecore_idle_enterer_add(_e_main_cb_idler_after, NULL); - - e_init_status_set(_("Almost Done")); - TS("MAIN LOOP AT LAST"); - /* no longer starting up */ - starting = 0; - /* start our main loop */ - -#ifdef DBG_EINA_STRINGSHARE - // enable to debug eina stringshare usage - ecore_timer_add(5.0, stdbg, NULL); -#endif - - inloop = EINA_TRUE; - if (!setjmp(x_fatal_buf)) - ecore_main_loop_begin(); - else - printf("FATAL: X died. Connection gone. abbreviated shutdown\n"); - inloop = EINA_FALSE; - - stopping = 1; - - if (!x_fatal) e_canvas_idle_flush(); - - /* ask all modules to save their config and then shutdown */ - /* NB: no need to do this as config shutdown will flush any saves */ - /* and all changed config was already saved before */ - e_config_save_flush(); - - /* Store current selected desktops */ - _e_main_desk_save(); - - e_remember_internal_save(); - - /* unroll our stack of shutdown functions with exit code of 0 */ - _e_main_shutdown(0); - - /* if we were flagged to restart, then restart. */ - if (restart) - { - e_util_env_set("E_RESTART_OK", "1"); - ecore_app_restart(); - } - - e_prefix_shutdown(); - - /* just return 0 to keep the compiler quiet */ - return 0; + return ECORE_CALLBACK_RENEW; } -/* FIXME: make safe to delete within a callback */ -EAPI E_Before_Idler * -e_main_idler_before_add(int (*func) (void *data), void *data, int once) -{ - E_Before_Idler *eb; - - eb = calloc(1, sizeof(E_Before_Idler)); - eb->func = func; - eb->data = data; - eb->once = once; - _e_main_idler_before_list = eina_list_append(_e_main_idler_before_list, eb); - return eb; -} - -EAPI void -e_main_idler_before_del(E_Before_Idler *eb) -{ - eb->delete_me = 1; -} - -/* local subsystem functions */ -static void -_e_main_shutdown_push(int (*func) (void)) -{ - _e_main_level++; - if (_e_main_level > MAX_LEVEL) - { - _e_main_level--; - e_error_message_show("WARNING: too many init levels. MAX = %i", MAX_LEVEL); - return; - } - _e_main_shutdown_func[_e_main_level - 1] = func; -} - -static void -_e_main_shutdown(int errorcode) -{ - int i; - - printf("E17: Begin shutdown procedure!\n"); - if (_e_main_idle_enterer_before) - { - ecore_idle_enterer_del(_e_main_idle_enterer_before); - _e_main_idle_enterer_before = NULL; - } - if (_e_main_idle_enterer_after) - { - ecore_idle_enterer_del(_e_main_idle_enterer_after); - _e_main_idle_enterer_after = NULL; - } - if (_e_main_idle_enterer_flusher) - { - ecore_idle_enterer_del(_e_main_idle_enterer_flusher); - _e_main_idle_enterer_flusher = NULL; - } - for (i = _e_main_level - 1; i >= 0; i--) - (*_e_main_shutdown_func[i])(); - if (errorcode < 0) exit(errorcode); -} - -static int +static int _e_main_x_shutdown(void) { if (x_fatal) return 1; -/* ecore_x_ungrab(); */ + /* ecore_x_ungrab(); */ ecore_x_focus_reset(); ecore_x_events_allow_all(); ecore_x_shutdown(); return 1; } -static int +static int _e_main_dirs_init(void) { const char *base; - const char *dirs[] = { - "images", - "fonts", - "themes", - "icons", - "backgrounds", - "applications", - "applications/menu", - "applications/menu/favorite", - "applications/menu/all", - "applications/bar", - "applications/bar/default", - "applications/startup", - "applications/restart", - "applications/trash", - "modules", - "config", - "locale", - "input_methods", - NULL - }; + const char *dirs[] = + { + "images", + "fonts", + "themes", + "icons", + "backgrounds", + "applications", + "applications/menu", + "applications/menu/favorite", + "applications/menu/all", + "applications/bar", + "applications/bar/default", + "applications/startup", + "applications/restart", + "applications/trash", + "modules", + "config", + "locale", + "input_methods", + NULL + }; base = e_user_dir_get(); if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs)/sizeof(dirs[0]) - 1) { - e_error_message_show - ("Could not create one of the required subdirectories of '%s'", base); + e_error_message_show("Could not create one of the required " + "subdirectories of '%s'", base); return 0; } return 1; } -static int +static int _e_main_dirs_shutdown(void) { return 1; } -static int -_e_main_screens_init(void) -{ - Ecore_X_Window *roots; - int num, i; - - TS("screens: atoms"); - if (!e_atoms_init()) return 0; - TS("screens: manager"); - if (!e_manager_init()) return 0; - TS("screens: container"); - if (!e_container_init()) return 0; - TS("screens: zone"); - if (!e_zone_init()) return 0; - TS("screens: desk"); - if (!e_desk_init()) return 0; - TS("screens: menu"); - if (!e_menu_init()) return 0; - TS("screens: exehist"); - if (!e_exehist_init()) return 0; - - TS("screens: get roots"); - num = 0; - roots = ecore_x_window_root_list(&num); - if ((!roots) || (num <= 0)) - { - e_error_message_show("X reports there are no root windows and %i screens!\n", - num); - return 0; - } - TS("screens: focus"); - if (!e_focus_init()) return 0; - TS("screens: border"); - if (!e_border_init()) return 0; - TS("screens: win"); - if (!e_win_init()) return 0; - TS("screens: manage roots"); - for (i = 0; i < num; i++) - { - E_Manager *man; - E_Container *con; - - man = e_manager_new(roots[i], i); - if (man) - e_manager_show(man); - else - { - e_error_message_show("Cannot create manager object for screen %i\n", - i); - free(roots); - return 0; - } - con = e_container_new(man); - if (con) - { - e_container_show(con); - e_grabinput_focus(con->bg_win, E_FOCUS_METHOD_PASSIVE); - e_hints_manager_init(man); - _e_main_desk_restore(man, con); -// e_manager_manage_windows(man); - } - else - { - e_error_message_show("Cannot create desktop object for manager on screen %i\n", - i); - free(roots); - return 0; - } - } - TS("screens: sync"); - - free(roots); - ecore_x_sync(); - return 1; -} - -static int -_e_main_screens_shutdown(void) -{ - e_win_shutdown(); - e_border_shutdown(); - e_focus_shutdown(); - e_exehist_shutdown(); - e_menu_shutdown(); -// ecore_evas closes evas - deletes objs - deletes fm widgets which tries to -// ipc to slave to stop monitoring - but ipc has been shut down. dont shut -// down. -// e_desk_shutdown(); -// e_zone_shutdown(); -// e_container_shutdown(); -// e_manager_shutdown(); - e_atoms_shutdown(); - return 1; -} - -static void -_e_main_manage_all(void) -{ - Eina_List *l; - E_Manager *man; - - EINA_LIST_FOREACH(e_manager_list(), l, man) - e_manager_manage_windows(man); -} - static int _e_main_path_init(void) { @@ -1573,125 +1383,179 @@ _e_main_path_shutdown(void) return 1; } -static void -_e_main_cb_x_fatal(void *data __UNUSED__) +static void +_e_main_test_formats(void) { - e_error_message_show("Lost X connection."); - ecore_main_loop_quit(); - // x is foobared - best to get the hell out of the mainloop - if (!x_fatal) + Evas *evas; + Ecore_Evas *ee; + Evas_Object *im, *txt; + Evas_Coord tw, th; + char buff[PATH_MAX]; + + if (e_config->show_splash) + e_init_status_set(_("Testing Format Support")); + + if (!(ee = ecore_evas_buffer_new(1, 1))) { - x_fatal = EINA_TRUE; - if (inloop) longjmp(x_fatal_buf, -99); + e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n" + "Evas has Software Buffer engine support.\n")); + _e_main_shutdown(-1); } -} + e_canvas_add(ee); + evas = ecore_evas_get(ee); + im = evas_object_image_add(evas); -static Eina_Bool -_e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__) -{ - /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */ - e_sys_action_do(E_SYS_EXIT, NULL); - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__) -{ - e_sys_action_do(E_SYS_RESTART, NULL); - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) -{ - Ecore_Event_Signal_User *e = ev; - - if (e->number == 1) + e_prefix_data_concat_static(buff, "data/images/test.svg"); + evas_object_image_file_set(im, buff, NULL); + if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) { - E_Action *a = e_action_find("configuration"); - if ((a) && (a->func.go)) a->func.go(NULL, NULL); + e_error_message_show(_("Enlightenment found Evas can't load SVG files. " + "Check Evas has SVG loader support.\n")); } - else if (e->number == 2) + else + efreet_icon_extension_add(".svg"); + + e_prefix_data_concat_static(buff, "data/images/test.jpg"); + evas_object_image_file_set(im, buff, NULL); + if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) { - // comp module has its own handler for this for enabling/disabling fps debug + e_error_message_show(_("Enlightenment found Evas can't load JPEG files. " + "Check Evas has JPEG loader support.\n")); + _e_main_shutdown(-1); } - return ECORE_CALLBACK_RENEW; -} + efreet_icon_extension_add(".jpg"); -static Eina_Bool -_e_main_cb_x_flusher(void *data __UNUSED__) -{ - eet_clearcache(); - ecore_x_flush(); - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_e_main_cb_idler_before(void *data __UNUSED__) -{ - Eina_List *l, *pl; - E_Before_Idler *eb; - - e_menu_idler_before(); - e_focus_idler_before(); - e_border_idler_before(); - e_popup_idler_before(); - e_drag_idler_before(); - e_pointer_idler_before(); - EINA_LIST_FOREACH(_e_main_idler_before_list, l, eb) + e_prefix_data_concat_static(buff, "data/images/test.png"); + evas_object_image_file_set(im, buff, NULL); + if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) { - if (!eb->delete_me) + e_error_message_show(_("Enlightenment found Evas can't load PNG files. " + "Check Evas has PNG loader support.\n")); + _e_main_shutdown(-1); + } + efreet_icon_extension_add(".png"); + + e_prefix_data_concat_static(buff, "data/images/test.edj"); + evas_object_image_file_set(im, buff, "images/0"); + if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) + { + e_error_message_show(_("Enlightenment found Evas can't load EET files. " + "Check Evas has EET loader support.\n")); + _e_main_shutdown(-1); + } + efreet_icon_extension_add(".edj"); + + evas_object_del(im); + + txt = evas_object_text_add(evas); + evas_object_text_font_set(txt, "Sans", 10); + evas_object_text_text_set(txt, "Hello"); + evas_object_geometry_get(txt, NULL, NULL, &tw, &th); + if ((tw <= 0) && (th <= 0)) + { + e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n" + "support and system fontconfig defines a 'Sans' font.\n")); + _e_main_shutdown(-1); + } + evas_object_del(txt); + e_canvas_del(ee); + ecore_evas_free(ee); +} + +static int +_e_main_screens_init(void) +{ + Ecore_X_Window *roots; + int num, i; + + TS("\tscreens: atoms"); + if (!e_atoms_init()) return 0; + TS("\tscreens: manager"); + if (!e_manager_init()) return 0; + TS("\tscreens: container"); + if (!e_container_init()) return 0; + TS("\tscreens: zone"); + if (!e_zone_init()) return 0; + TS("\tscreens: desk"); + if (!e_desk_init()) return 0; + TS("\tscreens: menu"); + if (!e_menu_init()) return 0; + TS("\tscreens: exehist"); + if (!e_exehist_init()) return 0; + + TS("\tscreens: get roots"); + num = 0; + roots = ecore_x_window_root_list(&num); + if ((!roots) || (num <= 0)) + { + e_error_message_show("X reports there are no root windows and %i screens!\n", + num); + return 0; + } + TS("\tscreens: focus"); + if (!e_focus_init()) return 0; + TS("\tscreens: border"); + if (!e_border_init()) return 0; + TS("\tscreens: win"); + if (!e_win_init()) return 0; + TS("\tscreens: manage roots"); + for (i = 0; i < num; i++) + { + E_Manager *man; + E_Container *con; + + man = e_manager_new(roots[i], i); + if (man) + e_manager_show(man); + else { - if (!eb->func(eb->data)) eb->delete_me = 1; + e_error_message_show("Cannot create manager object for screen %i\n", + i); + free(roots); + return 0; + } + con = e_container_new(man); + if (con) + { + e_container_show(con); + e_grabinput_focus(con->bg_win, E_FOCUS_METHOD_PASSIVE); + e_hints_manager_init(man); + _e_main_desk_restore(man, con); +// e_manager_manage_windows(man); + } + else + { + e_error_message_show("Cannot create desktop object for manager on screen %i\n", + i); + free(roots); + return 0; } } - EINA_LIST_FOREACH_SAFE(_e_main_idler_before_list, pl, l, eb) - { - if ((eb->once) || (eb->delete_me)) - { - _e_main_idler_before_list = - eina_list_remove_list(_e_main_idler_before_list, pl); - free(eb); - } - } - _e_cacheburst--; -/* eet_cacheburst(_e_cacheburst); */ - edje_thaw(); - return ECORE_CALLBACK_RENEW; + free(roots); + + TS("\tscreens: sync"); + ecore_x_sync(); + + return 1; } -static Eina_Bool -_e_main_cb_idler_after(void *data __UNUSED__) +static int +_e_main_screens_shutdown(void) { - edje_freeze(); - _e_cacheburst++; -/* eet_cacheburst(_e_cacheburst); */ - { - static int first_idle = 1; - - if (first_idle) - { - TS("SLEEP"); - first_idle = 0; - e_precache_end = 1; - } - } - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_e_main_cb_eet_cacheburst_end(void *data __UNUSED__) -{ - _e_cacheburst--; -/* eet_cacheburst(_e_cacheburst); */ - return ECORE_CALLBACK_CANCEL; -} - -static Eina_Bool -_e_main_cb_startup_fake_end(void *data __UNUSED__) -{ - e_init_hide(); - return ECORE_CALLBACK_CANCEL; + e_win_shutdown(); + e_border_shutdown(); + e_focus_shutdown(); + e_exehist_shutdown(); + e_menu_shutdown(); +// ecore_evas closes evas - deletes objs - deletes fm widgets which tries to +// ipc to slave to stop monitoring - but ipc has been shut down. dont shut +// down. +// e_desk_shutdown(); +// e_zone_shutdown(); +// e_container_shutdown(); +// e_manager_shutdown(); + e_atoms_shutdown(); + return 1; } static void @@ -1743,3 +1607,145 @@ _e_main_desk_restore(E_Manager *man, E_Container *con) e_desk_show(desk); } } + +static void +_e_main_efreet_paths_init(void) +{ + Eina_List **list; + + if ((list = efreet_icon_extra_list_get())) + { + char buff[PATH_MAX]; + + e_user_dir_concat_static(buff, "icons"); + *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff)); + e_prefix_data_concat_static(buff, "data/icons"); + *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff)); + } +} + +static void +_e_main_modules_load(Eina_Bool safe_mode) +{ + if (!safe_mode) + e_module_all_load(); + else + { + E_Module *m; + char *crashmodule; + + crashmodule = getenv("E_MODULE_LOAD"); + if (crashmodule) m = e_module_new(crashmodule); + + if ((crashmodule) && (m)) + { + e_module_disable(m); + e_object_del(E_OBJECT(m)); + + e_int_config_modules(e_container_current_get(e_manager_current_get()), NULL); + e_error_message_show + (_("Enlightenment crashed early on start and has
" + "been restarted. There was an error loading
" + "module named: %s. This module has been disabled
" + "and will not be loaded."), crashmodule); + e_util_dialog_show + (_("Enlightenment crashed early on start and has been restarted"), + _("Enlightenment crashed early on start and has been restarted.
" + "There was an error loading module named: %s

" + "This module has been disabled and will not be loaded."), crashmodule); + e_module_all_load(); + } + else + { + e_int_config_modules(e_container_current_get(e_manager_current_get()), NULL); + e_error_message_show + (_("Enlightenment crashed early on start and has
" + "been restarted. All modules have been disabled
" + "and will not be loaded to help remove any problem
" + "modules from your configuration. The module
" + "configuration dialog should let you select your
" + "modules again.")); + e_util_dialog_show + (_("Enlightenment crashed early on start and has been restarted"), + _("Enlightenment crashed early on start and has been restarted.
" + "All modules have been disabled and will not be loaded to help
" + "remove any problem modules from your configuration.

" + "The module configuration dialog should let you select your
" + "modules again.")); + } + } +} + +static void +_e_main_manage_all(void) +{ + Eina_List *l; + E_Manager *man; + + EINA_LIST_FOREACH(e_manager_list(), l, man) + e_manager_manage_windows(man); +} + +static Eina_Bool +_e_main_cb_idle_before(void *data __UNUSED__) +{ + Eina_List *l, *pl; + E_Before_Idler *eb; + + e_menu_idler_before(); + e_focus_idler_before(); + e_border_idler_before(); + e_popup_idler_before(); + e_drag_idler_before(); + e_pointer_idler_before(); + EINA_LIST_FOREACH(_idle_before_list, l, eb) + { + if (!eb->delete_me) + { + if (!eb->func(eb->data)) eb->delete_me = 1; + } + } + EINA_LIST_FOREACH_SAFE(_idle_before_list, pl, l, eb) + { + if ((eb->once) || (eb->delete_me)) + { + _idle_before_list = + eina_list_remove_list(_idle_before_list, pl); + free(eb); + } + } + edje_thaw(); + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_e_main_cb_idle_after(void *data __UNUSED__) +{ + static int first_idle = 1; + + edje_freeze(); + + if (first_idle) + { + TS("SLEEP"); + first_idle = 0; + e_precache_end = EINA_TRUE; + } + + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_e_main_cb_x_flusher(void *data __UNUSED__) +{ + eet_clearcache(); + ecore_x_flush(); + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_e_main_cb_startup_fake_end(void *data __UNUSED__) +{ + e_init_hide(); + return ECORE_CALLBACK_CANCEL; +} diff --git a/src/bin/e_signals.c b/src/bin/e_signals.c index 9e61cb75d..60911ad45 100644 --- a/src/bin/e_signals.c +++ b/src/bin/e_signals.c @@ -4,7 +4,6 @@ * to add backtrace support. */ #include "e.h" -#include #ifdef HAVE_EXECINFO_H # include @@ -15,14 +14,14 @@ static volatile Eina_Bool _e_x_composite_shutdown_try = 0; static void _e_x_composite_shutdown(void) { - Ecore_X_Display *dpy; +// Ecore_X_Display *dpy; Ecore_X_Window root; if (_e_x_composite_shutdown_try) return; /* we failed :-( */ _e_x_composite_shutdown_try = 1; - dpy = ecore_x_display_get(); - root = DefaultRootWindow(dpy); +// dpy = ecore_x_display_get(); + root = ecore_x_window_root_first_get(); /* ignore errors, we really don't care at this point */ ecore_x_composite_unredirect_subwindows(root, ECORE_X_COMPOSITE_UPDATE_MANUAL); @@ -69,7 +68,7 @@ _e_gdb_print_backtrace(int fd) // printf bt and allows e to continue and pop up box, perferably allowing // debugging in the gui etc. etc. return; - + if (getenv("E_NO_GDB_BACKTRACE")) return; @@ -89,16 +88,14 @@ _e_gdb_print_backtrace(int fd) #define _e_backtrace(msg) _e_backtrace_int(2, msg, sizeof(msg)) static void -_e_backtrace_int(int fd __UNUSED__, const char *msg __UNUSED__, size_t msg_len __UNUSED__) +_e_backtrace_int(int fd, const char *msg, size_t msg_len) { - /* char attachmsg[1024]; void *array[255]; size_t size; - */ return; // disable. causes hangs and problems -/* + _e_write_safe_int(fd, msg, msg_len); _e_write_safe(fd, "\nBEGIN TRACEBACK\n"); size = backtrace(array, 255); @@ -111,7 +108,6 @@ _e_backtrace_int(int fd __UNUSED__, const char *msg __UNUSED__, size_t msg_len _ _e_write_safe_int(fd, attachmsg, size); _e_gdb_print_backtrace(fd); - */ } /* a tricky little devil, requires e and it's libs to be built @@ -120,108 +116,52 @@ _e_backtrace_int(int fd __UNUSED__, const char *msg __UNUSED__, size_t msg_len _ EAPI void e_sigseg_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__) { - char msg[1024]; - _e_backtrace("**** SEGMENTATION FAULT ****"); _e_x_composite_shutdown(); ecore_x_pointer_ungrab(); ecore_x_keyboard_ungrab(); ecore_x_ungrab(); ecore_x_sync(); - snprintf(msg, sizeof(msg), - "This is very bad. Enlightenment SEGV'd.\n" - "\n" - "This is not meant to happen and is likely a sign of\n" - "a bug in Enlightenment or the libraries it relies\n" - "on. You can gdb attach to this process (%d) now\n" - "to try debug it or you could exit, or just hit\n" - "restart to try and get your desktop back the way\n" - "it was.\n" - "\n" - "Please compile everything with -g in your CFLAGS.\n", - getpid()); - e_alert_show(msg); + e_alert_show(SIGSEGV); exit(-11); } EAPI void e_sigill_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__) { - char msg[1024]; - _e_backtrace("**** ILLEGAL INSTRUCTION ****"); _e_x_composite_shutdown(); ecore_x_pointer_ungrab(); ecore_x_keyboard_ungrab(); ecore_x_ungrab(); ecore_x_sync(); - snprintf(msg, sizeof(msg), - "This is very bad. Enlightenment SIGILL'd.\n" - "\n" - "This is not meant to happen and is likely a sign of\n" - "a bug in Enlightenment or the libraries it relies\n" - "on. You can gdb attach to this process (%d) now\n" - "to try debug it or you could exit, or just hit\n" - "restart to try and get your desktop back the way\n" - "it was.\n" - "\n" - "Please compile everything with -g in your CFLAGS.\n", - getpid()); - e_alert_show(msg); + e_alert_show(SIGILL); exit(-11); } EAPI void e_sigfpe_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__) { - char msg[1024]; - _e_backtrace("**** FLOATING POINT EXCEPTION ****"); _e_x_composite_shutdown(); ecore_x_pointer_ungrab(); ecore_x_keyboard_ungrab(); ecore_x_ungrab(); ecore_x_sync(); - snprintf(msg, sizeof(msg), - "This is very bad. Enlightenment SIGFPE'd.\n" - "\n" - "This is not meant to happen and is likely a sign of\n" - "a bug in Enlightenment or the libraries it relies\n" - "on. You can gdb attach to this process (%d) now\n" - "to try debug it or you could exit, or just hit\n" - "restart to try and get your desktop back the way\n" - "it was.\n" - "\n" - "Please compile everything with -g in your CFLAGS.\n", - getpid()); - e_alert_show(msg); + e_alert_show(SIGFPE); exit(-11); } EAPI void e_sigbus_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__) { - char msg[1024]; - _e_backtrace("**** BUS ERROR ****"); _e_x_composite_shutdown(); ecore_x_pointer_ungrab(); ecore_x_keyboard_ungrab(); ecore_x_ungrab(); ecore_x_sync(); - snprintf(msg, sizeof(msg), - "This is very bad. Enlightenment SIGBUS'd.\n" - "\n" - "This is not meant to happen and is likely a sign of\n" - "a bug in Enlightenment or the libraries it relies\n" - "on. You can gdb attach to this process (%d) now\n" - "to try debug it or you could exit, or just hit\n" - "restart to try and get your desktop back the way\n" - "it was.\n" - "\n" - "Please compile everything with -g in your CFLAGS.\n", - getpid()); - e_alert_show(msg); + e_alert_show(SIGBUS); exit(-11); } @@ -234,14 +174,6 @@ e_sigabrt_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED_ ecore_x_keyboard_ungrab(); ecore_x_ungrab(); ecore_x_sync(); - e_alert_show("This is very bad. Enlightenment SIGABRT'd.\n" - "\n" - "This is not meant to happen and is likely a sign of\n" - "a bug in Enlightenment or the libraries it relies\n" - "on. You can gdb attach to this process now to try\n" - "debug it or you could exit, or just hit restart to\n" - "try and get your desktop back the way it was.\n" - "\n" - "Please compile everything with -g in your CFLAGS\n"); + e_alert_show(SIGABRT); exit(-11); } diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c index 7a99a6b1c..792d8bdc6 100644 --- a/src/bin/e_start_main.c +++ b/src/bin/e_start_main.c @@ -527,21 +527,48 @@ main(int argc, char **argv) void *lib, *func; /* sanity checks - if precache might fail - check here first */ - lib = dlopen("libevas.so", RTLD_GLOBAL | RTLD_LAZY); - if (!lib) dlopen("libevas.so.1", RTLD_GLOBAL | RTLD_LAZY); + lib = dlopen("libeina.so", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) dlopen("libeina.so.1", RTLD_GLOBAL | RTLD_LAZY); if (!lib) goto done; - func = dlsym(lib, "evas_init"); + func = dlsym(lib, "eina_init"); if (!func) goto done; + + lib = dlopen("libecore.so", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) dlopen("libecore.so.1", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) goto done; + func = dlsym(lib, "ecore_init"); + if (!func) goto done; + lib = dlopen("libecore_file.so", RTLD_GLOBAL | RTLD_LAZY); if (!lib) dlopen("libecore_file.so.1", RTLD_GLOBAL | RTLD_LAZY); if (!lib) goto done; func = dlsym(lib, "ecore_file_init"); if (!func) goto done; + + lib = dlopen("libecore_x.so", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) dlopen("libecore_x.so.1", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) goto done; + func = dlsym(lib, "ecore_x_init"); + if (!func) goto done; + + lib = dlopen("libevas.so", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) dlopen("libevas.so.1", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) goto done; + func = dlsym(lib, "evas_init"); + if (!func) goto done; + + lib = dlopen("libedje.so", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) dlopen("libedje.so.1", RTLD_GLOBAL | RTLD_LAZY); + if (!lib) goto done; + func = dlsym(lib, "edje_init"); + if (!func) goto done; + lib = dlopen("libeet.so", RTLD_GLOBAL | RTLD_LAZY); if (!lib) dlopen("libeet.so.0", RTLD_GLOBAL | RTLD_LAZY); if (!lib) goto done; func = dlsym(lib, "eet_init"); if (!func) goto done; + /* precache SHOULD work */ snprintf(buf, sizeof(buf), "%s/lib/enlightenment/preload/e_precache.so", _prefix_path); env_set("LD_PRELOAD", buf); diff --git a/src/bin/e_utils.c b/src/bin/e_utils.c index bfea18a02..97f218c19 100644 --- a/src/bin/e_utils.c +++ b/src/bin/e_utils.c @@ -8,11 +8,6 @@ EAPI E_Path *path_icons = NULL; EAPI E_Path *path_modules = NULL; EAPI E_Path *path_backgrounds = NULL; EAPI E_Path *path_messages = NULL; -EAPI int restart = 0; -EAPI int good = 0; -EAPI int evil = 0; -EAPI int starting = 1; -EAPI int stopping = 0; typedef struct _E_Util_Fake_Mouse_Up_Info E_Util_Fake_Mouse_Up_Info; typedef struct _E_Util_Image_Import_Settings E_Util_Image_Import_Settings; diff --git a/src/modules/comp/e_mod_comp.c b/src/modules/comp/e_mod_comp.c index 60249e1cc..9fc338695 100644 --- a/src/modules/comp/e_mod_comp.c +++ b/src/modules/comp/e_mod_comp.c @@ -3139,7 +3139,7 @@ _e_mod_comp_add(E_Manager *man) } ecore_x_screen_is_composited_set(c->man->num, c->cm_selection); - if (c->man->num == 0) e_alert_composite_win = c->win; +// if (c->man->num == 0) e_alert_composite_win = c->win; if (_comp_mod->conf->engine == E_EVAS_ENGINE_GL_X11) { @@ -3309,7 +3309,7 @@ _e_mod_comp_del(E_Comp *c) ecore_x_composite_unredirect_subwindows (c->man->root, ECORE_X_COMPOSITE_UPDATE_MANUAL); ecore_x_composite_render_window_disable(c->win); - if (c->man->num == 0) e_alert_composite_win = 0; +// if (c->man->num == 0) e_alert_composite_win = 0; if (c->render_animator) ecore_animator_del(c->render_animator); if (c->new_up_timer) ecore_timer_del(c->new_up_timer); if (c->update_job) ecore_job_del(c->update_job); diff --git a/src/preload/Makefile.am b/src/preload/Makefile.am index cf74c6bc3..1f5fc01f4 100644 --- a/src/preload/Makefile.am +++ b/src/preload/Makefile.am @@ -3,7 +3,6 @@ MAINTAINERCLEANFILES = Makefile.in INCLUDES = -I. \ -I$(top_srcdir) \ -I$(top_srcdir)src/preload \ - @x_cflags@ \ @e_cflags@ pkgdir = $(libdir)/enlightenment/preload @@ -14,7 +13,7 @@ pkg_LTLIBRARIES = e_precache.la #e_hack_la_SOURCES = \ #e_hack.c \ #e_hack.h -#e_hack_la_LIBADD = @x_libs@ @dlopen_libs@ +#e_hack_la_LIBADD = @dlopen_libs@ #e_hack_la_LDFLAGS = -module -avoid-version #e_hack_la_DEPENDENCIES = $(top_builddir)/config.h diff --git a/src/preload/e_precache.c b/src/preload/e_precache.c index 8795dc30a..272fa2ad1 100644 --- a/src/preload/e_precache.c +++ b/src/preload/e_precache.c @@ -1,8 +1,12 @@ #include "config.h" #include "e_precache.h" -static void *lib_evas = NULL; +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; @@ -105,21 +109,35 @@ lib_func(const char *lib1, const char *lib2, const char *fname, const char *libn } /* intercepts */ -void -evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key) +Eina_Module * +eina_module_find(const Eina_Array *array, const char *module) { - 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); + 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); @@ -131,6 +149,7 @@ 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); @@ -142,6 +161,7 @@ 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); @@ -153,6 +173,7 @@ 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); @@ -164,6 +185,7 @@ 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); @@ -175,6 +197,7 @@ 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); @@ -186,6 +209,7 @@ 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); @@ -197,6 +221,7 @@ 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); @@ -204,13 +229,52 @@ ecore_file_ls(const char *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); } +