summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cpmichael1@comcast.net>2011-07-25 09:40:18 +0000
committerChristopher Michael <cpmichael1@comcast.net>2011-07-25 09:40:18 +0000
commit1a13f8c26f67c2a13c1dffdb60b4577a5e3e704d (patch)
treed040dc396d43194a63647c69e7cdb25d15cc212c
parentbc5f550546f5e2994d6fb95feb8651a82240d8e5 (diff)
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
-rw-r--r--configure.ac64
-rw-r--r--src/bin/Makefile.am14
-rw-r--r--src/bin/e.h324
-rw-r--r--src/bin/e_alert.c247
-rw-r--r--src/bin/e_alert.h11
-rw-r--r--src/bin/e_alert_main.c615
-rw-r--r--src/bin/e_config.c22
-rw-r--r--src/bin/e_fm/Makefile.am2
-rw-r--r--src/bin/e_ipc.c153
-rw-r--r--src/bin/e_ipc.h1
-rw-r--r--src/bin/e_main.c2030
-rw-r--r--src/bin/e_signals.c90
-rw-r--r--src/bin/e_start_main.c33
-rw-r--r--src/bin/e_utils.c5
-rw-r--r--src/modules/comp/e_mod_comp.c4
-rw-r--r--src/preload/Makefile.am3
-rw-r--r--src/preload/e_precache.c82
17 files changed, 2103 insertions, 1597 deletions
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
77AC_CHECK_FUNCS(setenv) 77AC_CHECK_FUNCS(setenv)
78AC_CHECK_FUNCS(unsetenv) 78AC_CHECK_FUNCS(unsetenv)
79 79
80AC_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])) 80dnl 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]))
81 81
82AC_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])) 82AC_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]))
83 83
@@ -160,25 +160,25 @@ AC_ARG_ENABLE(simple-x11,
160 [ want_evas_simple_x11=$enableval ] 160 [ want_evas_simple_x11=$enableval ]
161) 161)
162 162
163x_dir="" 163dnl x_dir=""
164x_cflags="" 164dnl x_cflags=""
165x_libs="" 165dnl x_libs=""
166AC_PATH_XTRA 166dnl AC_PATH_XTRA
167AC_CHECK_HEADER(X11/X.h, 167dnl AC_CHECK_HEADER(X11/X.h,
168 [ 168dnl [
169 if test "x$want_evas_simple_x11" = "xyes"; then 169dnl if test "x$want_evas_simple_x11" = "xyes"; then
170 x_libs="${x_libs} -lX11 -lXext" 170dnl x_libs="${x_libs} -lX11 -lXext"
171 else 171dnl else
172 x_dir=${x_dir:-/usr/X11R6} 172dnl x_dir=${x_dir:-/usr/X11R6}
173 x_cflags=${x_cflags:--I${x_includes:-$x_dir/include}} 173dnl x_cflags=${x_cflags:--I${x_includes:-$x_dir/include}}
174 x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext" 174dnl x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext"
175 fi 175dnl fi
176 ],[ 176dnl ],[
177 AC_MSG_ERROR([Cannot find X headers and libraries.]) 177dnl AC_MSG_ERROR([Cannot find X headers and libraries.])
178 ] 178dnl ]
179) 179dnl )
180AC_SUBST(x_cflags) 180dnl AC_SUBST(x_cflags)
181AC_SUBST(x_libs) 181dnl AC_SUBST(x_libs)
182 182
183cf_cflags="" 183cf_cflags=""
184cf_libs="" 184cf_libs=""
@@ -372,12 +372,16 @@ eeze_mount=
372EEZE_MOUNT_CONFIG=0 372EEZE_MOUNT_CONFIG=0
373if test "x$e_cv_want_mount_eeze" != "xno" ; then 373if test "x$e_cv_want_mount_eeze" != "xno" ; then
374 AC_CHECK_LIB([eeze], [eeze_disk_function], 374 AC_CHECK_LIB([eeze], [eeze_disk_function],
375## [
376## eeze_mount="eeze >= 1.1.0"
377## EEZE_MOUNT_CONFIG=1
378## AC_DEFINE_UNQUOTED([HAVE_EEZE_MOUNT], [1], [enable eeze mounting])
379## AC_MSG_NOTICE([eeze mounting enabled])
380## ],
375 [ 381 [
376 eeze_mount="eeze >= 1.0.99 ecore-con >= 1.0.999" 382 AC_MSG_NOTICE([eeze mounting disabled])
377 EEZE_MOUNT_CONFIG=1 383 e_cv_want_mount_eeze=no
378 AC_DEFINE_UNQUOTED([HAVE_EEZE_MOUNT], [1], [enable eeze mounting]) 384 ]
379 AC_MSG_NOTICE([eeze mounting enabled])
380 ],
381 ) 385 )
382else 386else
383 AC_MSG_NOTICE([eeze mounting disabled]) 387 AC_MSG_NOTICE([eeze mounting disabled])
@@ -390,7 +394,7 @@ AM_CONDITIONAL([HAVE_EEZE_MOUNT], [false])
390test -n "$hal_mount" && AC_DEFINE_UNQUOTED([HAVE_HAL_MOUNT], [1], [enable HAL mounting]) 394test -n "$hal_mount" && AC_DEFINE_UNQUOTED([HAVE_HAL_MOUNT], [1], [enable HAL mounting])
391test -n "$udisks_mount" && AC_DEFINE_UNQUOTED([HAVE_UDISKS_MOUNT], [1], [enable Udisks mounting]) 395test -n "$udisks_mount" && AC_DEFINE_UNQUOTED([HAVE_UDISKS_MOUNT], [1], [enable Udisks mounting])
392AM_CONDITIONAL([HAVE_UDISKS_MOUNT], [test -n "$udisks_mount"]) 396AM_CONDITIONAL([HAVE_UDISKS_MOUNT], [test -n "$udisks_mount"])
393AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test -n "$eeze_mount"]) 397##AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test -n "$eeze_mount"])
394 398
395# doxygen program for documentation building 399# doxygen program for documentation building
396 400
@@ -442,6 +446,7 @@ PKG_CHECK_MODULES(E_FM_OP, [
442PKG_CHECK_MODULES(E_FM_OPEN, [ 446PKG_CHECK_MODULES(E_FM_OPEN, [
443 ecore >= 1.0.999 447 ecore >= 1.0.999
444 ecore-ipc >= 1.0.999 448 ecore-ipc >= 1.0.999
449 ecore-con >= 1.0.999
445 eet >= 1.4.0 450 eet >= 1.4.0
446 eina >= 1.0.999 451 eina >= 1.0.999
447]) 452])
@@ -460,6 +465,13 @@ PKG_CHECK_MODULES(E_INIT, [
460 eina >= 1.0.999 465 eina >= 1.0.999
461]) 466])
462 467
468PKG_CHECK_MODULES(E_ALERT, [
469 xcb
470 eina >= 1.0.999
471 ecore >= 1.0.999
472 ecore-ipc >= 1.0.999
473])
474
463PKG_CHECK_MODULES(E, [ 475PKG_CHECK_MODULES(E, [
464 evas >= 1.0.999 476 evas >= 1.0.999
465 ecore >= 1.0.999 477 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 = \
9-I$(top_srcdir) \ 9-I$(top_srcdir) \
10-I$(top_srcdir)/src/bin \ 10-I$(top_srcdir)/src/bin \
11@e_cflags@ \ 11@e_cflags@ \
12@x_cflags@ \
13@cf_cflags@ \ 12@cf_cflags@ \
14@VALGRIND_CFLAGS@ \ 13@VALGRIND_CFLAGS@ \
15@EDJE_DEF@ \ 14@EDJE_DEF@ \
@@ -30,7 +29,8 @@ enlightenment_fm_op \
30enlightenment_init \ 29enlightenment_init \
31enlightenment_sys \ 30enlightenment_sys \
32enlightenment_thumb \ 31enlightenment_thumb \
33enlightenment_backlight 32enlightenment_backlight \
33enlightenment_alert
34 34
35ENLIGHTENMENTHEADERS = \ 35ENLIGHTENMENTHEADERS = \
36e_about.h \ 36e_about.h \
@@ -184,8 +184,8 @@ e_zone.h
184enlightenment_src = \ 184enlightenment_src = \
185e_about.c \ 185e_about.c \
186e_acpi.c \ 186e_acpi.c \
187e_actions.c \
188e_alert.c \ 187e_alert.c \
188e_actions.c \
189e_atoms.c \ 189e_atoms.c \
190e_backlight.c \ 190e_backlight.c \
191e_bg.c \ 191e_bg.c \
@@ -331,7 +331,7 @@ e_main.c \
331$(enlightenment_src) 331$(enlightenment_src)
332 332
333enlightenment_LDFLAGS = -export-dynamic 333enlightenment_LDFLAGS = -export-dynamic
334enlightenment_LDADD = @e_libs@ @x_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm 334enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm
335 335
336enlightenment_imc_SOURCES = \ 336enlightenment_imc_SOURCES = \
337e.h \ 337e.h \
@@ -375,6 +375,12 @@ e_xinerama.c
375 375
376enlightenment_init_LDADD = @E_INIT_LIBS@ 376enlightenment_init_LDADD = @E_INIT_LIBS@
377 377
378enlightenment_alert_SOURCES = \
379e_alert_main.c
380
381enlightenment_alert_LDADD = @E_ALERT_LIBS@
382enlightenment_alert_CFLAGS = @E_ALERT_CFLAGS@
383
378# HACK! why install-data-hook? install-exec-hook is run after bin_PROGRAMS 384# HACK! why install-data-hook? install-exec-hook is run after bin_PROGRAMS
379# and before internal_bin_PROGRAMS are installed. install-data-hook is 385# and before internal_bin_PROGRAMS are installed. install-data-hook is
380# run after both 386# 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 @@
1#ifndef E_H 1#ifndef E_H
2#define E_H 2# define E_H
3 3
4#ifdef HAVE_CONFIG_H 4# ifdef HAVE_CONFIG_H
5#include "config.h" 5# include "config.h"
6#endif 6# endif
7 7
8#define USE_IPC 8# define USE_IPC
9#if 0 9# if 0
10#define OBJECT_PARANOIA_CHECK 10# define OBJECT_PARANOIA_CHECK
11#define OBJECT_CHECK 11# define OBJECT_CHECK
12#endif 12# endif
13 13
14#ifndef _FILE_OFFSET_BITS 14# ifndef _FILE_OFFSET_BITS
15#define _FILE_OFFSET_BITS 64 15# define _FILE_OFFSET_BITS 64
16#endif 16# endif
17 17
18#ifdef HAVE_ALLOCA_H 18# ifdef HAVE_ALLOCA_H
19# include <alloca.h> 19# include <alloca.h>
20#elif defined __GNUC__ 20# elif defined __GNUC__
21# define alloca __builtin_alloca 21# define alloca __builtin_alloca
22#elif defined _AIX 22# elif defined _AIX
23# define alloca __alloca 23# define alloca __alloca
24#elif defined _MSC_VER 24# elif defined _MSC_VER
25# include <malloc.h> 25# include <malloc.h>
26# define alloca _alloca 26# define alloca _alloca
27#else 27# else
28# include <stddef.h> 28# include <stddef.h>
29# ifdef __cplusplus 29# ifdef __cplusplus
30extern "C" 30extern "C"
31# endif 31# endif
32void *alloca (size_t); 32void *alloca (size_t);
33#endif 33# endif
34 34
35# ifdef __linux__
36# include <features.h>
37# endif
35 38
36#ifdef __linux__ 39# include <stdio.h>
37#include <features.h> 40# include <stdlib.h>
38#endif 41# include <unistd.h>
39#include <stdio.h> 42# include <string.h>
40#include <stdlib.h> 43# include <sys/types.h>
41#include <unistd.h> 44# include <sys/stat.h>
42#include <string.h> 45# include <sys/time.h>
43#include <sys/types.h> 46# include <sys/param.h>
44#include <sys/stat.h> 47# include <sys/resource.h>
45#include <sys/time.h> 48# include <utime.h>
46#include <sys/param.h> 49# include <dlfcn.h>
47#include <utime.h> 50# include <math.h>
48#include <dlfcn.h> 51# include <fcntl.h>
49#include <math.h> 52# include <fnmatch.h>
50#include <fnmatch.h> 53# include <limits.h>
51#include <limits.h> 54# include <ctype.h>
52#include <ctype.h> 55# include <time.h>
53#include <time.h> 56# include <dirent.h>
54#include <dirent.h> 57# include <pwd.h>
55#include <pwd.h> 58# include <grp.h>
56#include <grp.h> 59# include <glob.h>
57#include <glob.h> 60# include <locale.h>
58#include <locale.h> 61# include <errno.h>
59#include <errno.h> 62# include <signal.h>
60#include <signal.h> 63# include <inttypes.h>
61#include <inttypes.h> 64
62#include <sys/time.h> 65# ifdef HAVE_GETTEXT
63#include <sys/resource.h> 66# include <libintl.h>
64 67# endif
65#ifdef HAVE_GETTEXT
66# include <libintl.h>
67#endif
68 68
69#ifndef _POSIX_HOST_NAME_MAX 69# ifndef _POSIX_HOST_NAME_MAX
70#define _POSIX_HOST_NAME_MAX 255 70# define _POSIX_HOST_NAME_MAX 255
71#endif 71# endif
72 72
73#ifdef HAVE_VALGRIND 73# ifdef HAVE_VALGRIND
74# include <memcheck.h> 74# include <memcheck.h>
75#endif 75# endif
76 76
77#ifdef __GLIBC__ 77# ifdef __GLIBC__
78#include <execinfo.h> 78# include <execinfo.h>
79#include <setjmp.h> 79# include <setjmp.h>
80#endif 80# endif
81 81
82#include <Eina.h> 82# include <Eina.h>
83#include <Evas.h> 83# include <Eet.h>
84#include <Evas_Engine_Buffer.h> 84# include <Evas.h>
85#include <Ecore.h> 85# include <Evas_Engine_Buffer.h>
86#include <Ecore_X.h> 86# include <Ecore.h>
87#include <Ecore_Evas.h> 87# include <Ecore_X.h>
88#include <Ecore_Input.h> 88# include <Ecore_Evas.h>
89#include <Ecore_Input_Evas.h> 89# include <Ecore_Input.h>
90#include <Ecore_Con.h> 90# include <Ecore_Input_Evas.h>
91#include <Ecore_Ipc.h> 91# include <Ecore_Con.h>
92#include <Ecore_File.h> 92# include <Ecore_Ipc.h>
93#include <Eet.h> 93# include <Ecore_File.h>
94#include <Edje.h> 94# include <Efreet.h>
95#include <Efreet.h> 95# include <Efreet_Mime.h>
96#include <Efreet_Mime.h> 96# include <Edje.h>
97#include <E_DBus.h> 97# include <E_DBus.h>
98 98
99#ifdef EAPI 99# ifdef EAPI
100#undef EAPI 100# undef EAPI
101#endif
102#ifdef WIN32
103# ifdef BUILDING_DLL
104# define EAPI __declspec(dllexport)
105# else
106# define EAPI __declspec(dllimport)
107# endif 101# endif
108#else 102# ifdef WIN32
109# ifdef __GNUC__ 103# ifdef BUILDING_DLL
110# if __GNUC__ >= 4 104# define EAPI __declspec(dllexport)
105# else
106# define EAPI __declspec(dllimport)
107# endif
108# else
109# ifdef __GNUC__
110# if __GNUC__ >= 4
111/* BROKEN in gcc 4 on amd64 */ 111/* BROKEN in gcc 4 on amd64 */
112#if 0 112# if 0
113# pragma GCC visibility push(hidden) 113# pragma GCC visibility push(hidden)
114#endif 114# endif
115# define EAPI __attribute__ ((visibility("default"))) 115# define EAPI __attribute__ ((visibility("default")))
116# else
117# define EAPI
118# endif
116# else 119# else
117# define EAPI 120# define EAPI
118# endif 121# endif
119# else
120# define EAPI
121# endif 122# endif
122#endif
123 123
124#ifdef EINTERN 124# ifdef EINTERN
125#undef EINTERN 125# undef EINTERN
126#endif 126# endif
127#ifdef __GNUC__ 127# ifdef __GNUC__
128# if __GNUC__ >= 4 128# if __GNUC__ >= 4
129# define EINTERN __attribute__ ((visibility("hidden"))) 129# define EINTERN __attribute__ ((visibility("hidden")))
130# else
131# define EINTERN
132# endif
130# else 133# else
131# define EINTERN 134# define EINTERN
132# endif 135# endif
133#else
134# define EINTERN
135#endif
136 136
137typedef struct _E_Before_Idler E_Before_Idler; 137typedef struct _E_Before_Idler E_Before_Idler;
138typedef struct _E_Rect E_Rect; 138typedef struct _E_Rect E_Rect;
139 139
140/* convenience macro to compress code and avoid typos */ 140/* convenience macro to compress code and avoid typos */
141#define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; } 141# define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; }
142#define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy))) 142# define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
143#define E_INSIDE(x, y, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy))) 143 (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
144#define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) (((xx) >= (x)) && (((x) + (w)) >= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) >= ((yy) + (hh)))) 144# define E_INSIDE(x, y, xx, yy, ww, hh) \
145#define E_SPANS_COMMON(x1, w1, x2, w2) (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) 145 (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
146#define E_REALLOC(p, s, n) p = (s *)realloc(p, sizeof(s) * n) 146# define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) \
147#define E_NEW(s, n) (s *)calloc(n, sizeof(s)) 147 (((xx) >= (x)) && (((x) + (w)) >= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) >= ((yy) + (hh))))
148#define E_NEW_RAW(s, n) (s *)malloc(n * sizeof(s)) 148# define E_SPANS_COMMON(x1, w1, x2, w2) \
149#define E_FREE(p) do { free(p); p = NULL; } while (0) 149 (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
150#define E_FREE_LIST(list, free) \ 150# define E_REALLOC(p, s, n) p = (s *)realloc(p, sizeof(s) * n)
151 do \ 151# define E_NEW(s, n) (s *)calloc(n, sizeof(s))
152 { \ 152# define E_NEW_RAW(s, n) (s *)malloc(n * sizeof(s))
153 if (list) \ 153# define E_FREE(p) do { free(p); p = NULL; } while (0)
154 { \ 154# define E_FREE_LIST(list, free) \
155 void *data; \ 155 do \
156 EINA_LIST_FREE(list, data) \ 156 { \
157 { \ 157 if (list) \
158 free(data); \ 158 { \
159 } \ 159 void *data; \
160 list = NULL; \ 160 EINA_LIST_FREE(list, data) \
161 } \ 161 { \
162 } \ 162 free(data); \
163 while (0) 163 } \
164 164 list = NULL; \
165#define E_CLAMP(x, min, max) (x < min ? min : (x > max ? max : x)) 165 } \
166#define E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \ 166 } \
167 while (0)
168
169# define E_CLAMP(x, min, max) (x < min ? min : (x > max ? max : x))
170# define E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \
167 { \ 171 { \
168 if (E_INTERSECTS(_x, _y, _w, _h, _cx, _cy, _cw, _ch)) \ 172 if (E_INTERSECTS(_x, _y, _w, _h, _cx, _cy, _cw, _ch)) \
169 { \ 173 { \
@@ -190,28 +194,27 @@ typedef struct _E_Rect E_Rect;
190 } \ 194 } \
191 } 195 }
192 196
193#define E_REMOTE_OPTIONS 1 197# define E_REMOTE_OPTIONS 1
194#define E_REMOTE_OUT 2 198# define E_REMOTE_OUT 2
195#define E_WM_IN 3 199# define E_WM_IN 3
196#define E_REMOTE_IN 4 200# define E_REMOTE_IN 4
197#define E_ENUM 5 201# define E_ENUM 5
198#define E_LIB_IN 6 202# define E_LIB_IN 6
199 203
200#define E_TYPEDEFS 1 204# define E_TYPEDEFS 1
201#include "e_includes.h" 205# include "e_includes.h"
202#undef E_TYPEDEFS 206# undef E_TYPEDEFS
203#include "e_includes.h" 207# include "e_includes.h"
204 208
205EAPI E_Before_Idler *e_main_idler_before_add(int (*func) (void *data), void *data, int once); 209EAPI E_Before_Idler *e_main_idler_before_add(int (*func) (void *data), void *data, int once);
206EAPI void e_main_idler_before_del(E_Before_Idler *eb); 210EAPI void e_main_idler_before_del(E_Before_Idler *eb);
207
208 211
209struct _E_Before_Idler 212struct _E_Before_Idler
210{ 213{
211 int (*func) (void *data); 214 int (*func) (void *data);
212 void *data; 215 void *data;
213 unsigned char once : 1; 216 Eina_Bool once : 1;
214 unsigned char delete_me : 1; 217 Eina_Bool delete_me : 1;
215}; 218};
216 219
217struct _E_Rect 220struct _E_Rect
@@ -227,14 +230,15 @@ extern EAPI E_Path *path_icons;
227extern EAPI E_Path *path_modules; 230extern EAPI E_Path *path_modules;
228extern EAPI E_Path *path_backgrounds; 231extern EAPI E_Path *path_backgrounds;
229extern EAPI E_Path *path_messages; 232extern EAPI E_Path *path_messages;
230extern EAPI int restart; 233extern EAPI Eina_Bool good;
231extern EAPI int good; 234extern EAPI Eina_Bool evil;
232extern EAPI int evil; 235extern EAPI Eina_Bool starting;
233extern EAPI int starting; 236extern EAPI Eina_Bool stopping;
234extern EAPI int stopping; 237extern EAPI Eina_Bool restart;
235 238
239extern EAPI Eina_Bool e_precache_end;
236extern EAPI Eina_Bool x_fatal; 240extern EAPI Eina_Bool x_fatal;
237 241
238extern EAPI unsigned long e_alert_composite_win; 242//extern EAPI unsigned long e_alert_composite_win;
239 243
240#endif 244#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 @@
1#include "e.h" 1#include "e.h"
2#include "e_alert.h"
3 2
4#include <stdio.h> 3/* local function prototypes */
5#include <stdlib.h> 4static Eina_Bool _e_alert_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event);
6#include <stdarg.h>
7#include <string.h>
8#include <unistd.h>
9#include <signal.h>
10#include <X11/Xlib.h>
11#include <X11/X.h>
12#include <X11/extensions/shape.h>
13#include <Ecore.h>
14 5
15/* local subsystem functions */ 6/* local variables */
7static Ecore_Exe *alert_exe = NULL;
8static Ecore_Event_Handler *alert_exe_hdl = NULL;
16 9
17/* local subsystem globals */ 10EINTERN int
18static Display *dd = NULL; 11e_alert_init(void)
19static char *title = NULL, *str1 = NULL, *str2 = NULL;
20static Font font = 0;
21static XFontStruct *fs = NULL;
22static GC gc = 0;
23static Window win = 0, b1 = 0, b2 = 0;
24static int ww = 320, hh = 240, wx = 20, wy = 20;
25
26EAPI unsigned long e_alert_composite_win = 0;
27
28/* externally accessible functions */
29EINTERN int
30e_alert_init(const char *disp)
31{ 12{
32 XGCValues gcv; 13 alert_exe_hdl =
33 int wid, hih, mask; 14 ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_alert_cb_exe_del, NULL);
34 XSetWindowAttributes att;
35
36 dd = XOpenDisplay(disp);
37 if (!dd) return 0;
38 font = XLoadFont(dd, "fixed");
39 fs = XQueryFont(dd, font);
40
41 /* dont i18n this - i dont want gettext doing anything as this is called
42 from a segv */
43 title = "Enlightenment Error";
44 str1 = "(F1) Recover";
45 str2 = "(F2) Exit";
46
47 wid = DisplayWidth(dd, DefaultScreen(dd));
48 hih = DisplayHeight(dd, DefaultScreen(dd));
49 att.background_pixel = WhitePixel(dd, DefaultScreen(dd));
50 att.border_pixel = BlackPixel(dd, DefaultScreen(dd));
51 att.override_redirect = True;
52 mask = CWBackPixel | CWBorderPixel | CWOverrideRedirect;
53
54 wx = (wid - ww) / 2;
55 wy = (hih - hh) / 2;
56
57 win = XCreateWindow(dd, DefaultRootWindow(dd),
58 wx, wy, ww, hh, 0,
59 CopyFromParent, InputOutput,
60 CopyFromParent, mask, &att);
61
62 b1 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent,
63 InputOutput, CopyFromParent, mask, &att);
64 b2 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent,
65 InputOutput, CopyFromParent, mask, &att);
66 XMapWindow(dd, b1);
67 XMapWindow(dd, b2);
68
69 gc = XCreateGC(dd, win, 0, &gcv);
70 XSetForeground(dd, gc, att.border_pixel);
71 XSelectInput(dd, win, KeyPressMask | KeyReleaseMask | ExposureMask);
72 15
73 return 1; 16 return 1;
74} 17}
75 18
76EINTERN int 19EINTERN int
77e_alert_shutdown(void) 20e_alert_shutdown(void)
78{ 21{
79 if (!x_fatal) 22 e_alert_hide();
80 { 23
81 XDestroyWindow(dd, win); 24 if (alert_exe_hdl) ecore_event_handler_del(alert_exe_hdl);
82 XFreeGC(dd, gc); 25 alert_exe_hdl = NULL;
83 XFreeFont(dd, fs); 26
84 XCloseDisplay(dd);
85 }
86 title = NULL;
87 str1 = NULL;
88 str2 = NULL;
89 dd = NULL;
90 font = 0;
91 fs = NULL;
92 gc = 0;
93 return 1; 27 return 1;
94} 28}
95 29
96EAPI void 30EAPI void
97e_alert_show(const char *text) 31e_alert_show(int sig)
98{ 32{
99 int w, i, j, k; 33 char buf[8192];
100 char line[1024];
101 XEvent ev;
102 int fw, fh, mh;
103 KeyCode key;
104 int button;
105 34
106 if (!text) return; 35 snprintf(buf, sizeof(buf),
36 "%s/enlightenment/utils/enlightenment_alert %d %d",
37 e_prefix_lib_get(), sig, getpid());
107 38
108 if ((!dd) || (!fs)) 39 alert_exe = ecore_exe_run(buf, NULL);
109 { 40 pause();
110 fputs(text, stderr); 41}
111 fflush(stderr);
112 exit(1);
113 }
114
115 fh = fs->ascent + fs->descent;
116 mh = ((ww - 20) / 2) - 20;
117 42
118 /* fixed size... */ 43EAPI void
119 w = 20; 44e_alert_hide(void)
120 XMoveResizeWindow(dd, b1, w, hh - 15 - fh, mh + 10, fh + 10); 45{
121 XSelectInput(dd, b1, ButtonPressMask | ButtonReleaseMask | ExposureMask); 46 if (alert_exe) ecore_exe_terminate(alert_exe);
122 w = ww - 20 - mh; 47}
123 XMoveResizeWindow(dd, b2, w, hh - 15 - fh, mh + 10, fh + 10);
124 XSelectInput(dd, b2, ButtonPressMask | ButtonReleaseMask | ExposureMask);
125 48
126 if (e_alert_composite_win) 49/* local functions */
127 { 50static Eina_Bool
128#ifdef ShapeInput 51_e_alert_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event)
129 XRectangle rect; 52{
130 53 Ecore_Exe_Event_Del *ev;
131 rect.x = wx;
132 rect.y = wy;
133 rect.width = ww;
134 rect.height = hh;
135 XShapeCombineRectangles(dd, e_alert_composite_win, ShapeInput,
136 0, 0, &rect, 1, ShapeSet, Unsorted);
137#endif
138 XReparentWindow(dd, win, e_alert_composite_win, wx, wy);
139 }
140 XMapRaised(dd, win);
141 XGrabPointer(dd, win, True, ButtonPressMask | ButtonReleaseMask,
142 GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
143 XGrabKeyboard(dd, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
144 XSetInputFocus(dd, win, RevertToPointerRoot, CurrentTime);
145 XSync(dd, False);
146
147 button = 0;
148 while (button == 0)
149 {
150 XNextEvent(dd, &ev);
151 switch (ev.type)
152 {
153 case KeyPress:
154 key = XKeysymToKeycode(dd, XStringToKeysym("F1"));
155 if (key == ev.xkey.keycode)
156 {
157 button = 1;
158 break;
159 }
160 key = XKeysymToKeycode(dd, XStringToKeysym("F2"));
161 if (key == ev.xkey.keycode)
162 {
163 button = 2;
164 break;
165 }
166 break;
167 case ButtonPress:
168 if (ev.xbutton.window == b1)
169 button = 1;
170 else if (ev.xbutton.window == b2)
171 button = 2;
172 break;
173 case Expose:
174 while (XCheckTypedWindowEvent(dd, ev.xexpose.window, Expose, &ev));
175
176 /* outline */
177 XDrawRectangle(dd, win, gc, 0, 0, ww - 1, hh - 1);
178
179 XDrawRectangle(dd, win, gc, 2, 2, ww - 4 - 1, fh + 4 - 1);
180
181 fw = XTextWidth(fs, title, strlen(title));
182 XDrawString(dd, win, gc, 2 + 2 + ((ww - 4 - 4 - fw) / 2) , 2 + 2 + fs->ascent, title, strlen(title));
183
184 i = 0;
185 j = 0;
186 k = 2 + fh + 4 + 2;
187 while (text[i])
188 {
189 line[j++] = text[i++];
190 if (line[j - 1] == '\n')
191 {
192 line[j - 1] = 0;
193 j = 0;
194 XDrawString(dd, win, gc, 4, k + fs->ascent, line, strlen(line));
195 k += fh + 2;
196 }
197 }
198 fw = XTextWidth(fs, str1, strlen(str1));
199 XDrawRectangle(dd, b1, gc, 0, 0, mh - 1, fh + 10 - 1);
200 XDrawString(dd, b1, gc, 5 + ((mh - fw) / 2), 5 + fs->ascent, str1, strlen(str1));
201 54
202 fw = XTextWidth(fs, str2, strlen(str2)); 55 ev = event;
203 XDrawRectangle(dd, b2, gc, 0, 0, mh - 1, fh + 10 - 1); 56 if (!alert_exe) return ECORE_CALLBACK_RENEW;
204 XDrawString(dd, b2, gc, 5 + ((mh - fw) / 2), 5 + fs->ascent, str2, strlen(str2)); 57 if (ev->exe == alert_exe) alert_exe = NULL;
205
206 XSync(dd, False);
207 break;
208 58
209 default: 59 return ECORE_CALLBACK_RENEW;
210 break;
211 }
212 }
213 XDestroyWindow(dd, win);
214 XSync(dd, False);
215
216 switch (button)
217 {
218 case 1:
219 ecore_app_restart();
220 break;
221 case 2:
222 exit(-11);
223 break;
224 default:
225 break;
226 }
227} 60}
228
229/* local subsystem functions */
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 @@
1#ifdef E_TYPEDEFS 1#ifdef E_TYPEDEFS
2 2
3typedef enum _E_Alert_Op_Type
4{
5 E_ALERT_OP_RESTART = 0,
6 E_ALERT_OP_EXIT
7} E_Alert_Op_Type;
8
3#else 9#else
4#ifndef E_ALERT_H 10#ifndef E_ALERT_H
5#define E_ALERT_H 11#define E_ALERT_H
6 12
7EINTERN int e_alert_init(const char *disp); 13EINTERN int e_alert_init(void);
8EINTERN int e_alert_shutdown(void); 14EINTERN int e_alert_shutdown(void);
9 15
10void e_alert_show(const char *text); 16EAPI void e_alert_show(int sig);
17EAPI void e_alert_hide(void);
11 18
12#endif 19#endif
13#endif 20#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 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <stdarg.h>
4#include <string.h>
5#include <sys/types.h>
6#include <unistd.h>
7#include <signal.h>
8#include <limits.h>
9#include <Eina.h>
10#include <Ecore.h>
11#include <Ecore_Ipc.h>
12#include <xcb/xcb.h>
13
14#define WINDOW_WIDTH 320
15#define WINDOW_HEIGHT 240
16
17/* local function prototypes */
18static int _e_alert_ipc_init(void);
19static Eina_Bool _e_alert_ipc_server_add(void *data, int type, void *event);
20static int _e_alert_connect(void);
21static void _e_alert_create(void);
22static void _e_alert_display(void);
23static void _e_alert_button_move_resize(xcb_window_t btn, int x, int y, int w, int h);
24static void _e_alert_window_raise(xcb_window_t win);
25static void _e_alert_sync(void);
26static void _e_alert_shutdown(void);
27static void _e_alert_run(void);
28static void _e_alert_draw(void);
29static int _e_alert_handle_key_press(xcb_generic_event_t *event);
30static int _e_alert_handle_button_press(xcb_generic_event_t *event);
31static xcb_char2b_t *_e_alert_build_string(const char *str);
32static void _e_alert_draw_outline(void);
33static void _e_alert_draw_title_outline(void);
34static void _e_alert_draw_title(void);
35static void _e_alert_draw_text(void);
36static void _e_alert_draw_button_outlines(void);
37static void _e_alert_draw_button_text(void);
38static void _e_alert_restart_e(void);
39static void _e_alert_exit_e(void);
40
41/* local variables */
42static Ecore_Ipc_Server *_ipc_server = NULL;
43static Ecore_Ipc_Server *_server = NULL;
44static xcb_connection_t *conn = NULL;
45static xcb_screen_t *screen = NULL;
46static xcb_window_t win = 0;
47static xcb_window_t btn1 = 0;
48static xcb_window_t btn2 = 0;
49static xcb_font_t font = 0;
50static xcb_gcontext_t gc = 0;
51static int sw = 0, sh = 0;
52static int fa = 0, fh = 0, fw = 0;
53static const char *title = NULL, *str1 = NULL, *str2 = NULL;
54static int ret = 0, sig = 0;
55static pid_t pid;
56
57int
58main(int argc, char **argv)
59{
60 int i = 0;
61
62 for (i = 1; i < argc; i++)
63 {
64 if ((!strcmp(argv[i], "-h")) ||
65 (!strcmp(argv[i], "-help")) ||
66 (!strcmp(argv[i], "--help")))
67 {
68 printf("This is an internal tool for Enlightenment.\n"
69 "do not use it.\n");
70 exit(0);
71 }
72 else if ((i == 1))
73 sig = atoi(argv[i]); // signal
74 else if ((i == 2))
75 pid = atoi(argv[i]); // E's pid
76 }
77
78 if (!ecore_init()) return EXIT_FAILURE;
79 if (!ecore_ipc_init())
80 {
81 ecore_shutdown();
82 return EXIT_FAILURE;
83 }
84
85 if (!_e_alert_connect())
86 {
87 printf("FAILED TO INIT ALERT SYSTEM!!!\n");
88 ecore_ipc_shutdown();
89 ecore_shutdown();
90 return EXIT_FAILURE;
91 }
92
93 if (!_e_alert_ipc_init())
94 {
95 printf("Failed to Connect to Enlightenment!!!\n");
96 ecore_ipc_shutdown();
97 ecore_shutdown();
98 return EXIT_FAILURE;
99 }
100
101 title = "Enlightenment Error";
102 str1 = "(F1) Recover";
103 str2 = "(F2) Exit";
104
105 _e_alert_create();
106 _e_alert_display();
107 _e_alert_run();
108 _e_alert_shutdown();
109
110 if (ret == 1)
111 _e_alert_restart_e();
112 else if (ret == 2)
113 _e_alert_exit_e();
114
115 if (_ipc_server)
116 ecore_ipc_server_del(_ipc_server);
117
118 ecore_ipc_shutdown();
119 ecore_shutdown();
120
121 return EXIT_SUCCESS;
122}
123
124/* local functions */
125static int
126_e_alert_ipc_init(void)
127{
128 char *edir = NULL;
129
130 if (!(edir = getenv("E_IPC_SOCKET"))) return 0;
131 _ipc_server =
132 ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, edir, 0, NULL);
133 if (!_ipc_server) return 0;
134
135 ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
136 _e_alert_ipc_server_add, NULL);
137 return 1;
138}
139
140static Eina_Bool
141_e_alert_ipc_server_add(void *data, int type, void *event)
142{
143 Ecore_Ipc_Event_Server_Add *e;
144
145 e = event;
146 _server = e->server;
147 return ECORE_CALLBACK_PASS_ON;
148}
149
150static int
151_e_alert_connect(void)
152{
153 conn = xcb_connect(NULL, NULL);
154 if ((!conn) || (xcb_connection_has_error(conn)))
155 {
156 printf("E_Alert_Main: Error Trying to Connect!!\n");
157 return 0;
158 }
159
160 /* grab default screen */
161 screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
162 sw = screen->width_in_pixels;
163 sh = screen->height_in_pixels;
164
165 return 1;
166}
167
168static void
169_e_alert_create(void)
170{
171 uint32_t mask, mask_list[4];
172 int wx = 0, wy = 0;
173
174 wx = ((sw - WINDOW_WIDTH) / 2);
175 wy = ((sh - WINDOW_HEIGHT) / 2);
176
177 font = xcb_generate_id(conn);
178 xcb_open_font(conn, font, strlen("fixed"), "fixed");
179
180 /* create main window */
181 mask = (XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL |
182 XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK);
183 mask_list[0] = screen->white_pixel;
184 mask_list[1] = screen->black_pixel;
185 mask_list[2] = 1;
186 mask_list[3] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
187 XCB_EVENT_MASK_EXPOSURE);
188
189 win = xcb_generate_id(conn);
190 xcb_create_window(conn, XCB_COPY_FROM_PARENT, win, screen->root,
191 wx, wy, WINDOW_WIDTH, WINDOW_HEIGHT, 0,
192 XCB_WINDOW_CLASS_INPUT_OUTPUT,
193 XCB_COPY_FROM_PARENT, mask, mask_list);
194
195 /* create button 1 */
196 mask_list[3] = (XCB_EVENT_MASK_BUTTON_PRESS |
197 XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_EXPOSURE);
198
199 btn1 = xcb_generate_id(conn);
200 xcb_create_window(conn, XCB_COPY_FROM_PARENT, btn1, win,
201 -100, -100, 1, 1, 0,
202 XCB_WINDOW_CLASS_INPUT_OUTPUT,
203 XCB_COPY_FROM_PARENT, mask, mask_list);
204 xcb_map_window(conn, btn1);
205
206 /* create button 2 */
207 btn2 = xcb_generate_id(conn);
208 xcb_create_window(conn, XCB_COPY_FROM_PARENT, btn2, win,
209 -100, -100, 1, 1, 0,
210 XCB_WINDOW_CLASS_INPUT_OUTPUT,
211 XCB_COPY_FROM_PARENT, mask, mask_list);
212 xcb_map_window(conn, btn2);
213
214 /* create drawing gc */
215 mask = (XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT);
216 mask_list[0] = screen->black_pixel;
217 mask_list[1] = screen->white_pixel;
218 mask_list[2] = font;
219
220 gc = xcb_generate_id(conn);
221 xcb_create_gc(conn, gc, win, mask, mask_list);
222}
223
224static void
225_e_alert_display(void)
226{
227 xcb_char2b_t *str = NULL;
228 xcb_query_text_extents_cookie_t cookie;
229 xcb_query_text_extents_reply_t *reply;
230 int x = 0, w = 0;
231
232 str = _e_alert_build_string(title);
233
234 cookie =
235 xcb_query_text_extents_unchecked(conn, font, strlen(title), str);
236 reply = xcb_query_text_extents_reply(conn, cookie, NULL);
237 if (reply)
238 {
239 fa = reply->font_ascent;
240 fh = (fa + reply->font_descent);
241 fw = reply->overall_width;
242 free(reply);
243 }
244 free(str);
245
246 /* move buttons */
247 x = 20;
248 w = (WINDOW_WIDTH / 2) - 40;
249 _e_alert_button_move_resize(btn1, x, WINDOW_HEIGHT - 20 - (fh + 20),
250 w, (fh + 20));
251
252 x = ((WINDOW_WIDTH / 2) + 20);
253 _e_alert_button_move_resize(btn2, x, WINDOW_HEIGHT - 20 - (fh + 20),
254 w, (fh + 20));
255
256 /* FIXME: May need e_alert_composite_win here and checks for shapedinput */
257 /* if (e_alert_composite_win) */
258 /* { */
259/* #ifdef ShapeInput */
260 /* XRectangle rect; */
261
262 /* rect.x = wx; */
263 /* rect.y = wy; */
264 /* rect.width = ww; */
265 /* rect.height = hh; */
266 /* XShapeCombineRectangles(dd, e_alert_composite_win, ShapeInput, */
267 /* 0, 0, &rect, 1, ShapeSet, Unsorted); */
268/* #endif */
269 /* XReparentWindow(dd, win, e_alert_composite_win, wx, wy); */
270 /* } */
271
272 /* map and raise main window */
273 xcb_map_window(conn, win);
274 _e_alert_window_raise(win);
275
276 /* grab pointer & keyboard */
277 xcb_grab_pointer_unchecked(conn, 0, win,
278 (XCB_EVENT_MASK_BUTTON_PRESS |
279 XCB_EVENT_MASK_BUTTON_RELEASE),
280 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
281 XCB_NONE, XCB_NONE, XCB_CURRENT_TIME);
282 xcb_grab_keyboard_unchecked(conn, 0, win, XCB_CURRENT_TIME,
283 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
284 xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT,
285 win, XCB_CURRENT_TIME);
286
287 /* flush screen */
288 xcb_flush(conn);
289
290 /* sync */
291 _e_alert_sync();
292}
293
294static void
295_e_alert_button_move_resize(xcb_window_t btn, int x, int y, int w, int h)
296{
297 uint32_t list[4], mask;
298
299 if (!btn) return;
300
301 mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
302 XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT);
303 list[0] = x;
304 list[1] = y;
305 list[2] = w;
306 list[3] = h;
307
308 xcb_configure_window(conn, btn, mask, (const uint32_t *)&list);
309}
310
311static void
312_e_alert_window_raise(xcb_window_t win)
313{
314 uint32_t list[] = { XCB_STACK_MODE_ABOVE };
315
316 if (!win) return;
317 xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, list);
318}
319
320static void
321_e_alert_sync(void)
322{
323 xcb_flush(conn);
324 free(xcb_get_input_focus_reply(conn,
325 xcb_get_input_focus(conn), NULL));
326}
327
328static void
329_e_alert_shutdown(void)
330{
331 xcb_close_font(conn, font);
332 xcb_destroy_window(conn, btn1);
333 xcb_destroy_window(conn, btn2);
334 xcb_destroy_window(conn, win);
335 xcb_free_gc(conn, gc);
336 xcb_disconnect(conn);
337}
338
339static void
340_e_alert_run(void)
341{
342 xcb_generic_event_t *event = NULL;
343
344 xcb_flush(conn);
345 while ((event = xcb_wait_for_event(conn)))
346 {
347 switch (event->response_type & ~0x80)
348 {
349 case XCB_BUTTON_PRESS:
350 ret = _e_alert_handle_button_press(event);
351 break;
352 case XCB_KEY_PRESS:
353 ret = _e_alert_handle_key_press(event);
354 break;
355 case XCB_EXPOSE:
356 {
357 xcb_expose_event_t *ev;
358
359 ev = (xcb_expose_event_t *)event;
360 if (ev->window != win) break;
361
362 _e_alert_draw();
363 _e_alert_sync();
364
365 break;
366 }
367 default:
368 break;
369 }
370 free(event);
371 if (ret > 0) break;
372 }
373}
374
375static void
376_e_alert_draw(void)
377{
378 _e_alert_draw_outline();
379 _e_alert_draw_title_outline();
380 _e_alert_draw_title();
381 _e_alert_draw_text();
382 _e_alert_draw_button_outlines();
383 _e_alert_draw_button_text();
384
385 xcb_flush(conn);
386}
387
388static int
389_e_alert_handle_key_press(xcb_generic_event_t *event)
390{
391 xcb_key_press_event_t *ev;
392
393 ev = (xcb_key_press_event_t *)event;
394 if (ev->detail == 67) // F1
395 return 1;
396 else if (ev->detail == 68) // F2
397 return 2;
398 else
399 return 0;
400}
401
402static int
403_e_alert_handle_button_press(xcb_generic_event_t *event)
404{
405 xcb_button_press_event_t *ev;
406
407 ev = (xcb_button_press_event_t *)event;
408 if (ev->child == btn1)
409 return 1;
410 else if (ev->child == btn2)
411 return 2;
412 else
413 return 0;
414}
415
416static xcb_char2b_t *
417_e_alert_build_string(const char *str)
418{
419 unsigned int i = 0;
420 xcb_char2b_t *ret = NULL;
421
422 if (!(ret = malloc(strlen(str) * sizeof(xcb_char2b_t))))
423 return NULL;
424
425 for (i = 0; i < strlen(str); i++)
426 {
427 ret[i].byte1 = 0;
428 ret[i].byte2 = str[i];
429 }
430
431 return ret;
432}
433
434static void
435_e_alert_draw_outline(void)
436{
437 xcb_rectangle_t rect;
438
439 /* draw outline */
440 rect.x = 0;
441 rect.y = 0;
442 rect.width = (WINDOW_WIDTH - 1);
443 rect.height = (WINDOW_HEIGHT - 1);
444 xcb_poly_rectangle(conn, win, gc, 1, &rect);
445}
446
447static void
448_e_alert_draw_title_outline(void)
449{
450 xcb_rectangle_t rect;
451
452 /* draw title box */
453 rect.x = 2;
454 rect.y = 2;
455 rect.width = (WINDOW_WIDTH - 4 - 1);
456 rect.height = (fh + 4 + 2);
457 xcb_poly_rectangle(conn, win, gc, 1, &rect);
458}
459
460static void
461_e_alert_draw_title(void)
462{
463 xcb_void_cookie_t cookie;
464 int x = 0, y = 0;
465
466 /* draw title */
467 x = (2 + 2 + ((WINDOW_WIDTH - 4 - 4 - fw) / 2));
468 y = (2 + 2 + fh);
469
470 cookie =
471 xcb_image_text_8(conn, strlen(title), win, gc, x, y, title);
472}
473
474static void
475_e_alert_draw_text(void)
476{
477 xcb_void_cookie_t cookie;
478 char warn[1024], msg[PATH_MAX], line[1024];
479 int i = 0, j = 0, k = 0;
480
481 snprintf(msg, sizeof(msg),
482 "This is not meant to happen and is likely a sign of \n"
483 "a bug in Enlightenment or the libraries it relies \n"
484 "on. You can gdb attach to this process (%d) now \n"
485 "to try debug it or you could exit, or just hit \n"
486 "restart to try and get your desktop back the way \n"
487 "it was.\n"
488 "\n"
489 "Please compile everything with -g in your CFLAGS.", pid);
490
491 switch (sig)
492 {
493 case SIGSEGV:
494 snprintf(warn, sizeof(warn),
495 "This is very bad. Enlightenment SEGV'd.");
496 break;
497 case SIGILL:
498 snprintf(warn, sizeof(warn),
499 "This is very bad. Enlightenment SIGILL'd.");
500 break;
501 case SIGFPE:
502 snprintf(warn, sizeof(warn),
503 "This is very bad. Enlightenment SIGFPE'd.");
504 break;
505 case SIGBUS:
506 snprintf(warn, sizeof(warn),
507 "This is very bad. Enlightenment SIGBUS'd.");
508 break;
509 case SIGABRT:
510 snprintf(warn, sizeof(warn),
511 "This is very bad. Enlightenment SIGABRT'd.");
512 break;
513 default:
514 break;
515 }
516
517 /* draw text */
518 k = (fh + 12);
519 cookie =
520 xcb_image_text_8(conn, strlen(warn), win, gc,
521 4, (k + fa), warn);
522 k += (2 * (fh + 2));
523 while (msg[i])
524 {
525 line[j++] = msg[i++];
526 if (line[j - 1] == '\n')
527 {
528 line[j - 1] = 0;
529 j = 0;
530 cookie =
531 xcb_image_text_8(conn, strlen(line), win, gc,
532 4, (k + fa), line);
533 k += (fh + 2);
534 }
535 }
536}
537
538static void
539_e_alert_draw_button_outlines(void)
540{
541 xcb_rectangle_t rect;
542
543 rect.x = 0;
544 rect.y = 0;
545 rect.width = (WINDOW_WIDTH / 2) - 40 - 1;
546 rect.height = (fh + 20) - 1;
547
548 /* draw button outlines */
549 xcb_poly_rectangle(conn, btn1, gc, 1, &rect);
550 xcb_poly_rectangle(conn, btn2, gc, 1, &rect);
551}
552
553static void
554_e_alert_draw_button_text(void)
555{
556 xcb_void_cookie_t dcookie;
557 xcb_char2b_t *str = NULL;
558 xcb_query_text_extents_cookie_t cookie;
559 xcb_query_text_extents_reply_t *reply;
560 int x = 0, w = 0, bw = 0;
561
562 bw = (WINDOW_WIDTH / 2) - 40 - 1;
563
564 /* draw button1 text */
565 str = _e_alert_build_string(str1);
566
567 cookie =
568 xcb_query_text_extents_unchecked(conn, font, strlen(str1), str);
569 reply = xcb_query_text_extents_reply(conn, cookie, NULL);
570 if (reply)
571 {
572 w = reply->overall_width;
573 free(reply);
574 }
575 free(str);
576
577 x = (5 + ((bw - w) / 2));
578
579 dcookie =
580 xcb_image_text_8(conn, strlen(str1), btn1, gc, x, (10 + fa), str1);
581
582 /* draw button2 text */
583 str = _e_alert_build_string(str2);
584
585 cookie =
586 xcb_query_text_extents_unchecked(conn, font, strlen(str2), str);
587 reply = xcb_query_text_extents_reply(conn, cookie, NULL);
588 if (reply)
589 {
590 w = reply->overall_width;
591 free(reply);
592 }
593 free(str);
594
595 x = (5 + ((bw - w) / 2));
596
597 dcookie =
598 xcb_image_text_8(conn, strlen(str2), btn2, gc, x, (10 + fa), str2);
599}
600
601static void
602_e_alert_restart_e(void)
603{
604 kill(getppid(), SIGUSR2);
605 ecore_ipc_server_send(_server, 8, 0, 0, 0, 0, NULL, 0);
606 ecore_ipc_server_flush(_server);
607}
608
609static void
610_e_alert_exit_e(void)
611{
612 kill(getppid(), SIGUSR2);
613 ecore_ipc_server_send(_server, 8, 1, 0, 0, 0, NULL, 0);
614 ecore_ipc_server_flush(_server);
615}
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)
903 E_CONFIG_VAL(D, T, exec.show_exit_dialog, UCHAR); 903 E_CONFIG_VAL(D, T, exec.show_exit_dialog, UCHAR);
904 904
905 E_CONFIG_VAL(D, T, null_container_win, UCHAR); 905 E_CONFIG_VAL(D, T, null_container_win, UCHAR);
906 906
907 E_CONFIG_LIST(D, T, env_vars, _e_config_env_var_edd); 907 E_CONFIG_LIST(D, T, env_vars, _e_config_env_var_edd);
908 908
909 E_CONFIG_VAL(D, T, backlight.normal, DOUBLE); 909 E_CONFIG_VAL(D, T, backlight.normal, DOUBLE);
910 E_CONFIG_VAL(D, T, backlight.dim, DOUBLE); 910 E_CONFIG_VAL(D, T, backlight.dim, DOUBLE);
911 E_CONFIG_VAL(D, T, backlight.transition, DOUBLE); 911 E_CONFIG_VAL(D, T, backlight.transition, DOUBLE);
@@ -914,7 +914,7 @@ e_config_init(void)
914 E_CONFIG_VAL(D, T, deskenv.load_xmodmap, UCHAR); 914 E_CONFIG_VAL(D, T, deskenv.load_xmodmap, UCHAR);
915 E_CONFIG_VAL(D, T, deskenv.load_gnome, UCHAR); 915 E_CONFIG_VAL(D, T, deskenv.load_gnome, UCHAR);
916 E_CONFIG_VAL(D, T, deskenv.load_kde, UCHAR); 916 E_CONFIG_VAL(D, T, deskenv.load_kde, UCHAR);
917 917
918 e_config_load(); 918 e_config_load();
919 919
920 e_config_save_queue(); 920 e_config_save_queue();
@@ -1021,15 +1021,13 @@ e_config_load(void)
1021 { 1021 {
1022 printf("EEEK! no config of any sort! abort abort abort!\n"); 1022 printf("EEEK! no config of any sort! abort abort abort!\n");
1023 fprintf(stderr, "EEEK! no config of any sort! abort abort abort!\n"); 1023 fprintf(stderr, "EEEK! no config of any sort! abort abort abort!\n");
1024 e_alert_show("Enlightenment was started without any configuration\n" 1024 e_error_message_show("Enlightenment was started without any configuration\n"
1025 "files available for the given profile (normally\n" 1025 "files available for the given profile (normally\n"
1026 "default or the last profile used or provided on the\n" 1026 "default or the last profile used or provided on the\n"
1027 "command-line with -profile etc.)\n" 1027 "command-line with -profile etc.)\n\n"
1028 "\n" 1028 "Cannot contiue without configuration to work with.\n"
1029 "Cannot contiue without configuration to work with.\n" 1029 "Please ensure you have system or user configuration\n"
1030 "Please ensure you have system or user configuration\n" 1030 "for the profile you are using before proceeeding.");
1031 "for the profile you are using before proceeeding."
1032 );
1033 abort(); 1031 abort();
1034 } 1032 }
1035 if (e_config->config_version < E_CONFIG_FILE_VERSION) 1033 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 = \
6-I$(top_srcdir) \ 6-I$(top_srcdir) \
7-I$(top_srcdir)/src/bin \ 7-I$(top_srcdir)/src/bin \
8@e_cflags@ \ 8@e_cflags@ \
9@x_cflags@ \
10@cf_cflags@ \ 9@cf_cflags@ \
11@VALGRIND_CFLAGS@ \ 10@VALGRIND_CFLAGS@ \
12@EDJE_DEF@ \ 11@EDJE_DEF@ \
@@ -61,4 +60,3 @@ $(eeze_s) \
61../e_sha1.c 60../e_sha1.c
62 61
63enlightenment_fm_LDADD = @E_FM_LIBS@ 62enlightenment_fm_LDADD = @E_FM_LIBS@
64
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 @@
2 2
3#ifdef USE_IPC 3#ifdef USE_IPC
4/* local subsystem functions */ 4/* local subsystem functions */
5static Eina_Bool _e_ipc_cb_client_add(void *data __UNUSED__, 5static Eina_Bool _e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event);
6 int type __UNUSED__, 6static Eina_Bool _e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event);
7 void *event); 7static Eina_Bool _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event);
8static Eina_Bool _e_ipc_cb_client_del(void *data __UNUSED__,
9 int type __UNUSED__,
10 void *event);
11static Eina_Bool _e_ipc_cb_client_data(void *data __UNUSED__,
12 int type __UNUSED__,
13 void *event);
14 8
15/* local subsystem globals */ 9/* local subsystem globals */
16static Ecore_Ipc_Server *_e_ipc_server = NULL; 10static Ecore_Ipc_Server *_e_ipc_server = NULL;
@@ -42,8 +36,7 @@ e_ipc_init(void)
42 36
43 if (stat(buf, &st) == 0) 37 if (stat(buf, &st) == 0)
44 { 38 {
45 if ((st.st_uid == 39 if ((st.st_uid == getuid()) &&
46 getuid()) &&
47 ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) == 40 ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) ==
48 (S_IRWXU | S_IFDIR))) 41 (S_IRWXU | S_IFDIR)))
49 { 42 {
@@ -68,15 +61,19 @@ e_ipc_init(void)
68 return 0; 61 return 0;
69 } 62 }
70 } 63 }
71 snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i", tmp, user, disp, pid); 64 snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i",
65 tmp, user, disp, pid);
72 _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, buf, 0, NULL); 66 _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, buf, 0, NULL);
73 e_util_env_set("E_IPC_SOCKET", ""); 67 e_util_env_set("E_IPC_SOCKET", "");
74 if (!_e_ipc_server) return 0; 68 if (!_e_ipc_server) return 0;
75 e_util_env_set("E_IPC_SOCKET", buf); 69 e_util_env_set("E_IPC_SOCKET", buf);
76 printf("INFO: E_IPC_SOCKET=%s\n", buf); 70 printf("INFO: E_IPC_SOCKET=%s\n", buf);
77 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _e_ipc_cb_client_add, NULL); 71 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD,
78 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _e_ipc_cb_client_del, NULL); 72 _e_ipc_cb_client_add, NULL);
79 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _e_ipc_cb_client_data, NULL); 73 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL,
74 _e_ipc_cb_client_del, NULL);
75 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA,
76 _e_ipc_cb_client_data, NULL);
80 77
81 e_ipc_codec_init(); 78 e_ipc_codec_init();
82#endif 79#endif
@@ -100,26 +97,24 @@ e_ipc_shutdown(void)
100#ifdef USE_IPC 97#ifdef USE_IPC
101/* local subsystem globals */ 98/* local subsystem globals */
102static Eina_Bool 99static Eina_Bool
103_e_ipc_cb_client_add(void *data __UNUSED__, 100_e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event)
104 int type __UNUSED__,
105 void *event)
106{ 101{
107 Ecore_Ipc_Event_Client_Add *e; 102 Ecore_Ipc_Event_Client_Add *e;
108 103
109 e = event; 104 e = event;
110 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return ECORE_CALLBACK_PASS_ON; 105 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server)
106 return ECORE_CALLBACK_PASS_ON;
111 return ECORE_CALLBACK_PASS_ON; 107 return ECORE_CALLBACK_PASS_ON;
112} 108}
113 109
114static Eina_Bool 110static Eina_Bool
115_e_ipc_cb_client_del(void *data __UNUSED__, 111_e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event)
116 int type __UNUSED__,
117 void *event)
118{ 112{
119 Ecore_Ipc_Event_Client_Del *e; 113 Ecore_Ipc_Event_Client_Del *e;
120 114
121 e = event; 115 e = event;
122 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return ECORE_CALLBACK_PASS_ON; 116 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server)
117 return ECORE_CALLBACK_PASS_ON;
123 /* delete client sruct */ 118 /* delete client sruct */
124 e_thumb_client_del(e); 119 e_thumb_client_del(e);
125 e_fm2_client_del(e); 120 e_fm2_client_del(e);
@@ -129,14 +124,13 @@ _e_ipc_cb_client_del(void *data __UNUSED__,
129} 124}
130 125
131static Eina_Bool 126static Eina_Bool
132_e_ipc_cb_client_data(void *data __UNUSED__, 127_e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
133 int type __UNUSED__,
134 void *event)
135{ 128{
136 Ecore_Ipc_Event_Client_Data *e; 129 Ecore_Ipc_Event_Client_Data *e;
137 130
138 e = event; 131 e = event;
139 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return ECORE_CALLBACK_PASS_ON; 132 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server)
133 return ECORE_CALLBACK_PASS_ON;
140 switch (e->major) 134 switch (e->major)
141 { 135 {
142 case E_IPC_DOMAIN_SETUP: 136 case E_IPC_DOMAIN_SETUP:
@@ -146,50 +140,50 @@ _e_ipc_cb_client_data(void *data __UNUSED__,
146 switch (e->minor) 140 switch (e->minor)
147 { 141 {
148 case E_IPC_OP_EXEC_ACTION: 142 case E_IPC_OP_EXEC_ACTION:
149 { 143 {
150 E_Ipc_2Str *req = NULL; 144 E_Ipc_2Str *req = NULL;
151 145
152 if (e_ipc_codec_2str_dec(e->data, e->size, &req)) 146 if (e_ipc_codec_2str_dec(e->data, e->size, &req))
153 { 147 {
154 Eina_List *m = e_manager_list(); 148 Eina_List *m = e_manager_list();
155 int len, ok = 0; 149 int len, ok = 0;
156 void *d; 150 void *d;
157 151
158 if (m) 152 if (m)
159 { 153 {
160 E_Manager *man = eina_list_data_get(m); 154 E_Manager *man = eina_list_data_get(m);
161 155
162 if (man) 156 if (man)
163 { 157 {
164 E_Action *act = e_action_find(req->str1); 158 E_Action *act = e_action_find(req->str1);
165 159
166 if (act && act->func.go) 160 if ((act) && (act->func.go))
167 { 161 {
168 act->func.go(E_OBJECT(man), req->str2); 162 act->func.go(E_OBJECT(man), req->str2);
169 ok = 1; 163 ok = 1;
170 } 164 }
171 } 165 }
172 } 166 }
173 167
174 d = e_ipc_codec_int_enc(ok, &len); 168 d = e_ipc_codec_int_enc(ok, &len);
175 if (d) 169 if (d)
176 { 170 {
177 ecore_ipc_client_send(e->client, 171 ecore_ipc_client_send(e->client,
178 E_IPC_DOMAIN_REPLY, 172 E_IPC_DOMAIN_REPLY,
179 E_IPC_OP_EXEC_ACTION_REPLY, 173 E_IPC_OP_EXEC_ACTION_REPLY,
180 0, 0, 0, d, len); 174 0, 0, 0, d, len);
181 free(d); 175 free(d);
182 } 176 }
183 177
184 if (req) 178 if (req)
185 { 179 {
186 E_FREE(req->str1); 180 E_FREE(req->str1);
187 E_FREE(req->str2); 181 E_FREE(req->str2);
188 E_FREE(req); 182 E_FREE(req);
189 } 183 }
190 } 184 }
191 } 185 }
192 break; 186 break;
193 187
194 default: 188 default:
195 break; 189 break;
@@ -208,6 +202,23 @@ _e_ipc_cb_client_data(void *data __UNUSED__,
208 e_init_client_data(e); 202 e_init_client_data(e);
209 break; 203 break;
210 204
205 case E_IPC_DOMAIN_ALERT:
206 {
207 E_Action *a = NULL;
208
209 switch (e->minor)
210 {
211 case E_ALERT_OP_RESTART:
212 a = e_action_find("restart");
213 break;
214 case E_ALERT_OP_EXIT:
215 a = e_action_find("exit");
216 break;
217 }
218 if ((a) && (a->func.go)) a->func.go(NULL, NULL);
219 break;
220 }
221
211 default: 222 default:
212 break; 223 break;
213 } 224 }
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
15 E_IPC_DOMAIN_THUMB, 15 E_IPC_DOMAIN_THUMB,
16 E_IPC_DOMAIN_FM, 16 E_IPC_DOMAIN_FM,
17 E_IPC_DOMAIN_INIT, 17 E_IPC_DOMAIN_INIT,
18 E_IPC_DOMAIN_ALERT,
18 E_IPC_DOMAIN_LAST 19 E_IPC_DOMAIN_LAST
19} E_Ipc_Domain; 20} E_Ipc_Domain;
20 21
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 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "e.h" 1#include "e.h"
6
7#ifdef HAVE_ECORE_IMF 2#ifdef HAVE_ECORE_IMF
8#include <Ecore_IMF.h> 3# include <Ecore_IMF.h>
9#endif 4#endif
10 5
11#include <fcntl.h> 6#define MAX_LEVEL 55
12#include <setjmp.h> 7
8#define TS_DO
9#ifdef TS_DO
10#define TS(x) \
11 { \
12 t1 = ecore_time_unix_get(); \
13 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
14 t2 = t1; \
15 }
16static double t0, t1, t2;
17#else
18# define TS(x)
19#endif
13 20
14/* 21/*
15 * i need to make more use of these when i'm baffled as to when something is 22 * 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)
59} 66}
60*/ 67*/
61 68
62EAPI int e_precache_end = 0; 69/* local function prototypes */
63EAPI Eina_Bool x_fatal = EINA_FALSE; 70static void _e_main_shutdown(int errcode);
64
65static int really_know = 0;
66
67/* local subsystem functions */
68static void _e_main_shutdown_push(int (*func)(void)); 71static void _e_main_shutdown_push(int (*func)(void));
69static void _e_main_shutdown(int errorcode); 72static void _e_main_parse_arguments(int argc, char **argv);
70
71static int _e_main_x_shutdown(void);
72static int _e_main_dirs_init(void);
73static int _e_main_dirs_shutdown(void);
74static int _e_main_screens_init(void);
75static int _e_main_screens_shutdown(void);
76static void _e_main_manage_all(void);
77static int _e_main_path_init(void);
78static int _e_main_path_shutdown(void);
79
80static void _e_main_cb_x_fatal(void *data __UNUSED__); 73static void _e_main_cb_x_fatal(void *data __UNUSED__);
81static Eina_Bool _e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__); 74static Eina_Bool _e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__);
82static Eina_Bool _e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__); 75static Eina_Bool _e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__);
83static Eina_Bool _e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev); 76static Eina_Bool _e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev);
84static Eina_Bool _e_main_cb_x_flusher(void *data __UNUSED__); 77static int _e_main_x_shutdown(void);
85static Eina_Bool _e_main_cb_idler_before(void *data __UNUSED__); 78static int _e_main_dirs_init(void);
86static Eina_Bool _e_main_cb_idler_after(void *data __UNUSED__); 79static int _e_main_dirs_shutdown(void);
87static Eina_Bool _e_main_cb_eet_cacheburst_end(void *data __UNUSED__); 80static int _e_main_path_init(void);
88static Eina_Bool _e_main_cb_startup_fake_end(void *data __UNUSED__); 81static int _e_main_path_shutdown(void);
82static void _e_main_test_formats(void);
83static int _e_main_screens_init(void);
84static int _e_main_screens_shutdown(void);
89static void _e_main_desk_save(void); 85static void _e_main_desk_save(void);
90static void _e_main_desk_restore(E_Manager *man, E_Container *con); 86static void _e_main_desk_restore(E_Manager *man, E_Container *con);
87static void _e_main_efreet_paths_init(void);
88static void _e_main_modules_load(Eina_Bool safe_mode);
89static void _e_main_manage_all(void);
90static Eina_Bool _e_main_cb_x_flusher(void *data __UNUSED__);
91static Eina_Bool _e_main_cb_idle_before(void *data __UNUSED__);
92static Eina_Bool _e_main_cb_idle_after(void *data __UNUSED__);
93static Eina_Bool _e_main_cb_startup_fake_end(void *data __UNUSED__);
91 94
92/* local subsystem globals */ 95/* local variables */
93#define MAX_LEVEL 64 96static Eina_Bool really_know = EINA_FALSE;
94static int (*_e_main_shutdown_func[MAX_LEVEL]) (void);
95static int _e_main_level = 0;
96static int _e_cacheburst = 0;
97static Eina_Bool locked = EINA_FALSE; 97static Eina_Bool locked = EINA_FALSE;
98
99static jmp_buf x_fatal_buf;
100static Eina_Bool inloop = EINA_FALSE; 98static Eina_Bool inloop = EINA_FALSE;
99static jmp_buf x_fatal_buff;
101 100
102static Eina_List *_e_main_idler_before_list = NULL; 101static int _e_main_lvl = 0;
103 102static int (*_e_main_shutdown_func[MAX_LEVEL])(void);
104static Ecore_Idle_Enterer *_e_main_idle_enterer_before = NULL;
105static Ecore_Idle_Enterer *_e_main_idle_enterer_after = NULL;
106static Ecore_Idle_Enterer *_e_main_idle_enterer_flusher = NULL;
107 103
108#define TS_DO 104static Eina_List *_idle_before_list = NULL;
105static Ecore_Idle_Enterer *_idle_before = NULL;
106static Ecore_Idle_Enterer *_idle_after = NULL;
107static Ecore_Idle_Enterer *_idle_flush = NULL;
109 108
110#ifdef TS_DO 109/* external variables */
111#define TS(x) \ 110EAPI Eina_Bool e_precache_end = EINA_FALSE;
112 { \ 111EAPI Eina_Bool x_fatal = EINA_FALSE;
113 t1 = ecore_time_unix_get(); \ 112EAPI Eina_Bool good = EINA_FALSE;
114 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \ 113EAPI Eina_Bool evil = EINA_FALSE;
115 t2 = t1; \ 114EAPI Eina_Bool starting = EINA_TRUE;
116 } 115EAPI Eina_Bool stopping = EINA_FALSE;
117static double t0, t1, t2; 116EAPI Eina_Bool restart = EINA_FALSE;
118#else
119#define TS(x)
120#endif
121
122#undef DBG_EINA_STRINGSHARE
123
124#ifdef DBG_EINA_STRINGSHARE
125static Eina_Bool
126stdbg(void *data __UNUSED__)
127{
128// enable to debug eina stringshare usage
129 eina_stringshare_dump();
130 return ECORE_CALLBACK_CANCEL;
131}
132#endif
133 117
134/* externally accessible functions */ 118/* externally accessible functions */
135int 119int
136main(int argc, char **argv) 120main(int argc, char **argv)
137{ 121{
138 int i; 122 Eina_Bool nostartup = EINA_FALSE;
139 int nostartup = 0; 123 Eina_Bool safe_mode = EINA_FALSE;
140 int after_restart = 0; 124 Eina_Bool after_restart = EINA_FALSE;
141 int safe_mode = 0; 125 double t = 0.0, tstart = 0.0;
142 char buf[PATH_MAX]; 126 char *s = NULL, buff[PATH_MAX];
143 char *s;
144 struct sigaction action; 127 struct sigaction action;
145 double t, tstart;
146
147#ifdef TS_DO 128#ifdef TS_DO
148 t0 = t1 = t2 = ecore_time_unix_get(); 129 t0 = t1 = t2 = ecore_time_unix_get();
149#endif 130#endif
150 TS("begin");
151
152#if 0
153 {
154 stack_t ss;
155 131
156 ss.ss_sp = malloc(8 * 1024); 132 TS("Begin Startup");
157 ss.ss_size = 8 * 1024;
158 ss.ss_flags = 0;
159 sigaltstack(&ss, NULL);
160 }
161#endif
162 133
163 /* trap deadly bug signals and allow some form of sane recovery */ 134 /* trap deadly bug signals and allow some form of sane recovery */
164 /* or ability to gdb attach and debug at this point - better than your */ 135 /* or ability to gdb attach and debug at this point - better than your */
165 /* wm/desktop vanishing and not knowing what happened */ 136 /* wm/desktop vanishing and not knowing what happened */
166 137 TS("Signal Trap");
167 action.sa_sigaction = e_sigseg_act; 138 action.sa_sigaction = e_sigseg_act;
168 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO; 139 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
169 sigemptyset(&action.sa_mask); 140 sigemptyset(&action.sa_mask);
@@ -188,344 +159,255 @@ main(int argc, char **argv)
188 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO; 159 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
189 sigemptyset(&action.sa_mask); 160 sigemptyset(&action.sa_mask);
190 sigaction(SIGABRT, &action, NULL); 161 sigaction(SIGABRT, &action, NULL);
191 162 TS("Signal Trap Done");
192 TS("signals done");
193 163
194 t = ecore_time_unix_get(); 164 t = ecore_time_unix_get();
195 s = getenv("E_START_TIME"); 165 s = getenv("E_START_TIME");
196 if ((s) && (!getenv("E_RESTART_OK"))) 166 if ((s) && (!getenv("E_RESTART_OK")))
197 { 167 {
198 tstart = atof(s); 168 tstart = atof(s);
199 if ((t - tstart) < 5.0) safe_mode = 1; 169 if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
200 } 170 }
201
202 tstart = t; 171 tstart = t;
203 snprintf(buf, sizeof(buf), "%1.1f", tstart); 172 snprintf(buff, sizeof(buff), "%1.1f", tstart);
204 e_util_env_set("E_START_TIME", buf); 173 e_util_env_set("E_START_TIME", buff);
205 174
206 TS("eina init"); 175 TS("Eina Init");
207 eina_init(); 176 if (!eina_init())
177 {
178 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
179 _e_main_shutdown(-1);
180 }
181 TS("Eina Init Done");
208 _e_main_shutdown_push(eina_shutdown); 182 _e_main_shutdown_push(eina_shutdown);
209 183
210 TS("determine prefix"); 184 TS("Determine Prefix");
211 if (!e_prefix_determine(argv[0])) 185 if (!e_prefix_determine(argv[0]))
212 { 186 {
213 fprintf(stderr, 187 fprintf(stderr,
214 "ERROR: Enlightenment cannot determine its installed\n" 188 "ERROR: Enlightenment cannot determine it's installed\n"
215 " prefix from the system or argv[0].\n" 189 " prefix from the system or argv[0].\n"
216 " This is because it is not on Linux AND has been\n" 190 " This is because it is not on Linux AND has been\n"
217 " Executed strangely. This is unusual.\n" 191 " executed strangely. This is unusual.\n");
218 );
219 } 192 }
220 TS("prefix done"); 193 TS("Determine Prefix Done");
221 194
222 /* for debugging by redirecting stdout of e to a log file to tail */ 195 /* for debugging by redirecting stdout of e to a log file to tail */
223 setvbuf(stdout, NULL, _IONBF, 0); 196 setvbuf(stdout, NULL, _IONBF, 0);
224 197
225 if (getenv("E_RESTART")) after_restart = 1; 198 TS("Environment Variables");
226 199 if (getenv("E_RESTART")) after_restart = EINA_TRUE;
227 if (getenv("DESKTOP_STARTUP_ID")) 200 if (getenv("DESKTOP_STARTUP_ID"))
228 e_util_env_set("DESKTOP_STARTUP_ID", NULL); 201 e_util_env_set("DESKTOP_STARTUP_ID", NULL);
229
230 e_util_env_set("E_RESTART_OK", NULL); 202 e_util_env_set("E_RESTART_OK", NULL);
231 e_util_env_set("E_RESTART", "1"); 203 e_util_env_set("E_RESTART", "1");
232
233 /* envrionment varabiles so you know E is running/launched you */
234 e_util_env_set("PANTS", "ON"); 204 e_util_env_set("PANTS", "ON");
235 e_util_env_set("DESKTOP", "Enlightenment-0.17.0"); 205 e_util_env_set("DESKTOP", "Enlightenment-0.17.0");
206 TS("Environment Variables Done");
236 207
237 TS("intl init"); 208 TS("Parse Arguments");
238 e_intl_init(); 209 _e_main_parse_arguments(argc, argv);
239 _e_main_shutdown_push(e_intl_shutdown); 210 TS("Parse Arguments Done");
240 211
241 TS("parse args"); 212 /*** Initialize Core EFL Libraries We Need ***/
242 /* handle some command-line parameters */
243 for (i = 1; i < argc; i++)
244 {
245 if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
246 {
247 i++;
248 e_util_env_set("DISPLAY", argv[i]);
249 }
250 else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
251 {
252 int x, y, w, h;
253 213
254 i++; 214 TS("Eet Init");
255 /* WWxHH+XX+YY */ 215 if (!eet_init())
256 if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4) 216 {
257 e_xinerama_fake_screen_add(x, y, w, h); 217 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
258 } 218 _e_main_shutdown(-1);
259 else if (!strcmp(argv[i], "-good"))
260 {
261 good = 1;
262 evil = 0;
263 printf("LA LA LA\n");
264 }
265 else if (!strcmp(argv[i], "-evil"))
266 {
267 good = 0;
268 evil = 1;
269 printf("MUHAHAHAHHAHAHAHAHA\n");
270 }
271 else if (!strcmp(argv[i], "-psychotic"))
272 {
273 good = 1;
274 evil = 1;
275 printf("MUHAHALALALALALALALA\n");
276 }
277 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
278 {
279 i++;
280 if (!getenv("E_CONF_PROFILE"))
281 e_util_env_set("E_CONF_PROFILE", argv[i]);
282 }
283 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
284 {
285 really_know = 1;
286 }
287 else if (!strcmp(argv[i], "-locked"))
288 {
289 locked = EINA_TRUE;
290 puts("enlightenment will start with desklock on.");
291 }
292 else if ((!strcmp(argv[i], "-h")) ||
293 (!strcmp(argv[i], "-help")) ||
294 (!strcmp(argv[i], "--help")))
295 {
296 printf
297 (_(
298 "Options:\n"
299 "\t-display DISPLAY\n"
300 "\t\tConnect to display named DISPLAY.\n"
301 "\t\tEG: -display :1.0\n"
302 "\t-fake-xinerama-screen WxH+X+Y\n"
303 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
304 "\t\tgiven the geometry. Add as many as you like. They all\n"
305 "\t\treplace the real xinerama screens, if any. This can\n"
306 "\t\tbe used to simulate xinerama.\n"
307 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
308 "\t-profile CONF_PROFILE\n"
309 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
310 "\t-good\n"
311 "\t\tBe good.\n"
312 "\t-evil\n"
313 "\t\tBe evil.\n"
314 "\t-psychotic\n"
315 "\t\tBe psychotic.\n"
316 "\t-locked\n"
317 "\t\tStart with desklock on, so password will be asked.\n"
318 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
319 "\t\tIf you need this help, you don't need this option.\n"
320 )
321 );
322 _e_main_shutdown(-1);
323 }
324 } 219 }
220 TS("Eet Init Done");
221 _e_main_shutdown_push(eet_shutdown);
325 222
326 /* fix up DISPLAY to be :N.0 if no .screen is in it */ 223 TS("Ecore Init");
327 s = getenv("DISPLAY"); 224 if (!ecore_init())
328 if (s)
329 { 225 {
330 char *p; 226 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
331 227 _e_main_shutdown(-1);
332 p = strrchr(s, ':');
333 if (!p)
334 {
335 snprintf(buf, sizeof(buf), "%s:0.0", s);
336 e_util_env_set("DISPLAY", buf);
337 }
338 else
339 {
340 p = strrchr(p, '.');
341 if (!p)
342 {
343 snprintf(buf, sizeof(buf), "%s.0", s);
344 e_util_env_set("DISPLAY", buf);
345 }
346 }
347 } 228 }
229 TS("Ecore Init Done");
230 _e_main_shutdown_push(ecore_shutdown);
348 231
349 TS("arg parse done"); 232 ecore_app_args_set(argc, (const char **)argv);
350 /* fixes for FOOLS that keep cp'ing default.edj into ~/.e/e/themes */ 233
234 TS("Ecore Event Handlers");
235 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
236 _e_main_cb_signal_exit, NULL))
351 { 237 {
352 e_user_dir_concat_static(buf, "themes/default.edj"); 238 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
353 if (ecore_file_exists(buf)) ecore_file_unlink(buf); 239 "Perhaps you are out of memory?"));
240 _e_main_shutdown(-1);
354 } 241 }
355 242 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
356 TS("ecore init"); 243 _e_main_cb_signal_hup, NULL))
357 /* basic ecore init */
358 if (!ecore_init())
359 { 244 {
360 e_error_message_show(_("Enlightenment cannot Initialize Ecore!\n" 245 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
361 "Perhaps you are out of memory?")); 246 "Perhaps you are out of memory?"));
362 _e_main_shutdown(-1); 247 _e_main_shutdown(-1);
248 }
249 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
250 _e_main_cb_signal_user, NULL))
251 {
252 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
253 "Perhaps you are out of memory?"));
254 _e_main_shutdown(-1);
363 } 255 }
256 TS("Ecore Event Handlers Done");
257
364#ifdef HAVE_ECORE_IMF 258#ifdef HAVE_ECORE_IMF
365 ecore_imf_init(); 259 TS("Ecore_IMF Init");
260 if (!ecore_imf_init())
261 {
262 e_error_message_show(_("Enlightenment cannot initialize Ecore_IMF!\n"));
263 _e_main_shutdown(-1);
264 }
265 TS("Ecore_IMF Init Done");
366 _e_main_shutdown_push(ecore_imf_shutdown); 266 _e_main_shutdown_push(ecore_imf_shutdown);
367#endif 267#endif
368// FIXME: SEGV's on shutdown if fm2 windows up - disable for now. => is it history ?
369 _e_main_shutdown_push(ecore_shutdown);
370
371 /* init edje and set it up in frozen mode */
372 edje_init();
373 edje_freeze();
374 _e_main_shutdown_push(edje_shutdown);
375 268
376 _e_cacheburst++; 269 TS("Ecore_File Init");
377/* eet_cacheburst(_e_cacheburst); */ 270 if (!ecore_file_init())
378 ecore_timer_add(5.0, _e_main_cb_eet_cacheburst_end, NULL);
379
380 TS("ecore_file init");
381 /* init the file system */
382 if (!ecore_file_init())
383 { 271 {
384 e_error_message_show(_("Enlightenment cannot initialize the File system.\n" 272 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
385 "Perhaps you are out of memory?")); 273 _e_main_shutdown(-1);
386 _e_main_shutdown(-1);
387 } 274 }
388 _e_main_shutdown_push(ecore_file_shutdown); 275 TS("Ecore_File Init Done");
276 _e_main_shutdown_push(ecore_file_shutdown);
389 277
390 TS("more ecore"); 278 TS("Ecore_Con Init");
391 /* setup my args */ 279 if (!ecore_con_init())
392 ecore_app_args_set(argc, (const char **)argv); 280 {
281 e_error_message_show(_("Enlightenment cannot initialize Ecore_Con!\n"));
282 _e_main_shutdown(-1);
283 }
284 TS("Ecore_Con Init Done");
285 _e_main_shutdown_push(ecore_con_shutdown);
393 286
394 /* setup a handler for when e is asked to exit via a system signal */ 287 TS("Ecore_Ipc Init");
395 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _e_main_cb_signal_exit, NULL)) 288 if (!ecore_ipc_init())
396 { 289 {
397 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n" 290 e_error_message_show(_("Enlightenment cannot initialize Ecore_Ipc!\n"));
398 "Perhaps you are out of memory?")); 291 _e_main_shutdown(-1);
399 _e_main_shutdown(-1);
400 } 292 }
401 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, _e_main_cb_signal_hup, NULL)) 293 TS("Ecore_Ipc Init Done");
294 _e_main_shutdown_push(ecore_ipc_shutdown);
295
296 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
297
298 TS("Ecore_X Init");
299 if (!ecore_x_init(NULL))
402 { 300 {
403 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n" 301 e_error_message_show(_("Enlightenment cannot initialize Ecore_X!\n"));
404 "Perhaps you are out of memory?")); 302 _e_main_shutdown(-1);
405 _e_main_shutdown(-1);
406 } 303 }
407 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, _e_main_cb_signal_user, NULL)) 304 TS("Ecore_X Init Done");
305 _e_main_shutdown_push(_e_main_x_shutdown);
306
307 ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL);
308
309 TS("Ecore_Evas Init");
310 if (!ecore_evas_init())
408 { 311 {
409 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n" 312 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
410 "Perhaps you are out of memory?")); 313 _e_main_shutdown(-1);
411 _e_main_shutdown(-1);
412 } 314 }
315 TS("Ecore_Evas Init Done");
316// _e_main_shutdown_push(ecore_evas_shutdown);
413 317
414 /* an idle enterer to be called before all others */ 318 /* e doesn't sync to compositor - it should be one */
415 _e_main_idle_enterer_before = ecore_idle_enterer_before_add(_e_main_cb_idler_before, NULL); 319 ecore_evas_app_comp_sync_set(0);
416 320
417 TS("x connect"); 321 TS("Ecore_Evas Engine Check");
418 /* init x */ 322 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
419 if (!ecore_x_init(NULL))
420 { 323 {
421 e_error_message_show(_("Enlightenment cannot initialize its X connection.\n" 324 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
422 "Have you set your DISPLAY variable?")); 325 {
423 _e_main_shutdown(-1); 326 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
327 "rendering in Evas. Please check your installation of Evas and\n"
328 "Ecore and check they support the Software X11 rendering engine."));
329 _e_main_shutdown(-1);
330 }
424 } 331 }
425 _e_main_shutdown_push(_e_main_x_shutdown); 332 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
426 /* init white box of death alert */
427 if (!e_alert_init(NULL))
428 { 333 {
429 e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n" 334 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
430 "Have you set your DISPLAY variable?")); 335 "rendering in Evas. Please check your installation of Evas and\n"
336 "Ecore and check they support the Software Buffer rendering engine."));
431 _e_main_shutdown(-1); 337 _e_main_shutdown(-1);
432 } 338 }
433 _e_main_shutdown_push(e_alert_shutdown); 339 TS("Ecore_Evas Engine Check Done");
434 340
435 /* we want to have been launched by enlightenment_start. there is a very */ 341 TS("Efreet Init");
436 /* good reason we want to have been launched this way, thus check */ 342 if (!efreet_init())
437 if (!getenv("E_START"))
438 { 343 {
439 e_alert_show("You are executing enlightenment directly. This is\n" 344 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
440 "bad. Please do not execute the \"enlightenment\"\n" 345 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
441 "binary. Use the \"enlightenment_start\" launcher. It\n" 346 "out of memory or disk space?"));
442 "will handle setting up environment variables, paths,\n" 347 _e_main_shutdown(-1);
443 "and launching any other required services etc.\n"
444 "before enlightenment itself begins running.\n");
445 _e_main_shutdown(-1);
446 } 348 }
349 TS("Efreet Init Done");
350 _e_main_shutdown_push(efreet_shutdown);
447 351
448 TS("ecore_con"); 352 TS("Edje Init");
449 /* init generic communications */ 353 if (!edje_init())
450 if (!ecore_con_init())
451 { 354 {
452 e_error_message_show(_("Enlightenment cannot initialize the connections system.\n" 355 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
453 "Perhaps you are out of memory?")); 356 _e_main_shutdown(-1);
454 _e_main_shutdown(-1);
455 } 357 }
456 _e_main_shutdown_push(ecore_con_shutdown); 358 TS("Edje Init Done");
457 /* init ipc */ 359 _e_main_shutdown_push(edje_shutdown);
458 if (!ecore_ipc_init()) 360 edje_freeze();
361
362 /*** Initialize E Subsystems We Need ***/
363
364 TS("E Intl Init");
365 if (!e_intl_init())
459 { 366 {
460 e_error_message_show(_("Enlightenment cannot initialize the IPC system.\n" 367 e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n"));
461 "Perhaps you are out of memory?")); 368 _e_main_shutdown(-1);
462 _e_main_shutdown(-1);
463 } 369 }
464 _e_main_shutdown_push(ecore_ipc_shutdown); 370 TS("E Intl Init Done");
371 _e_main_shutdown_push(e_intl_shutdown);
465 372
466 TS("xinerama"); 373 /* init white box of death alert */
467 if (!e_xinerama_init()) 374 TS("E_Alert Init");
375 if (!e_alert_init())
468 { 376 {
469 e_error_message_show(_("Enlightenment cannot setup xinerama wrapping.\n" 377 e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
470 "This should not happen.")); 378 "Have you set your DISPLAY variable?"));
471 _e_main_shutdown(-1); 379 _e_main_shutdown(-1);
472 } 380 }
473 _e_main_shutdown_push(e_xinerama_shutdown); 381 TS("E_Alert Init Done");
382 _e_main_shutdown_push(e_alert_shutdown);
474 383
475 TS("randr"); 384 TS("E_Xinerama Init");
476 if (!e_randr_init()) 385 if (!e_xinerama_init())
477 { 386 {
478 e_error_message_show(_("Enlightenment cannot setup randr wrapping.\n" 387 e_error_message_show(_("Enlightenment cannot initialize E_Xinerama!\n"));
479 "This should not happen.")); 388 _e_main_shutdown(-1);
480 } 389 }
481 else 390 TS("E_Xinerama Init Done");
391 _e_main_shutdown_push(e_xinerama_shutdown);
392
393 TS("E_Randr Init");
394 if (!e_randr_init())
482 { 395 {
483 _e_main_shutdown_push(e_randr_shutdown); 396 e_error_message_show(_("Enlightenment cannot initialize E_Randr!\n"));
397 _e_main_shutdown(-1);
484 } 398 }
399 TS("E_Randr Init Done");
400 _e_main_shutdown_push(e_randr_shutdown);
485 401
486/* ecore_x_grab(); */ 402 TS("E_Hints Init");
487
488 ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL);
489
490 TS("x hints");
491 /* Init window manager hints */
492 e_hints_init(); 403 e_hints_init();
493 TS("x hints done"); 404 TS("E_Hints Init Done");
494 405
495 TS("ecore_evas init"); 406 TS("E_Configure Init");
496 /* init the evas wrapper */ 407 e_configure_init();
497 if (!ecore_evas_init()) 408 TS("E_Configure Init Done");
498 {
499 e_error_message_show(_("Enlightenment cannot initialize the Evas system.\n"
500 "Perhaps you are out of memory?"));
501 _e_main_shutdown(-1);
502 }
503 ecore_evas_app_comp_sync_set(0); /* e doesn't sync to compositor - it should be one */
504 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
505 {
506 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
507 "rendering in Evas. Please check your installation of Evas and\n"
508 "Ecore and check they support the Software X11 rendering engine."));
509 _e_main_shutdown(-1);
510 }
511 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
512 {
513 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
514 "rendering in Evas. Please check your installation of Evas and\n"
515 "Ecore and check they support the Software Buffer rendering engine."));
516 _e_main_shutdown(-1);
517 }
518// ecore_evas closes evas - deletes objs - deletes fm widgets which tries to
519// ipc to slave to stop monitoring - but ipc has been shut down. dont shut
520// down.
521// _e_main_shutdown_push(ecore_evas_shutdown);
522 TS("test done");
523
524 /*** Finished loading subsystems, Loading WM Specifics ***/
525 TS("configure");
526 e_configure_init();
527 409
528 TS("dirs"); 410 TS("E Directories Init");
529 /* setup directories we will be using for configurations storage etc. */ 411 /* setup directories we will be using for configurations storage etc. */
530 if (!_e_main_dirs_init()) 412 if (!_e_main_dirs_init())
531 { 413 {
@@ -533,664 +415,539 @@ main(int argc, char **argv)
533 "Perhaps you have no home directory or the disk is full?")); 415 "Perhaps you have no home directory or the disk is full?"));
534 _e_main_shutdown(-1); 416 _e_main_shutdown(-1);
535 } 417 }
418 TS("E Directories Init Done");
536 _e_main_shutdown_push(_e_main_dirs_shutdown); 419 _e_main_shutdown_push(_e_main_dirs_shutdown);
537 420
538 TS("filereg"); 421 TS("E_Filereg Init");
539 /* setup file registry */
540 if (!e_filereg_init()) 422 if (!e_filereg_init())
541 { 423 {
542 e_error_message_show(_("Enlightenment cannot set up its file registry system.")); 424 e_error_message_show(_("Enlightenment cannot set up its file registry system."));
543 _e_main_shutdown(-1); 425 _e_main_shutdown(-1);
544 } 426 }
427 TS("E_Filereg Init Done");
545 _e_main_shutdown_push(e_filereg_shutdown); 428 _e_main_shutdown_push(e_filereg_shutdown);
546 429
547 TS("config"); 430 TS("E_Config Init");
548 /* init config system */
549 if (!e_config_init()) 431 if (!e_config_init())
550 { 432 {
551 e_error_message_show(_("Enlightenment cannot set up its config system.")); 433 e_error_message_show(_("Enlightenment cannot set up its config system."));
552 _e_main_shutdown(-1); 434 _e_main_shutdown(-1);
553 } 435 }
436 TS("E_Config Init Done");
554 _e_main_shutdown_push(e_config_shutdown); 437 _e_main_shutdown_push(e_config_shutdown);
555 438
556 TS("env"); 439 /* fix for FOOLS that keep cp'ing default.edj into ~/.e/e/themes */
557 /* init config system */ 440 e_user_dir_concat_static(buff, "themes/default.edj");
441 if (ecore_file_exists(buff)) ecore_file_unlink(buff);
442
443 TS("E_Env Init");
558 if (!e_env_init()) 444 if (!e_env_init())
559 { 445 {
560 e_error_message_show(_("Enlightenment cannot set up its environment.")); 446 e_error_message_show(_("Enlightenment cannot set up its environment."));
561 _e_main_shutdown(-1); 447 _e_main_shutdown(-1);
562 } 448 }
449 TS("E_Env Init Done");
563 _e_main_shutdown_push(e_env_shutdown); 450 _e_main_shutdown_push(e_env_shutdown);
564 451
565 e_util_env_set("E_ICON_THEME", e_config->icon_theme); 452 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
566
567 locked |= e_config->desklock_start_locked;
568
569 /* set all execced stuff to configured priority */
570 ecore_exe_run_priority_set(e_config->priority); 453 ecore_exe_run_priority_set(e_config->priority);
454 locked |= e_config->desklock_start_locked;
571 455
572 TS("scale"); 456 TS("E_Scale Init");
573 /* init config system */
574 if (!e_scale_init()) 457 if (!e_scale_init())
575 { 458 {
576 e_error_message_show(_("Enlightenment cannot set up its scale system.")); 459 e_error_message_show(_("Enlightenment cannot set up its scale system."));
577 _e_main_shutdown(-1); 460 _e_main_shutdown(-1);
578 } 461 }
462 TS("E_Scale Init Done");
579 _e_main_shutdown_push(e_scale_shutdown); 463 _e_main_shutdown_push(e_scale_shutdown);
580 464
581 TS("pointer"); 465 TS("E_Pointer Init");
582 if (!e_pointer_init()) 466 if (!e_pointer_init())
583 { 467 {
584 e_error_message_show(_("Enlightenment cannot set up the pointer system.")); 468 e_error_message_show(_("Enlightenment cannot set up its pointer system."));
585 _e_main_shutdown(-1); 469 _e_main_shutdown(-1);
586 } 470 }
471 TS("E_Pointer Init Done");
587 _e_main_shutdown_push(e_pointer_shutdown); 472 _e_main_shutdown_push(e_pointer_shutdown);
588 473
589 TS("path"); 474 TS("E Paths Init");
590 /* setup paths for finding things */
591 if (!_e_main_path_init()) 475 if (!_e_main_path_init())
592 { 476 {
593 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n" 477 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
594 "Perhaps you are out of memory?")); 478 "Perhaps you are out of memory?"));
595 _e_main_shutdown(-1); 479 _e_main_shutdown(-1);
596 } 480 }
481 TS("E Paths Init Done");
597 _e_main_shutdown_push(_e_main_path_shutdown); 482 _e_main_shutdown_push(_e_main_path_shutdown);
598 483
599 TS("ipc"); 484 TS("E_Ipc Init");
600 /* setup e ipc service */ 485 if (!e_ipc_init()) _e_main_shutdown(-1);
601 if (e_ipc_init()) 486 TS("E_Ipc Init Done");
602 _e_main_shutdown_push(e_ipc_shutdown); 487 _e_main_shutdown_push(e_ipc_shutdown);
603 488
604 /* setup edje to animate @ e_config->framerate frames per sec. */
605 edje_frametime_set(1.0 / e_config->framerate); 489 edje_frametime_set(1.0 / e_config->framerate);
606 490
607 TS("font"); 491 TS("E_Font Init");
608 /* init font system */ 492 if (!e_font_init())
609 if (!e_font_init())
610 { 493 {
611 e_error_message_show(_("Enlightenment cannot set up its font system.")); 494 e_error_message_show(_("Enlightenment cannot set up its font system."));
612 _e_main_shutdown(-1); 495 _e_main_shutdown(-1);
613 } 496 }
497 TS("E_Font Init Done");
614 _e_main_shutdown_push(e_font_shutdown); 498 _e_main_shutdown_push(e_font_shutdown);
499
500 TS("E_Font Apply");
615 e_font_apply(); 501 e_font_apply();
502 TS("E_Font Apply Done");
503
504 TS("E_Canvas Recache");
616 e_canvas_recache(); 505 e_canvas_recache();
506 TS("E_Canvas Recache Done");
617 507
618 TS("theme"); 508 TS("E_Theme Init");
619 /* init theme system */ 509 if (!e_theme_init())
620 if (!e_theme_init())
621 { 510 {
622 e_error_message_show(_("Enlightenment cannot set up its theme system.")); 511 e_error_message_show(_("Enlightenment cannot set up its theme system."));
623 _e_main_shutdown(-1); 512 _e_main_shutdown(-1);
624 } 513 }
514 TS("E_Theme Init Done");
625 _e_main_shutdown_push(e_theme_shutdown); 515 _e_main_shutdown_push(e_theme_shutdown);
626 516
627 TS("move/resize info"); 517 TS("E_Moveresize Init");
628 /* init move resize popup */
629 e_moveresize_init(); 518 e_moveresize_init();
519 TS("E_Moveresize Init Done");
630 _e_main_shutdown_push(e_moveresize_shutdown); 520 _e_main_shutdown_push(e_moveresize_shutdown);
631 521
632 TS("splash"); 522 if (e_config->show_splash)
633 /* setup init status window/screen */
634 if (!e_init_init())
635 { 523 {
636 e_error_message_show(_("Enlightenment cannot set up init screen.\n" 524 TS("E_Splash Init");
637 "Perhaps you are out of memory?")); 525 if (!e_init_init())
638 _e_main_shutdown(-1); 526 {
527 e_error_message_show(_("Enlightenment cannot set up its init screen."));
528 _e_main_shutdown(-1);
529 }
530 TS("E_Splash Init Done");
531 _e_main_shutdown_push(e_init_shutdown);
639 } 532 }
640 _e_main_shutdown_push(e_init_shutdown); 533 if (!((!e_config->show_splash) || (after_restart)))
641 if (!((!e_config->show_splash) || (after_restart)))
642 { 534 {
643 e_init_title_set(_("Enlightenment")); 535 e_init_title_set(_("Enlightenment"));
644 e_init_version_set(VERSION); 536 e_init_version_set(VERSION);
645 e_init_show(); 537 e_init_show();
646 pause(); 538 pause();
647 } 539 }
648 540
649 e_init_status_set(_("Starting International Support")); 541 if (e_config->show_splash)
650 TS("intl post"); 542 e_init_status_set(_("Starting International Support"));
651 /* init intl system */ 543 TS("E_Intl Post Init");
652 if (!e_intl_post_init()) 544 if (!e_intl_post_init())
653 { 545 {
654 e_error_message_show(_("Enlightenment cannot set up its intl system.")); 546 e_error_message_show(_("Enlightenment cannot set up its intl system."));
655 _e_main_shutdown(-1); 547 _e_main_shutdown(-1);
656 } 548 }
549 TS("E_Intl Post Init Done");
657 _e_main_shutdown_push(e_intl_post_shutdown); 550 _e_main_shutdown_push(e_intl_post_shutdown);
658 551
659 TS("efreet"); 552 if (!really_know)
660 /* init FDO desktop */
661 if (!efreet_init())
662 { 553 {
663 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n" 554 TS("Test File Format Support");
664 "Perhaps you lack permissions on ~/.cache/efreet or are\n" 555 _e_main_test_formats();
665 "out of memory or disk space?")); 556 TS("Test File Format Support Done");
666 _e_main_shutdown(-1);
667 } 557 }
668 _e_main_shutdown_push(efreet_shutdown); 558 else
669 TS("efreet done");
670
671 if (!really_know)
672 { 559 {
673 e_init_status_set(_("Testing Format Support")); 560 efreet_icon_extension_add(".svg");
674 TS("test file format support"); 561 efreet_icon_extension_add(".jpg");
675 { 562 efreet_icon_extension_add(".png");
676 Ecore_Evas *ee; 563 efreet_icon_extension_add(".edj");
677 Evas_Object *im, *txt;
678 char buf[PATH_MAX];
679 Evas_Coord tw, th;
680
681 ee = ecore_evas_buffer_new(1, 1);
682 if (!ee)
683 {
684 e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
685 "Evas has Software Buffer engine support.\n"));
686 _e_main_shutdown(-1);
687 }
688 e_canvas_add(ee);
689 im = evas_object_image_add(ecore_evas_get(ee));
690
691 e_prefix_data_concat_static(buf, "data/images/test.png");
692 evas_object_image_file_set(im, buf, NULL);
693 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
694 {
695 e_error_message_show(_("Enlightenment found Evas can't load PNG files. Check Evas has PNG\n"
696 "loader support.\n"));
697 _e_main_shutdown(-1);
698 }
699
700 e_prefix_data_concat_static(buf, "data/images/test.jpg");
701 evas_object_image_file_set(im, buf, NULL);
702 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
703 {
704 e_error_message_show(_("Enlightenment found Evas can't load JPEG files. Check Evas has JPEG\n"
705 "loader support.\n"));
706 _e_main_shutdown(-1);
707 }
708
709 e_prefix_data_concat_static(buf, "data/images/test.edj");
710 evas_object_image_file_set(im, buf, "images/0");
711 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
712 {
713 e_error_message_show(_("Enlightenment found Evas can't load EET files. Check Evas has EET\n"
714 "loader support.\n"));
715 _e_main_shutdown(-1);
716 }
717 evas_object_del(im);
718 txt = evas_object_text_add(ecore_evas_get(ee));
719 evas_object_text_font_set(txt, "Sans", 10);
720 evas_object_text_text_set(txt, "Hello");
721 evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
722 if ((tw <= 0) && (th <= 0))
723 {
724 e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
725 "support and system fontconfig defines a 'Sans' font.\n"));
726 _e_main_shutdown(-1);
727 }
728 evas_object_del(txt);
729 e_canvas_del(ee);
730 ecore_evas_free(ee);
731 }
732 } 564 }
733 565
734 e_init_status_set(_("Check SVG Support")); 566 if (e_config->show_splash)
735 TS("svg"); 567 e_init_status_set(_("Setup Screens"));
568 TS("Screens Init");
569 if (!_e_main_screens_init())
736 { 570 {
737 Ecore_Evas *ee; 571 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
738 Evas_Object *im; 572 "failed. Perhaps another window manager is running?\n"));
739 char buf[PATH_MAX]; 573 _e_main_shutdown(-1);
574 }
575 TS("Screens Init Done");
576 _e_main_shutdown_push(_e_main_screens_shutdown);
740 577
741 ee = ecore_evas_buffer_new(1, 1); 578 if (e_config->show_splash)
742 if (!ee) 579 e_init_status_set(_("Setup ACPI"));
743 { 580 TS("E_Acpi Init");
744 e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n" 581 e_acpi_init();
745 "Evas has Software Buffer engine support.\n")); 582 TS("E_Acpi Init Done");
746 _e_main_shutdown(-1); 583 _e_main_shutdown_push(e_acpi_shutdown);
747 }
748 e_canvas_add(ee);
749 im = evas_object_image_add(ecore_evas_get(ee));
750 584
751 e_prefix_data_concat_static(buf, "data/images/test.svg"); 585 if (e_config->show_splash)
752 evas_object_image_file_set(im, buf, NULL); 586 e_init_status_set(_("Setup Backlight"));
753 if (evas_object_image_load_error_get(im) == EVAS_LOAD_ERROR_NONE) 587 TS("E_Backlight Init");
754 { 588 if (!e_backlight_init())
755 efreet_icon_extension_add(".svg"); 589 {
756 /* prefer png over svg */ 590 e_error_message_show(_("Enlightenment cannot configure the backlight."));
757 efreet_icon_extension_add(".png"); 591 _e_main_shutdown(-1);
758 }
759 evas_object_del(im);
760 e_canvas_del(ee);
761 ecore_evas_free(ee);
762 } 592 }
593 TS("E_Backlight Init Done");
594 _e_main_shutdown_push(e_backlight_shutdown);
763 595
764 e_init_status_set(_("Setup Screens")); 596 if (e_config->show_splash)
765 TS("screens"); 597 e_init_status_set(_("Setup DPMS"));
766 /* manage the root window */ 598 TS("E_Dpms Init");
767 if (!_e_main_screens_init()) 599 if (!e_dpms_init())
768 { 600 {
769 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n" 601 e_error_message_show(_("Enlightenment cannot configure the DPMS settings."));
770 "failed. Perhaps another window manager is running?\n"));
771 _e_main_shutdown(-1); 602 _e_main_shutdown(-1);
772 } 603 }
773 _e_main_shutdown_push(_e_main_screens_shutdown); 604 TS("E_Dpms Init Done");
605 _e_main_shutdown_push(e_dpms_shutdown);
774 606
775 e_init_status_set(_("Setup Screensaver")); 607 if (e_config->show_splash)
776 TS("screensaver"); 608 e_init_status_set(_("Setup Screensaver"));
777 /* setup screensaver */ 609 TS("E_Screensaver Init");
778 if (!e_screensaver_init()) 610 if (!e_screensaver_init())
779 { 611 {
780 e_error_message_show(_("Enlightenment cannot configure the X screensaver.")); 612 e_error_message_show(_("Enlightenment cannot configure the X screensaver."));
781 _e_main_shutdown(-1); 613 _e_main_shutdown(-1);
782 } 614 }
615 TS("E_Screensaver Init Done");
783 _e_main_shutdown_push(e_screensaver_shutdown); 616 _e_main_shutdown_push(e_screensaver_shutdown);
784 617
785 e_init_status_set(_("Setup Desklock")); 618 if (e_config->show_splash)
786 TS("desklock"); 619 e_init_status_set(_("Setup Powersave Modes"));
787 /* setup desklock */ 620 TS("E_Powersave Init");
788 if (!e_desklock_init()) 621 if (!e_powersave_init())
622 {
623 e_error_message_show(_("Enlightenment cannot set up its powersave modes."));
624 _e_main_shutdown(-1);
625 }
626 TS("E_Powersave Init Done");
627 _e_main_shutdown_push(e_powersave_shutdown);
628
629 if (e_config->show_splash)
630 e_init_status_set(_("Setup Desklock"));
631 TS("E_Desklock Init");
632 if (!e_desklock_init())
789 { 633 {
790 e_error_message_show(_("Enlightenment cannot set up its desk locking system.")); 634 e_error_message_show(_("Enlightenment cannot set up its desk locking system."));
791 _e_main_shutdown(-1); 635 _e_main_shutdown(-1);
792 } 636 }
637 TS("E_Desklock Init Done");
793 _e_main_shutdown_push(e_desklock_shutdown); 638 _e_main_shutdown_push(e_desklock_shutdown);
794 639
795 e_init_status_set(_("Setup Popups")); 640 if (e_config->show_splash)
796 TS("popup"); 641 e_init_status_set(_("Setup Popups"));
797 /* init popup system */ 642 TS("E_Popups Init");
798 if (!e_popup_init()) 643 if (!e_popup_init())
799 { 644 {
800 e_error_message_show(_("Enlightenment cannot set up its popup system.")); 645 e_error_message_show(_("Enlightenment cannot set up its popup system."));
801 _e_main_shutdown(-1); 646 _e_main_shutdown(-1);
802 } 647 }
648 TS("E_Popups Init Done");
803 _e_main_shutdown_push(e_popup_shutdown); 649 _e_main_shutdown_push(e_popup_shutdown);
804 650
805 if ((locked) && ((!e_config->show_splash) && (!after_restart))) 651 if ((locked) && ((!e_config->show_splash) && (!after_restart)))
806 e_desklock_show(); 652 e_desklock_show();
807 653
808 TS("msgbus"); 654 if (e_config->show_splash)
809 /* setup e msgbus (DBUS) service */ 655 e_init_status_set(_("Setup Message Bus"));
810 if (e_msgbus_init()) 656 TS("E_Msgbus Init");
657 if (e_msgbus_init())
811 _e_main_shutdown_push(e_msgbus_shutdown); 658 _e_main_shutdown_push(e_msgbus_shutdown);
659 TS("E_Msgbus Init Done");
812 660
813 e_init_status_set(_("Setup Paths")); 661 if (e_config->show_splash)
814 TS("efreet paths"); 662 e_init_status_set(_("Setup Paths"));
815 { 663 TS("Efreet Paths");
816 Eina_List **list; 664 _e_main_efreet_paths_init();
817 665 TS("Efreet Paths Done");
818 list = efreet_icon_extra_list_get();
819 if (list)
820 {
821 e_user_dir_concat_static(buf, "icons");
822 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
823 e_prefix_data_concat_static(buf, "data/icons");
824 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
825 }
826 }
827 efreet_icon_extension_add(".edj");
828 TS("efreet paths done");
829 666
830 e_init_status_set(_("Setup System Controls")); 667 if (e_config->show_splash)
831 TS("sys init"); 668 e_init_status_set(_("Setup System Controls"));
832 /* init the enlightenment sys command system */ 669 TS("E_Sys Init");
833 if (!e_sys_init()) 670 if (!e_sys_init())
834 { 671 {
835 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n")); 672 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
836 _e_main_shutdown(-1); 673 _e_main_shutdown(-1);
837 } 674 }
675 TS("E_Sys Init Done");
838 _e_main_shutdown_push(e_sys_shutdown); 676 _e_main_shutdown_push(e_sys_shutdown);
839 677
840 e_init_status_set(_("Setup Actions")); 678 if (e_config->show_splash)
841 TS("actions"); 679 e_init_status_set(_("Setup Actions"));
842 /* init actions system */ 680 TS("E_Actions Init");
843 if (!e_actions_init()) 681 if (!e_actions_init())
844 { 682 {
845 e_error_message_show(_("Enlightenment cannot set up its actions system.")); 683 e_error_message_show(_("Enlightenment cannot set up its actions system."));
846 _e_main_shutdown(-1); 684 _e_main_shutdown(-1);
847 } 685 }
686 TS("E_Actions Init Done");
687 _e_main_shutdown_push(e_actions_shutdown);
848 688
849 e_init_status_set(_("Setup Execution System")); 689 if (e_config->show_splash)
850 TS("exec"); 690 e_init_status_set(_("Setup Execution System"));
851 /* init app system */ 691 TS("E_Exec Init");
852 if (!e_exec_init()) 692 if (!e_exec_init())
853 { 693 {
854 e_error_message_show(_("Enlightenment cannot set up its exec system.")); 694 e_error_message_show(_("Enlightenment cannot set up its exec system."));
855 _e_main_shutdown(-1); 695 _e_main_shutdown(-1);
856 } 696 }
697 TS("E_Exec Init Done");
857 _e_main_shutdown_push(e_exec_shutdown); 698 _e_main_shutdown_push(e_exec_shutdown);
858 699
859 TS("container freeze"); 700 TS("E_Container Freeze");
860 e_container_all_freeze(); 701 e_container_all_freeze();
702 TS("E_Container Freeze Done");
861 703
862 e_init_status_set(_("Setup FM")); 704 if (e_config->show_splash)
863 TS("fm2"); 705 e_init_status_set(_("Setup Filemanager"));
864 /* init the enlightenment file manager */ 706 TS("E_Fm2 Init");
865 if (!e_fm2_init()) 707 if (!e_fm2_init())
866 { 708 {
867 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n")); 709 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
868 _e_main_shutdown(-1); 710 _e_main_shutdown(-1);
869 } 711 }
712 TS("E_Fm2 Init Done");
870 _e_main_shutdown_push(e_fm2_shutdown); 713 _e_main_shutdown_push(e_fm2_shutdown);
871 714
872 /* 715 if (e_config->show_splash)
873 TS("fwin"); 716 e_init_status_set(_("Setup Message System"));
874 if (!e_fwin_init()) 717 TS("E_Msg Init");
875 { 718 if (!e_msg_init())
876 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
877 _e_main_shutdown(-1);
878 }
879 _e_main_shutdown_push(e_fwin_shutdown);
880 */
881
882 e_init_status_set(_("Setup Message System"));
883 TS("msg");
884 /* setup generic msg handling etc */
885 if (!e_msg_init())
886 { 719 {
887 e_error_message_show(_("Enlightenment cannot set up its msg system.")); 720 e_error_message_show(_("Enlightenment cannot set up its msg system."));
888 _e_main_shutdown(-1); 721 _e_main_shutdown(-1);
889 } 722 }
723 TS("E_Msg Init Done");
890 _e_main_shutdown_push(e_msg_shutdown); 724 _e_main_shutdown_push(e_msg_shutdown);
891 725
892 e_init_status_set(_("Setup DND")); 726 if (e_config->show_splash)
893 TS("dnd"); 727 e_init_status_set(_("Setup DND"));
894 /* setup dnd */ 728 TS("E_Dnd Init");
895 if (!e_dnd_init()) 729 if (!e_dnd_init())
896 { 730 {
897 e_error_message_show(_("Enlightenment cannot set up its dnd system.")); 731 e_error_message_show(_("Enlightenment cannot set up its dnd system."));
898 _e_main_shutdown(-1); 732 _e_main_shutdown(-1);
899 } 733 }
734 TS("E_Dnd Init Done");
900 _e_main_shutdown_push(e_dnd_shutdown); 735 _e_main_shutdown_push(e_dnd_shutdown);
901 736
902 e_init_status_set(_("Setup Grab Input Handling")); 737 if (e_config->show_splash)
903 TS("grabinput"); 738 e_init_status_set(_("Setup Grab Input Handling"));
904 /* setup input grabbing co-operation system */ 739 TS("E_Grabinput Init");
905 if (!e_grabinput_init()) 740 if (!e_grabinput_init())
906 { 741 {
907 e_error_message_show(_("Enlightenment cannot set up its input grab handling system.")); 742 e_error_message_show(_("Enlightenment cannot set up its grab input handling system."));
908 _e_main_shutdown(-1); 743 _e_main_shutdown(-1);
909 } 744 }
745 TS("E_Grabinput Init Done");
910 _e_main_shutdown_push(e_grabinput_shutdown); 746 _e_main_shutdown_push(e_grabinput_shutdown);
911 747
912 e_init_status_set(_("Setup Modules")); 748 if (e_config->show_splash)
913 TS("modules"); 749 e_init_status_set(_("Setup Modules"));
914 /* setup module loading etc */ 750 TS("E_Module Init");
915 if (!e_module_init()) 751 if (!e_module_init())
916 { 752 {
917 e_error_message_show(_("Enlightenment cannot set up its module system.")); 753 e_error_message_show(_("Enlightenment cannot set up its module system."));
918 _e_main_shutdown(-1); 754 _e_main_shutdown(-1);
919 } 755 }
756 TS("E_Module Init Done");
920 _e_main_shutdown_push(e_module_shutdown); 757 _e_main_shutdown_push(e_module_shutdown);
921 758
922 e_init_status_set(_("Setup Remembers")); 759 if (e_config->show_splash)
923 TS("remember"); 760 e_init_status_set(_("Setup Remembers"));
924 /* do remember stuff */ 761 TS("E_Remember Init");
925 if (!e_remember_init(after_restart ? E_STARTUP_RESTART: E_STARTUP_START)) 762 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
926 { 763 {
927 e_error_message_show(_("Enlightenment cannot setup remember settings.")); 764 e_error_message_show(_("Enlightenment cannot setup remember settings."));
928 _e_main_shutdown(-1); 765 _e_main_shutdown(-1);
929 } 766 }
767 TS("E_Remember Init Done");
930 _e_main_shutdown_push(e_remember_shutdown); 768 _e_main_shutdown_push(e_remember_shutdown);
931 769
932 e_init_status_set(_("Setup Color Classes")); 770 if (e_config->show_splash)
933 TS("colorclasses"); 771 e_init_status_set(_("Setup Color Classes"));
934 /* setup color_class */ 772 TS("E_Color_Class Init");
935 if (!e_color_class_init()) 773 if (!e_color_class_init())
936 { 774 {
937 e_error_message_show(_("Enlightenment cannot set up its color class system.")); 775 e_error_message_show(_("Enlightenment cannot set up its color class system."));
938 _e_main_shutdown(-1); 776 _e_main_shutdown(-1);
939 } 777 }
778 TS("E_Color_Class Init Done");
940 _e_main_shutdown_push(e_color_class_shutdown); 779 _e_main_shutdown_push(e_color_class_shutdown);
941 780
942 e_init_status_set(_("Setup Gadcon")); 781 if (e_config->show_splash)
943 TS("gadcon"); 782 e_init_status_set(_("Setup Gadcon"));
944 /* setup gadcon */ 783 TS("E_Gadcon Init");
945 if (!e_gadcon_init()) 784 if (!e_gadcon_init())
946 { 785 {
947 e_error_message_show(_("Enlightenment cannot set up its gadget control system.")); 786 e_error_message_show(_("Enlightenment cannot set up its gadget control system."));
948 _e_main_shutdown(-1); 787 _e_main_shutdown(-1);
949 } 788 }
789 TS("E_Gadcon Init Done");
950 _e_main_shutdown_push(e_gadcon_shutdown); 790 _e_main_shutdown_push(e_gadcon_shutdown);
951 791
952 e_init_status_set(_("Setup ACPI")); 792 if (e_config->show_splash)
953 TS("acpi"); 793 e_init_status_set(_("Setup Wallpaper"));
954 /* acpi init will never fail. It always returns one even if acpid 794 TS("E_Bg Init");
955 * is not running, so no need to trap the return */ 795 if (!e_bg_init())
956 e_acpi_init();
957 _e_main_shutdown_push(e_acpi_shutdown);
958
959 e_init_status_set(_("Setup Backlight"));
960 TS("backlight");
961 /* setup dpms */
962 if (!e_backlight_init())
963 {
964 e_error_message_show(_("Enlightenment cannot configure the backlight."));
965 _e_main_shutdown(-1);
966 }
967 _e_main_shutdown_push(e_backlight_shutdown);
968
969 e_init_status_set(_("Setup DPMS"));
970 TS("dpms");
971 /* setup dpms */
972 if (!e_dpms_init())
973 {
974 e_error_message_show(_("Enlightenment cannot configure the DPMS settings."));
975 _e_main_shutdown(-1);
976 }
977 _e_main_shutdown_push(e_dpms_shutdown);
978
979 e_init_status_set(_("Setup Powersave modes"));
980 TS("powersave");
981 if (!e_powersave_init())
982 {
983 e_error_message_show(_("Enlightenment cannot set up its powersave modes."));
984 _e_main_shutdown(-1);
985 }
986 _e_main_shutdown_push(e_powersave_shutdown);
987
988 e_init_status_set(_("Setup Wallpaper"));
989 TS("bg");
990 /* init desktop background system */
991 if (!e_bg_init())
992 { 796 {
993 e_error_message_show(_("Enlightenment cannot set up its desktop background system.")); 797 e_error_message_show(_("Enlightenment cannot set up its desktop background system."));
994 _e_main_shutdown(-1); 798 _e_main_shutdown(-1);
995 } 799 }
800 TS("E_Bg Init Done");
996 _e_main_shutdown_push(e_bg_shutdown); 801 _e_main_shutdown_push(e_bg_shutdown);
997 802
998 e_init_status_set(_("Setup Mouse")); 803 if (e_config->show_splash)
999 TS("mouse"); 804 e_init_status_set(_("Setup Mouse"));
1000 /* setup mouse accel */ 805 TS("E_Mouse Init");
1001 if (!e_mouse_update()) 806 if (!e_mouse_update())
1002 { 807 {
1003 e_error_message_show(_("Enlightenment cannot configure the mouse settings.")); 808 e_error_message_show(_("Enlightenment cannot configure the mouse settings."));
1004 _e_main_shutdown(-1); 809 _e_main_shutdown(-1);
1005 } 810 }
1006 _e_main_shutdown_push(e_actions_shutdown); 811 TS("E_Mouse Init Done");
1007 812
1008 e_init_status_set(_("Setup Bindings")); 813 if (e_config->show_splash)
1009 TS("bindings"); 814 e_init_status_set(_("Setup Bindings"));
1010 /* init bindings system */ 815 TS("E_Bindings Init");
1011 if (!e_bindings_init()) 816 if (!e_bindings_init())
1012 { 817 {
1013 e_error_message_show(_("Enlightenment cannot set up its bindings system.")); 818 e_error_message_show(_("Enlightenment cannot set up its bindings system."));
1014 _e_main_shutdown(-1); 819 _e_main_shutdown(-1);
1015 } 820 }
821 TS("E_Bindings Init Done");
1016 _e_main_shutdown_push(e_bindings_shutdown); 822 _e_main_shutdown_push(e_bindings_shutdown);
1017 823
1018 e_init_status_set(_("Setup Shelves")); 824 if (e_config->show_splash)
1019 TS("shelves"); 825 e_init_status_set(_("Setup Shelves"));
1020 /* setup shelves */ 826 TS("E_Shelf Init");
1021 if (!e_shelf_init()) 827 if (!e_shelf_init())
1022 { 828 {
1023 e_error_message_show(_("Enlightenment cannot set up its shelf system.")); 829 e_error_message_show(_("Enlightenment cannot set up its module system."));
1024 _e_main_shutdown(-1); 830 _e_main_shutdown(-1);
1025 } 831 }
832 TS("E_Shelf Init Done");
1026 _e_main_shutdown_push(e_shelf_shutdown); 833 _e_main_shutdown_push(e_shelf_shutdown);
1027 834
1028 e_init_status_set(_("Setup Thumbnailer")); 835 if (e_config->show_splash)
1029 TS("thumb init"); 836 e_init_status_set(_("Setup Thumbnailer"));
1030 /* init the enlightenment thumbnailing system */ 837 TS("E_Thumb Init");
1031 if (!e_thumb_init()) 838 if (!e_thumb_init())
1032 { 839 {
1033 e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n")); 840 e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
1034 _e_main_shutdown(-1); 841 _e_main_shutdown(-1);
1035 } 842 }
843 TS("E_Thumb Init Done");
1036 _e_main_shutdown_push(e_thumb_shutdown); 844 _e_main_shutdown_push(e_thumb_shutdown);
1037 845
1038 if (!after_restart) 846 if (!after_restart)
1039 { 847 {
1040 TS("deskenv"); 848 if (e_config->show_splash)
1041 /* init deskenv system */ 849 e_init_status_set(_("Setup Desktop Environment"));
1042 if (!e_deskenv_init()) 850 TS("E_Deskenv Init");
851 if (!e_deskenv_init())
1043 { 852 {
1044 e_error_message_show(_("Enlightenment cannot set up its desktop environment system.")); 853 e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n"));
1045 _e_main_shutdown(-1); 854 _e_main_shutdown(-1);
1046 } 855 }
856 TS("E_Deskenv Init Done");
1047 _e_main_shutdown_push(e_deskenv_shutdown); 857 _e_main_shutdown_push(e_deskenv_shutdown);
1048 } 858 }
1049 859
1050 e_init_status_set(_("Setup File Ordering")); 860 if (e_config->show_splash)
1051 TS("order"); 861 e_init_status_set(_("Setup File Ordering"));
1052 if (!e_order_init()) 862 TS("E_Order Init");
863 if (!e_order_init())
1053 { 864 {
1054 e_error_message_show(_("Enlightenment cannot set up its order file system.")); 865 e_error_message_show(_("Enlightenment cannot set up its order file system."));
1055 _e_main_shutdown(-1); 866 _e_main_shutdown(-1);
1056 } 867 }
868 TS("E_Order Init Done");
1057 _e_main_shutdown_push(e_order_shutdown); 869 _e_main_shutdown_push(e_order_shutdown);
1058 870
1059 TS("add idle enterers"); 871 TS("Add Idler For X Flush");
1060 /* 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() */ 872 _idle_flush = ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL);
1061 _e_main_idle_enterer_flusher = 873 TS("Add Idler For X Flush Done");
1062 ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL);
1063 874
875 TS("E_Manager Keys Grab");
1064 e_managers_keys_grab(); 876 e_managers_keys_grab();
877 TS("E_Manager Keys Grab Done");
1065 878
1066 /* ecore_x_ungrab(); */ 879 if (e_config->show_splash)
880 e_init_status_set(_("Load Modules"));
881 TS("Load Modules");
882 _e_main_modules_load(safe_mode);
883 TS("Load Modules Done");
1067 884
1068 /* load modules */ 885 TS("Run Startup Apps");
1069 e_init_status_set(_("Load Modules")); 886 if (!nostartup)
1070 TS("load modules");
1071 if (safe_mode)
1072 { 887 {
1073 E_Module *m; 888 if (after_restart)
1074 char *crashmodule; 889 e_startup(E_STARTUP_RESTART);
1075 890 else
1076 crashmodule = getenv("E_MODULE_LOAD"); 891 e_startup(E_STARTUP_START);
1077 if (crashmodule) m = e_module_new(crashmodule);
1078
1079 if ((crashmodule) && (m))
1080 {
1081 e_module_disable(m);
1082 e_object_del(E_OBJECT(m));
1083
1084 e_int_config_modules(e_container_current_get(e_manager_current_get()), NULL);
1085 e_error_message_show
1086 (_("Enlightenment crashed early on start and has<br>"
1087 "been restarted. There was an error loading<br>"
1088 "module named: %s. This module has been disabled<br>"
1089 "and will not be loaded."), crashmodule);
1090 e_util_dialog_show
1091 (_("Enlightenment crashed early on start and has been restarted"),
1092 _("Enlightenment crashed early on start and has been restarted.<br>"
1093 "There was an error loading module named: %s<br><br>"
1094 "This module has been disabled and will not be loaded."), crashmodule);
1095 e_module_all_load();
1096 }
1097 else
1098 {
1099 e_int_config_modules(e_container_current_get(e_manager_current_get()), NULL);
1100 e_error_message_show
1101 (_("Enlightenment crashed early on start and has<br>"
1102 "been restarted. All modules have been disabled<br>"
1103 "and will not be loaded to help remove any problem<br>"
1104 "modules from your configuration. The module<br>"
1105 "configuration dialog should let you select your<br>"
1106 "modules again."));
1107 e_util_dialog_show
1108 (_("Enlightenment crashed early on start and has been restarted"),
1109 _("Enlightenment crashed early on start and has been restarted.<br>"
1110 "All modules have been disabled and will not be loaded to help<br>"
1111 "remove any problem modules from your configuration.<br><br>"
1112 "The module configuration dialog should let you select your<br>"
1113 "modules again."));
1114 }
1115 }
1116 else
1117 e_module_all_load();
1118
1119 TS("init properites");
1120 if (!nostartup)
1121 {
1122 if (after_restart) e_startup(E_STARTUP_RESTART);
1123 else e_startup(E_STARTUP_START);
1124 } 892 }
893 TS("Run Startup Apps Done");
1125 894
1126 if (!((!e_config->show_splash) || (after_restart))) 895 if (!((!e_config->show_splash) || (after_restart)))
1127 { 896 {
1128 ecore_timer_add(16.0, _e_main_cb_startup_fake_end, NULL); 897 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1129 if (locked) e_desklock_show(); 898 if (locked) e_desklock_show();
1130 } 899 }
1131 900
901 TS("E_Container Thaw");
1132 e_container_all_thaw(); 902 e_container_all_thaw();
903 TS("E_Container Thaw Done");
1133 904
1134 TS("test code"); 905 TS("E_Test Init");
1135 /* run any testing code now we are set up */
1136 e_test(); 906 e_test();
907 TS("E_Test Done");
1137 908
1138 e_init_status_set(_("Configure Shelves")); 909 if (e_config->show_splash)
1139 TS("shelf config update"); 910 e_init_status_set(_("Configure Shelves"));
911 TS("E_Shelf Config Update");
1140 e_shelf_config_update(); 912 e_shelf_config_update();
913 TS("E_Shelf Config Update Done");
1141 914
1142 TS("manage all windows"); 915 TS("Manage all windows");
1143 _e_main_manage_all(); 916 _e_main_manage_all();
1144 917
1145 /* an idle enterer to be called after all others */ 918 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
1146 _e_main_idle_enterer_after =
1147 ecore_idle_enterer_add(_e_main_cb_idler_after, NULL);
1148 919
1149 e_init_status_set(_("Almost Done")); 920 if (e_config->show_splash)
1150 TS("MAIN LOOP AT LAST"); 921 e_init_status_set(_("Almost Done"));
1151 /* no longer starting up */
1152 starting = 0;
1153 /* start our main loop */
1154
1155#ifdef DBG_EINA_STRINGSHARE
1156 // enable to debug eina stringshare usage
1157 ecore_timer_add(5.0, stdbg, NULL);
1158#endif
1159 922
923 starting = EINA_FALSE;
1160 inloop = EINA_TRUE; 924 inloop = EINA_TRUE;
1161 if (!setjmp(x_fatal_buf)) 925
1162 ecore_main_loop_begin(); 926 TS("MAIN LOOP AT LAST");
927 if (!setjmp(x_fatal_buff))
928 ecore_main_loop_begin();
1163 else 929 else
1164 printf("FATAL: X died. Connection gone. abbreviated shutdown\n"); 930 printf("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
931
1165 inloop = EINA_FALSE; 932 inloop = EINA_FALSE;
1166 933 stopping = EINA_TRUE;
1167 stopping = 1;
1168 934
1169 if (!x_fatal) e_canvas_idle_flush(); 935 if (!x_fatal) e_canvas_idle_flush();
1170 936
1171 /* ask all modules to save their config and then shutdown */
1172 /* NB: no need to do this as config shutdown will flush any saves */
1173 /* and all changed config was already saved before */
1174 e_config_save_flush(); 937 e_config_save_flush();
1175
1176 /* Store current selected desktops */
1177 _e_main_desk_save(); 938 _e_main_desk_save();
1178
1179 e_remember_internal_save(); 939 e_remember_internal_save();
1180 940
1181 /* unroll our stack of shutdown functions with exit code of 0 */
1182 _e_main_shutdown(0); 941 _e_main_shutdown(0);
1183 942
1184 /* if we were flagged to restart, then restart. */ 943 if (restart)
1185 if (restart)
1186 { 944 {
1187 e_util_env_set("E_RESTART_OK", "1"); 945 e_util_env_set("E_RESTART_OK", "1");
1188 ecore_app_restart(); 946 ecore_app_restart();
1189 } 947 }
1190 948
1191 e_prefix_shutdown(); 949 e_prefix_shutdown();
1192 950
1193 /* just return 0 to keep the compiler quiet */
1194 return 0; 951 return 0;
1195} 952}
1196 953
@@ -1204,7 +961,7 @@ e_main_idler_before_add(int (*func) (void *data), void *data, int once)
1204 eb->func = func; 961 eb->func = func;
1205 eb->data = data; 962 eb->data = data;
1206 eb->once = once; 963 eb->once = once;
1207 _e_main_idler_before_list = eina_list_append(_e_main_idler_before_list, eb); 964 _idle_before_list = eina_list_append(_idle_before_list, eb);
1208 return eb; 965 return eb;
1209} 966}
1210 967
@@ -1214,206 +971,259 @@ e_main_idler_before_del(E_Before_Idler *eb)
1214 eb->delete_me = 1; 971 eb->delete_me = 1;
1215} 972}
1216 973
1217/* local subsystem functions */ 974/* local functions */
1218static void 975static void
1219_e_main_shutdown_push(int (*func) (void)) 976_e_main_shutdown(int errcode)
977{
978 int i = 0;
979
980 printf("E17: Begin Shutdown Procedure!\n");
981
982 if (_idle_before) ecore_idle_enterer_del(_idle_before);
983 _idle_before = NULL;
984 if (_idle_after) ecore_idle_enterer_del(_idle_after);
985 _idle_after = NULL;
986 if (_idle_flush) ecore_idle_enterer_del(_idle_flush);
987 _idle_flush = NULL;
988
989 for (i = (_e_main_lvl - 1); i >= 0; i--)
990 (*_e_main_shutdown_func[i])();
991 if (errcode < 0) exit(errcode);
992}
993
994static void
995_e_main_shutdown_push(int (*func)(void))
1220{ 996{
1221 _e_main_level++; 997 _e_main_lvl++;
1222 if (_e_main_level > MAX_LEVEL) 998 if (_e_main_lvl > MAX_LEVEL)
1223 { 999 {
1224 _e_main_level--; 1000 _e_main_lvl--;
1225 e_error_message_show("WARNING: too many init levels. MAX = %i", MAX_LEVEL); 1001 e_error_message_show("WARNING: too many init levels. MAX = %i",
1226 return; 1002 MAX_LEVEL);
1003 return;
1227 } 1004 }
1228 _e_main_shutdown_func[_e_main_level - 1] = func; 1005 _e_main_shutdown_func[_e_main_lvl - 1] = func;
1229} 1006}
1230 1007
1231static void 1008static void
1232_e_main_shutdown(int errorcode) 1009_e_main_parse_arguments(int argc, char **argv)
1233{ 1010{
1234 int i; 1011 char *s = NULL;
1012 int i = 0;
1235 1013
1236 printf("E17: Begin shutdown procedure!\n"); 1014 /* handle some command-line parameters */
1237 if (_e_main_idle_enterer_before) 1015 for (i = 1; i < argc; i++)
1238 { 1016 {
1239 ecore_idle_enterer_del(_e_main_idle_enterer_before); 1017 if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
1240 _e_main_idle_enterer_before = NULL; 1018 {
1019 i++;
1020 e_util_env_set("DISPLAY", argv[i]);
1021 }
1022 else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
1023 {
1024 int x, y, w, h;
1025
1026 i++;
1027 if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
1028 e_xinerama_fake_screen_add(x, y, w, h);
1029 }
1030 else if (!strcmp(argv[i], "-good"))
1031 {
1032 good = EINA_TRUE;
1033 evil = EINA_FALSE;
1034 printf("LA LA LA\n");
1035 }
1036 else if (!strcmp(argv[i], "-evil"))
1037 {
1038 good = EINA_FALSE;
1039 evil = EINA_TRUE;
1040 printf("MUHAHAHAHHAHAHAHAHA\n");
1041 }
1042 else if (!strcmp(argv[i], "-psychotic"))
1043 {
1044 good = EINA_TRUE;
1045 evil = EINA_TRUE;
1046 printf("MUHAHALALALALALALALA\n");
1047 }
1048 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
1049 {
1050 i++;
1051 if (!getenv("E_CONF_PROFILE"))
1052 e_util_env_set("E_CONF_PROFILE", argv[i]);
1053 }
1054 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
1055 really_know = EINA_TRUE;
1056 else if (!strcmp(argv[i], "-locked"))
1057 locked = EINA_TRUE;
1058 else if ((!strcmp(argv[i], "-h")) ||
1059 (!strcmp(argv[i], "-help")) ||
1060 (!strcmp(argv[i], "--help")))
1061 {
1062 printf
1063 (_(
1064 "Options:\n"
1065 "\t-display DISPLAY\n"
1066 "\t\tConnect to display named DISPLAY.\n"
1067 "\t\tEG: -display :1.0\n"
1068 "\t-fake-xinerama-screen WxH+X+Y\n"
1069 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
1070 "\t\tgiven the geometry. Add as many as you like. They all\n"
1071 "\t\treplace the real xinerama screens, if any. This can\n"
1072 "\t\tbe used to simulate xinerama.\n"
1073 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
1074 "\t-profile CONF_PROFILE\n"
1075 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
1076 "\t-good\n"
1077 "\t\tBe good.\n"
1078 "\t-evil\n"
1079 "\t\tBe evil.\n"
1080 "\t-psychotic\n"
1081 "\t\tBe psychotic.\n"
1082 "\t-locked\n"
1083 "\t\tStart with desklock on, so password will be asked.\n"
1084 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
1085 "\t\tIf you need this help, you don't need this option.\n"
1086 )
1087 );
1088 _e_main_shutdown(-1);
1089 }
1241 } 1090 }
1242 if (_e_main_idle_enterer_after) 1091
1092 /* fix up DISPLAY to be :N.0 if no .screen is in it */
1093 s = getenv("DISPLAY");
1094 if (s)
1095 {
1096 char *p, buff[PATH_MAX];
1097
1098 if (!(p = strrchr(s, ':')))
1099 {
1100 snprintf(buff, sizeof(buff), "%s:0.0", s);
1101 e_util_env_set("DISPLAY", buff);
1102 }
1103 else
1104 {
1105 if (!(p = strrchr(p, '.')))
1106 {
1107 snprintf(buff, sizeof(buff), "%s.0", s);
1108 e_util_env_set("DISPLAY", buff);
1109 }
1110 }
1111 }
1112
1113 /* we want to have been launched by enlightenment_start. there is a very */
1114 /* good reason we want to have been launched this way, thus check */
1115 if (!getenv("E_START"))
1243 { 1116 {
1244 ecore_idle_enterer_del(_e_main_idle_enterer_after); 1117 e_error_message_show(_("You are executing enlightenment directly. This is\n"
1245 _e_main_idle_enterer_after = NULL; 1118 "bad. Please do not execute the \"enlightenment\"\n"
1119 "binary. Use the \"enlightenment_start\" launcher. It\n"
1120 "will handle setting up environment variables, paths,\n"
1121 "and launching any other required services etc.\n"
1122 "before enlightenment itself begins running.\n"));
1123 _e_main_shutdown(-1);
1246 } 1124 }
1247 if (_e_main_idle_enterer_flusher) 1125}
1126
1127static void
1128_e_main_cb_x_fatal(void *data __UNUSED__)
1129{
1130 e_error_message_show("Lost X Connection.");
1131 ecore_main_loop_quit();
1132 if (!x_fatal)
1248 { 1133 {
1249 ecore_idle_enterer_del(_e_main_idle_enterer_flusher); 1134 x_fatal = EINA_TRUE;
1250 _e_main_idle_enterer_flusher = NULL; 1135 if (inloop) longjmp(x_fatal_buff, -99);
1251 } 1136 }
1252 for (i = _e_main_level - 1; i >= 0; i--)
1253 (*_e_main_shutdown_func[i])();
1254 if (errorcode < 0) exit(errorcode);
1255} 1137}
1256 1138
1257static int 1139static Eina_Bool
1140_e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1141{
1142 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
1143 e_sys_action_do(E_SYS_EXIT, NULL);
1144 return ECORE_CALLBACK_RENEW;
1145}
1146
1147static Eina_Bool
1148_e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1149{
1150 e_sys_action_do(E_SYS_RESTART, NULL);
1151 return ECORE_CALLBACK_RENEW;
1152}
1153
1154static Eina_Bool
1155_e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1156{
1157 Ecore_Event_Signal_User *e = ev;
1158
1159 if (e->number == 1)
1160 {
1161 E_Action *a = e_action_find("configuration");
1162 if ((a) && (a->func.go)) a->func.go(NULL, NULL);
1163 }
1164 else if (e->number == 2)
1165 {
1166 // comp module has its own handler for this for enabling/disabling fps debug
1167 }
1168 return ECORE_CALLBACK_RENEW;
1169}
1170
1171static int
1258_e_main_x_shutdown(void) 1172_e_main_x_shutdown(void)
1259{ 1173{
1260 if (x_fatal) return 1; 1174 if (x_fatal) return 1;
1261/* ecore_x_ungrab(); */ 1175 /* ecore_x_ungrab(); */
1262 ecore_x_focus_reset(); 1176 ecore_x_focus_reset();
1263 ecore_x_events_allow_all(); 1177 ecore_x_events_allow_all();
1264 ecore_x_shutdown(); 1178 ecore_x_shutdown();
1265 return 1; 1179 return 1;
1266} 1180}
1267 1181
1268static int 1182static int
1269_e_main_dirs_init(void) 1183_e_main_dirs_init(void)
1270{ 1184{
1271 const char *base; 1185 const char *base;
1272 const char *dirs[] = { 1186 const char *dirs[] =
1273 "images", 1187 {
1274 "fonts", 1188 "images",
1275 "themes", 1189 "fonts",
1276 "icons", 1190 "themes",
1277 "backgrounds", 1191 "icons",
1278 "applications", 1192 "backgrounds",
1279 "applications/menu", 1193 "applications",
1280 "applications/menu/favorite", 1194 "applications/menu",
1281 "applications/menu/all", 1195 "applications/menu/favorite",
1282 "applications/bar", 1196 "applications/menu/all",
1283 "applications/bar/default", 1197 "applications/bar",
1284 "applications/startup", 1198 "applications/bar/default",
1285 "applications/restart", 1199 "applications/startup",
1286 "applications/trash", 1200 "applications/restart",
1287 "modules", 1201 "applications/trash",
1288 "config", 1202 "modules",
1289 "locale", 1203 "config",
1290 "input_methods", 1204 "locale",
1291 NULL 1205 "input_methods",
1292 }; 1206 NULL
1207 };
1293 1208
1294 base = e_user_dir_get(); 1209 base = e_user_dir_get();
1295 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs)/sizeof(dirs[0]) - 1) 1210 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs)/sizeof(dirs[0]) - 1)
1296 { 1211 {
1297 e_error_message_show 1212 e_error_message_show("Could not create one of the required "
1298 ("Could not create one of the required subdirectories of '%s'", base); 1213 "subdirectories of '%s'", base);
1299 return 0; 1214 return 0;
1300 } 1215 }
1301 1216
1302 return 1; 1217 return 1;
1303} 1218}
1304 1219
1305static int 1220static int
1306_e_main_dirs_shutdown(void) 1221_e_main_dirs_shutdown(void)
1307{ 1222{
1308 return 1; 1223 return 1;
1309} 1224}
1310 1225
1311static int 1226static int
1312_e_main_screens_init(void)
1313{
1314 Ecore_X_Window *roots;
1315 int num, i;
1316
1317 TS("screens: atoms");
1318 if (!e_atoms_init()) return 0;
1319 TS("screens: manager");
1320 if (!e_manager_init()) return 0;
1321 TS("screens: container");
1322 if (!e_container_init()) return 0;
1323 TS("screens: zone");
1324 if (!e_zone_init()) return 0;
1325 TS("screens: desk");
1326 if (!e_desk_init()) return 0;
1327 TS("screens: menu");
1328 if (!e_menu_init()) return 0;
1329 TS("screens: exehist");
1330 if (!e_exehist_init()) return 0;
1331
1332 TS("screens: get roots");
1333 num = 0;
1334 roots = ecore_x_window_root_list(&num);
1335 if ((!roots) || (num <= 0))
1336 {
1337 e_error_message_show("X reports there are no root windows and %i screens!\n",
1338 num);
1339 return 0;
1340 }
1341 TS("screens: focus");
1342 if (!e_focus_init()) return 0;
1343 TS("screens: border");
1344 if (!e_border_init()) return 0;
1345 TS("screens: win");
1346 if (!e_win_init()) return 0;
1347 TS("screens: manage roots");
1348 for (i = 0; i < num; i++)
1349 {
1350 E_Manager *man;
1351 E_Container *con;
1352
1353 man = e_manager_new(roots[i], i);
1354 if (man)
1355 e_manager_show(man);
1356 else
1357 {
1358 e_error_message_show("Cannot create manager object for screen %i\n",
1359 i);
1360 free(roots);
1361 return 0;
1362 }
1363 con = e_container_new(man);
1364 if (con)
1365 {
1366 e_container_show(con);
1367 e_grabinput_focus(con->bg_win, E_FOCUS_METHOD_PASSIVE);
1368 e_hints_manager_init(man);
1369 _e_main_desk_restore(man, con);
1370// e_manager_manage_windows(man);
1371 }
1372 else
1373 {
1374 e_error_message_show("Cannot create desktop object for manager on screen %i\n",
1375 i);
1376 free(roots);
1377 return 0;
1378 }
1379 }
1380 TS("screens: sync");
1381
1382 free(roots);
1383 ecore_x_sync();
1384 return 1;
1385}
1386
1387static int
1388_e_main_screens_shutdown(void)
1389{
1390 e_win_shutdown();
1391 e_border_shutdown();
1392 e_focus_shutdown();