Esempio n. 1
0
File: iconify.c Progetto: Limsik/e17
static Container   *
SelectIconboxForEwin(EWin * ewin)
{
   /* find the appropriate iconbox from all available ones for this app */
   /* if it is to be iconified, or if it is alreayd return which iconbox */
   /* it's in */
   Container          *ct, *ib_sel = NULL;

   if (!ewin)
      return NULL;

   if (ewin->state.iconified)
     {
	/* find the iconbox this window got iconifed into */
	ib_sel = ContainersIterate(IconboxFindEwin, IB_TYPE_ICONBOX, ewin);
     }
   else
     {
	/* pick the closest iconbox physically on screen to put it in */
	int                 min_dist;
	int                 dx, dy, dist;
	int                 i, num;
	Container         **lst;

	lst = ContainersGetList(&num);
	min_dist = 0x7fffffff;
	for (i = 0; i < num; i++)
	  {
	     ct = lst[i];
	     if (!ct->ewin || ct->type != IB_TYPE_ICONBOX)
		continue;

	     dx = (EoGetX(ct->ewin) + (EoGetW(ct->ewin) / 2)) -
		(EoGetX(ewin) + (EoGetW(ewin) / 2));
	     dy = (EoGetY(ct->ewin) + (EoGetH(ct->ewin) / 2)) -
		(EoGetY(ewin) + (EoGetH(ewin) / 2));
	     dist = (dx * dx) + (dy * dy);
	     if ((!EoIsSticky(ct->ewin)) &&
		 (EoGetDesk(ct->ewin) != EoGetDesk(ewin)))
		dist += (WinGetW(VROOT) * WinGetW(VROOT)) +
		   (WinGetH(VROOT) * WinGetH(VROOT));
	     if (dist < min_dist)
	       {
		  min_dist = dist;
		  ib_sel = ct;
	       }
	  }
	Efree(lst);
     }

   return ib_sel;
}
Esempio n. 2
0
static void
_SnapUpdateEwinLocation(Snapshot * sn, const EWin * ewin)
{
   int                 ax, ay;

   sn->x = EoGetX(ewin);
   sn->y = EoGetY(ewin);
   sn->area_x = ewin->area_x;
   sn->area_y = ewin->area_y;
   if (!EoIsSticky(ewin))
     {
	DeskGetArea(EoGetDesk(ewin), &ax, &ay);
	sn->x += ((ax - sn->area_x) * WinGetW(VROOT));
	sn->y += ((ay - sn->area_y) * WinGetH(VROOT));
     }
}
Esempio n. 3
0
static void
_SnapUpdateEwinSticky(Snapshot * sn, const EWin * ewin)
{
   sn->sticky = EoIsSticky(ewin);
}
Esempio n. 4
0
File: warp.c Progetto: Limsik/e17
void
WarpFocus(int delta)
{
   WarpFocusWin       *fw = warpFocusWindow;
   EWin               *const *lst;
   EWin               *ewin;
   int                 i, num;
   WarplistItem       *wl;

   /* Remember invoking keycode (ugly hack) */
   if (!fw || !EoIsShown(fw))
     {
	warpFocusKey = Mode.events.last_keycode;
	warpFocusState = Mode.events.last_keystate;
     }

   if (!warplist)
     {
	warplist_num = 0;	/* Not necessary but silences clang */
	lst = EwinListFocusGet(&num);
	for (i = 0; i < num; i++)
	  {
	     ewin = lst[i];
	     if (		/* Either visible or iconified */
		   ((EwinIsOnScreen(ewin)) || (ewin->state.iconified) ||
		    (Conf.warplist.showalldesks)) &&
		   /* Exclude windows that explicitely say so */
		   (!ewin->props.skip_focuslist) &&
		   (!ewin->props.skip_ext_task) &&
		   /* Keep shaded windows if conf say so */
		   ((!ewin->state.shaded) || (Conf.warplist.showshaded)) &&
		   /* Keep sticky windows if conf say so */
		   ((!EoIsSticky(ewin)) || (Conf.warplist.showsticky)) &&
		   /* Keep iconified windows if conf say so */
		   ((!ewin->state.iconified) || (Conf.warplist.showiconified)))
	       {
		  warplist_num++;
		  warplist = EREALLOC(WarplistItem, warplist, warplist_num);
		  wl = warplist + warplist_num - 1;
		  wl->ewin = ewin;
	       }
	  }

	/* Hmmm. Hack... */
	if (warplist_num >= 2 && warplist[1].ewin == GetFocusEwin())
	  {
	     warplist[1].ewin = warplist[0].ewin;
	     warplist[0].ewin = GetFocusEwin();
	  }

	warpFocusIndex = 0;
     }

   if (!warplist)
      return;

   warpFocusIndex = (warpFocusIndex + warplist_num + delta) % warplist_num;
   ewin = warplist[warpFocusIndex].ewin;
   if (!EwinFindByPtr(ewin))
      ewin = NULL;
   if (!ewin)
      return;

   WarpFocusShow();

   if (!EwinIsOnScreen(ewin))
      return;

   if (Conf.warplist.show_shape)
      WarpShapeDraw(ewin);

   if (Conf.focus.raise_on_next)
      EwinRaise(ewin);
   if (Conf.focus.warp_on_next)
      EwinWarpTo(ewin, 0);
   if (Conf.warplist.warpfocused)
      FocusToEWin(ewin, FOCUS_SET);
}
Esempio n. 5
0
File: warp.c Progetto: 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);
}