Example #1
0
File: warp.c Project: 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);
}
Example #2
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;
        }
    }
}
Example #3
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();
}