1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
|
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#define _GNU_SOURCE
#include "e.h"
#ifdef HAVE_ECORE_IMF
#include <Ecore_IMF.h>
#endif
#include <fcntl.h>
/*
* i need to make more use of these when i'm baffled as to when something is
* up. other hooks:
*
* void *(*__malloc_hook)(size_t size, const void *caller);
*
* void *(*__realloc_hook)(void *ptr, size_t size, const void *caller);
*
* void *(*__memalign_hook)(size_t alignment, size_t size,
* const void *caller);
*
* void (*__free_hook)(void *ptr, const void *caller);
*
* void (*__malloc_initialize_hook)(void);
*
* void (*__after_morecore_hook)(void);
*
static void my_init_hook(void);
static void my_free_hook(void *p, const void *caller);
static void (*old_free_hook)(void *ptr, const void *caller) = NULL;
void (*__free_hook)(void *ptr, const void *caller);
void (*__malloc_initialize_hook) (void) = my_init_hook;
static void
my_init_hook(void)
{
old_free_hook = __free_hook;
__free_hook = my_free_hook;
}
//void *magicfree = NULL;
static void my_free_hook(void *p, const void *caller)
{
__free_hook = old_free_hook;
// if ((p) && (p == magicfree))
// {
// printf("CAUGHT!!!!! %p ...\n", p);
// abort();
// }
free(p);
__free_hook = my_free_hook;
}
*/
EAPI int e_precache_end = 0;
static int really_know = 0;
/* local subsystem functions */
static void _e_main_shutdown_push(int (*func)(void));
static void _e_main_shutdown(int errorcode);
static int _e_main_x_shutdown(void);
static int _e_main_dirs_init(void);
static int _e_main_dirs_shutdown(void);
static int _e_main_screens_init(void);
static int _e_main_screens_shutdown(void);
static void _e_main_manage_all(void);
static int _e_main_path_init(void);
static int _e_main_path_shutdown(void);
static void _e_main_cb_x_fatal(void *data);
static int _e_main_cb_signal_exit(void *data, int ev_type, void *ev);
static int _e_main_cb_signal_hup(void *data, int ev_type, void *ev);
static int _e_main_cb_x_flusher(void *data);
static int _e_main_cb_idler_before(void *data);
static int _e_main_cb_idler_after(void *data);
static int _e_main_cb_eet_cacheburst_end(void *data);
static int _e_main_cb_startup_fake_end(void *data);
static void _e_main_desk_save(void);
static void _e_main_desk_restore(E_Manager *man, E_Container *con);
/* local subsystem globals */
#define MAX_LEVEL 64
static int (*_e_main_shutdown_func[MAX_LEVEL]) (void);
static int _e_main_level = 0;
static int _e_cacheburst = 0;
static Eina_Bool locked = EINA_FALSE;
static Eina_List *_e_main_idler_before_list = NULL;
static Ecore_Idle_Enterer *_e_main_idle_enterer_before = NULL;
static Ecore_Idle_Enterer *_e_main_idle_enterer_after = NULL;
static Ecore_Idle_Enterer *_e_main_idle_enterer_flusher = NULL;
#define TS_DO
#ifdef TS_DO
#define TS(x) \
{ \
t1 = ecore_time_get(); \
printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
t2 = t1; \
}
static double t0, t1, t2;
#else
#define TS(x)
#endif
static int stdbg(void *data __UNUSED__)
{
// enable to debug eina stringshare usage
// eina_stringshare_dump();
return 0;
}
/* externally accessible functions */
int
main(int argc, char **argv)
{
int i;
int nostartup = 0;
int after_restart = 0;
int safe_mode = 0;
char buf[PATH_MAX];
char *s;
struct sigaction action;
double t, tstart;
#ifdef TS_DO
t0 = t1 = t2 = ecore_time_get();
#endif
TS("begin");
#if 0
{
stack_t ss;
ss.ss_sp = malloc(8 * 1024);
ss.ss_size = 8 * 1024;
ss.ss_flags = 0;
sigaltstack(&ss, NULL);
}
#endif
/* trap deadly bug signals and allow some form of sane recovery */
/* or ability to gdb attach and debug at this point - better than your */
/* wm/desktop vanishing and not knowing what happened */
action.sa_sigaction = e_sigseg_act;
action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
sigemptyset(&action.sa_mask);
sigaction(SIGSEGV, &action, NULL);
action.sa_sigaction = e_sigill_act;
action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
sigemptyset(&action.sa_mask);
sigaction(SIGILL, &action, NULL);
action.sa_sigaction = e_sigfpe_act;
action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
sigemptyset(&action.sa_mask);
sigaction(SIGFPE, &action, NULL);
action.sa_sigaction = e_sigbus_act;
action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
sigemptyset(&action.sa_mask);
sigaction(SIGBUS, &action, NULL);
action.sa_sigaction = e_sigabrt_act;
action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
sigemptyset(&action.sa_mask);
sigaction(SIGABRT, &action, NULL);
TS("signals done");
t = ecore_time_get();
s = getenv("E_START_TIME");
if ((s) && (!getenv("E_RESTART_OK")))
{
tstart = atof(s);
if ((t - tstart) < 5.0) safe_mode = 1;
}
tstart = t;
snprintf(buf, sizeof(buf), "%1.1f", tstart);
e_util_env_set("E_START_TIME", buf);
/* FIXME: this is the init code for letting e be relocatable. right now
* its not used - so i want to see if it can reliably determine its exe
* prefix
*/
TS("determine prefix");
if (!e_prefix_determine(argv[0]))
{
fprintf(stderr,
"ERROR: Enlightenment cannot determine its installed\n"
" prefix from the system or argv[0].\n"
" This is because it is not on Linux AND has been\n"
" Executed strangely. This is unusual.\n"
);
e_prefix_fallback();
}
else
{
/* do some extra tests to see if the prefix really is right */
char buf[4096];
e_prefix_data_concat_static(buf, "data/themes/default.edj");
if (!ecore_file_exists(buf))
{
printf("WARNING: Prefix guess was wrong. Guessed:\n"
" %s\n"
" Tried to find file:\n"
" %s\n",
e_prefix_get(), buf);
e_prefix_fallback();
}
else
{
snprintf(buf, sizeof(buf), "%s/enlightenment/modules",
e_prefix_lib_get());
if (!ecore_file_is_dir(buf))
{
printf("WARNING: Prefix guess was wrong. Guessed:\n"
" %s\n"
" Tried to find directory:\n"
" %s\n",
e_prefix_get(), buf);
e_prefix_fallback();
}
}
}
TS("prefix done");
/* for debugging by redirecting stdout of e to a log file to tail */
setvbuf(stdout, NULL, _IONBF, 0);
if (getenv("E_RESTART")) after_restart = 1;
if (getenv("DESKTOP_STARTUP_ID"))
e_util_env_set("DESKTOP_STARTUP_ID", NULL);
e_util_env_set("E_RESTART_OK", NULL);
e_util_env_set("E_RESTART", "1");
/* envrionment varabiles so you know E is running/launched you */
e_util_env_set("PANTS", "ON");
e_util_env_set("DESKTOP", "Enlightenment-0.17.0");
TS("eina init");
eina_init();
_e_main_shutdown_push(eina_shutdown);
TS("intl init");
e_intl_init();
_e_main_shutdown_push(e_intl_shutdown);
TS("parse args");
/* handle some command-line parameters */
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
{
i++;
e_util_env_set("DISPLAY", argv[i]);
}
else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
{
int x, y, w, h;
i++;
/* WWxHH+XX+YY */
if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
e_xinerama_fake_screen_add(x, y, w, h);
}
else if (!strcmp(argv[i], "-good"))
{
good = 1;
evil = 0;
printf("LA LA LA\n");
}
else if (!strcmp(argv[i], "-evil"))
{
good = 0;
evil = 1;
printf("MUHAHAHAHHAHAHAHAHA\n");
}
else if (!strcmp(argv[i], "-psychotic"))
{
good = 1;
evil = 1;
printf("MUHAHALALALALALALALA\n");
}
else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
{
i++;
if (!getenv("E_CONF_PROFILE"))
e_util_env_set("E_CONF_PROFILE", argv[i]);
}
else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
{
really_know = 1;
}
else if (!strcmp(argv[i], "-locked"))
{
locked = EINA_TRUE;
puts("enlightenment will start with desklock on.");
}
else if ((!strcmp(argv[i], "-h")) ||
(!strcmp(argv[i], "-help")) ||
(!strcmp(argv[i], "--help")))
{
printf
(_(
"Options:\n"
"\t-display DISPLAY\n"
"\t\tConnect to display named DISPLAY.\n"
"\t\tEG: -display :1.0\n"
"\t-fake-xinerama-screen WxH+X+Y\n"
"\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
"\t\tgiven the geometry. Add as many as you like. They all\n"
"\t\treplace the real xinerama screens, if any. This can\n"
"\t\tbe used to simulate xinerama.\n"
"\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
"\t-profile CONF_PROFILE\n"
"\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
"\t-good\n"
"\t\tBe good.\n"
"\t-evil\n"
"\t\tBe evil.\n"
"\t-psychotic\n"
"\t\tBe psychotic.\n"
"\t-locked\n"
"\t\tStart with desklock on, so password will be asked.\n"
"\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
"\t\tIf you need this help, you don't need this option.\n"
)
);
exit(0);
}
}
/* fix up DISPLAY to be :N.0 if no .screen is in it */
s = getenv("DISPLAY");
if (s)
{
char *p;
p = strrchr(s, ':');
if (!p)
{
snprintf(buf, sizeof(buf), "%s:0.0", s);
e_util_env_set("DISPLAY", buf);
}
else
{
p = strrchr(p, '.');
if (!p)
{
snprintf(buf, sizeof(buf), "%s.0", s);
e_util_env_set("DISPLAY", buf);
}
}
}
TS("arg parse done");
/* fixes for FOOLS that keep cp'ing default.edj into ~/.e/e/themes */
{
e_user_dir_concat_static(buf, "themes/default.edj");
if (ecore_file_exists(buf)) ecore_file_unlink(buf);
}
TS("ecore init");
/* basic ecore init */
if (!ecore_init())
{
e_error_message_show(_("Enlightenment cannot Initialize Ecore!\n"
"Perhaps you are out of memory?"));
exit(-1);
}
#ifdef HAVE_ECORE_IMF
ecore_imf_init();
_e_main_shutdown_push(ecore_imf_shutdown);
#endif
// FIXME: SEGV's on shutdown if fm2 windows up - disable for now.
// _e_main_shutdown_push(ecore_shutdown);
ecore_job_init();
_e_main_shutdown_push(ecore_job_shutdown);
/* init edje and set it up in frozen mode */
edje_init();
edje_freeze();
_e_main_shutdown_push(edje_shutdown);
_e_cacheburst++;
/* eet_cacheburst(_e_cacheburst); */
ecore_timer_add(5.0, _e_main_cb_eet_cacheburst_end, NULL);
TS("ecore_file init");
/* init the file system */
if (!ecore_file_init())
{
e_error_message_show(_("Enlightenment cannot initialize the File system.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(ecore_file_shutdown);
TS("more ecore");
/* setup my args */
ecore_app_args_set(argc, (const char **)argv);
/* setup a handler for when e is asked to exit via a system signal */
if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _e_main_cb_signal_exit, NULL))
{
e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, _e_main_cb_signal_hup, NULL))
{
e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
/* an idle enterer to be called before all others */
_e_main_idle_enterer_before = ecore_idle_enterer_before_add(_e_main_cb_idler_before, NULL);
TS("x connect");
/* init x */
if (!ecore_x_init(NULL))
{
e_error_message_show(_("Enlightenment cannot initialize its X connection.\n"
"Have you set your DISPLAY variable?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(_e_main_x_shutdown);
/* init white box of death alert */
if (!e_alert_init(NULL))
{
e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
"Have you set your DISPLAY variable?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_alert_shutdown);
/* we want to have been launched by enlightenment_start. there is a very */
/* good reason we want to have been launched this way, thus check */
if (!getenv("E_START"))
{
e_alert_show("You are executing enlightenment directly. This is\n"
"bad. Please do not execute the \"enlightenment\"\n"
"binary. Use the \"enlightenment_start\" launcher. It\n"
"will handle setting up environment variables, paths,\n"
"and launching any other required services etc.\n"
"before enlightenment itself begins running.\n");
exit(-1);
}
TS("ecore_con");
/* init generic communications */
if (!ecore_con_init())
{
e_error_message_show(_("Enlightenment cannot initialize the connections system.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(ecore_con_shutdown);
/* init ipc */
if (!ecore_ipc_init())
{
e_error_message_show(_("Enlightenment cannot initialize the IPC system.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(ecore_ipc_shutdown);
TS("xinerama");
if (!e_xinerama_init())
{
e_error_message_show(_("Enlightenment cannot setup xinerama wrapping.\n"
"This should not happen."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_xinerama_shutdown);
/* ecore_x_grab(); */
ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL);
TS("x hints");
/* Init window manager hints */
e_hints_init();
TS("x hints done");
TS("ecore_evas init");
/* init the evas wrapper */
if (!ecore_evas_init())
{
e_error_message_show(_("Enlightenment cannot initialize the Evas system.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
{
e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
"rendering in Evas. Please check your installation of Evas and\n"
"Ecore and check they support the Software X11 rendering engine."));
_e_main_shutdown(-1);
}
if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
{
e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
"rendering in Evas. Please check your installation of Evas and\n"
"Ecore and check they support the Software Buffer rendering engine."));
_e_main_shutdown(-1);
}
// ecore_evas closes evas - deletes objs - deletes fm widgets which tries to
// ipc to slave to stop monitoring - but ipc has been shut down. dont shut
// down.
// _e_main_shutdown_push(ecore_evas_shutdown);
TS("test done");
/*** Finished loading subsystems, Loading WM Specifics ***/
TS("efreet");
/* init FDO desktop */
if (!efreet_init())
{
e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(efreet_shutdown);
if (!efreet_util_init())
{
e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(efreet_util_shutdown);
TS("efreet done");
TS("configure");
e_configure_init();
TS("dirs");
/* setup directories we will be using for configurations storage etc. */
if (!_e_main_dirs_init())
{
e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
"Perhaps you have no home directory or the disk is full?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(_e_main_dirs_shutdown);
TS("filereg");
/* setup file registry */
if (!e_filereg_init())
{
e_error_message_show(_("Enlightenment cannot set up its file registry system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_filereg_shutdown);
TS("config");
/* init config system */
if (!e_config_init())
{
e_error_message_show(_("Enlightenment cannot set up its config system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_config_shutdown);
locked |= e_config->desklock_start_locked;
/* set all execced stuff to configured priority */
ecore_exe_run_priority_set(e_config->priority);
TS("scale");
/* init config system */
if (!e_scale_init())
{
e_error_message_show(_("Enlightenment cannot set up its scale system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_scale_shutdown);
TS("pointer");
if (!e_pointer_init())
{
e_error_message_show(_("Enlightenment cannot set up the pointer system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_pointer_shutdown);
TS("path");
/* setup paths for finding things */
if (!_e_main_path_init())
{
e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(_e_main_path_shutdown);
TS("ipc");
/* setup e ipc service */
if (e_ipc_init())
_e_main_shutdown_push(e_ipc_shutdown);
/* setup edje to animate @ e_config->framerate frames per sec. */
edje_frametime_set(1.0 / e_config->framerate);
TS("font");
/* init font system */
if (!e_font_init())
{
e_error_message_show(_("Enlightenment cannot set up its font system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_font_shutdown);
e_font_apply();
e_canvas_recache();
TS("theme");
/* init theme system */
if (!e_theme_init())
{
e_error_message_show(_("Enlightenment cannot set up its theme system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_theme_shutdown);
e_init_status_set(_("Starting International Support"));
TS("intl post");
/* init intl system */
if (!e_intl_post_init())
{
e_error_message_show(_("Enlightenment cannot set up its intl system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_intl_post_shutdown);
TS("move/resize info");
/* init move resize popup */
e_moveresize_init();
_e_main_shutdown_push(e_moveresize_shutdown);
TS("splash");
if (!((!e_config->show_splash) || (after_restart)))
{
/* setup init status window/screen */
if (!e_init_init())
{
e_error_message_show(_("Enlightenment cannot set up init screen.\n"
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
e_init_title_set(_("Enlightenment"));
e_init_version_set(VERSION);
e_init_show();
_e_main_shutdown_push(e_init_shutdown);
pause();
}
if (!really_know)
{
e_init_status_set(_("Testing Format Support"));
TS("test file format support");
{
Ecore_Evas *ee;
Evas_Object *im, *txt;
char buf[4096];
Evas_Coord tw, th;
ee = ecore_evas_buffer_new(1, 1);
if (!ee)
{
e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
"Evas has Software Buffer engine support.\n"));
_e_main_shutdown(-1);
}
e_canvas_add(ee);
im = evas_object_image_add(ecore_evas_get(ee));
e_prefix_data_concat_static(buf, "data/images/test.png");
evas_object_image_file_set(im, buf, NULL);
if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
{
e_error_message_show(_("Enlightenment found Evas can't load PNG files. Check Evas has PNG\n"
"loader support.\n"));
_e_main_shutdown(-1);
}
e_prefix_data_concat_static(buf, "data/images/test.jpg");
evas_object_image_file_set(im, buf, NULL);
if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
{
e_error_message_show(_("Enlightenment found Evas can't load JPEG files. Check Evas has JPEG\n"
"loader support.\n"));
_e_main_shutdown(-1);
}
e_prefix_data_concat_static(buf, "data/images/test.edj");
evas_object_image_file_set(im, buf, "images/0");
if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
{
e_error_message_show(_("Enlightenment found Evas can't load EET files. Check Evas has EET\n"
"loader support.\n"));
_e_main_shutdown(-1);
}
evas_object_del(im);
txt = evas_object_text_add(ecore_evas_get(ee));
evas_object_text_font_set(txt, "Sans", 10);
evas_object_text_text_set(txt, "Hello");
evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
if ((tw <= 0) && (th <= 0))
{
e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
"support and system fontconfig defines a 'Sans' font.\n"));
_e_main_shutdown(-1);
}
evas_object_del(txt);
e_canvas_del(ee);
ecore_evas_free(ee);
}
}
e_init_status_set(_("Setup Screens"));
TS("screens");
/* manage the root window */
if (!_e_main_screens_init())
{
e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
"failed. Perhaps another window manager is running?\n"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(_e_main_screens_shutdown);
e_init_status_set(_("Setup Screensaver"));
TS("screensaver");
/* setup screensaver */
if (!e_screensaver_init())
{
e_error_message_show(_("Enlightenment cannot configure the X screensaver."));
_e_main_shutdown(-1);
}
e_init_status_set(_("Setup Desklock"));
TS("desklock");
/* setup desklock */
if (!e_desklock_init())
{
e_error_message_show(_("Enlightenment cannot set up its desk locking system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_desklock_shutdown);
if (locked && ((!e_config->show_splash) && (!after_restart)))
e_desklock_show();
TS("msgbus");
/* setup e msgbus (DBUS) service */
if (e_msgbus_init())
_e_main_shutdown_push(e_msgbus_shutdown);
e_init_status_set(_("Setting up Paths"));
TS("efreet paths");
{
Eina_List **list;
list = efreet_icon_extra_list_get();
if (list)
{
e_user_dir_concat_static(buf, "icons");
*list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
e_prefix_data_concat_static(buf, "data/icons");
*list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
}
}
efreet_icon_extension_add(".edj");
TS("efreet paths done");
e_init_status_set(_("Setup System Controls"));
TS("sys init");
/* init the enlightenment sys command system */
if (!e_sys_init())
{
e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_sys_shutdown);
e_init_status_set(_("Setup Actions"));
TS("actions");
/* init actions system */
if (!e_actions_init())
{
e_error_message_show(_("Enlightenment cannot set up its actions system."));
_e_main_shutdown(-1);
}
e_init_status_set(_("Setup Execution System"));
TS("exec");
/* init app system */
if (!e_exec_init())
{
e_error_message_show(_("Enlightenment cannot set up its exec system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_exec_shutdown);
TS("container freeze");
e_container_all_freeze();
e_init_status_set(_("Setup FM"));
TS("fm2");
/* init the enlightenment file manager */
if (!e_fm2_init())
{
e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_fm2_shutdown);
/*
TS("fwin");
if (!e_fwin_init())
{
e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_fwin_shutdown);
*/
e_init_status_set(_("Setup Message System"));
TS("msg");
/* setup generic msg handling etc */
if (!e_msg_init())
{
e_error_message_show(_("Enlightenment cannot set up its msg system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_msg_shutdown);
e_init_status_set(_("Setup DND"));
TS("dnd");
/* setup dnd */
if (!e_dnd_init())
{
e_error_message_show(_("Enlightenment cannot set up its dnd system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_dnd_shutdown);
e_init_status_set(_("Setup Grab Input Handling"));
TS("grabinput");
/* setup input grabbing co-operation system */
if (!e_grabinput_init())
{
e_error_message_show(_("Enlightenment cannot set up its input grab handling system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_grabinput_shutdown);
e_init_status_set(_("Setup Modules"));
TS("modules");
/* setup module loading etc */
if (!e_module_init())
{
e_error_message_show(_("Enlightenment cannot set up its module system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_module_shutdown);
e_init_status_set(_("Setup Remembers"));
TS("remember");
/* do remember stuff */
if (!e_remember_init(after_restart ? E_STARTUP_RESTART: E_STARTUP_START))
{
e_error_message_show(_("Enlightenment cannot setup remember settings."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_remember_shutdown);
e_init_status_set(_("Setup Color Classes"));
TS("colorclasses");
/* setup color_class */
if (!e_color_class_init())
{
e_error_message_show(_("Enlightenment cannot set up its color class system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_color_class_shutdown);
e_init_status_set(_("Setup Gadcon"));
TS("gadcon");
/* setup gadcon */
if (!e_gadcon_init())
{
e_error_message_show(_("Enlightenment cannot set up its gadget control system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_gadcon_shutdown);
e_init_status_set(_("Setup DPMS"));
TS("dpms");
/* setup dpms */
if (!e_dpms_init())
{
e_error_message_show(_("Enlightenment cannot configure the DPMS settings."));
_e_main_shutdown(-1);
}
e_init_status_set(_("Set Up Powersave modes"));
TS("powersave");
if (!e_powersave_init())
{
e_error_message_show(_("Enlightenment cannot set up its powersave modes."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_powersave_shutdown);
e_init_status_set(_("Setup Wallpaper"));
TS("bg");
/* init desktop background system */
if (!e_bg_init())
{
e_error_message_show(_("Enlightenment cannot set up its desktop background system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_bg_shutdown);
e_init_status_set(_("Setup Mouse"));
TS("mouse");
/* setup mouse accel */
if (!e_mouse_init())
{
e_error_message_show(_("Enlightenment cannot configure the mouse settings."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_actions_shutdown);
e_init_status_set(_("Setup Bindings"));
TS("bindings");
/* init bindings system */
if (!e_bindings_init())
{
e_error_message_show(_("Enlightenment cannot set up its bindings system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_bindings_shutdown);
e_init_status_set(_("Setup Popups"));
TS("popup");
/* init popup system */
if (!e_popup_init())
{
e_error_message_show(_("Enlightenment cannot set up its popup system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_popup_shutdown);
e_init_status_set(_("Setup Shelves"));
TS("shelves");
/* setup shelves */
if (!e_shelf_init())
{
e_error_message_show(_("Enlightenment cannot set up its shelf system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_shelf_shutdown);
e_init_status_set(_("Setup Thumbnailer"));
TS("thumb init");
/* init the enlightenment thumbnailing system */
if (!e_thumb_init())
{
e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_thumb_shutdown);
e_init_status_set(_("Set Up File Ordering"));
TS("order");
if (!e_order_init())
{
e_error_message_show(_("Enlightenment cannot set up its order file system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_order_shutdown);
TS("add idle enterers");
/* add in a handler that just before we go idle we flush x - will happen after ecore_evas's idle rendering as it's after ecore_evas_init() */
_e_main_idle_enterer_flusher =
ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL);
e_managers_keys_grab();
/* ecore_x_ungrab(); */
TS("init properites");
if (!nostartup)
{
if (after_restart) e_startup(E_STARTUP_RESTART);
else e_startup(E_STARTUP_START);
}
if (!((!e_config->show_splash) || (after_restart)))
{
ecore_timer_add(16.0, _e_main_cb_startup_fake_end, NULL);
if (locked) e_desklock_show();
}
e_container_all_thaw();
TS("test code");
/* run any testing code now we are set up */
e_test();
/* load modules */
e_init_status_set(_("Load Modules"));
TS("load modules");
if (!safe_mode)
e_module_all_load();
else
{
e_int_config_modules(e_container_current_get(e_manager_current_get()), NULL);
e_error_message_show
(_("Enlightenment crashed early on start and has<br>"
"been restarted. All modules have been disabled<br>"
"and will not be loaded to help remove any problem<br>"
"modules from your configuration. The module<br>"
"configuration dialog should let you select your<br>"
"modules again."));
e_util_dialog_show
(_("Enlightenment crashed early on start and has been restarted"),
_("Enlightenment crashed early on start and has been restarted.<br>"
"All modules have been disabled and will not be loaded to help<br>"
"remove any problem modules from your configuration.<br><br>"
"The module configuration dialog should let you select your<br>"
"modules again."));
e_config_save_queue();
}
e_init_status_set(_("Configure Shelves"));
TS("shelf config init");
e_shelf_config_init();
TS("manage all windows");
_e_main_manage_all();
/* an idle enterer to be called after all others */
_e_main_idle_enterer_after =
ecore_idle_enterer_add(_e_main_cb_idler_after, NULL);
e_init_status_set(_("Almost Done"));
TS("MAIN LOOP AT LAST");
/* no longer starting up */
starting = 0;
/* start our main loop */
ecore_timer_add(5.0, stdbg, NULL);
ecore_main_loop_begin();
e_canvas_idle_flush();
stopping = 1;
/* ask all modules to save their config and then shutdown */
/* NB: no need to do this as config shutdown will flush any saves */
/* and all changed config was already saved before */
e_config_save_flush();
/* Store current selected desktops */
_e_main_desk_save();
e_remember_internal_save();
/* unroll our stack of shutdown functions with exit code of 0 */
_e_main_shutdown(0);
/* if we were flagged to restart, then restart. */
if (restart)
{
e_util_env_set("E_RESTART_OK", "1");
ecore_app_restart();
}
e_prefix_shutdown();
/* just return 0 to keep the compiler quiet */
return 0;
}
/* FIXME: make safe to delete within a callback */
EAPI E_Before_Idler *
e_main_idler_before_add(int (*func) (void *data), void *data, int once)
{
E_Before_Idler *eb;
eb = calloc(1, sizeof(E_Before_Idler));
eb->func = func;
eb->data = data;
eb->once = once;
_e_main_idler_before_list = eina_list_append(_e_main_idler_before_list, eb);
return eb;
}
EAPI void
e_main_idler_before_del(E_Before_Idler *eb)
{
eb->delete_me = 1;
}
/* local subsystem functions */
static void
_e_main_shutdown_push(int (*func) (void))
{
_e_main_level++;
if (_e_main_level > MAX_LEVEL)
{
_e_main_level--;
e_error_message_show("WARNING: too many init levels. MAX = %i", MAX_LEVEL);
return;
}
_e_main_shutdown_func[_e_main_level - 1] = func;
}
static void
_e_main_shutdown(int errorcode)
{
int i;
printf("E17: Begin shutdown procedure!\n");
if (_e_main_idle_enterer_before)
{
ecore_idle_enterer_del(_e_main_idle_enterer_before);
_e_main_idle_enterer_before = NULL;
}
if (_e_main_idle_enterer_after)
{
ecore_idle_enterer_del(_e_main_idle_enterer_after);
_e_main_idle_enterer_after = NULL;
}
if (_e_main_idle_enterer_flusher)
{
ecore_idle_enterer_del(_e_main_idle_enterer_flusher);
_e_main_idle_enterer_flusher = NULL;
}
for (i = _e_main_level - 1; i >= 0; i--)
(*_e_main_shutdown_func[i])();
if (errorcode < 0) exit(errorcode);
}
static int
_e_main_x_shutdown(void)
{
/* ecore_x_ungrab(); */
ecore_x_focus_reset();
ecore_x_events_allow_all();
ecore_x_shutdown();
return 1;
}
static int
_e_main_dirs_init(void)
{
const char *base;
const char *dirs[] = {
"images",
"fonts",
"themes",
"icons",
"backgrounds",
"applications",
"applications/menu",
"applications/menu/favorite",
"applications/menu/all",
"applications/bar",
"applications/bar/default",
"applications/startup",
"applications/restart",
"applications/trash",
"modules",
"config",
"locale",
"input_methods",
NULL
};
base = e_user_dir_get();
if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs)/sizeof(dirs[0]) - 1)
{
e_error_message_show
("Could not create one of the required subdirectories of '%s'", base);
return 0;
}
return 1;
}
static int
_e_main_dirs_shutdown(void)
{
return 1;
}
static int
_e_main_screens_init(void)
{
Ecore_X_Window *roots;
int num, i;
TS("screens: atoms");
if (!e_atoms_init()) return 0;
TS("screens: manager");
if (!e_manager_init()) return 0;
TS("screens: container");
if (!e_container_init()) return 0;
TS("screens: zone");
if (!e_zone_init()) return 0;
TS("screens: desk");
if (!e_desk_init()) return 0;
TS("screens: menu");
if (!e_menu_init()) return 0;
TS("screens: exehist");
if (!e_exehist_init()) return 0;
TS("screens: get roots");
num = 0;
roots = ecore_x_window_root_list(&num);
if ((!roots) || (num <= 0))
{
e_error_message_show("X reports there are no root windows and %i screens!\n",
num);
return 0;
}
TS("screens: focus");
if (!e_focus_init()) return 0;
TS("screens: border");
if (!e_border_init()) return 0;
TS("screens: win");
if (!e_win_init()) return 0;
TS("screens: manage roots");
for (i = 0; i < num; i++)
{
E_Manager *man;
E_Container *con;
man = e_manager_new(roots[i], i);
if (man)
e_manager_show(man);
else
{
e_error_message_show("Cannot create manager object for screen %i\n",
i);
free(roots);
return 0;
}
con = e_container_new(man);
if (con)
{
e_container_show(con);
e_grabinput_focus(con->bg_win, E_FOCUS_METHOD_PASSIVE);
e_hints_manager_init(man);
_e_main_desk_restore(man, con);
// e_manager_manage_windows(man);
}
else
{
e_error_message_show("Cannot create desktop object for manager on screen %i\n",
i);
free(roots);
return 0;
}
}
TS("screens: sync");
free(roots);
ecore_x_sync();
return 1;
}
static int
_e_main_screens_shutdown(void)
{
e_win_shutdown();
e_border_shutdown();
e_focus_shutdown();
e_exehist_shutdown();
e_menu_shutdown();
// ecore_evas closes evas - deletes objs - deletes fm widgets which tries to
// ipc to slave to stop monitoring - but ipc has been shut down. dont shut
// down.
// e_desk_shutdown();
// e_zone_shutdown();
// e_container_shutdown();
// e_manager_shutdown();
e_atoms_shutdown();
return 1;
}
static void
_e_main_manage_all(void)
{
Eina_List *l;
E_Manager *man;
EINA_LIST_FOREACH(e_manager_list(), l, man)
e_manager_manage_windows(man);
}
static int
_e_main_path_init(void)
{
char buf[4096];
/* setup data paths */
path_data = e_path_new();
if (!path_data)
{
e_error_message_show("Cannot allocate path for path_data\n");
return 0;
}
e_prefix_data_concat_static(buf, "data");
e_path_default_path_append(path_data, buf);
e_path_user_path_set(path_data, &(e_config->path_append_data));
/* setup image paths */
path_images = e_path_new();
if (!path_images)
{
e_error_message_show("Cannot allocate path for path_images\n");
return 0;
}
e_path_default_path_append(path_images, "~/.e/e/images");
e_prefix_data_concat_static(buf, "data/images");
e_path_default_path_append(path_images, buf);
e_path_user_path_set(path_images, &(e_config->path_append_images));
/* setup font paths */
path_fonts = e_path_new();
if (!path_fonts)
{
e_error_message_show("Cannot allocate path for path_fonts\n");
return 0;
}
e_path_default_path_append(path_fonts, "~/.e/e/fonts");
e_prefix_data_concat_static(buf, "data/fonts");
e_path_default_path_append(path_fonts, buf);
e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
/* setup theme paths */
path_themes = e_path_new();
if (!path_themes)
{
e_error_message_show("Cannot allocate path for path_themes\n");
return 0;
}
e_path_default_path_append(path_themes, "~/.e/e/themes");
e_prefix_data_concat_static(buf, "data/themes");
e_path_default_path_append(path_themes, buf);
e_path_user_path_set(path_themes, &(e_config->path_append_themes));
/* setup icon paths */
path_icons = e_path_new();
if (!path_icons)
{
e_error_message_show("Cannot allocate path for path_icons\n");
return 0;
}
e_path_default_path_append(path_icons, "~/.e/e/icons");
e_prefix_data_concat_static(buf, "data/icons");
e_path_default_path_append(path_icons, buf);
e_path_user_path_set(path_icons, &(e_config->path_append_icons));
/* setup module paths */
path_modules = e_path_new();
if (!path_modules)
{
e_error_message_show("Cannot allocate path for path_modules\n");
return 0;
}
e_path_default_path_append(path_modules, "~/.e/e/modules");
snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
e_path_default_path_append(path_modules, buf);
/* FIXME: eventually this has to go - moduels shoudl have installers that
* add appropriate install paths (if not installed to user homedir) to
* e's module search dirs
*/
snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
e_path_default_path_append(path_modules, buf);
e_path_user_path_set(path_modules, &(e_config->path_append_modules));
/* setup background paths */
path_backgrounds = e_path_new();
if (!path_backgrounds)
{
e_error_message_show("Cannot allocate path for path_backgrounds\n");
return 0;
}
e_path_default_path_append(path_backgrounds, "~/.e/e/backgrounds");
e_prefix_data_concat_static(buf, "data/backgrounds");
e_path_default_path_append(path_backgrounds, buf);
e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));
path_messages = e_path_new();
if (!path_messages)
{
e_error_message_show("Cannot allocate path for path_messages\n");
return 0;
}
e_path_default_path_append(path_messages, "~/.e/e/locale");
e_path_default_path_append(path_messages, e_prefix_locale_get());
e_path_user_path_set(path_messages, &(e_config->path_append_messages));
return 1;
}
static int
_e_main_path_shutdown(void)
{
if (path_data)
{
e_object_del(E_OBJECT(path_data));
path_data = NULL;
}
if (path_images)
{
e_object_del(E_OBJECT(path_images));
path_images = NULL;
}
if (path_fonts)
{
e_object_del(E_OBJECT(path_fonts));
path_fonts = NULL;
}
if (path_themes)
{
e_object_del(E_OBJECT(path_themes));
path_themes = NULL;
}
if (path_icons)
{
e_object_del(E_OBJECT(path_icons));
path_icons = NULL;
}
if (path_modules)
{
e_object_del(E_OBJECT(path_modules));
path_modules = NULL;
}
if (path_backgrounds)
{
e_object_del(E_OBJECT(path_backgrounds));
path_backgrounds = NULL;
}
if (path_messages)
{
e_object_del(E_OBJECT(path_messages));
path_messages = NULL;
}
return 1;
}
static void
_e_main_cb_x_fatal(void *data __UNUSED__)
{
e_error_message_show("Lost X connection.");
ecore_main_loop_quit();
}
static int
_e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
{
/* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
e_sys_action_do(E_SYS_EXIT, NULL);
return 1;
}
static int
_e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
{
e_sys_action_do(E_SYS_RESTART, NULL);
return 1;
}
static int
_e_main_cb_x_flusher(void *data __UNUSED__)
{
eet_clearcache();
ecore_x_flush();
return 1;
}
static int
_e_main_cb_idler_before(void *data __UNUSED__)
{
Eina_List *l, *pl;
E_Before_Idler *eb;
e_menu_idler_before();
e_focus_idler_before();
e_border_idler_before();
e_popup_idler_before();
e_drag_idler_before();
e_pointer_idler_before();
EINA_LIST_FOREACH(_e_main_idler_before_list, l, eb)
{
if (!eb->delete_me)
{
if (!eb->func(eb->data)) eb->delete_me = 1;
}
}
EINA_LIST_FOREACH_SAFE(_e_main_idler_before_list, pl, l, eb)
{
if ((eb->once) || (eb->delete_me))
{
_e_main_idler_before_list =
eina_list_remove_list(_e_main_idler_before_list, pl);
free(eb);
}
}
_e_cacheburst--;
/* eet_cacheburst(_e_cacheburst); */
edje_thaw();
return 1;
}
static int
_e_main_cb_idler_after(void *data __UNUSED__)
{
edje_freeze();
_e_cacheburst++;
/* eet_cacheburst(_e_cacheburst); */
{
static int first_idle = 1;
if (first_idle)
{
TS("SLEEP");
first_idle = 0;
e_precache_end = 1;
}
}
return 1;
}
static int
_e_main_cb_eet_cacheburst_end(void *data __UNUSED__)
{
_e_cacheburst--;
/* eet_cacheburst(_e_cacheburst); */
return 0;
}
static int
_e_main_cb_startup_fake_end(void *data __UNUSED__)
{
e_init_hide();
return 0;
}
static void
_e_main_desk_save(void)
{
Eina_List *ml;
E_Manager *man;
char env[1024], name[1024];
EINA_LIST_FOREACH(e_manager_list(), ml, man)
{
Eina_List *cl;
E_Container *con;
EINA_LIST_FOREACH(man->containers, cl, con)
{
Eina_List *zl;
E_Zone *zone;
EINA_LIST_FOREACH(con->zones, zl, zone)
{
snprintf(name, sizeof(name), "DESK_%d_%d_%d", man->num, con->num, zone->num);
snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
e_util_env_set(name, env);
}
}
}
}
static void
_e_main_desk_restore(E_Manager *man, E_Container *con)
{
Eina_List *zl;
E_Zone *zone;
char *env;
char name[1024];
EINA_LIST_FOREACH(con->zones, zl, zone)
{
E_Desk *desk;
int desk_x, desk_y;
snprintf(name, sizeof(name), "DESK_%d_%d_%d", man->num, con->num, zone->num);
env = getenv(name);
if (!env) continue;
if (!sscanf(env, "%d,%d", &desk_x, &desk_y)) continue;
desk = e_desk_at_xy_get(zone, desk_x, desk_y);
if (!desk) continue;
e_desk_show(desk);
}
}
|