Exemple #1
0
Fichier : x.c Projet : Limsik/e17
static              Pixmap
_EWindowGetShapePixmap(Win win, unsigned int fg, unsigned int bg)
{
   Pixmap              mask;
   GC                  gc;
   int                 i;
   const XRectangle   *rect;

   if (win->num_rect == 0)	/* Not shaped */
      return None;

   mask = ECreatePixmap(win, win->w, win->h, 1);
   gc = EXCreateGC(mask, 0, NULL);

   XSetForeground(disp, gc, bg);
   XFillRectangle(disp, mask, gc, 0, 0, win->w, win->h);

   XSetForeground(disp, gc, fg);
   rect = win->rects;
   for (i = 0; i < win->num_rect; i++)
      XFillRectangle(disp, mask, gc, rect[i].x, rect[i].y,
		     rect[i].width, rect[i].height);

   EXFreeGC(gc);

   return mask;
}
Exemple #2
0
Fichier : x.c Projet : Limsik/e17
void
EXCopyArea(Drawable src, Drawable dst, int sx, int sy, unsigned int w,
	   unsigned int h, int dx, int dy)
{
   GC                  gc;

   gc = EXCreateGC(src, 0, NULL);
   XCopyArea(disp, src, dst, gc, sx, sy, w, h, dx, dy);
   EXFreeGC(gc);
}
Exemple #3
0
static void
ImagestateDrawNoImg(ImageState * is, Drawable draw, int x, int y, int w, int h)
{
   GC                  gc;

   ImagestateColorsAlloc(is);

   gc = EXCreateGC(draw, 0, NULL);
   XSetFillStyle(disp, gc, FillSolid);
   XSetForeground(disp, gc, is->bg_pixel);
   XFillRectangle(disp, draw, gc, x, y, w, h);
   if (is->bevelstyle != BEVEL_NONE)
      ImagestateDrawBevel(is, draw, gc, x, y, w, h);
   EXFreeGC(gc);
}
Exemple #4
0
Fichier : x.c Projet : Limsik/e17
Pixmap
EXCreatePixmapCopy(Pixmap src, unsigned int w, unsigned int h,
		   unsigned int depth)
{
   Pixmap              pmap;
   GC                  gc;

   pmap = XCreatePixmap(disp, src, w, h, depth);
   gc = EXCreateGC(src, 0, NULL);
   XCopyArea(disp, src, pmap, gc, 0, 0, w, h, 0, 0);
   EXFreeGC(gc);
#if DEBUG_PIXMAP
   Eprintf("%s: %#lx\n", __func__, pmap);
#endif
   return pmap;
}
Exemple #5
0
Fichier : x.c Projet : Limsik/e17
void
EXCopyAreaTiled(Drawable src, Pixmap mask, Drawable dst, int sx, int sy,
		unsigned int w, unsigned int h, int dx, int dy)
{
   GC                  gc;
   XGCValues           gcv;

   gcv.fill_style = FillTiled;
   gcv.tile = src;
   gcv.ts_x_origin = sx;
   gcv.ts_y_origin = sy;
   gcv.clip_mask = mask;
   gc = EXCreateGC(dst, GCFillStyle |
		   GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCClipMask,
		   &gcv);
   XFillRectangle(disp, dst, gc, dx, dy, w, h);
   EXFreeGC(gc);
}
Exemple #6
0
Fichier : x.c Projet : Limsik/e17
static void
EShapeCombineMaskTiled(Win win, int dest, int x, int y,
		       Pixmap pmap, int op, int w, int h)
{
   XGCValues           gcv;
   GC                  gc;
   Window              tm;

   gcv.fill_style = FillTiled;
   gcv.tile = pmap;
   gcv.ts_x_origin = 0;
   gcv.ts_y_origin = 0;
   tm = ECreatePixmap(win, w, h, 1);
   gc = EXCreateGC(tm, GCFillStyle | GCTile |
		   GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
   XFillRectangle(disp, tm, gc, 0, 0, w, h);
   EXFreeGC(gc);
   EShapeCombineMask(win, dest, x, y, tm, op);
   EFreePixmap(tm);
}
Exemple #7
0
static void
_ShapeDrawNontranslucent(EWin * ewin, int md, int firstlast,
                         int xn, int yn, int wn, int hn)
{
    ShapeData          *psd = (ShapeData *) ewin->shape_data;
    DrawFunc           *drf;

    if (firstlast == 0)
    {
        XGCValues           gcv;

        gcv.function = GXxor;
        gcv.foreground = Dpy.pixel_white;
        if (gcv.foreground == 0)
            gcv.foreground = Dpy.pixel_black;
        gcv.subwindow_mode = IncludeInferiors;
        psd->gc = EXCreateGC(psd->root,
                             GCFunction | GCForeground | GCSubwindowMode, &gcv);
    }

    drf = draw_functions[md - 1];

    if (firstlast > 0)
        drf(psd->root, psd->gc, psd->xo, psd->yo, psd->wo, psd->ho,
            psd->bl, psd->br, psd->bt, psd->bb);

    CoordsShow(ewin);

    if (firstlast < 2)
        drf(psd->root, psd->gc, xn, yn, wn, hn,
            psd->bl, psd->br, psd->bt, psd->bb);

    if (firstlast == 2)
    {
        EXFreeGC(psd->gc);
        psd->gc = NULL;
    }
}
Exemple #8
0
void
ITApply(Win win, ImageClass * ic, ImageState * is,
	int state, int active, int sticky, int image_type,
	TextClass * tc, TextState * ts, const char *text, int flags)
{
   int                 w, h;

   if (!win || !ic)
      return;

   w = WinGetW(win);
   h = WinGetH(win);
   if (w <= 0 || h <= 0)
      return;

   if (!is)
      is = ImageclassGetImageState(ic, state, active, sticky);
   if (!is)
      return;

   if (tc && text)
     {
	if (!ts)
	   ts = TextclassGetTextState(tc, state, active, sticky);
     }

   if (!is->im)
      ImagestateRealize(is);

   /* Imlib2 will not render pixmaps with dimensions > 8192 */
   if (is->im && w <= 8192 && h <= 8192)
     {
	PmapMask            pmm;

	ImagestateMakePmapMask(is, win, &pmm, IC_FLAG_MAKE_MASK, w, h,
			       image_type);

	if (pmm.pmap)
	  {
	     Pixmap              pmap = pmm.pmap;

	     if ((ts && text) || (is->bevelstyle != BEVEL_NONE) ||
		 (flags & ITA_BGPMAP))
	       {
		  if (pmm.type != 0)
		    {
		       pmap = EGetWindowBackgroundPixmap(win);
		       EXCopyAreaTiled(pmm.pmap, None, pmap, 0, 0, w, h, 0, 0);
		    }

		  if (is->bevelstyle != BEVEL_NONE)
		    {
		       GC                  gc;

		       gc = EXCreateGC(WinGetXwin(win), 0, NULL);
		       ImagestateDrawBevel(is, pmap, gc, 0, 0, w, h);
		       EXFreeGC(gc);
		    }

		  if (ts && text)
		     TextstateTextDraw(ts, win, pmap, text, 0, 0, w, h,
				       &(ic->padding), 0,
				       TextclassGetJustification(tc),
				       flags & ITA_JUSTV);
	       }

	     /* Set window pixmap */
	     if (pmap == pmm.pmap)
	       {
		  ESetWindowBackgroundPixmap(win, pmap);
		  EFreeWindowBackgroundPixmap(win);
	       }

	     if (pmm.w == w && pmm.h == h)
		EShapeSetMask(win, 0, 0, pmm.mask);
	     else if (pmm.mask)
		EShapeSetMaskTiled(win, 0, 0, pmm.mask, w, h);
	  }

	PmapMaskFree(&pmm);

	if ((is->unloadable) || (Conf.memory_paranoia))
	  {
	     EImageFree(is->im);
	     is->im = NULL;
	  }
     }
   else
     {
	ImagestateColorsAlloc(is);

	if (is->bevelstyle == BEVEL_NONE && !text)
	  {
	     ESetWindowBackground(win, is->bg_pixel);
	  }
	else
	  {
	     Pixmap              pmap;

	     pmap = EGetWindowBackgroundPixmap(win);
	     ImagestateDrawNoImg(is, pmap, 0, 0, w, h);
	     if (ts && text)
		TextstateTextDraw(ts, win, pmap, text, 0, 0, w, h,
				  &(ic->padding), 0,
				  TextclassGetJustification(tc),
				  flags & ITA_JUSTV);
	  }
     }
   EClearWindow(win);
}
Exemple #9
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();
}
Exemple #10
0
static void
MenuDrawItem(Menu * m, MenuItem * mi, char shape, int state)
{
   PmapMask           *mi_pmm;

   if (state >= 0)
      mi->state = state;
   mi_pmm = &(mi->pmm[(int)(mi->state)]);

   if (!mi_pmm->pmap)
     {
	int                 x, y, w, h;
	int                 item_type;
	ImageClass         *ic;
	GC                  gc;
	PmapMask            pmm;

	EGetGeometry(mi->win, NULL, &x, &y, &w, &h, NULL, NULL);

	mi_pmm->type = 0;
	mi_pmm->pmap = ECreatePixmap(mi->win, w, h, 0);
	mi_pmm->mask = None;

	ic = (mi->child) ? m->style->sub_iclass : m->style->item_iclass;
	item_type = (mi->state != STATE_NORMAL) ? ST_MENU_ITEM : ST_MENU;

	if (!m->style->use_item_bg)
	  {
	     gc = EXCreateGC(m->pmm.pmap, 0, NULL);
	     XCopyArea(disp, WinGetPmap(m->win), mi_pmm->pmap, gc, x, y, w, h,
		       0, 0);
	     if ((mi->state != STATE_NORMAL) || (mi->child))
	       {
		  ImageclassApplyCopy(ic, mi->win, w, h, 0, 0, mi->state, &pmm,
				      IC_FLAG_MAKE_MASK, item_type);
		  EXCopyAreaTiled(pmm.pmap, pmm.mask, mi_pmm->pmap,
				  0, 0, w, h, 0, 0);
		  PmapMaskFree(&pmm);
	       }
	     EXFreeGC(gc);
	  }
	else
	  {
	     ImageclassApplyCopy(ic, mi->win, w, h, 0, 0, mi->state, &pmm,
				 IC_FLAG_MAKE_MASK, item_type);
	     EXCopyAreaTiled(pmm.pmap, pmm.mask, mi_pmm->pmap,
			     0, 0, w, h, 0, 0);
	     PmapMaskFree(&pmm);
	  }

	if (mi->text)
	  {
	     TextDraw(m->style->tclass, mi->win, mi_pmm->pmap, 0, 0, mi->state,
		      _(mi->text), mi->text_x, mi->text_y, mi->text_w,
		      mi->text_h, 17,
		      TextclassGetJustification(m->style->tclass));
	  }
     }

   ESetWindowBackgroundPixmap(mi->win, mi_pmm->pmap);
   EShapeSetMask(mi->win, 0, 0, mi_pmm->mask);
   EClearWindow(mi->win);

   if ((shape) && (m->style->use_item_bg))
      EShapePropagate(m->win);
}
Exemple #11
0
static void
ImagestateDrawBevel(ImageState * is, EX_Drawable win,
		    int x, int y, int w, int h)
{
   GC                  gc;

   gc = EXCreateGC(win, 0, NULL);

   ImagestateColorsAlloc(is);

   switch (is->bevelstyle)
     {
     case BEVEL_AMIGA:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	break;
     case BEVEL_MOTIF:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(0, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	LINE(1, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_NEXT:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_DOUBLE:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, 1, w - 3, 1);
	LINE(1, 1, 1, h - 3);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_WIDEDOUBLE:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	LINE(3, h - 4, w - 4, h - 4);
	LINE(w - 4, 3, w - 4, h - 4);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	LINE(3, 3, w - 4, 3);
	LINE(3, 3, 3, h - 4);
	break;
     case BEVEL_THINPOINT:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, 1, 0);
	LINE(0, 0, 0, 1);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(w - 2, h - 1, w - 1, h - 1);
	LINE(w - 1, h - 2, w - 1, h - 1);
	break;
     case BEVEL_THICKPOINT:
	XSetForeground(disp, gc, is->hi_pixel);
	RECT(x, y, w - 1, h - 1);
	break;
     default:
	break;
     }

   EXFreeGC(gc);
}
Exemple #12
0
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);
}
Exemple #13
0
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);
}