Exemplo n.º 1
0
Arquivo: x.c Projeto: Limsik/e17
Win
ECreateObjectWindow(Win parent, int x, int y, int w, int h, int saveunder,
		    int type, Win cwin)
{
   Win                 win;
   int                 argb = 0;

   switch (type)
     {
     default:
     case WIN_TYPE_NO_ARGB:
	break;
     case WIN_TYPE_CLIENT:
	if (Conf.testing.argb_clients || EVisualIsARGB(cwin->visual))
	   argb = 1;
	break;
     case WIN_TYPE_INTERNAL:
	if (Conf.testing.argb_internal_objects)
	   argb = 1;
	break;
#if USE_GLX
     case WIN_TYPE_GLX:	/* Internal GL */
	win =
	   ECreateWindowVD(parent, x, y, w, h, EGlGetVisual(), EGlGetDepth());
	return win;
#endif
     }

   if (argb)
      win = ECreateArgbWindow(parent, x, y, w, h, cwin);
   else
      win = ECreateWindow(parent, x, y, w, h, saveunder);

   return win;
}
Exemplo n.º 2
0
Arquivo: x.c Projeto: Limsik/e17
Win
ECreateClientWindow(Win parent, int x, int y, int w, int h)
{
#if USE_COMPOSITE
   if (Conf.testing.argb_internal_clients)
      return ECreateArgbWindow(parent, x, y, w, h, NULL);
#endif

   return ECreateWindow(parent, x, y, w, h, 0);
}
Exemplo n.º 3
0
static void
TooltipRealize(ToolTip * tt)
{
   int                 i, wh;
   EObj               *eo;

   for (i = 0; i < 5; i++)
     {
	if (!tt->iclass[i])
	   continue;

	wh = (i + 1) * 8;
	eo = EobjWindowCreate(EOBJ_TYPE_MISC, -50, -100, wh, wh, 1, tt->name);
	eo->fade = eo->shadow = 1;
	EobjChangeOpacity(eo, OpacityFromPercent(Conf.opacity.tooltips));
	tt->win[i] = eo;
     }
   tt->iwin = ECreateWindow(EobjGetWin(tt->TTWIN), 0, 0, 1, 1, 0);
}
Exemplo n.º 4
0
Arquivo: x.c Projeto: Limsik/e17
Win
ECreateObjectWindow(Win parent, int x, int y, int w, int h, int saveunder,
		    int type __UNUSED__, Win cwin __UNUSED__)
{
   return ECreateWindow(parent, x, y, w, h, saveunder);
}
Exemplo n.º 5
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();
}
Exemplo n.º 6
0
Arquivo: warp.c Projeto: Limsik/e17
static void
WarpFocusWinShow(WarpFocusWin * fw)
{
   WarplistItem       *wi;
   EImageBorder       *pad;
   EWin               *ewin;
   int                 i, x, y, w, h, ww, hh;
   char                s[1024], ss[32];
   const char         *fmt;

   w = 0;
   h = 0;
   pad = ImageclassGetPadding(fw->ic);

   for (i = 0; i < warplist_num; i++)
     {
	wi = warplist + i;
	wi->win = ECreateWindow(EoGetWin(fw), 0, 0, 1, 1, 0);
	EMapWindow(wi->win);

	ewin = wi->ewin;
	if (ewin->state.iconified)
	   fmt = "%s[%s]";
	else if (ewin->state.shaded)
	   fmt = "%s=%s=";
	else
	   fmt = "%s%s";
	ss[0] = '\0';
	if (Conf.warplist.showalldesks)
	  {
	     if (EoIsSticky(ewin) || ewin->state.iconified)
		strcpy(ss, "[-] ");
	     else
		Esnprintf(ss, sizeof(ss), "[%d] ", EoGetDeskNum(ewin));
	  }
	Esnprintf(s, sizeof(s), fmt, ss, EwinGetTitle(ewin));
	wi->txt = strdup(s);
	TextSize(fw->tc, 0, 0, 0, wi->txt, &ww, &hh, 17);
	if (ww > w)
	   w = ww;
	if (hh > h)
	   h = hh;
     }

   fw->tw = w;			/* Text size */
   fw->th = h;
   w += pad->left + pad->right;
   h += pad->top + pad->bottom;
   if (Conf.warplist.icon_mode != 0)
     {
	if (Conf.warplist.icon_mode != EWIN_ICON_MODE_APP_IMG &&
	    Conf.warplist.icon_mode != EWIN_ICON_MODE_IMG_APP)
	   Conf.warplist.icon_mode = EWIN_ICON_MODE_APP_IMG;
	w += h;
     }
   fw->mw = w;			/* Focus list item size */
   fw->mh = h;

   /* Reset shape */
   EShapeSetMask(EoGetWin(fw), 0, 0, None);

   ScreenGetAvailableAreaByPointer(&x, &y, &ww, &hh, Conf.place.ignore_struts);
   x += (ww - w) / 2;
   y += (hh - h * warplist_num) / 2;
   EoMoveResize(fw, x, y, w, h * warplist_num);

   for (i = 0; i < warplist_num; i++)
      EMoveResizeWindow(warplist[i].win, 0, (h * i), fw->mw, fw->mh);

   EoMap(fw, 0);

   /*
    * Grab the keyboard. The grab is automatically released when
    * WarpFocusHide unmaps warpFocusWindow.
    */
   GrabKeyboardSet(EoGetWin(fw));
   GrabPointerSet(EoGetWin(fw), None, 0);

   TooltipsEnable(0);
}
Exemplo n.º 7
0
static void
MenuRealize(Menu * m)
{
   int                 i, maxh, maxw, nmaxy;
   int                 maxx1, maxx2, w, h, x, y, r, mmw, mmh;
   EImage             *im;
   EImageBorder       *pad, *pad_item, *pad_sub;
   char                has_i, has_s;

   if (m->num <= 0)
      return;

   if (!m->style)
     {
	MenuSetStyle(m, NULL);
	if (!m->style)
	   return;
     }

   if (!m->win)
     {
	m->win = ECreateClientWindow(VROOT, 0, 0, 1, 1);
	EventCallbackRegister(m->win, MenuHandleEvents, m);
     }

   maxh = maxw = 0;
   maxx1 = 0;
   maxx2 = 0;
   has_i = 0;
   has_s = 0;

   for (i = 0; i < m->num; i++)
     {
	m->items[i]->menu = m;

	if (m->items[i]->child)
	   has_s = 1;
	else
	   has_i = 1;

	m->items[i]->win = ECreateWindow(m->win, 0, 0, 1, 1, 0);
	EventCallbackRegister(m->items[i]->win, MenuItemHandleEvents,
			      m->items[i]);
	ESelectInput(m->items[i]->win, MENU_ITEM_EVENT_MASK);
	EMapWindow(m->items[i]->win);

	if ((m->style->tclass) && (m->items[i]->text))
	  {
	     TextSize(m->style->tclass, 0, 0, 0, _(m->items[i]->text), &w, &h,
		      17);
	     if (h > maxh)
		maxh = h;
	     if (w > maxx1)
		maxx1 = w;
	     m->items[i]->text_w = w;
	     m->items[i]->text_h = h;
	  }
	if (m->items[i]->icon_iclass && Conf.menus.show_icons)
	  {
	     im = ImageclassGetImage(m->items[i]->icon_iclass, 0, 0, 0);
	     if (im)
	       {
		  w = h = 0;
		  if (m->icon_size > 0)
		     w = h = m->icon_size;
		  else if (m->icon_size == 0)
		     w = h = Conf.menus.icon_size;
		  if (w <= 0 || h <= 0)
		     EImageGetSize(im, &w, &h);
		  m->items[i]->icon_w = w;
		  m->items[i]->icon_h = h;
		  m->items[i]->icon_win =
		     ECreateWindow(m->items[i]->win, 0, 0, w, h, 0);
		  EMapWindow(m->items[i]->icon_win);
		  if (h > maxh)
		     maxh = h;
		  if (w > maxx2)
		     maxx2 = w;
		  EImageFree(im);
	       }
	     else
		m->items[i]->icon_iclass = NULL;
	  }
     }

   pad = ImageclassGetPadding(m->style->bg_iclass);
   pad_item = ImageclassGetPadding(m->style->item_iclass);
   pad_sub = ImageclassGetPadding(m->style->sub_iclass);
   if (((has_i) && (has_s)) || ((!has_i) && (!has_s)))
     {
	if (pad_item->top > pad_sub->top)
	   maxh += pad_item->top;
	else
	   maxh += pad_sub->top;
	if (pad_item->bottom > pad_sub->bottom)
	   maxh += pad_item->bottom;
	else
	   maxh += pad_sub->bottom;
	maxw = maxx1 + maxx2;
	if (pad_item->left > pad_sub->left)
	   maxw += pad_item->left;
	else
	   maxw += pad_sub->left;
	if (pad_item->right > pad_sub->right)
	   maxw += pad_item->right;
	else
	   maxw += pad_sub->right;
     }
   else if (has_i)
     {
	maxh += pad_item->top;
	maxh += pad_item->bottom;
	maxw = maxx1 + maxx2;
	maxw += pad_item->left;
	maxw += pad_item->right;
     }
   else if (has_s)
     {
	maxh += pad_sub->top;
	maxh += pad_sub->bottom;
	maxw = maxx1 + maxx2;
	maxw += pad_sub->left;
	maxw += pad_sub->right;
     }

   mmw = 0;
   mmh = 0;

   nmaxy = 3 * WinGetH(VROOT) / (4 * maxh + 1);
   if (m->style->maxy && nmaxy > m->style->maxy)
      nmaxy = m->style->maxy;

   r = 0;
   x = 0;
   y = 0;
   for (i = 0; i < m->num; i++)
     {
	if (r == 0 && (m->style->bg_iclass) && (!m->style->use_item_bg))
	  {
	     x += pad->left;
	     y += pad->top;
	  }
	EMoveResizeWindow(m->items[i]->win, x, y, maxw, maxh);
	if (m->style->iconpos == ICON_LEFT)
	  {
	     m->items[i]->text_x = pad_item->left + maxx2;
	     m->items[i]->text_w = maxx1;
	     m->items[i]->text_y = (maxh - m->items[i]->text_h) / 2;
	     if (m->items[i]->icon_win)
		EMoveWindow(m->items[i]->icon_win,
			    pad_item->left +
			    ((maxx2 - m->items[i]->icon_w) / 2),
			    ((maxh - m->items[i]->icon_h) / 2));
	  }
	else
	  {
	     m->items[i]->text_x = pad_item->left;
	     m->items[i]->text_w = maxx1;
	     m->items[i]->text_y = (maxh - m->items[i]->text_h) / 2;
	     if (m->items[i]->icon_win)
		EMoveWindow(m->items[i]->icon_win,
			    maxw - pad_item->right - maxx2 +
			    ((maxx2 - m->items[i]->icon_w) / 2),
			    ((maxh - m->items[i]->icon_h) / 2));
	  }
	if (m->items[i]->icon_iclass && Conf.menus.show_icons)
	  {
	     ImageclassApply(m->items[i]->icon_iclass, m->items[i]->icon_win,
			     0, 0, STATE_NORMAL, ST_MENU_ITEM);
	  }
	if (x + maxw > mmw)
	   mmw = x + maxw;
	if (y + maxh > mmh)
	   mmh = y + maxh;
	if ((m->style->maxx) || (nmaxy))
	  {
	     if (nmaxy)
	       {
		  y += maxh;
		  r++;
		  if (r >= nmaxy)
		    {
		       r = 0;
		       x += maxw;
		       y = 0;
		    }
	       }
	     else
	       {
		  x += maxw;
		  r++;
		  if (r >= m->style->maxx)
		    {
		       r = 0;
		       y += maxh;
		       x = 0;
		    }
	       }
	  }
	else
	   y += maxh;
     }

   if ((m->style->bg_iclass) && (!m->style->use_item_bg))
     {
	mmw += pad->right;
	mmh += pad->bottom;
     }

   m->redraw = 1;
   m->w = mmw;
   m->h = mmh;
   EResizeWindow(m->win, mmw, mmh);
}
Exemplo n.º 8
0
Arquivo: startup.c Projeto: Limsik/e17
void
StartupWindowsCreate(void)
{
   Win                 w1, w2, win1, win2, b1, b2;
   Background         *bg;
   ImageClass         *ic;
   int                 x, y, bx, by, bw, bh, dbw;
   EObj               *eo;

   /* Acting only as boolean? */
   if (BackgroundFind("STARTUP_BACKGROUND_SIDEWAYS"))
      bg_sideways = 1;

   ic = ImageclassFind("STARTUP_BAR", 0);
   if (!ic)
      ic = ImageclassFind("DESKTOP_DRAGBUTTON_HORIZ", 0);
   bg = BackgroundFind("STARTUP_BACKGROUND");
   if (!ic || !bg)
      return;

   dbw = Conf.desks.dragbar_width;
   if (dbw <= 0)
      dbw = 16;
   if (bg_sideways)
     {
	x = WinGetW(VROOT) / 2;
	y = 0;
	bx = WinGetW(VROOT) - dbw;
	by = 0;
	bw = dbw;
	bh = WinGetH(VROOT);
     }
   else
     {
	x = 0;
	y = WinGetH(VROOT) / 2;
	bx = 0;
	by = WinGetH(VROOT) - dbw;
	bw = WinGetW(VROOT);
	bh = dbw;
     }

   eo = EobjWindowCreate(EOBJ_TYPE_MISC,
			 -x, -y, WinGetW(VROOT), WinGetH(VROOT), 1, "Init-1");
   if (!eo)
      return;
   init_win1 = eo;
   w1 = EobjGetWin(eo);
   win1 = ECreateWindow(w1, x, y, WinGetW(VROOT), WinGetH(VROOT), 0);

   eo = EobjWindowCreate(EOBJ_TYPE_MISC,
			 x, y, WinGetW(VROOT), WinGetH(VROOT), 1, "Init-2");
   if (!eo)
      return;
   init_win2 = eo;
   w2 = EobjGetWin(eo);
   win2 = ECreateWindow(w2, -x, -y, WinGetW(VROOT), WinGetH(VROOT), 0);

   EMapWindow(win1);
   EMapWindow(win2);

   if (bw > 0 && bh > 0)
     {
	b1 = ECreateWindow(w1, bx, by, bw, bh, 0);
	b2 = ECreateWindow(w2, 0, 0, bw, bh, 0);
	EMapRaised(b1);
	EMapRaised(b2);

	ImageclassApply(ic, b1, 0, 0, 0, ST_SOLID);
	ImageclassApply(ic, b2, 0, 0, 0, ST_SOLID);
     }

   BackgroundSet(bg, win1, WinGetW(VROOT), WinGetH(VROOT));
   BackgroundSet(bg, win2, WinGetW(VROOT), WinGetH(VROOT));
   StartupBackgroundsDestroy();

   EobjMap(init_win1, 0);
   EobjMap(init_win2, 0);

   EobjsRepaint();
}