Exemplo n.º 1
0
Arquivo: iconify.c Projeto: 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;
}
Exemplo n.º 2
0
Arquivo: magwin.c Projeto: gzorin/e17
static MagWindow   *
MagwinCreate(const char *title, int width, int height)
{
   MagWindow          *mw;
   Win                 win;
   int                 x, y, w, h;

   mw = ECALLOC(MagWindow, 1);
   if (!mw)
      return NULL;

   win = VROOT;
   w = width;
   h = height;
   x = (win->w - w) / 2;
   y = (win->h - h) / 2;

   win = ECreateClientWindow(VROOT, x, y, w, h);

   mw->title = title;
   mw->ewin = AddInternalToFamily(win, NULL, EWIN_TYPE_MISC, &_MagEwinOps, mw);
   if (!mw->ewin)
     {
	Efree(mw);
	return NULL;
     }

   mw->filter = 1;
   mw->disable_text = 1;

   mw->ewin->o.ghost = 1;
   EoSetLayer(mw->ewin, 10);
   EwinMoveResize(mw->ewin, EoGetX(mw->ewin), EoGetY(mw->ewin),
		  mw->ewin->client.w, mw->ewin->client.h);

   mw->ewin->client.event_mask |=
      KeyPressMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
      StructureNotifyMask;
   ESelectInput(win, mw->ewin->client.event_mask);

   EventCallbackRegister(win, MagwinEvent, mw);

   EQueryPointer(VROOT, &mw->cx, &mw->cy, NULL, NULL);
   mw->scale = Conf.magwin.zoom_res;
   mw->step = 4;

   return mw;
}
Exemplo n.º 3
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));
     }
}
Exemplo n.º 4
0
Arquivo: warp.c Projeto: Limsik/e17
static void
WarpShapeDraw(EWin * ewin)
{
   static ShapeWin    *shape_win = NULL;
   int                 bl, br, bt, bb;

   if (!ewin)
     {
	ShapewinDestroy(shape_win);
	shape_win = NULL;
	return;
     }

   if (!shape_win)
      shape_win = ShapewinCreate(MR_BOX);
   if (!shape_win)
      return;

   EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
   ShapewinShapeSet(shape_win, MR_BOX, EoGetX(ewin), EoGetY(ewin),
		    ewin->client.w, ewin->client.h, bl, br, bt, bb, 0);
   EoMap(shape_win, 0);
}
Exemplo n.º 5
0
void
DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h,
              int firstlast, int seqno)
{
    ShapeData          *psd;
    int                 dx, dy;

    /* Quit if no change */
    if (firstlast == 1 &&
            (x == ewin->shape_x && y == ewin->shape_y &&
             (ewin->state.shaded || (w == ewin->shape_w && h == ewin->shape_h))))
        return;

    if ((md == MR_OPAQUE) || (md == MR_TECH_OPAQUE))
    {
        EwinOpMoveResize(ewin, OPSRC_USER, x, y, w, h);
        EwinShapeSet(ewin);
        CoordsShow(ewin);
        if (md == MR_OPAQUE)
            goto done;
    }

    if (firstlast == 0)
    {
        EwinShapeSet(ewin);

        psd = ECALLOC(ShapeData, 1);
        ewin->shape_data = psd;
        if (!psd)
            goto done;
        psd->root = WinGetXwin(VROOT);
        EwinBorderGetSize(ewin, &psd->bl, &psd->br, &psd->bt, &psd->bb);
    }
    psd = (ShapeData *) ewin->shape_data;
    if (!psd)
        goto done;

    dx = EoGetX(EoGetDesk(ewin));
    dy = EoGetY(EoGetDesk(ewin));
    ewin->shape_x = x;
    ewin->shape_y = y;
    x += dx;
    y += dy;

    if (!ewin->state.shaded)
    {
        ewin->shape_w = w;
        ewin->shape_h = h;
    }
    else
    {
        w = ewin->shape_w;
        h = ewin->shape_h;
    }

    if (((md <= MR_BOX) || (md == MR_TECH_OPAQUE)) &&
            Conf.movres.avoid_server_grab)
    {
        _ShapeDrawNograb_tech_box(ewin, md, firstlast, x, y, w, h, seqno);
        goto done;
    }

    switch (md)
    {
    case MR_TECHNICAL:
    case MR_TECH_OPAQUE:
    case MR_BOX:
        _ShapeDrawNontranslucent(ewin, md, firstlast, x, y, w, h);
        break;
    default:
        /* Fall back to opaque mode */
        Conf.movres.mode_move = MR_OPAQUE;
        break;
    }

    psd->xo = x;
    psd->yo = y;
    psd->wo = w;
    psd->ho = h;

done:
    if (firstlast == 0 || firstlast == 2 || firstlast == 4)
    {
        ewin->req_x = ewin->shape_x;
        ewin->req_y = ewin->shape_y;
        if (firstlast == 2)
        {
            CoordsHide();
            Efree(ewin->shape_data);
            ewin->shape_data = NULL;
        }
    }
}
Exemplo n.º 6
0
static void
MenuShow(Menu * m, char noshow)
{
   EWin               *ewin;
   int                 x, y, w, h;
   int                 wx, wy, mw, mh;
   int                 head_num = 0;

   if (m->shown)
      return;

   if (MenuLoad(m) || m->redraw)
      MenuRealize(m);

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

   if (!m->win || !m->items[0]->win)
      MenuRealize(m);

   if (!m->style)
      return;

   ewin = m->ewin;
   if (ewin)
     {
#if 0				/* ??? */
	EwinRaise(ewin);
	EwinShow(ewin);
	return;
#else
	MenuHide(m);
#endif
     }

   EGetGeometry(m->items[0]->win, NULL, &x, &y, &w, &h, NULL, NULL);
   mw = m->w;
   mh = m->h;

   EQueryPointer(NULL, &wx, &wy, NULL, NULL);
   wx -= EoGetX(DesksGetCurrent()) + x + (w / 2);
   wy -= EoGetY(DesksGetCurrent()) + y + (h / 2);
   if (Conf.menus.onscreen)
     {
	Border             *b;

	b = BorderFind(m->style->border_name);
	if (b)
	  {
	     int                 sx, sy, sw, sh;

	     head_num = ScreenGetGeometryByPointer(&sx, &sy, &sw, &sh);

	     if (wx > sx + sw - mw - b->border.right)
		wx = sx + sw - mw - b->border.right;
	     if (wx < sx + b->border.left)
		wx = sx + b->border.left;

	     if (wy > sy + sh - mh - b->border.bottom)
		wy = sy + sh - mh - b->border.bottom;
	     if (wy < sy + b->border.top)
		wy = sy + b->border.top;
	  }
     }

   EMoveWindow(m->win, wx, wy);

   ewin = AddInternalToFamily(m->win, m->style->border_name, EWIN_TYPE_MENU,
			      &_MenuEwinOps, m);
   if (ewin)
     {
	ewin->client.event_mask |= KeyPressMask;
	ESelectInput(m->win, ewin->client.event_mask);

	ewin->head = head_num;

	EwinResize(ewin, ewin->client.w, ewin->client.h, 0);

	if (Conf.menus.animate)
	   EwinInstantShade(ewin, 0);

	if (!noshow)
	  {
	     ICCCM_Cmap(NULL);
	     EwinOpFloatAt(ewin, OPSRC_NA, EoGetX(ewin), EoGetY(ewin));
	     EwinShow(ewin);
	     if (Conf.menus.animate)
		EwinUnShade(ewin);
	  }
     }

   m->shown = 1;
   m->last_access = time(0);
   Mode_menus.just_shown = 1;

   if (!Mode_menus.first)
     {
	Mode_menus.context_ewin = GetContextEwin();
#if 0
	Eprintf("Mode_menus.context_ewin set %s\n",
		EwinGetTitle(Mode_menus.context_ewin));
#endif
	ESync(ESYNC_MENUS);
	Mode_menus.first = m;
	MenuShowMasker(m);
	TooltipsEnable(0);
	GrabKeyboardSet(m->win);
     }
   m->ref_count++;
}
Exemplo n.º 7
0
static void
_CoordsShow(EWin * ewin, int mode)
{
   TextClass          *tc;
   ImageClass         *ic;
   char                s[256];
   int                 md;
   int                 x, y;
   unsigned int        w, h;
   int                 cx, cy, cw, ch;
   EObj               *eo = coord_eo;
   EImageBorder       *pad;
   int                 bl, br, bt, bb;

   if (!Conf.movres.mode_info)
      return;
   if (!ewin || !ewin->state.show_coords)
      return;

   tc = TextclassFind("COORDS", 1);
   ic = ImageclassFind("COORDS", 1);
   if ((!ic) || (!tc))
      return;

   cx = cy = cw = ch = 0;

   x = ewin->shape_x;
   y = ewin->shape_y;
   w = (ewin->state.shaded) ? ewin->client.w : ewin->shape_w;
   h = (ewin->state.shaded) ? ewin->client.h : ewin->shape_h;
   ICCCM_GetIncrementalSize(ewin, w, h, &w, &h);

   switch (mode)
     {
     default:
     case 0:
	Esnprintf(s, sizeof(s), "%i x %i (%i, %i)", w, h, x, y);
	break;
     case 1:
	Esnprintf(s, sizeof(s), _("Focused/unfocused opacity: %d/%d %%"),
		  OpacityToPercent(ewin->props.focused_opacity),
		  OpacityToPercent(ewin->ewmh.opacity));
	break;
     }
   TextSize(tc, 0, 0, 0, s, &cw, &ch, 17);
   pad = ImageclassGetPadding(ic);
   cw += pad->left + pad->right;
   ch += pad->top + pad->bottom;

   /* Width hysteresis (hack - assuming horizontal text) */
   cw += 8;
   if (eo && abs(EobjGetW(eo) - cw) < 8)
      cw = EobjGetW(eo);

   if (Mode.mode == MODE_MOVE)
      md = Conf.movres.mode_move;
   else
      md = Conf.movres.mode_resize;

   if ((md == 0) || ((cw < ewin->shape_w - 2) && (ch < ewin->shape_h - 2)))
     {
	if (Conf.movres.mode_info == 1)
	  {
	     switch (md)
	       {
	       case 0:
	       case 1:
	       case 2:
		  EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
		  w = (ewin->state.shaded) ?
		     EoGetW(ewin) : ewin->shape_w + bl + br;
		  h = (ewin->state.shaded) ?
		     EoGetH(ewin) : ewin->shape_h + bt + bb;
		  cx = x + (w - cw) / 2 + EoGetX(EoGetDesk(ewin));
		  cy = y + (h - ch) / 2 + EoGetY(EoGetDesk(ewin));
		  break;
	       }
	  }
     }

   if (!eo)
     {
	eo = EobjWindowCreate(EOBJ_TYPE_MISC, 0, 0, 1, 1, 2, "Coord");
	if (!eo)
	   return;
	coord_eo = eo;
	eo->fade = eo->shadow = 1;

	/* Center text (override theme) */
	TextclassSetJustification(tc, 512);
     }

#define TEST_COORD_REPARENT_TO_FRAME 0
#if TEST_COORD_REPARENT_TO_FRAME
   cx -= x;
   cy -= y;
#endif
   md = cw != EobjGetW(eo) || ch != EobjGetH(eo);	/* md is change size flag */
   EobjMoveResize(eo, cx, cy, cw, ch);

   if (!eo->shown)
     {
#if TEST_COORD_REPARENT_TO_FRAME
	EobjReparent(eo, EoObj(ewin), cx, cy);
#endif
	EobjMap(eo, 0);
     }

   ITApply(EobjGetWin(eo), ic, NULL, STATE_NORMAL, 1, 0, ST_SOLID, tc, NULL, s,
	   1);

   if (md)			/* Assuming that shape change only happens when size changes too */
      EobjShapeUpdate(eo, 0);

   EFlush();
}
Exemplo n.º 8
0
/* outstanding BUG: zooming on shaped windows leaves stuff exposed beneath them..... */
void
Zoom(EWin * ewin, int on)
{
   if (Mode.wm.window)
      return;

   if (!ewin)
      ewin = zoom_last_ewin;
   if (!ewin)
      return;

   if (zoom_can == 0)
      ZoomInit();

   if (zoom_can <= 0)
      return;

   Dprintf("%s: on=%d\n", __func__, on);
   if (!on)
     {
	/* Unzoom */

	if (ewin != zoom_last_ewin)
	   return;

	_ZoomEwinRestore(ewin);
	SwitchRes(0, 0, 0, 0, 0, NULL, NULL);
	zw = zh = 0;
	zoom_last_ewin = NULL;
     }
   else if (ewin == zoom_last_ewin)
     {
	/* Already zoomed */
	return;
     }
   else
     {
	/* Zoom */

	if (ewin->state.fullscreen)
	   return;

	if (!zoom_last_ewin)	/* first zoom */
	  {
	     on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h, &zw, &zh);
	  }
	else			/* we are zoomed in on another window already.... */
	  {
	     _ZoomEwinRestore(zoom_last_ewin);
	     if ((ewin->client.w <= zw) && (ewin->client.h <= zh) &&
		 ((ewin->client.w >= zw / 2) || (ewin->client.h >= zh / 2)))
	       {
		  /* YAY no need to change resolution :-D */
	       }
	     else
	       {
		  /* SwitchRes only tracks the LAST mode, so we have to switch back to
		   * the original mode before switching to new target mode
		   * so that we can restore the original vid mode when we zoom
		   * out of the last window ;( */
		  SwitchRes(0, 0, 0, 0, 0, NULL, NULL);
		  on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h,
				 &zw, &zh);
	       }
	  }

	Dprintf("%s: SwitchRes=%d - client size %dx%d -> screen %dx%d\n",
		__func__, on, ewin->client.w, ewin->client.h, zw, zh);
	if (!on)
	   return;

	ewin->save_fs.x = EoGetX(ewin);
	ewin->save_fs.y = EoGetY(ewin);
	EwinRaise(ewin);
	EwinBorderSetTo(ewin, BorderCreateFiller(ewin->client.w,
						 ewin->client.h, zw, zh));
	EwinMoveResize(ewin, 0, 0, ewin->client.w, ewin->client.h, 0);
	ewin->state.zoomed = 1;
	FocusToEWin(ewin, FOCUS_SET);
	zoom_last_ewin = ewin;
     }

   EwinWarpTo(ewin, 1);
   ESync(0);
   EwinStateUpdate(ewin);
   HintsSetWindowState(ewin);
}
Exemplo n.º 9
0
Arquivo: iconify.c Projeto: Limsik/e17
static void
IB_Animate_A(char iconify, EWin * ewin, EWin * ibox)
{
   EWin               *fr, *to;
   unsigned int        t0;
   double              a, aa, spd;
   int                 x, y, x1, y1, x2, y2, x3, y3, x4, y4, w, h;
   int                 fx, fy, fw, fh, tx, ty, tw, th;
   Window              root = WinGetXwin(VROOT);
   GC                  gc;
   XGCValues           gcv;

   /* Window: Extents, Iconbox: Center */
   if (iconify)
     {
	fr = ewin;
	to = ibox;
	fw = EoGetW(fr) + 4;
	fh = EoGetH(fr) + 4;
	fx = EoGetX(fr) - 2;
	fy = EoGetY(fr) - 2;
	tw = 4;
	th = 4;
	tx = EoGetX(to) + EoGetW(to) / 2 - 2;
	ty = EoGetY(to) + EoGetH(to) / 2 - 2;
     }
   else
     {
	fr = ibox;
	to = ewin;
	fw = 4;
	fh = 4;
	fx = EoGetX(fr) + EoGetW(fr) / 2 - 2;
	fy = EoGetY(fr) + EoGetH(fr) / 2 - 2;
	tw = EoGetW(to) + 4;
	th = EoGetH(to) + 4;
	tx = EoGetX(to) + 2;
	ty = EoGetY(to) + 2;
     }
   fx += EoGetX(EoGetDesk(fr));
   fy += EoGetY(EoGetDesk(fr));
   tx += EoGetX(EoGetDesk(to));
   ty += EoGetY(EoGetDesk(to));

   gcv.subwindow_mode = IncludeInferiors;
   gcv.function = GXxor;
   gcv.line_width = 2;
   gcv.foreground = Dpy.pixel_white;
   if (gcv.foreground == 0)
      gcv.foreground = Dpy.pixel_black;
   gc = EXCreateGC(root,
		   GCFunction | GCForeground | GCSubwindowMode | GCLineWidth,
		   &gcv);

   spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;

   t0 = GetTimeMs();
   for (a = 0.0; a < 1.0; a += spd)
     {
	aa = 1.0 - a;

	x = (int)((fx * aa) + (tx * a));
	y = (int)((fy * aa) + (ty * a));
	w = (int)((fw * aa) + (tw * a));
	h = (int)((fh * aa) + (th * a));

	x = (2 * x + w) / 2;	/* x middle */
	y = (2 * y + h) / 2;	/* y middle */
	w /= 2;			/* width/2 */
	h /= 2;			/* height/2 */

	x1 = (int)(x + w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
	y1 = (int)(y + h * cos(a * 6.2831853072));
	x2 = (int)(x + w * (1 - .5 * sin(a * 6.2831853072)));
	y2 = (int)(y - h * cos(a * 6.2831853072));
	x3 = (int)(x - w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
	y3 = (int)(y - h * cos(a * 6.2831853072));
	x4 = (int)(x - w * (1 - .5 * sin(a * 6.2831853072)));
	y4 = (int)(y + h * cos(a * 6.2831853072));

	XDrawLine(disp, root, gc, x1, y1, x2, y2);
	XDrawLine(disp, root, gc, x2, y2, x3, y3);
	XDrawLine(disp, root, gc, x3, y3, x4, y4);
	XDrawLine(disp, root, gc, x4, y4, x1, y1);

	ESync(0);
	IB_Animate_Sleep(t0, a);

	XDrawLine(disp, root, gc, x1, y1, x2, y2);
	XDrawLine(disp, root, gc, x2, y2, x3, y3);
	XDrawLine(disp, root, gc, x3, y3, x4, y4);
	XDrawLine(disp, root, gc, x4, y4, x1, y1);
     }

   EXFreeGC(gc);
}
Exemplo n.º 10
0
Arquivo: iconify.c Projeto: Limsik/e17
static void
IB_Animate_B(char iconify, EWin * ewin, EWin * ibox)
{
   EWin               *fr, *to;
   unsigned int        t0;
   double              a, spd;
   int                 x, y, w, h;
   int                 fx, fy, fw, fh, tx, ty, tw, th;
   Window              root = WinGetXwin(VROOT);
   GC                  gc;
   XGCValues           gcv;

   if (iconify)
     {
	fr = ewin;
	to = ibox;
     }
   else
     {
	fr = ibox;
	to = ewin;
     }

   fx = EoGetX(fr) - 2;
   fy = EoGetY(fr) - 2;
   fw = EoGetW(fr) + 3;
   fh = EoGetH(fr) + 3;

   tx = EoGetX(to) - 2;
   ty = EoGetY(to) - 2;
   tw = EoGetW(to) + 3;
   th = EoGetH(to) + 3;

   fx += EoGetX(EoGetDesk(fr));
   fy += EoGetY(EoGetDesk(fr));
   tx += EoGetX(EoGetDesk(to));
   ty += EoGetY(EoGetDesk(to));

   gcv.subwindow_mode = IncludeInferiors;
   gcv.function = GXxor;
   gcv.fill_style = FillOpaqueStippled;
   gcv.foreground = Dpy.pixel_white;
   if (gcv.foreground == 0)
      gcv.foreground = Dpy.pixel_black;
   gc = EXCreateGC(root,
		   GCFunction | GCForeground | GCSubwindowMode | GCFillStyle,
		   &gcv);

   XDrawLine(disp, root, gc, fx, fy, tx, ty);
   XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
   XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
   XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
   XDrawRectangle(disp, root, gc, tx, ty, tw, th);
   XDrawRectangle(disp, root, gc, fx, fy, fw, fh);

   spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;

   t0 = GetTimeMs();
   for (a = 0.0; a < 1.0; a += spd)
     {
	x = (int)(fx + a * (tx - fx));
	w = (int)(fw + a * (tw - fw));
	y = (int)(fy + a * (ty - fy));
	h = (int)(fh + a * (th - fh));
	XDrawRectangle(disp, root, gc, x, y, w, h);

	ESync(0);
	IB_Animate_Sleep(t0, a);

	XDrawRectangle(disp, root, gc, x, y, w, h);
     }

   XDrawLine(disp, root, gc, fx, fy, tx, ty);
   XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
   XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
   XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
   XDrawRectangle(disp, root, gc, tx, ty, tw, th);
   XDrawRectangle(disp, root, gc, fx, fy, fw, fh);

   EXFreeGC(gc);
}