1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2004-01-19 14:30:35 -08:00
|
|
|
* Copyright (C) 2000-2004 Carsten Haitzler, Geoff Harrison and various contributors
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
|
|
|
#include "timestamp.h"
|
1999-10-28 05:24:39 -07:00
|
|
|
#include <sys/utsname.h>
|
1999-08-17 15:56:46 -07:00
|
|
|
|
1999-10-01 12:54:23 -07:00
|
|
|
static void
|
1999-10-01 11:15:04 -07:00
|
|
|
runDocBrowser(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
char file[FILEPATH_LEN_MAX];
|
|
|
|
|
|
|
|
if (fork())
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
2000-06-04 12:45:55 -07:00
|
|
|
Esnprintf(file, sizeof(file), "exec %s/dox %s/E-docs", ENLIGHTENMENT_BIN,
|
2003-05-22 12:15:03 -07:00
|
|
|
ENLIGHTENMENT_ROOT);
|
1999-12-06 09:12:20 -08:00
|
|
|
execl(usershell(getuid()), usershell(getuid()), "-c", (char *)file, NULL);
|
1999-10-01 11:15:04 -07:00
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2003-12-07 01:18:55 -08:00
|
|
|
int i;
|
1999-09-22 19:31:53 -07:00
|
|
|
Background *bg;
|
|
|
|
ECursor *ec = NULL;
|
1999-10-28 05:24:39 -07:00
|
|
|
struct utsname ubuf;
|
2003-06-15 08:27:05 -07:00
|
|
|
char *str;
|
1999-09-22 19:31:53 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* This function runs all the setup for startup, and then
|
|
|
|
* proceeds into the primary event loop at the end.
|
|
|
|
*/
|
|
|
|
|
|
|
|
single_screen_mode = 0;
|
|
|
|
/* unsetenv("LD_PRELOAD"); */
|
|
|
|
|
1999-12-06 09:12:20 -08:00
|
|
|
/* Part of gettext stuff */
|
|
|
|
|
2000-01-10 04:22:58 -08:00
|
|
|
setlocale(LC_ALL, "");
|
1999-12-10 05:47:37 -08:00
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
1999-12-06 09:12:20 -08:00
|
|
|
textdomain(PACKAGE);
|
|
|
|
|
|
|
|
/* End of gettext stuff */
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
call_level = 0;
|
|
|
|
debug_level = 0;
|
2003-06-15 08:27:05 -07:00
|
|
|
str = getenv("EDBUG");
|
|
|
|
if (str)
|
|
|
|
debug_level = atoi(str);
|
1999-08-17 15:56:46 -07:00
|
|
|
#endif
|
2003-06-15 08:27:05 -07:00
|
|
|
str = getenv("EDBUG_FLAGS");
|
|
|
|
if (str)
|
2004-01-04 10:07:18 -08:00
|
|
|
EventDebugInit(str);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
EDBUG(1, "main");
|
|
|
|
|
|
|
|
/* go head and set up the internal data lists that enlightenment
|
|
|
|
* uses for finding everything
|
|
|
|
*/
|
|
|
|
lists = Emalloc(sizeof(List) * LIST_TYPE_COUNT);
|
|
|
|
lists = memset(lists, 0, (sizeof(List) * LIST_TYPE_COUNT));
|
|
|
|
|
|
|
|
/* Set up all the text bits that belong on the GSOD */
|
1999-12-21 00:09:27 -08:00
|
|
|
AssignTitleText(_("Enlightenment Message Dialog"));
|
|
|
|
AssignIgnoreText(_("Ignore this"));
|
|
|
|
AssignRestartText(_("Restart Enlightenment"));
|
|
|
|
AssignExitText(_("Quit Enlightenment"));
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
/* We'll set up what the buttons do now, too */
|
2004-01-03 04:55:08 -08:00
|
|
|
AssignRestartFunction(SessionExit, "restart");
|
|
|
|
AssignExitFunction(SessionExit, NULL);
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
srand(time(NULL));
|
|
|
|
|
1999-10-28 05:24:39 -07:00
|
|
|
if (!uname(&ubuf))
|
|
|
|
e_machine_name = duplicate(ubuf.nodename);
|
|
|
|
if (!e_machine_name)
|
|
|
|
e_machine_name = duplicate("localhost");
|
1999-08-17 15:56:46 -07:00
|
|
|
command = duplicate(argv[0]);
|
|
|
|
themepath[0] = 0;
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
|
|
|
|
/* Now we're going to interpret any of the commandline parameters
|
|
|
|
* that are passed to it -- Well, at least the ones that we
|
|
|
|
* understand.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (j = 1; j < argc; j++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
if ((!strcmp("-theme", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
Esnprintf(themepath, sizeof(themepath), "%s", argv[++j]);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-econfdir", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
SetEDir(argv[++j]);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-ecachedir", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
SetCacheDir(argv[++j]);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-display", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
dstr = argv[++j];
|
|
|
|
}
|
|
|
|
else if (!strcmp("-single", argv[j]))
|
|
|
|
{
|
|
|
|
single_screen_mode = 1;
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-smid", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
SetSMID(argv[++j]);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-clientId", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
SetSMID(argv[++j]);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("--sm-client-id", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
SetSMID(argv[++j]);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-smfile", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
SetSMFile(argv[++j]);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-ext_init_win", argv[j])) && (argc - j > 1))
|
|
|
|
{
|
|
|
|
init_win_ext = atoi(argv[++j]);
|
|
|
|
}
|
|
|
|
else if (!strcmp("-no_overwrite", argv[j]))
|
|
|
|
{
|
|
|
|
no_overwrite = 1;
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-help", argv[j]))
|
|
|
|
|| (!strcmp("--help", argv[j]))
|
|
|
|
|| (!strcmp("-h", argv[j])) || (!strcmp("-?", argv[j])))
|
|
|
|
{
|
|
|
|
printf("enlightenment options: \n"
|
|
|
|
"\t-theme /path/to/theme \n"
|
|
|
|
"\t-econfdir /path/to/.enlightenment/conf/dir\n"
|
|
|
|
"\t-ecachedir /path/to/cached/dir \n"
|
|
|
|
"\t[-smid | -clientId | --sm-client-id] id \n"
|
|
|
|
"\t-smfile file \n"
|
|
|
|
"\t-ext_init_win window_id \n"
|
|
|
|
"\t-no_overwrite \n"
|
|
|
|
"\t[-v | -version | --version] \n"
|
|
|
|
"\t-display display_name \n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
else if ((!strcmp("-v", argv[j]))
|
|
|
|
|| (!strcmp("-version", argv[j]))
|
|
|
|
|| (!strcmp("--version", argv[j]))
|
|
|
|
|| (!strcmp("-v", argv[j])))
|
|
|
|
{
|
|
|
|
printf(_("Enlightenment Version: %s\nLast updated on: %s\n"),
|
|
|
|
ENLIGHTENMENT_VERSION, E_CHECKOUT_DATE);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
2000-03-14 14:29:04 -08:00
|
|
|
|
|
|
|
/* Set a default location for the "previous session" data when
|
|
|
|
* we do not actually have a previous session. */
|
|
|
|
SetSMFile(NULL);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (themepath[0] == 0)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
FILE *f;
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
char *file;
|
|
|
|
|
|
|
|
file = FindFile("user_theme.cfg");
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
s[0] = 0;
|
1999-10-18 10:42:01 -07:00
|
|
|
#ifndef __EMX__
|
2003-05-22 12:15:03 -07:00
|
|
|
f = fopen(file, "r");
|
1999-10-18 10:42:01 -07:00
|
|
|
#else
|
2003-05-22 12:15:03 -07:00
|
|
|
f = fopen(file, "rt");
|
1999-10-18 10:42:01 -07:00
|
|
|
#endif
|
2003-05-22 12:15:03 -07:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
if (fscanf(f, "%4000s", s) < 1)
|
|
|
|
s[0] = 0;
|
|
|
|
fclose(f);
|
|
|
|
if (s[0])
|
|
|
|
Esnprintf(themepath, sizeof(themepath), "%s", s);
|
|
|
|
}
|
|
|
|
Efree(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (themepath[0] == 0)
|
|
|
|
{
|
|
|
|
char *def;
|
|
|
|
|
2004-02-11 07:27:54 -08:00
|
|
|
def = ThemeGetDefault();
|
2003-05-22 12:15:03 -07:00
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
Esnprintf(themepath, sizeof(themepath), "%s", def);
|
|
|
|
Efree(def);
|
|
|
|
}
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
SetSMUserThemePath(themepath);
|
|
|
|
|
|
|
|
/* run most of the setup */
|
2003-08-18 14:54:27 -07:00
|
|
|
SignalsSetup();
|
1999-08-17 15:56:46 -07:00
|
|
|
SetupX();
|
1999-10-10 10:15:03 -07:00
|
|
|
BlumFlimFrub();
|
1999-08-17 15:56:46 -07:00
|
|
|
ZoomInit();
|
|
|
|
SetupDirs();
|
|
|
|
InitDesktopBgs();
|
|
|
|
GotoDesktop(0);
|
|
|
|
CommsSetup();
|
|
|
|
CommsFindCommsWindow();
|
|
|
|
GrabX();
|
1999-09-06 20:41:10 -07:00
|
|
|
LoadGroups();
|
1999-08-17 15:56:46 -07:00
|
|
|
LoadSnapInfo();
|
|
|
|
MapUnmap(0);
|
|
|
|
|
|
|
|
/* make all of our fallback classes */
|
|
|
|
SetupFallbackClasses();
|
|
|
|
UngrabX();
|
2004-01-03 04:55:08 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
desks.desk[0].viewable = 0;
|
|
|
|
/* now we're going to load the configuration/theme */
|
|
|
|
LoadEConfig(themepath);
|
2004-02-06 11:56:26 -08:00
|
|
|
SetAreaSize(conf.areas.nx, conf.areas.ny);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
desks.desk[0].viewable = 1;
|
|
|
|
RefreshDesktop(0);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.sound)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-03 04:29:58 -08:00
|
|
|
SoundPlay("SOUND_STARTUP");
|
|
|
|
SoundFree("SOUND_STARTUP");
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
/* toss down the dragbar and related */
|
|
|
|
InitDesktopControls();
|
|
|
|
/* then draw all the buttons that belong on the desktop */
|
2003-12-07 01:18:55 -08:00
|
|
|
ShowDesktopButtons();
|
2003-11-15 14:27:17 -08:00
|
|
|
|
2003-03-23 19:48:09 -08:00
|
|
|
HintsInit();
|
1999-08-17 15:56:46 -07:00
|
|
|
SessionInit();
|
|
|
|
ShowDesktopControls();
|
|
|
|
CheckEvent();
|
|
|
|
/* retreive stuff from last time we were loaded if we're restarting */
|
|
|
|
ICCCM_GetMainEInfo();
|
1999-09-14 10:36:48 -07:00
|
|
|
SetupEnv();
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.mapslide)
|
1999-09-21 19:13:51 -07:00
|
|
|
CreateStartupDisplay(0);
|
1999-08-17 15:56:46 -07:00
|
|
|
MapUnmap(1);
|
2003-03-23 19:48:09 -08:00
|
|
|
/* set some more hints */
|
|
|
|
HintsSetDesktopViewport();
|
1999-08-17 15:56:46 -07:00
|
|
|
desks.current = 0;
|
|
|
|
/* Set up the internal pagers */
|
1999-08-26 11:56:06 -07:00
|
|
|
IB_Setup();
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.enable)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-12 12:43:18 -08:00
|
|
|
conf.pagers.enable = 0;
|
2003-05-22 12:15:03 -07:00
|
|
|
queue_up = 0;
|
|
|
|
EnableAllPagers();
|
2003-09-28 12:21:34 -07:00
|
|
|
queue_up = DRAW_QUEUE_ENABLE;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
if (getpid() == master_pid && init_win_ext)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
XKillClient(disp, init_win_ext);
|
|
|
|
init_win_ext = 0;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-03-23 19:48:09 -08:00
|
|
|
HintsSetClientList();
|
1999-09-07 16:16:39 -07:00
|
|
|
|
|
|
|
/* sync just to make sure */
|
1999-08-17 15:56:46 -07:00
|
|
|
XSync(disp, False);
|
2003-09-28 12:21:34 -07:00
|
|
|
queue_up = DRAW_QUEUE_ENABLE;
|
1999-09-07 16:16:39 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* hello! we don't have a resizemode of 5! */
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.resizemode == 5)
|
|
|
|
conf.resizemode = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
/* of course, we have to set the cursors */
|
1999-09-22 19:31:53 -07:00
|
|
|
ec = FindItem("DEFAULT", 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR);
|
|
|
|
if (ec)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
ApplyECursor(root.win, ec);
|
|
|
|
ec->ref_count++;
|
|
|
|
ec->inroot = 1;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
mode.startup = 0;
|
1999-09-21 19:13:51 -07:00
|
|
|
/* ok - paranoia - save current settings to disk */
|
1999-09-22 13:05:33 -07:00
|
|
|
if (root.scr == 0)
|
|
|
|
autosave();
|
1999-09-21 19:13:51 -07:00
|
|
|
/* let's make sure we set this up and go to our desk anyways */
|
|
|
|
ICCCM_GetMainEInfo();
|
|
|
|
GotoDesktop(desks.current);
|
2004-02-06 11:56:26 -08:00
|
|
|
if (desks.current < (conf.desks.num - 1))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
char ps = 0;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.mapslide)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-02-06 11:56:26 -08:00
|
|
|
ps = conf.desks.slidein;
|
|
|
|
conf.desks.slidein = 0;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
GotoDesktop(desks.current + 1);
|
|
|
|
GotoDesktop(desks.current - 1);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.mapslide)
|
2004-02-06 11:56:26 -08:00
|
|
|
conf.desks.slidein = ps;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-09-21 19:13:51 -07:00
|
|
|
else if (desks.current > 0)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
char ps = 0;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.mapslide)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-02-06 11:56:26 -08:00
|
|
|
ps = conf.desks.slidein;
|
|
|
|
conf.desks.slidein = 0;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
GotoDesktop(desks.current - 1);
|
|
|
|
GotoDesktop(desks.current + 1);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.mapslide)
|
2004-02-06 11:56:26 -08:00
|
|
|
conf.desks.slidein = ps;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-09-21 19:13:51 -07:00
|
|
|
XSync(disp, False);
|
2003-11-15 14:27:17 -08:00
|
|
|
|
1999-10-09 21:46:45 -07:00
|
|
|
/* if we didn't have an external window piped to us, we'll do some stuff */
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.mapslide)
|
1999-09-21 19:13:51 -07:00
|
|
|
CreateStartupDisplay(0);
|
2003-11-15 14:27:17 -08:00
|
|
|
|
|
|
|
if ((bg = RemoveItem("STARTUP_BACKGROUND_SIDEWAYS", 0,
|
|
|
|
LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND)))
|
2003-03-27 21:16:21 -08:00
|
|
|
FreeDesktopBG(bg);
|
2003-11-15 14:27:17 -08:00
|
|
|
if ((bg = RemoveItem("STARTUP_BACKGROUND", 0,
|
|
|
|
LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND)))
|
2003-03-27 21:16:21 -08:00
|
|
|
FreeDesktopBG(bg);
|
2003-11-15 14:27:17 -08:00
|
|
|
|
1999-10-18 10:42:01 -07:00
|
|
|
#ifdef SIGCONT
|
1999-09-22 19:31:53 -07:00
|
|
|
for (i = 0; i < child_count; i++)
|
|
|
|
kill(e_children[i], SIGCONT);
|
1999-10-18 10:42:01 -07:00
|
|
|
#endif
|
1999-09-07 16:16:39 -07:00
|
|
|
|
1999-10-07 10:23:20 -07:00
|
|
|
SetupUserInitialization();
|
1999-10-01 11:15:04 -07:00
|
|
|
if (mode.firsttime)
|
1999-10-13 07:45:28 -07:00
|
|
|
runDocBrowser();
|
2003-05-31 01:28:52 -07:00
|
|
|
|
|
|
|
mode.startup = 1;
|
|
|
|
SpawnSnappedCmds();
|
|
|
|
mode.startup = 0;
|
1999-09-23 14:08:03 -07:00
|
|
|
|
2004-02-11 07:27:54 -08:00
|
|
|
ThemeBadDialog();
|
1999-08-17 15:56:46 -07:00
|
|
|
/* The primary event loop */
|
|
|
|
for (;;)
|
|
|
|
WaitEvent();
|
|
|
|
/* Of course, we should NEVER get to this point */
|
|
|
|
EDBUG_RETURN(0);
|
|
|
|
}
|