Esempio n. 1
0
static void
EConfNameSet(const char *name)
{
    Efree(Mode.conf.name);
    Mode.conf.name = Estrdup(name);
    Esetenv("ECONFNAME", Mode.conf.name);
}
Esempio n. 2
0
static void
_SnapUpdateEwinCmd(Snapshot * sn, const EWin * ewin)
{
   if (ewin->icccm.wm_machine &&
       strcmp(ewin->icccm.wm_machine, Mode.wm.machine_name))
      return;

   Efree(sn->cmd);
   sn->cmd = Estrdup(ewin->icccm.wm_command);
}
Esempio n. 3
0
char               *
path_test(const char *file, unsigned int test)
{
   char               *cp, *ep;
   char               *s, *p;
   unsigned int        len, exelen;

   if (!file)
      return NULL;

   if (isabspath(file))
     {
	if (file_test(file, test))
	   return Estrdup(file);
	return NULL;
     }
   cp = getenv("PATH");
   if (!cp)
      return Estrdup(file);

   exelen = strlen(file);
   s = NULL;
   ep = cp;
   for (; ep; cp = ep + 1)
     {
	ep = strchr(cp, ':');
	len = (ep) ? (unsigned int)(ep - cp) : strlen(cp);
	if (len == 0)
	   continue;
	p = EREALLOC(char, s, len + exelen + 2);

	if (!p)
	   break;
	s = p;
	memcpy(s, cp, len);
	s[len] = '/';
	memcpy(s + len + 1, file, exelen + 1);
	if (file_test(s, test))
	   return s;
     }
   Efree(s);
   return NULL;
}
Esempio n. 4
0
static void DefTransitions(struct net_object *netobj, struct net_object *unf_netobj)
{ 
 struct trans_object *trans_el, *trans, *prev_trans;
 struct group_object *pri_group, *unf_new_group, *prev_group;
 list l, curr;
 int i;
  
  /* Immediate transition */
 for( pri_group = netobj->groups; pri_group != NULL; pri_group = pri_group->next)
 {
     
 
//    Create new group
   unf_new_group = (struct group_object *) Emalloc(sizeof(struct group_object));
   unf_new_group->tag = Estrdup(pri_group->tag);
   unf_new_group->pri = pri_group->pri;
   unf_new_group->trans = NULL;
   unf_new_group->center.x = pri_group->center.x;
   unf_new_group->center.y = pri_group->center.y;   
   unf_new_group->movelink = NULL;
   unf_new_group->next = unf_netobj->groups;
         
   i=0;
   for( trans_el = pri_group->trans;  trans_el != NULL; trans_el = trans_el->next)
   {
     l = expandtransition(trans_el, netobj, unf_netobj);     
     curr =NULL;
     while ( (curr = list_iterator(l, curr)) != NULL ){
       trans = (struct trans_object *) DATA(curr);
       trans->next = unf_new_group->trans;
       unf_new_group->trans = trans;             
     }
     
   }
   destroy(&l, NULL);
   unf_netobj->groups = unf_new_group;
   
     
 }

 /* Exponential and Deterministic Transition */
 i = 0;
 for( trans_el = netobj->trans; trans_el != NULL; trans_el = trans_el->next) {
   l = expandtransition(trans_el, netobj, unf_netobj);  
   curr = NULL;   
   while ( (curr = list_iterator(l, curr)) != NULL ){
     trans = (struct trans_object *) DATA(curr);
     trans->next =  unf_netobj->trans;      
     unf_netobj->trans = trans;     
   }
   destroy(&l, NULL);
 }

}
Esempio n. 5
0
File: session.c Progetto: Limsik/e17
void
SessionInit(void)
{
   if (Mode.wm.window)
      return;

#if 0				/* Unused */
   atom_sm_client_id = EInternAtom("SM_CLIENT_ID");
#endif

#if USE_SM
   ice_init();
#endif

   if (!Conf.session.script)
      Conf.session.script = Estrdup("$EROOT/scripts/session.sh");
   if (!Conf.session.cmd_reboot)
      Conf.session.cmd_reboot = Estrdup("reboot");
   if (!Conf.session.cmd_halt)
      Conf.session.cmd_halt = Estrdup("poweroff");
}
Esempio n. 6
0
/*
 *	Replace the contents of a string variable with another string
 */
char *Estrchg_(char ** const var, const char * const str)
{ 	DBG_ENTER("Estrchg_", Suppl_error)

	assert(var);

	DBG_ARGUMENTS( ("*var=%p, str=\"%s\"", *var, str) )

	chkHeap
	free(*var);
	chkHeap
	DBG_RETURN_BS( *var = Estrdup(str))
}
Esempio n. 7
0
char               *
fileof(const char *path)
{
   const char         *s1, *s2;

   s1 = strrchr(path, '/');
   s1 = (s1) ? s1 + 1 : path;
   s2 = strrchr(s1, '.');
   if (!s2)
      return Estrdup(s1);

   return Estrndup(s1, s2 - s1);
}
Esempio n. 8
0
static void
ECursorCreate(const char *name, const char *image, int native_id,
	      unsigned int fg, unsigned int bg)
{
   ECursor            *ec;

   if ((!name) || (!image && native_id == -1))
      return;

   ec = ECALLOC(ECursor, 1);
   if (!ec)
      return;

   ec->name = Estrdup(name);

   ec->file = Estrdup(image);
   ec->fg = 0xff000000 | fg;
   ec->bg = 0xff000000 | bg;
   ec->native_id = native_id;

   LIST_PREPEND(ECursor, &cursor_list, ec);
}
Esempio n. 9
0
MenuItem           *
MenuItemCreate(const char *text, ImageClass * iclass,
	       const char *action_params, Menu * child)
{
   MenuItem           *mi;

   mi = ECALLOC(MenuItem, 1);

   mi->icon_iclass = iclass;
#if 0
   if (iclass)
      ImageclassIncRefcount(iclass);
#endif

   mi->text = (text) ? Estrdup((text[0]) ? text : "?!?") : NULL;
   mi->params = Estrdup(action_params);
   mi->child = child;
   if (child)
      child->ref_count++;
   mi->state = STATE_NORMAL;

   return mi;
}
Esempio n. 10
0
static Snapshot    *
_SnapCreate(const char *name)
{
   Snapshot           *sn;

   sn = ECALLOC(Snapshot, 1);
   if (!sn)
      return NULL;

   LIST_APPEND(Snapshot, &ss_list, sn);

   sn->name = Estrdup(name);

   return sn;
}
Esempio n. 11
0
static ImageClass  *
ImageclassCreate(const char *name)
{
   ImageClass         *ic;

   ic = ECALLOC(ImageClass, 1);
   if (!ic)
      return NULL;

   LIST_PREPEND(ImageClass, &iclass_list, ic);

   ic->name = Estrdup(name);

   return ic;
}
Esempio n. 12
0
File: iclass.c Progetto: Limsik/e17
static ImageState  *
ImagestateCreate(const char *file)
{
   ImageState         *is;

   is = ECALLOC(ImageState, 1);
   if (!is)
      return NULL;

   is->pixmapfillstyle = FILL_STRETCH;
   ImagestateColorsSetGray(is, 255, 200, 160, 120, 64);
   is->bevelstyle = BEVEL_NONE;
   is->im_file = Estrdup(file);

   return is;
}
Esempio n. 13
0
static void
EDirsSetup(void)
{
    const char         *home;
    char                s[1024], *cfgdir;

    home = userhome();
    EDirCheck(home);

    /* Set user config dir if not already set */
    cfgdir = Mode.conf.dir;
    if (!cfgdir)
    {
        Esnprintf(s, sizeof(s), "%s/.e16", home);
        Mode.conf.dir = cfgdir = Estrdup(s);
    }

    if (exists(cfgdir))
    {
        if (!isdir(cfgdir))
        {
            Esnprintf(s, sizeof(s), "%s.old", cfgdir);
            E_mv(cfgdir, s);
            E_md(cfgdir);
        }
        else
            EDirCheck(cfgdir);
    }
    else
        E_md(cfgdir);

    if (!Mode.conf.cache_dir)
        Mode.conf.cache_dir = cfgdir;	/* Beware if ever freed */

    Esnprintf(s, sizeof(s), "%s/menus", cfgdir);
    Mode.firsttime = !exists(s);

    EDirMake(Mode.conf.dir, "themes");
    EDirMake(Mode.conf.dir, "backgrounds");
    EDirMake(Mode.conf.dir, "menus");

    EDirMake(Mode.conf.cache_dir, "cached");
    EDirMake(Mode.conf.cache_dir, "cached/cfg");
    EDirMake(Mode.conf.cache_dir, "cached/bgsel");
    EDirMake(Mode.conf.cache_dir, "cached/img");
    EDirMake(Mode.conf.cache_dir, "cached/pager");
}
Esempio n. 14
0
File: iclass.c Progetto: Limsik/e17
static ImageClass  *
ImageclassCreate(const char *name)
{
   ImageClass         *ic;

   ic = ECALLOC(ImageClass, 1);
   if (!ic)
      return NULL;

   if (!iclass_list)
      iclass_list = ecore_list_new();
   ecore_list_prepend(iclass_list, ic);

   ic->name = Estrdup(name);

   return ic;
}
Esempio n. 15
0
static MenuStyle   *
MenuStyleCreate(const char *name)
{
   MenuStyle          *ms;

   ms = ECALLOC(MenuStyle, 1);
   if (!ms)
      return NULL;

   if (!menu_style_list)
      menu_style_list = ecore_list_new();
   ecore_list_prepend(menu_style_list, ms);

   ms->name = Estrdup(name);
   ms->iconpos = ICON_LEFT;

   return ms;
}
Esempio n. 16
0
int
symbol_add(object_t **obj, char *sym, void *arg, int type)
{
    symbol_t *p, **q;

    _ASSERT(obj != NULL);
    _ASSERT(sym != NULL);

    p = (symbol_t *)Emalloc(sizeof(symbol_t));
    p->next = NULL;
    p->type = type;
    p->sym = Estrdup(sym);
    p->u.ptr = arg;

    for (q = (symbol_t **)obj; *q != NULL; q = &((*q)->next))
        continue;
    *q = p;

    return 0;
}
Esempio n. 17
0
struct place_object *create_place(struct place_object *place, char *tag)
{
  struct place_object *p;
  
  p = (struct place_object *) Emalloc(PLAOBJ_SIZE);
  p->tag = (char *) Estrdup(tag);
  p->color = NULL;
  p->lisp  = NULL;
  p->mpar  = NULL;
  p->layer  = NewLayerList(WHOLENET,NULL);
  p->cmark  = NULL;
  p->center.x = place->center.x;
  p->center.y = place->center.y;
  p->tagpos.x = place->tagpos.x;
  p->tagpos.y = place->tagpos.y;
  p->colpos.x = place->colpos.x;
  p->colpos.y = place->colpos.y;
  p->next = NULL;  
  return(p);
}
Esempio n. 18
0
/*
 * The user control config is called "~/.e16/e_config-$DISPLAY"
 * The client data appends ".clients" onto this filename and the snapshot data
 * appends ".snapshots".
 */
static void
ESavePrefixSetup(void)
{
#define ECFG_DEFAULT "e_config"
    char               *s, buf[1024];

    if (Mode.conf.name)
        Esnprintf(buf, sizeof(buf), "%s/%s-%d",
                  Mode.conf.dir, Mode.conf.name, Dpy.screen);
    else if (Mode.wm.window)
        Esnprintf(buf, sizeof(buf), "%s/%s-window", Mode.conf.dir, ECFG_DEFAULT);
    else
        Esnprintf(buf, sizeof(buf), "%s/%s-%s",
                  Mode.conf.dir, ECFG_DEFAULT, Dpy.name);

    Mode.conf.prefix = Estrdup(buf);

    for (s = Mode.conf.prefix; (s = strchr(s, ':')); *s = '-')
        ;
}
Esempio n. 19
0
static ToolTip     *
TooltipCreate(const char *name, const char *ic0, const char *ic1,
	      const char *ic2, const char *ic3, const char *ic4,
	      const char *tclass, int dist, const char *tooltippic)
{
   ToolTip            *tt;
   ImageClass         *ic;

   if (!ic0 || !tclass)
      return NULL;

   ic = ImageclassAlloc(ic0, 0);
   if (!ic)
      return NULL;

   tt = ECALLOC(ToolTip, 1);
   if (!tt)
      return NULL;

   tt->name = Estrdup(name);
   tt->iclass[0] = ImageclassAlloc(ic1, 0);
   tt->iclass[1] = ImageclassAlloc(ic2, 0);
   tt->iclass[2] = ImageclassAlloc(ic3, 0);
   tt->iclass[3] = ImageclassAlloc(ic4, 0);
   tt->iclass[4] = ic;
   tt->tclass = TextclassAlloc(tclass, 1);
   tt->tooltippic = ImageclassAlloc(tooltippic, 0);

   tt->dist = dist;

   if (!tt_list)
      tt_list = ecore_list_new();
   ecore_list_prepend(tt_list, tt);

   return tt;
}
Esempio n. 20
0
void openlog(const char * const ident, int option, int  facility)
{	static FLAG8 recursive = 0;			/* to prevent recursive calls
											to openlog() when using
											syslogo() */
	DBG_ENTER("openlog", Suppl_syslog)

		/* "++semaphore" is considered an atomic operation by
			many programs; it's native C's best approximation
			for the P(semaphore) operation */
	if(++recursive == 1		/* not recursively called */
	 && ++syslog_opencount == 1) {	/* not opened til now */
	 	/* When these statements are executed, no logfile has
	 		been opened so far. That means that they can be logged
	 		onto STDERR only. */
		chkHeap
		syslog_options = option;
		syslog_facility = facility;
		syslog_ident = Estrdup(ident);
		if((syslog_fnam = appNameEx()) == 0)
			Esuppl_noMem();
		syslog_fnam = SYSLOG_FNAM(syslog_fnam);
		syslog_logfile = Eopen(syslog_fnam, syslog_openmode);
		chkHeap
	}
Esempio n. 21
0
static void
EDirUserCacheSet(const char *dir)
{
    Efree(Mode.conf.cache_dir);
    Mode.conf.cache_dir = Estrdup(dir);
}
Esempio n. 22
0
static void
EDirUserSet(const char *dir)
{
    Efree(Mode.conf.dir);
    Mode.conf.dir = Estrdup(dir);
}
Esempio n. 23
0
File: session.c Progetto: Limsik/e17
static void
ice_init(void)
{
   static SmPointer    context;
   SmcCallbacks        callbacks;
   char                error_string_ret[4096];
   char               *client_id;
   char                style[2];
   SmPropValue         styleVal;
   SmProp              styleProp;
   SmProp             *props[1];
   int                 sm_fd;

   if (!getenv("SESSION_MANAGER"))
      return;

   IceSetIOErrorHandler(ice_io_error_handler);

   callbacks.save_yourself.callback = callback_save_yourself;
   callbacks.die.callback = callback_die;
   callbacks.save_complete.callback = callback_save_complete;
   callbacks.shutdown_cancelled.callback = callback_shutdown_cancelled;

   callbacks.save_yourself.client_data = callbacks.die.client_data =
      callbacks.save_complete.client_data =
      callbacks.shutdown_cancelled.client_data = (SmPointer) NULL;

   client_id = Estrdup(sm_client_id);

   error_string_ret[0] = '\0';

   sm_conn =
      SmcOpenConnection(NULL, &context, SmProtoMajor, SmProtoMinor,
			SmcSaveYourselfProcMask | SmcDieProcMask |
			SmcSaveCompleteProcMask |
			SmcShutdownCancelledProcMask, &callbacks,
			client_id, &sm_client_id, 4096, error_string_ret);
   Efree(client_id);

   if (error_string_ret[0])
      Eprintf("While connecting to session manager: %s.", error_string_ret);

   if (!sm_conn)
      return;

   style[0] = SmRestartIfRunning;
   style[1] = 0;

   styleVal.length = 1;
   styleVal.value = style;

   styleProp.name = (char *)SmRestartStyleHint;
   styleProp.type = (char *)SmCARD8;
   styleProp.num_vals = 1;
   styleProp.vals = &styleVal;

   props[0] = &styleProp;

   ice_conn = SmcGetIceConnection(sm_conn);
   sm_fd = IceConnectionNumber(ice_conn);
   /* Just in case we are a copy of E created by a doExit("restart") */
   SmcSetProperties(sm_conn, 1, props);
   fcntl(sm_fd, F_SETFD, fcntl(sm_fd, F_GETFD, 0) | FD_CLOEXEC);

   sm_efd = EventFdRegister(sm_fd, ice_msgs_process);
}
Esempio n. 24
0
struct trans_object *unfolding_transition(struct trans_object *t, int num, AssignmentPTR a, struct rpar_object **rpars)
{
  struct trans_object *result;
  struct rpar_object  *rpar, *rpar_curr;
  char *string_num;
  bool Already_defined;  
  
  result = (struct trans_object *) Emalloc(sizeof(struct trans_object));
  string_num = (char *) Ecalloc(TAG_SIZE, sizeof(char));
  sprintf(string_num, "_%d", num);
  result->tag = Estrdup(t->tag);
  result->tag = NewStringCat(result->tag, string_num);
  result->fire_rate.ff = t->fire_rate.ff;
  result->fire_rate.fp = t->fire_rate.fp;

  if(t->rpar!=NULL)
    result->rpar= t->rpar;
  else{
    Already_defined = FALSE;
    rpar = (struct rpar_object *) malloc(RPAOBJ_SIZE);
    rpar->tag = EmptyString();          
    rpar->tag = NewStringCat("Rate_",t->tag);
    
    for (rpar_curr = *rpars; rpar_curr != NULL && Already_defined == FALSE; rpar_curr = rpar_curr->next)
      if(strcmp(rpar_curr->tag, rpar->tag)==0){
        result->rpar= rpar_curr;
        Already_defined = TRUE;
      }
      
      
    if(Already_defined == FALSE){
      rpar->layer = NewLayerList(WHOLENET,NULL);
      rpar->value = t->fire_rate.ff;
      rpar->center.x = t->center.x +20;
      rpar->center.y = t->center.y +20;
      rpar->next = *rpars;      
      *rpars=rpar;      
      result->rpar= rpar;
    }    
  }
    
  result->enabl= t->enabl;
  result->kind= t->kind;
  result->mark_dep = t->mark_dep;
  result->center.x = t->center.x;
  result->center.y = t->center.y;
  result->tagpos.x = t->tagpos.x;
  result->tagpos.y = t->tagpos.y;
  result->colpos.x = t->colpos.x;
  result->colpos.y = t->colpos.y;  
  result->ratepos.x = t->ratepos.x;
  result->ratepos.y = t->ratepos.y;
  result->orient = t->orient;
  result->arcs = NULL;
  result->color = NULL;
  result->lisp = NULL;
  result->layer = NewLayerList(WHOLENET,NULL);
  result->next = NULL;

  fprintf(gTr_Ind_fp, "Transition %s : %s\n", result->tag, print_assignment(a));
    
  return(result);
}
Esempio n. 25
0
static void
_SnapUpdateEwinBorder(Snapshot * sn, const EWin * ewin)
{
   Efree(sn->border_name);
   sn->border_name = Estrdup(BorderGetName(ewin->normal_border));
}
Esempio n. 26
0
/* create a new one */
static Snapshot    *
_SnapEwinGet(EWin * ewin, unsigned int match_flags)
{
   Snapshot           *sn;
   char                buf[1024], *s;

   sn = _SnapEwinFind(ewin);
   if (sn)
      return sn;

   if ((match_flags & SNAP_MATCH_TITLE) && !EwinGetIcccmName(ewin))
      match_flags ^= SNAP_MATCH_TITLE;
   if ((match_flags & SNAP_MATCH_NAME) && !EwinGetIcccmCName(ewin))
      match_flags ^= SNAP_MATCH_NAME;
   if ((match_flags & SNAP_MATCH_CLASS) && !EwinGetIcccmClass(ewin))
      match_flags ^= SNAP_MATCH_CLASS;
   if ((match_flags & SNAP_MATCH_ROLE) && !ewin->icccm.wm_role)
      match_flags ^= SNAP_MATCH_ROLE;
   if (match_flags == 0)
     {
	if (!EwinGetIcccmName(ewin))
	   return NULL;
	match_flags = SNAP_MATCH_TITLE;
     }

   sn = _SnapCreate(NULL);
   if (!sn)
      return NULL;

   sn->match_flags = match_flags;
   if (match_flags & SNAP_MATCH_TITLE)
      sn->win_title = Estrdup(EwinGetIcccmName(ewin));
   if (match_flags & SNAP_MATCH_NAME)
      sn->win_name = Estrdup(EwinGetIcccmCName(ewin));
   if (match_flags & SNAP_MATCH_CLASS)
      sn->win_class = Estrdup(EwinGetIcccmClass(ewin));
   if (match_flags & SNAP_MATCH_ROLE)
     {
	s = _ParseRole(ewin->icccm.wm_role, buf, sizeof(buf));
	sn->win_role = Estrdup(s);
     }

   /* Set the snap name. Has no particular significance. */
   if ((sn->win_name || sn->win_class) && sn->win_role)
      Esnprintf(buf, sizeof(buf), "%s.%s:%s", ST(sn->win_name),
		ST(sn->win_class), sn->win_role);
   else if (sn->win_name || sn->win_class)
      Esnprintf(buf, sizeof(buf), "%s.%s", ST(sn->win_name), ST(sn->win_class));
   else if (sn->win_title)
      Esnprintf(buf, sizeof(buf), "TITLE.%s", sn->win_title);
   else				/* We should not go here */
      Esnprintf(buf, sizeof(buf), "TITLE.%s", EwinGetIcccmName(ewin));
   sn->name = Estrdup(buf);

   if (!(sn->match_flags & SNAP_MATCH_MULTIPLE))
     {
	sn->used = ewin;
	ewin->snap = sn;
     }

   return sn;
}
Esempio n. 27
0
int
main(int argc, char **argv)
{
    int                 ch, i, loop;
    struct utsname      ubuf;
    const char         *str, *dstr;

    /* This function runs all the setup for startup, and then
     * proceeds into the primary event loop at the end.
     */

    /* Init state variable struct */
    memset(&Mode, 0, sizeof(EMode));

    Mode.wm.master = 1;
    Mode.wm.pid = getpid();
    Mode.wm.exec_name = argv[0];
    Mode.wm.startup = 1;

    Mode.mode = MODE_NONE;

    EXInit();
    Dpy.screen = -1;

    str = getenv("EDEBUG");
    if (str)
        EDebugInit(str);
    str = getenv("EDEBUG_COREDUMP");
    if (str)
        Mode.wm.coredump = 1;
    str = getenv("EDEBUG_EXIT");
    if (str)
        Mode.debug_exit = atoi(str);

    str = getenv("ECONFNAME");
    if (str)
        EConfNameSet(str);
    str = getenv("ECONFDIR");
    if (str)
        EDirUserSet(str);
    str = getenv("ECACHEDIR");
    if (str)
        EDirUserCacheSet(str);

    srand((unsigned int)time(NULL));

    if (!uname(&ubuf))
        Mode.wm.machine_name = Estrdup(ubuf.nodename);
    if (!Mode.wm.machine_name)
        Mode.wm.machine_name = Estrdup("localhost");

    /* Now we're going to interpret any of the commandline parameters
     * that are passed to it -- Well, at least the ones that we
     * understand.
     */

    Mode.theme.path = NULL;
    dstr = NULL;

    for (loop = 1; loop;)
    {
        ch = EoptGet(argc, argv);
        if (ch <= 0)
            break;
#if 0
        Eprintf("Opt: %c: %d - %s\n", ch, eoptind, eoptarg);
#endif
        switch (ch)
        {
        default:
        case '?':
            printf("e16: Ignoring: ");
            for (i = eoptind; i < argc; i++)
                printf("%s ", argv[i]);
            printf("\n");
            loop = 0;
            break;
        case 'h':
            EoptHelp();
            exit(0);
            break;
        case 'd':
            dstr = eoptarg;
            break;
        case 'f':
            Mode.wm.restart = 1;
            break;
        case 'p':
            EConfNameSet(eoptarg);
            break;
        case 'P':
            EDirUserSet(eoptarg);
            break;
        case 'Q':
            EDirUserCacheSet(eoptarg);
            break;
        case 's':
            Mode.wm.single = 1;
            Dpy.screen = strtoul(eoptarg, NULL, 10);
            break;
        case 'S':
            SetSMID(eoptarg);
            break;
        case 't':
            Mode.theme.path = Estrdup(eoptarg);
            break;
        case 'V':
            printf("%s %s\n", e_wm_name, e_wm_version);
            exit(0);
            break;
        case 'v':
            EDebugSet(EDBUG_TYPE_VERBOSE, 1);
            break;
        case 'w':
            sscanf(eoptarg, "%dx%d", &Mode.wm.win_w, &Mode.wm.win_h);
            Mode.wm.window = 1;
            Mode.wm.single = 1;
            Mode.wm.master = 0;
            break;
#ifdef USE_EXT_INIT_WIN
        case 'X':
            ExtInitWinSet(strtoul(eoptarg, NULL, 0));
            Mode.wm.restart = 1;
            break;
#endif
        case 'm':
            Mode.wm.master = 0;
            Mode.wm.master_screen = strtoul(eoptarg, NULL, 10);
            break;
        }
    }

    SignalsSetup();		/* Install signal handlers */

    EDirsSetup();
    ECheckEprog("epp");
    ECheckEprog("eesh");

    SetupX(dstr);		/* This is where the we fork per screen */
    /* X is now running, and we have forked per screen */

    ESavePrefixSetup();

    /* So far nothing should rely on a selected settings or theme. */
    ConfigurationLoad();		/* Load settings */

    /* Initialise internationalisation */
    LangInit();

    /* The theme path must now be available for config file loading. */
    ThemePathFind();

    /* Set the Environment variables */
    Esetenv("EVERSION", e_wm_version);
    Esetenv("EROOT", EDirRoot());
    Esetenv("EBIN", EDirBin());
    Esetenv("ECONFDIR", EDirUser());
    Esetenv("ECACHEDIR", EDirUserCache());
    Esetenv("ETHEME", Mode.theme.path);

    /* Move elsewhere? */
    EImageInit();
    HintsInit();
    CommsInit();
    SessionInit();
    SnapshotsLoad();

#if USE_DBUS
    DbusInit();
#endif

    if (Mode.wm.window)
        EMapWindow(VROOT);

    ModulesSignal(ESIGNAL_INIT, NULL);

    /* Load the theme */
    ThemeConfigLoad();

    if (Mode.debug_exit)
        return 0;

    /* Do initial configuration */
    ModulesSignal(ESIGNAL_CONFIGURE, NULL);

    /* Set root window cursor */
    ECsrApply(ECSR_ROOT, WinGetXwin(VROOT));

#ifdef USE_EXT_INIT_WIN
    /* Kill the E process owning the "init window" */
    ExtInitWinKill();
#endif

    /* let's make sure we set this up and go to our desk anyways */
    DeskGoto(DesksGetCurrent());
    ESync(ESYNC_MAIN);

#ifdef SIGCONT
    for (i = 0; i < Mode.wm.child_count; i++)
        kill(Mode.wm.children[i], SIGCONT);
#endif

    ModulesSignal(ESIGNAL_START, NULL);
#if ENABLE_DIALOGS
    DialogsInit();
#endif
    EwinsManage();

    RunInitPrograms();
    SnapshotsSpawn();

    if (!Mode.wm.restart)
        StartupWindowsOpen();

    Conf.startup.firsttime = 0;
    Mode.wm.save_ok = Conf.autosave;
    Mode.wm.startup = 0;
    autosave();

    /* The primary event loop */
    EventsMain();

    SessionExit(EEXIT_QUIT, NULL);

    return 0;
}
Esempio n. 28
0
/*
 * This function sets up all of our connections to X
 */
void
SetupX(const char *dstr)
{
   int                 err;
   char                buf[128];
   unsigned int        mask;

   if (!dstr)
      dstr = getenv("DISPLAY");
   if (!dstr)
      dstr = ":0.0";

   /* Open a connection to the diplay nominated by the DISPLAY variable */
   err = EDisplayOpen(dstr, Dpy.screen);
   if (err)
     {
	Alert(_("Enlightenment cannot connect to the display nominated by\n"
		"your shell's DISPLAY environment variable. You may set this\n"
		"variable to indicate which display name Enlightenment is to\n"
		"connect to. It may be that you do not have an Xserver already\n"
		"running to serve that Display connection, or that you do not\n"
		"have permission to connect to that display. Please make sure\n"
		"all is correct before trying again. Run an Xserver by running\n"
		"xdm or startx first, or contact your local system\n"
		"administrator, or Xserver vendor, or read the X, xdm and\n"
		"startx manual pages before proceeding.\n"));
	EExit(1);
     }

   if (getenv("ESYNCHRONIZE"))
      XSynchronize(disp, True);

   Dpy.screens = ScreenCount(disp);
   Dpy.screen = DefaultScreen(disp);

   if (Mode.wm.master ||
       Mode.wm.master_screen < 0 || Mode.wm.master_screen >= Dpy.screens)
      Mode.wm.master_screen = Dpy.screen;

   /* Start up on multiple heads, if appropriate */
   if (Dpy.screens > 1 && !Mode.wm.single && !Mode.wm.restart)
     {
	int                 i;

	for (i = 0; i < Dpy.screens; i++)
	  {
	     pid_t               pid;

	     if (i == Dpy.screen)
		continue;

	     pid = fork();
	     if (pid)
	       {
		  /* We are the master */
		  Mode.wm.child_count++;
		  Mode.wm.children =
		     EREALLOC(pid_t, Mode.wm.children, Mode.wm.child_count);
		  Mode.wm.children[Mode.wm.child_count - 1] = pid;
	       }
	     else
	       {
		  /* We are a slave */
		  EDisplayDisconnect();
		  Mode.wm.master = 0;
		  Mode.wm.pid = getpid();
		  Dpy.screen = i;
		  ExtInitWinSet(NoXID);
#ifdef SIGSTOP
		  kill(getpid(), SIGSTOP);
#endif
		  EDisplayOpen(dstr, i);
		  /* Terminate the loop as I am the child process... */
		  break;
	       }
	  }
     }

   Dpy.name = Estrdup(DisplayString(disp));
   Esetenv("DISPLAY", Dpy.name);

   Dpy.pixel_black = BlackPixel(disp, Dpy.screen);
   Dpy.pixel_white = WhitePixel(disp, Dpy.screen);

   EDisplaySetErrorHandlers(EventShowError, HandleXIOError);

   /* Root defaults */
   RROOT = ERegisterWindow(DefaultRootWindow(disp), NULL);

   if (Mode.wm.window)
     {
	VROOT = ECreateWindow(RROOT, 0, 0, Mode.wm.win_w, Mode.wm.win_h, 0);

	/* Enable eesh and edox to pick up the virtual root */
	Esnprintf(buf, sizeof(buf), "%#x", WinGetXwin(VROOT));
	Esetenv("ENL_WM_ROOT", buf);
     }
   else
     {
	/* Running E normally on the root window */
	VROOT = RROOT;
     }

   Dpy.root_gc = EXCreateGC(WinGetXwin(VROOT), 0, NULL);

   /* Initialise event handling */
   EventsInit();

   /* select all the root window events to start managing */
   Dpy.last_error_code = 0;
   mask =
      StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Another Window Manager is already running"),
	       _("OK"), NULL, NULL,
	       _("Another Window Manager is already running.\n" "\n"
		 "You will have to quit your current Window Manager first before\n"
		 "you can successfully run Enlightenment.\n"));
	EExit(1);
     }

   mask |= ButtonPressMask | ButtonReleaseMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Cannot select root window button press events"),
	       _("OK"), NULL, NULL,
	       _("Root window button actions will not work.\n"));
     }

   /* warn, if necessary about X version problems */
   if (ProtocolVersion(disp) != 11)
     {
	AlertX(_("X server version error"), _("Ignore this error"), "",
	       _("Quit Enlightenment"),
	       _("WARNING:\n"
		 "This is not an X11 Xserver. It in fact talks the X%i protocol.\n"
		 "This may mean Enlightenment will either not function, or\n"
		 "function incorrectly. If it is later than X11, then your\n"
		 "server is one the author of Enlightenment neither have\n"
		 "access to, nor have heard of.\n"), ProtocolVersion(disp));
     }

   /* damn that bloody numlock stuff - ok I'd rather XFree got fixed to not */
   /* have it as a modifier and everyone have to write specific code to mask */
   /* it out - but well.... */
   /* ok under Xfree Numlock and Scollock are lock modifiers and we need */
   /* to hunt them down to mask them out - EVIL EVIL EVIL hack but needed */
   {
      XModifierKeymap    *mod;
      EX_KeyCode          nl, sl;
      unsigned int        numlock, scrollock;
      int                 i;

      int                 masks[8] = {
	 ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask,
	 Mod4Mask, Mod5Mask
      };

      numlock = scrollock = 0;
      mod = XGetModifierMapping(disp);
      nl = EKeysymToKeycode(XK_Num_Lock);
      sl = EKeysymToKeycode(XK_Scroll_Lock);
      if ((mod) && (mod->max_keypermod > 0))
	{
	   for (i = 0; i < (8 * mod->max_keypermod); i++)
	     {
		if ((nl) && (mod->modifiermap[i] == nl))
		   numlock = masks[i / mod->max_keypermod];
		else if ((sl) && (mod->modifiermap[i] == sl))
		   scrollock = masks[i / mod->max_keypermod];
	     }
	}
      Mode.masks.mod_combos[0] = 0;
      Mode.masks.mod_combos[1] = LockMask;
      if (numlock)
	{
	   Mode.masks.mod_combos[2] = numlock;
	   Mode.masks.mod_combos[5] = LockMask | numlock;
	}
      if (scrollock)
	{
	   Mode.masks.mod_combos[3] = scrollock;
	   Mode.masks.mod_combos[6] = LockMask | scrollock;
	}
      if (numlock && scrollock)
	{
	   Mode.masks.mod_combos[4] = numlock | scrollock;
	   Mode.masks.mod_combos[7] = LockMask | numlock | scrollock;
	}

      Mode.masks.mod_key_mask =
	 (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask |
	  Mod5Mask) & (~(numlock | scrollock | LockMask));

      if (mod)
	 XFreeModifiermap(mod);
   }

   ScreenInit();
}