Ejemplo n.º 1
0
Archivo: events.c Proyecto: gzorin/e17
static void
EventFetchXI2(XEvent * ev)
{
   XIDeviceEvent      *xie;

   if (!XGetEventData(disp, &ev->xcookie))
      return;

   xie = (XIDeviceEvent *) ev->xcookie.data;

   if (EDebug(EDBUG_TYPE_XI2))
      Eprintf("%s: %#lx: XI2 ext=%d type=%d devid=%d srcid=%d\n",
	      "EventsFetch", xie->event, xie->extension,
	      xie->evtype, xie->deviceid, xie->sourceid);

   switch (ev->xcookie.evtype)
     {
     default:
	break;
     case XI_ButtonPress:
     case XI_ButtonRelease:
     case XI_Motion:
	ev->type = ev->xcookie.evtype;
	ev->xbutton.window = xie->event;
	ev->xbutton.root = xie->root;
	ev->xbutton.subwindow = xie->child;
	ev->xbutton.time = xie->time;
	ev->xbutton.x = (int)xie->event_x;
	ev->xbutton.y = (int)xie->event_y;
	ev->xbutton.x_root = (int)xie->root_x;
	ev->xbutton.y_root = (int)xie->root_y;
	ev->xbutton.button = xie->detail;
	ev->xbutton.state = xie->mods.effective;
	ev->xbutton.same_screen = 1;	/* FIXME */
	break;
     }
   XFreeEventData(disp, &ev->xcookie);
}
Ejemplo n.º 2
0
Archivo: x.c Proyecto: Limsik/e17
void
EMoveResizeWindow(Win win, int x, int y, int w, int h)
{
   if (!win)
      return;

#if 0
   Eprintf("EMoveResizeWindow: %p %#lx: %d,%d %dx%d -> %d,%d %dx%d\n",
	   win, win->xwin, win->x, win->y, win->w, win->h, x, y, w, h);
#endif
   if ((w == win->w) && (h == win->h) && (x == win->x) && (y == win->y))
      return;

   if (w != win->w || h != win->h)
      WinBgInvalidate(win);

   win->x = x;
   win->y = y;
   win->w = w;
   win->h = h;

   XMoveResizeWindow(disp, win->xwin, x, y, w, h);
}
Ejemplo n.º 3
0
Archivo: x.c Proyecto: Limsik/e17
static void
EShapeCombineRectangles(Win win, int dest, int x, int y,
			XRectangle * rect, int n_rects, int op, int ordering)
{
   if (!win)
      return;
#if DEBUG_SHAPE_OPS
   Eprintf("EShapeCombineRectangles %#lx %d\n", win->xwin, n_rects);
#endif

   if (n_rects == 1 && op == ShapeSet)
     {
	if ((rect[0].x == 0) && (rect[0].y == 0) &&
	    (rect[0].width == win->w) && (rect[0].height == win->h))
	  {
	     win->num_rect = 0;
	     XFree(win->rects);
	     win->rects = NULL;
	     XShapeCombineMask(disp, win->xwin, dest, x, y, None, op);
	     return;
	  }
     }
   XShapeCombineRectangles(disp, win->xwin, dest, x, y, rect, n_rects, op,
			   ordering);
   if (n_rects > 1)
     {
	/* Limit shape to window extents */
	XRectangle          r;

	r.x = r.y = 0;
	r.width = win->w;
	r.height = win->h;
	XShapeCombineRectangles(disp, win->xwin, ShapeBounding, 0, 0, &r,
				1, ShapeIntersect, Unsorted);
     }
   EShapeUpdate(win);
}
Ejemplo n.º 4
0
static int
_xft_Load(TextState * ts, const char *name)
{
   XftFont            *font;
   FontCtxXft         *fdc;

   if (name[0] == '-')
      font = XftFontOpenXlfd(disp, Dpy.screen, name);
   else
      font = XftFontOpenName(disp, Dpy.screen, name);

   if (!font)
      return -1;

#if 0				/* Debug */
   {
      FT_Face             ftf = XftLockFace(font);

      if (ftf == NULL)
	 return -1;
      Eprintf("Font %s family_name=%s style_name=%s\n", name,
	      ftf->family_name, ftf->style_name);
      XftUnlockFace(font);
   }
#endif

   fdc = EMALLOC(FontCtxXft, 1);
   if (!fdc)
      return -1;
   fdc->font = font;
   ts->fdc = fdc;
   ts->need_utf8 = 1;
   ts->type = FONT_TYPE_XFT;
   ts->ops = &FontOps_xft;
   return 0;
}
Ejemplo n.º 5
0
Archivo: x.c Proyecto: Limsik/e17
static              Win
EXidSet(Window xwin, Win parent, int x, int y, int w, int h, int depth,
	Visual * visual, Colormap cmap)
{
   Win                 win;

   win = EXidCreate();
   win->parent = parent;
   win->xwin = xwin;
   win->x = x;
   win->y = y;
   win->w = w;
   win->h = h;
   win->depth = depth;
   win->visual = visual;
   win->cmap = cmap;
   win->argb = depth == 32;
#if DEBUG_XWIN
   Eprintf("EXidSet: %#lx\n", win->xwin);
#endif
   EXidAdd(win);

   return win;
}
Ejemplo n.º 6
0
Archivo: edge.c Proyecto: Limsik/e17
static void
EdgeEvent(int dir)
{
   static int          lastdir = -1;

#if 0
   Eprintf("EdgeEvent %d -> %d\n", lastdir, dir);
#endif
   if (lastdir == dir || Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
      return;

   if (Conf.desks.edge_flip_mode == EDGE_FLIP_MOVE && Mode.mode != MODE_MOVE)
      return;

   TIMER_DEL(edge_timer);
   if (dir >= 0)
     {
	if (Conf.desks.edge_flip_resistance <= 0)
	   Conf.desks.edge_flip_resistance = 1;
	TIMER_ADD(edge_timer, 10 * Conf.desks.edge_flip_resistance,
		  EdgeTimeout, INT2PTR(dir));
     }
   lastdir = dir;
}
Ejemplo n.º 7
0
static int
_GrabKeyboard(Win win, int sync_kbd)
{
   int                 rc;

#if USE_XI2
   EXIEventMask        em;

   EXIMaskSetup(&em, DEV_KBD, KeyPressMask | KeyReleaseMask);
   rc = XIGrabDevice(disp, DEV_KBD, WinGetXwin(win), CurrentTime, NoXID,
		     GrabModeAsync, sync_kbd ? GrabModeSync : GrabModeAsync,
		     False, &em.em);
#else
   rc = XGrabKeyboard(disp, WinGetXwin(win), False,
		      GrabModeAsync, sync_kbd ? GrabModeSync : GrabModeAsync,
		      CurrentTime);
#endif

#if 0
   Eprintf("%s: %#lx sync=%d rc=%d\n", __func__, WinGetXwin(win), sync_kbd, rc);
#endif

   return rc;
}
Ejemplo n.º 8
0
Archivo: rd.c Proyecto: palmerc/lab
void rdexec(int format)
{
	int i;

	for (i = 0; i < 32; i++)
	{
		Eprintf("   r%02d:  ", i);
		if(format == NORMAL)
		{
			Eprintf("%08X", m88000.Regs[i]);
			if ((i % 4) == 3)
				Eprintf("\n");
		}
		else if(format == SINGLE)
		{
			PPrintf("%.7e", *(float *)(&m88000.Regs[i]));
			if ((i % 3) == 2)
				PPrintf("\n");
		}
		else
		{
			union {int i[2]; double d;}u;
			u.i[0] = m88000.Regs[i];
			u.i[1] = m88000.Regs[i+1];
			PPrintf("%.16e", u.d);
			if (i % 2)
				PPrintf("\n");
		}
	}

	if(format ==SINGLE)
		PPrintf("\n");

	Eprintf("   ip:   0x%08X   vbr:  0x%08X   psr:  0x%08X\n", IP, VBR, PSR);
	Eprintf("   sbd:  0x%08X\n", m88000.scoreboard);
	Eprintf("   fpsr: 0x%08X   fpcr: 0x%08X \n", FPSR, FPCR);

	return;
}
Ejemplo n.º 9
0
static void
doFocusToEwin(EWin * ewin, int why)
{
   int                 do_focus = 0;
   int                 do_raise = 0, do_warp = 0;

   if (focus_inhibit)
      return;

   if (EDebug(EDBUG_TYPE_FOCUS))
      Eprintf("%s: %#x %s why=%d\n", __func__,
	      (ewin) ? EwinGetClientXwin(ewin) : 0,
	      (ewin) ? EwinGetTitle(ewin) : "None", why);

   switch (why)
     {
     case FOCUS_NEXT:
     case FOCUS_PREV:
	if (Conf.focus.raise_on_next)
	   do_raise = 1;
	if (Conf.focus.warp_on_next)
	   do_warp = 1;
	/* Fall thru */
     default:
     case FOCUS_SET:
     case FOCUS_ENTER:
     case FOCUS_LEAVE:		/* Unused */
     case FOCUS_CLICK:
	if (ewin && ewin == Mode.focuswin)
	   return;
	if (!ewin)		/* Unfocus */
	   break;
	if (!FocusEwinValid(ewin, 1, why == FOCUS_CLICK, 0))
	   return;
	break;

     case FOCUS_INIT:
     case FOCUS_DESK_ENTER:
	ewin = FocusEwinSelect();
	break;

     case FOCUS_DESK_LEAVE:
	focus_is_set = 0;
	/* FALLTHROUGH */
     case FOCUS_NONE:
	ewin = NULL;
	if (ewin == Mode.focuswin)
	   return;
	break;

     case FOCUS_EWIN_UNMAP:
	if (Mode.focuswin)
	   return;
	ewin = FocusEwinSelect();
	if (ewin == Mode.focuswin)
	   ewin = NULL;
	break;

     case FOCUS_EWIN_NEW:
	if (Conf.focus.all_new_windows_get_focus)
	   goto check_focus_new;

	if (Mode.place.doing_manual)
	   goto check_focus_new;

	if (ewin->props.focus_when_mapped)
	   goto check_focus_new;

	if (Conf.focus.new_windows_get_focus_if_group_focused && Mode.focuswin)
	  {
	     if (EwinGetWindowGroup(ewin) == EwinGetWindowGroup(Mode.focuswin))
		goto check_focus_new;
	  }

	if (EwinIsTransient(ewin))
	  {
	     if (Conf.focus.new_transients_get_focus)
	       {
		  do_focus = 1;
	       }
	     else if (Conf.focus.new_transients_get_focus_if_group_focused &&
		      Mode.focuswin)
	       {
		  if ((EwinGetTransientFor(ewin) ==
		       EwinGetClientXwin(Mode.focuswin)) ||
		      (EwinGetWindowGroup(ewin) ==
		       EwinGetWindowGroup(Mode.focuswin)))
		     do_focus = 1;
	       }

	     if (!do_focus)
		return;
	     DeskGotoByEwin(ewin);
	     goto check_focus_new;
	  }

	return;

      check_focus_new:
	if (!FocusEwinValid(ewin, 1, 0, 0))
	   return;
	break;
     }

   if (ewin == Mode.focuswin && focus_is_set)
      return;

   /* Check if ewin is a valid focus window target */

   if (!ewin)
      goto done;

   /* NB! ewin != NULL */

   if (why != FOCUS_CLICK && ewin->props.focusclick)
      return;

   if (Conf.autoraise.enable)
     {
	TIMER_DEL(focus_timer_autoraise);

	if (Conf.focus.mode != MODE_FOCUS_CLICK)
	   TIMER_ADD(focus_timer_autoraise, Conf.autoraise.delay,
		     AutoraiseTimeout, ewin);
     }

   if (do_raise)
      EwinRaise(ewin);

   if (Conf.focus.warp_always)
      do_warp = 1;
   if (do_warp)
      EwinWarpTo(ewin, 0);

   switch (why)
     {
     case FOCUS_PREV:
     case FOCUS_NEXT:
	GrabKeyboardSet(VROOT);	/* Causes idler to be called on KeyRelease */
	focus_pending_raise = ewin;
	break;
     case FOCUS_DESK_ENTER:
	if (Conf.focus.mode == MODE_FOCUS_CLICK)
	   break;
	/* FALLTHROUGH */
     default:
     case FOCUS_INIT:
	EwinListFocusRaise(ewin);
	break;
     }

   SoundPlay(SOUND_FOCUS_SET);
 done:

   ClickGrabsUpdate();

   /* Unset old focus window (if any) highlighting */
   if (Mode.focuswin)
      FocusEwinSetActive(Mode.focuswin, 0);
   ICCCM_Cmap(ewin);

   /* Quit if pointer is not on our screen */

   if (!Mode.events.on_screen)
     {
	Mode.focuswin = NULL;
	return;
     }

   /* Set new focus window (if any) highlighting */
   Mode.focuswin = ewin;
   if (Mode.focuswin)
      FocusEwinSetActive(Mode.focuswin, 1);

   if (why == FOCUS_DESK_LEAVE)
      return;

   ICCCM_Focus(ewin);
   focus_is_set = 1;
}
Ejemplo n.º 10
0
int
PicBuf_to_X11 ( const GEN_PAR * pg,  OUT_PAR * po)
/**
 ** Interface to higher-level routines,
 **   similar in structure to other previewers
 **/
{
  int row_c, x, y;
  int saved_col=0,saved_row=0;
  int xref = 0, yref = 0;
  const RowBuf *row;
  const PicBuf *pb;
  struct timeval tv;
  tv.tv_usec = 10;

  if (pg == NULL || po == NULL)
    return ERROR;
  pb = po->picbuf;
  if (pb == NULL)
    return ERROR;

  if (!pg->quiet)
    {
      Eprintf ("\nX11 preview follows.\n");
      Eprintf ("Press any key to end graphics mode\n");
    }

  if (win_open (pg, po->outfile, (int) (po->xoff * po->dpi_x / 25.4),
		(int) (po->yoff * po->dpi_y / 25.4), pb->nb << 3, pb->nr))
    return ERROR;
REDRAW:
  /* Backward since highest index is lowest line on screen! */
  for (row_c = row_start, y = MIN (height-row_start, pb->nr - 1);
       row_c < pb->nr; row_c++, y--)
    {
   row =NULL;
   if (row_c>=0) row = get_RowBuf (pb, row_c);
      /*if (row == NULL)
	return 0;*/
      for (x = col_start; x < pb->nc; x++)
	{
        if (row_c <0 || x < 0) setXcolor(GRAY);
         else
	  switch (index_from_RowBuf (row, x, pb))
	    {

	    case xxBackground:
	      continue;
/*	    case xxForeground:
	      setXcolor (WHITE);
	      break;*/
	    default:
	      setXcolor (index_from_RowBuf (row, x, pb));
	      break;
	    }
	  XDrawPoint (XDisplay, XWin, XGcWin, x - col_start, y + row_start);
	}
    }

/* Wait for KeyPress or mouse Button  - exit on keypress or button 3 */
  do
    {
      XNextEvent (XDisplay, &WaitEvent);
      if (WaitEvent.type == ButtonPress)
	{
	  if (WaitEvent.xbutton.button == Button1)
	    {
	      xref = WaitEvent.xbutton.x;
	      yref = WaitEvent.xbutton.y;
	    }
	  if (WaitEvent.xbutton.button == Button2)
	    {
	    if (!zoomed){
	      zoomed=1;
	       po->HP_to_xdots *=2;
	       po->HP_to_ydots *=2;
	       po->dpi_x *=2;
	       po->dpi_y *=2;
		saved_row=row_start;
		saved_col=col_start;
		  row_start = height-WaitEvent.xbutton.y+2*saved_row;
		  if (height < scr_height) row_start = height-WaitEvent.xbutton.y;
		  col_start =  WaitEvent.xbutton.x+col_start;
	    } else {
	      zoomed=0;
	      po->dpi_x = po->dpi_x/2;
	      po->dpi_y = po->dpi_y/2;
	       po->HP_to_xdots = po->HP_to_xdots/2;
	       po->HP_to_ydots = po->HP_to_ydots/2;
		row_start=saved_row;
		col_start=saved_col;

		}	
		free(po->picbuf);
		po->picbuf=NULL;    
	      TMP_to_BUF(pg, po);
	      pb=po->picbuf;
	    }
	  if (WaitEvent.xbutton.button == Button3) {win_close();return(0);}
	}
      else if (WaitEvent.type == ButtonRelease)
	{
	  if (WaitEvent.xbutton.button == Button1)
	    {
	      if (oversized)
		{
		  row_start += WaitEvent.xbutton.y - yref;
		  col_start += xref - WaitEvent.xbutton.x;
		}
	      XSetForeground (XDisplay, XGcWin,
			      WhitePixel (XDisplay, XScreen));
	      XFillRectangle (XDisplay, XWin, XGcWin, 0, 0, scr_width,
			      scr_height);
	      goto REDRAW;	/* yes, goto in C is ugly */
	    }
	  if (WaitEvent.xbutton.button == Button2){
	      XSetForeground (XDisplay, XGcWin,
			      WhitePixel (XDisplay, XScreen));
	      XFillRectangle (XDisplay, XWin, XGcWin, 0, 0, scr_width,
			      scr_height);
	      goto REDRAW;	/* yes, goto in C is ugly */
		} 	
	  break;
/*	  select (0, NULL, NULL, NULL, &tv);*/
	}
    }
  while (WaitEvent.type != KeyPress );

  win_close ();
  return 0;
}
Ejemplo n.º 11
0
static int
win_open (const GEN_PAR * pg, char *title, int x, int y, int w, int h)
{
  char *DisplayName = NULL;
  char **argv;
  XSizeHints Hints;
  unsigned long ValueMask;
  XSetWindowAttributes WinAttr;
  XEvent Event;
  char colorname[13];
  int i;

	/**
	 ** Simulate command line arguments
	 **/

  argv = (char **) malloc (3 * sizeof (char *));
  argv[0] = PROG_NAME;
  argv[1] = title;
  argv[2] = NULL;

	/**
	 ** X11 server reachable ?
	 **/

  if ((XDisplay = (Display *) XOpenDisplay (DisplayName)) == NULL)
    {
      Eprintf ("No X11 server found !\n");
      return NO_SERVER;
    }



  XScreen = DefaultScreen (XDisplay);
  XRoot = RootWindow (XDisplay, XScreen);
  XVisual = DefaultVisual (XDisplay, XScreen);
  XGcWin = DefaultGC (XDisplay, XScreen);

  scr_width = WidthOfScreen (ScreenOfDisplay (XDisplay, XScreen));
  scr_height = HeightOfScreen (ScreenOfDisplay (XDisplay, XScreen));
  if (x + w > scr_width || y + h > scr_height)
    {
  if (!pg->quiet)
      Eprintf ("Window exceeds screen limits, use mouse button 1 to pan\n");
      w = MIN (w, scr_width);
      h = MIN (h, scr_height);
      oversized = 1;
/*		return SIZE;*/
    }

	/**
	 ** Set window attributes
	 **/

  WinAttr.background_pixel = WhitePixel (XDisplay, XScreen);
  WinAttr.border_pixel = WhitePixel (XDisplay, XScreen);
  WinAttr.backing_store = Always;
  ValueMask = CWBackPixel | CWBorderPixel | CWBackingStore;

	/**
	 ** Create Window
	 **/

  XWin = XCreateWindow (XDisplay, XRoot,
			x, y, w, h,
			1, 0,
			CopyFromParent, CopyFromParent, ValueMask, &WinAttr);

	/**
	 ** Define window properties
	 **/

  Hints.flags = PSize | PMinSize | PMaxSize | USPosition;
  Hints.x = x;
  Hints.y = y;
  Hints.width = Hints.min_width = Hints.max_width = w;
  Hints.height = Hints.min_height = Hints.max_height = h;

  XSetStandardProperties (XDisplay, XWin,
			  title, title, 0, argv, 2, &Hints);

/**
 ** Define color table (compatible to SunView and Turbo-C usage)
 **/

  def_clut = DefaultColormap (XDisplay, XScreen);
  if (DefaultDepth (XDisplay, XScreen) < 4)
    {
      col_table[BLACK] = WhitePixel (XDisplay, XScreen);
      col_table[WHITE] = BlackPixel (XDisplay, XScreen);
      col_table[GRAY] = col_table[WHITE];
      col_table[RED] = col_table[WHITE];
      col_table[GREEN] = col_table[WHITE];
      col_table[BLUE] = col_table[WHITE];
      col_table[CYAN] = col_table[WHITE];
      col_table[MAGENTA] = col_table[WHITE];
      col_table[YELLOW] = col_table[WHITE];
      col_table[LIGHTGRAY] = col_table[WHITE];
      col_table[LIGHTRED] = col_table[WHITE];
      col_table[LIGHTGREEN] = col_table[WHITE];
      col_table[LIGHTBLUE] = col_table[WHITE];
      col_table[LIGHTCYAN] = col_table[WHITE];
      col_table[LIGHTMAGENTA] = col_table[WHITE];
    }
  else
    {
      XParseColor (XDisplay, def_clut, "gray10", &Xcol);
      XAllocColor (XDisplay, def_clut, &Xcol);
      col_table[GRAY] = Xcol.pixel;

      for (i = 1; i <= pg->maxpens; i++)
	{
	  sprintf (colorname, "#%2.2X%2.2X%2.2X",
		   pt.clut[i][0], pt.clut[i][1], pt.clut[i][2]);
	  if (XParseColor (XDisplay, def_clut, colorname, &Xcol)==0) fprintf(stderr,"failed tp map color for pen %d\n",i);
	if (XAllocColor (XDisplay, def_clut, &Xcol)==0) {
	fprintf(stderr,"failed to alloc X color for pen %d\n",i);
	col_table[i] = col_table[GRAY];
	}else
	  col_table[i] = Xcol.pixel;
	}
    }


	/**
	 **  Set foreground and background colors
	 **/

  XSetState (XDisplay, XGcWin,
	     col_table[BLACK], col_table[WHITE], GXcopy, AllPlanes);

	/**
	 ** Define permitted events for this window
	 **/

  XSelectInput (XDisplay, XWin,
		ExposureMask  | KeyPressMask | VisibilityChangeMask |
		ButtonPressMask | ButtonReleaseMask);

	/**
	 ** Display window
	 **/
  XMapWindow (XDisplay, XWin);
  do
    {
      XNextEvent (XDisplay, &Event);
    }
  while (Event.type != Expose && Event.type != VisibilityNotify );

  width = w;
  height = h;
  bytes = (w + 7) / 8;


  free ((char *) argv);
  return (0);
}
Ejemplo n.º 12
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++;
}
Ejemplo n.º 13
0
/**
** Higher-level interface: Windows  print it  (-m emp)
**/
int to_emp(const GEN_PAR * pg, const OUT_PAR * po)
{
	DEVMODE *dev;
	PRINTDLG pd;
	DOCINFO di = { 0 };

	int xpix, ypix;		//DPI

	int yprinter, xprinter, err;
	// Initialize PRINTDLG
	ZeroMemory(&pd, sizeof(PRINTDLG));
	pd.lStructSize = sizeof(PRINTDLG);
	pd.hwndOwner = NULL;
	pd.hDevMode = NULL;	// Don't forget to free or store hDevMode
	pd.hDevNames = NULL;	// Don't forget to free or store hDevNames
	pd.Flags = PD_RETURNDEFAULT;	// gives default printer
	pd.nCopies = 1;
	pd.nFromPage = 0xFFFF;
	pd.nToPage = 0xFFFF;
	pd.nMinPage = 1;
	pd.nMaxPage = 0xFFFF;

	PrintDlg(&pd);		// first call to fill devmode struct from default printer

	dev = GlobalLock(pd.hDevMode);

	//Auto orient paper
	if (fabs(po->xmax - po->xmin) < fabs(po->ymax - po->ymin))
		dev->dmOrientation = DMORIENT_PORTRAIT;
	else
		dev->dmOrientation = DMORIENT_LANDSCAPE;
	GlobalUnlock(pd.hDevMode);
	pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;

	// now check which printer he wants
	if (PrintDlg(&pd) != TRUE)
		return 0;

	Eprintf("\n\n- Printing it -\n");
	GlobalFree(pd.hDevMode);
	GlobalFree(pd.hDevNames);

	xprinter = GetDeviceCaps(pd.hDC, HORZRES);	// papper width in pixels
	yprinter = GetDeviceCaps(pd.hDC, VERTRES);	// height in pixels
	xpix = GetDeviceCaps(pd.hDC, LOGPIXELSX);	// DPI x to be checked
	ypix = GetDeviceCaps(pd.hDC, LOGPIXELSY);	// DPI y
	// the following code is an attempt to compensate for printers with different
	// X and y resolution ( Not tested !!!)
	if (xpix < ypix) {
		xprinter = (int) (xprinter * ((float) xpix) / ypix);
	} else if (xpix > ypix) {
		yprinter = (int) (yprinter * ((float) ypix) / xpix);
	}
	SetScale(pd.hDC, yprinter, xprinter, po);

	di.cbSize = sizeof(DOCINFO);
	di.lpszDocName = "HPGL File";

	// Begin a print job by calling the StartDoc function.
	StartDoc(pd.hDC, &di);

	// Inform the driver that the application is about to begin
	// sending data.
	StartPage(pd.hDC);

	err = plotit(pd.hDC, pg, po);
	EndPage(pd.hDC);
	EndDoc(pd.hDC);

	DeleteDC(pd.hDC);
	if (!pg->quiet) {
		Eprintf("\nlines=%d moves=%d", lines, moves);
		Eprintf("\n");
	}
	return err;
}
Ejemplo n.º 14
0
Archivo: events.c Proyecto: Limsik/e17
void
EventShow(const XEvent * ev)
{
   char               *txt, buf[64];

   Esnprintf(buf, sizeof(buf), "%#08lx %cEV-%s ev=%#lx",
	     ev->xany.serial, (ev->xany.send_event) ? '*' : ' ',
	     EventName(ev->type), ev->xany.window);

   switch (ev->type)
     {
     case KeyPress:
     case KeyRelease:
	Eprintf("%s sub=%#lx x,y=%d,%d state=%#x keycode=%#x ss=%d\n", buf,
		ev->xkey.subwindow, ev->xkey.x, ev->xkey.y,
		ev->xkey.state, ev->xkey.keycode, ev->xkey.same_screen);
	break;
     case ButtonPress:
     case ButtonRelease:
	Eprintf("%s sub=%#lx x,y=%d,%d state=%#x button=%#x ss=%d\n", buf,
		ev->xbutton.subwindow, ev->xbutton.x, ev->xbutton.y,
		ev->xbutton.state, ev->xbutton.button, ev->xbutton.same_screen);
	break;
     case MotionNotify:
	Eprintf("%s sub=%#lx x,y=%d,%d rx,ry=%d,%d ss=%d\n", buf,
		ev->xmotion.subwindow, ev->xmotion.x, ev->xmotion.y,
		ev->xmotion.x_root, ev->xmotion.y_root,
		ev->xmotion.same_screen);
	break;
     case EnterNotify:
     case LeaveNotify:
	Eprintf("%s sub=%#lx x,y=%d,%d m=%s d=%s ss=%d focus=%d\n", buf,
		ev->xcrossing.subwindow, ev->xcrossing.x, ev->xcrossing.y,
		EventNotifyModeName(ev->xcrossing.mode),
		EventNotifyDetailName(ev->xcrossing.detail),
		ev->xcrossing.same_screen, ev->xcrossing.focus);
	break;
     case FocusIn:
     case FocusOut:
	Eprintf("%s m=%s d=%s\n", buf, EventNotifyModeName(ev->xfocus.mode),
		EventNotifyDetailName(ev->xfocus.detail));
	break;
     case KeymapNotify:
     case Expose:
     case GraphicsExpose:
	Eprintf("%sx %d+%d %dx%d\n", buf,
		ev->xexpose.x, ev->xexpose.y,
		ev->xexpose.width, ev->xexpose.height);
	break;
     case VisibilityNotify:
	Eprintf("%s state=%d\n", buf, ev->xvisibility.state);
	break;
     case CreateNotify:
     case DestroyNotify:
     case UnmapNotify:
     case MapRequest:
     case EX_EVENT_CREATE_GONE:
     case EX_EVENT_UNMAP_GONE:
     case EX_EVENT_MAPREQUEST_GONE:
	Eprintf("%s win=%#lx\n", buf, ev->xcreatewindow.window);
	break;
     case MapNotify:
     case EX_EVENT_MAP_GONE:
	Eprintf("%s win=%#lx or=%d\n", buf, ev->xmap.window,
		ev->xmap.override_redirect);
	break;
     case ReparentNotify:
     case EX_EVENT_REPARENT_GONE:
	Eprintf("%s win=%#lx parent=%#lx %d+%d\n", buf,
		ev->xreparent.window, ev->xreparent.parent,
		ev->xreparent.x, ev->xreparent.y);
	break;
     case ConfigureNotify:
	Eprintf("%s win=%#lx %d+%d %dx%d bw=%d above=%#lx\n", buf,
		ev->xconfigure.window, ev->xconfigure.x,
		ev->xconfigure.y, ev->xconfigure.width, ev->xconfigure.height,
		ev->xconfigure.border_width, ev->xconfigure.above);
	break;
     case ConfigureRequest:
	Eprintf("%s win=%#lx m=%#lx %d+%d %dx%d bw=%d above=%#lx stk=%d\n",
		buf, ev->xconfigurerequest.window,
		ev->xconfigurerequest.value_mask, ev->xconfigurerequest.x,
		ev->xconfigurerequest.y, ev->xconfigurerequest.width,
		ev->xconfigurerequest.height,
		ev->xconfigurerequest.border_width, ev->xconfigurerequest.above,
		ev->xconfigurerequest.detail);
	break;
     case GravityNotify:
	goto case_common;
     case ResizeRequest:
	Eprintf("%s %dx%d\n", buf,
		ev->xresizerequest.width, ev->xresizerequest.height);
	break;
     case CirculateNotify:
     case CirculateRequest:
	goto case_common;
     case PropertyNotify:
	txt = XGetAtomName(disp, ev->xproperty.atom);
	Eprintf("%s Atom=%s(%ld)\n", buf, txt, ev->xproperty.atom);
	XFree(txt);
	break;
     case SelectionClear:
     case SelectionRequest:
     case SelectionNotify:
     case ColormapNotify:
	goto case_common;
     case ClientMessage:
	txt = XGetAtomName(disp, ev->xclient.message_type);
	Eprintf("%s ev_type=%s(%ld) data: %08lx %08lx %08lx %08lx %08lx\n",
		buf, txt, ev->xclient.message_type,
		ev->xclient.data.l[0], ev->xclient.data.l[1],
		ev->xclient.data.l[2], ev->xclient.data.l[3],
		ev->xclient.data.l[4]);
	XFree(txt);
	break;
     case MappingNotify:
	Eprintf("%s req=%d first=%d count=%d\n",
		buf, ev->xmapping.request,
		ev->xmapping.first_keycode, ev->xmapping.count);
	break;

     case EX_EVENT_SHAPE_NOTIFY:
#define se ((XShapeEvent *)ev)
	Eprintf("%s kind=%d shaped=%d %d,%d %dx%d\n", buf,
		se->kind, se->shaped, se->x, se->y, se->width, se->height);
#undef se
	break;
#if USE_XSCREENSAVER
     case EX_EVENT_SAVER_NOTIFY:
#define se ((XScreenSaverNotifyEvent *)ev)
	Eprintf("%s state=%d kind=%d\n", buf, se->state, se->kind);
#undef se
	break;
#endif
#if USE_XRANDR
     case EX_EVENT_SCREEN_CHANGE_NOTIFY:
	Eprintf("%s\n", buf);
	break;
#endif
#if USE_COMPOSITE
#define de ((XDamageNotifyEvent *)ev)
     case EX_EVENT_DAMAGE_NOTIFY:
	Eprintf("%s level=%d more=%x %d+%d %dx%d\n", buf,
		de->level, de->more,
		de->area.x, de->area.y, de->area.width, de->area.height);
	break;
#undef de
#endif
     default:
      case_common:
	Eprintf("%s\n", buf);
	break;
     }
}
Ejemplo n.º 15
0
int
main(int argc, char **argv)
{
    int                 ch, i, loop;
    struct utsname      ubuf;
    const char         *str, *dstr;

    /* This function runs all the setup for startup, and then
     * proceeds into the primary event loop at the end.
     */

    /* Init state variable struct */
    memset(&Mode, 0, sizeof(EMode));

    Mode.wm.master = 1;
    Mode.wm.pid = getpid();
    Mode.wm.exec_name = argv[0];
    Mode.wm.startup = 1;

    Mode.mode = MODE_NONE;

    EXInit();
    Dpy.screen = -1;

    str = getenv("EDEBUG");
    if (str)
        EDebugInit(str);
    str = getenv("EDEBUG_COREDUMP");
    if (str)
        Mode.wm.coredump = 1;
    str = getenv("EDEBUG_EXIT");
    if (str)
        Mode.debug_exit = atoi(str);

    str = getenv("ECONFNAME");
    if (str)
        EConfNameSet(str);
    str = getenv("ECONFDIR");
    if (str)
        EDirUserSet(str);
    str = getenv("ECACHEDIR");
    if (str)
        EDirUserCacheSet(str);

    srand((unsigned int)time(NULL));

    if (!uname(&ubuf))
        Mode.wm.machine_name = Estrdup(ubuf.nodename);
    if (!Mode.wm.machine_name)
        Mode.wm.machine_name = Estrdup("localhost");

    /* Now we're going to interpret any of the commandline parameters
     * that are passed to it -- Well, at least the ones that we
     * understand.
     */

    Mode.theme.path = NULL;
    dstr = NULL;

    for (loop = 1; loop;)
    {
        ch = EoptGet(argc, argv);
        if (ch <= 0)
            break;
#if 0
        Eprintf("Opt: %c: %d - %s\n", ch, eoptind, eoptarg);
#endif
        switch (ch)
        {
        default:
        case '?':
            printf("e16: Ignoring: ");
            for (i = eoptind; i < argc; i++)
                printf("%s ", argv[i]);
            printf("\n");
            loop = 0;
            break;
        case 'h':
            EoptHelp();
            exit(0);
            break;
        case 'd':
            dstr = eoptarg;
            break;
        case 'f':
            Mode.wm.restart = 1;
            break;
        case 'p':
            EConfNameSet(eoptarg);
            break;
        case 'P':
            EDirUserSet(eoptarg);
            break;
        case 'Q':
            EDirUserCacheSet(eoptarg);
            break;
        case 's':
            Mode.wm.single = 1;
            Dpy.screen = strtoul(eoptarg, NULL, 10);
            break;
        case 'S':
            SetSMID(eoptarg);
            break;
        case 't':
            Mode.theme.path = Estrdup(eoptarg);
            break;
        case 'V':
            printf("%s %s\n", e_wm_name, e_wm_version);
            exit(0);
            break;
        case 'v':
            EDebugSet(EDBUG_TYPE_VERBOSE, 1);
            break;
        case 'w':
            sscanf(eoptarg, "%dx%d", &Mode.wm.win_w, &Mode.wm.win_h);
            Mode.wm.window = 1;
            Mode.wm.single = 1;
            Mode.wm.master = 0;
            break;
#ifdef USE_EXT_INIT_WIN
        case 'X':
            ExtInitWinSet(strtoul(eoptarg, NULL, 0));
            Mode.wm.restart = 1;
            break;
#endif
        case 'm':
            Mode.wm.master = 0;
            Mode.wm.master_screen = strtoul(eoptarg, NULL, 10);
            break;
        }
    }

    SignalsSetup();		/* Install signal handlers */

    EDirsSetup();
    ECheckEprog("epp");
    ECheckEprog("eesh");

    SetupX(dstr);		/* This is where the we fork per screen */
    /* X is now running, and we have forked per screen */

    ESavePrefixSetup();

    /* So far nothing should rely on a selected settings or theme. */
    ConfigurationLoad();		/* Load settings */

    /* Initialise internationalisation */
    LangInit();

    /* The theme path must now be available for config file loading. */
    ThemePathFind();

    /* Set the Environment variables */
    Esetenv("EVERSION", e_wm_version);
    Esetenv("EROOT", EDirRoot());
    Esetenv("EBIN", EDirBin());
    Esetenv("ECONFDIR", EDirUser());
    Esetenv("ECACHEDIR", EDirUserCache());
    Esetenv("ETHEME", Mode.theme.path);

    /* Move elsewhere? */
    EImageInit();
    HintsInit();
    CommsInit();
    SessionInit();
    SnapshotsLoad();

#if USE_DBUS
    DbusInit();
#endif

    if (Mode.wm.window)
        EMapWindow(VROOT);

    ModulesSignal(ESIGNAL_INIT, NULL);

    /* Load the theme */
    ThemeConfigLoad();

    if (Mode.debug_exit)
        return 0;

    /* Do initial configuration */
    ModulesSignal(ESIGNAL_CONFIGURE, NULL);

    /* Set root window cursor */
    ECsrApply(ECSR_ROOT, WinGetXwin(VROOT));

#ifdef USE_EXT_INIT_WIN
    /* Kill the E process owning the "init window" */
    ExtInitWinKill();
#endif

    /* let's make sure we set this up and go to our desk anyways */
    DeskGoto(DesksGetCurrent());
    ESync(ESYNC_MAIN);

#ifdef SIGCONT
    for (i = 0; i < Mode.wm.child_count; i++)
        kill(Mode.wm.children[i], SIGCONT);
#endif

    ModulesSignal(ESIGNAL_START, NULL);
#if ENABLE_DIALOGS
    DialogsInit();
#endif
    EwinsManage();

    RunInitPrograms();
    SnapshotsSpawn();

    if (!Mode.wm.restart)
        StartupWindowsOpen();

    Conf.startup.firsttime = 0;
    Mode.wm.save_ok = Conf.autosave;
    Mode.wm.startup = 0;
    autosave();

    /* The primary event loop */
    EventsMain();

    SessionExit(EEXIT_QUIT, NULL);

    return 0;
}
Ejemplo n.º 16
0
Archivo: x.c Proyecto: Limsik/e17
int
EShapePropagate(Win win)
{
   Win                 xch;
   unsigned int        num_rects;
   int                 k, rn;
   int                 x, y, w, h;
   XRectangle         *rects, *rectsn, *rl;

   if (!win || win->w <= 0 || win->h <= 0)
      return 0;

#if DEBUG_SHAPE_PROPAGATE
   Eprintf("EShapePropagate %#lx %d,%d %dx%d\n", win->xwin,
	   win->x, win->y, win->w, win->h);
#endif

   num_rects = 0;
   rects = NULL;

   /* go through all child windows and create/inset spans */
   for (xch = win_first; xch; xch = xch->next)
     {
	if (xch->parent != win)
	   continue;

#if DEBUG_SHAPE_PROPAGATE > 1
	Eprintf("%#lx(%d): %4d,%4d %4dx%4d\n", xch->xwin, xch->mapped,
		xch->x, xch->y, xch->w, xch->h);
#endif
	if (!xch->mapped)
	   continue;

	x = xch->x;
	y = xch->y;
	w = xch->w;
	h = xch->h;
	if (x >= win->w || y >= win->h || x + w < 0 || y + h < 0)
	   continue;

	rn = xch->num_rect;

	if (rn > 0)
	  {
	     rl = xch->rects;
	     rectsn = EREALLOC(XRectangle, rects, num_rects + rn);
	     if (!rectsn)
		goto bail_out;
	     rects = rectsn;

	     /* go through all clip rects in thsi window's shape */
	     for (k = 0; k < rn; k++)
	       {
		  /* for each clip rect, add it to the rect list */
		  rects[num_rects + k].x = x + rl[k].x;
		  rects[num_rects + k].y = y + rl[k].y;
		  rects[num_rects + k].width = rl[k].width;
		  rects[num_rects + k].height = rl[k].height;
#if DEBUG_SHAPE_PROPAGATE > 1
		  Eprintf(" - %d: %4d,%4d %4dx%4d\n", k,
			  rects[num_rects + k].x,
			  rects[num_rects + k].y, rects[num_rects + k].width,
			  rects[num_rects + k].height);
#endif
	       }
	     num_rects += rn;
	  }
	else if (rn == 0)
	  {
	     /* Unshaped */
	     rectsn = EREALLOC(XRectangle, rects, num_rects + 1);
	     if (!rectsn)
		goto bail_out;
	     rects = rectsn;

	     rects[num_rects].x = x;
	     rects[num_rects].y = y;
	     rects[num_rects].width = w;
	     rects[num_rects].height = h;
	     num_rects++;
	  }
     }

#if DEBUG_SHAPE_PROPAGATE
   EShapeShow("EShapePropagate", win->xwin, rects, num_rects);
#endif

   /* set the rects as the shape mask */
   if (rects)
     {
	EShapeCombineRectangles(win, ShapeBounding, 0, 0, rects,
				num_rects, ShapeSet, Unsorted);
	Efree(rects);
     }
   else
     {
	/* Empty shape */
	EShapeCombineRectangles(win, ShapeBounding, 0, 0, NULL, 0, ShapeSet,
				Unsorted);
     }

   return win->num_rect;

 bail_out:
   Efree(rects);
   EShapeCombineMask(win, ShapeBounding, 0, 0, None, ShapeSet);
   return 0;
}
Ejemplo n.º 17
0
Archivo: trap.c Proyecto: palmerc/lab
/*********************************************************************
*	vector
*/
int vector(struct IR_FIELDS *ir,int vec)
{
	struct cmmu	*cmmu_ptr;
#ifdef NOT_SPEC95
	int 		retstat;
#endif
	int		syscall_num;

	if(vec > 0x1ff)
	{
		Eprintf("Vector to large\n");
		return(-1);
	}

	if((vecyes) && (ir->op == RTE))
	{
		if(!(PSR & 0x80000000))
			return(exception(E_TPRV, "Supervisor Privilege Violation"));

		PSR = TPSR;			/* get saved psr */
		m88000.scoreboard = TSB;	/* get scoreboard */

		if(TNIP & 2)
			IP = TNIP;		/* get saved ip */
		else if(TFIP & 2)
			IP = TFIP;
		else
			IP = TFIP + 4;

		IP &= 0xFFFFFFFC;
		return(0);
	}

	if(ir->op == TBND)
		return(exception(E_TBND, "Array Bounds Violation"));

/*
 * Process system call vectors.
 * Entry to this section is done if the trap vector is 80 which
 * indicates old scheme sysV system call interface or if the vector
 * is >= 0x100 which indicates Berkeley traps or new scheme sysV
 * system call interface vectors between 0x81 and 0x99 are used for
 * other purposes

   The BCS Standard corrected of July 1988 uses trap number 450 for all
   required POSIX system calls.
 */

	if(((vec == 0x80) || (vec >= 0x100)) && (ir->op >= (unsigned)TB0) && (ir->op <= (unsigned)TCND))
	{
		if(unixvec)
		{
			if ((!stdio_en) && (vec == 450))
			{
			/* Flush the data cache for sys call */
				cmmu_ptr = &Dcmmu;
				cmmu_ptr->control.SCMR = 0x0000001b;
				cmmu_ctrl_func(cmmu_ptr);
				/*
				** OCS_BCS system call interface
				*/
				syscall_num = (int) m88000.Regs[9];
				return(sysVbcs(syscall_num));
			}

#ifdef NOT_SPEC95
			/*
			** stdio IO interface
			*/
			if ((stdio_en) && (((retstat = stdio_io(vec)) == -1) || !retstat))
				return(retstat);
#endif

		}
#ifdef NOT_SPEC95
					/*
					** basic IO alway in
					*/
		if(((retstat = fake_io(vec)) == -1) || !retstat)
			return(retstat);
#endif


	}
	else if((vecyes) && (vec >= 0x00) && (vec <= 0x7F))
	{
		if(!(PSR & 0x80000000))
			return(exception(E_TPRV, "Supervisor Privilege Violation"));
	}

	return(exception(vec, null));
}
Ejemplo n.º 18
0
Archivo: events.c Proyecto: Limsik/e17
/*
 * This is the primary event loop.  Everything that is going to happen in the
 * window manager has to start here at some point.  This is where all the
 * events from the X server are interpreted, timer events are inserted, etc
 */
void
EventsMain(void)
{
   static int          evq_alloc = 0;
   static int          evq_fetch = 0;
   static XEvent      *evq_ptr = NULL;
   fd_set              fdset;
   struct timeval      tval;
   unsigned int        time1, time2;
   int                 dt;
   int                 count, pfetch;
   int                 fdsize, fd, i;

   time1 = GetTimeMs();

   for (;;)
     {
	pfetch = 0;
	count = EventsProcess(&evq_ptr, &evq_alloc, &pfetch);

	if (pfetch)
	  {
	     evq_fetch =
		(pfetch > evq_fetch) ? pfetch : (3 * evq_fetch + pfetch) / 4;
	     if (EDebug(EDBUG_TYPE_EVENTS))
		Eprintf("EventsMain - Alloc/fetch/pfetch/peak=%d/%d/%d/%d)\n",
			evq_alloc, evq_fetch, pfetch, count);
	     if ((evq_ptr) && ((evq_alloc - evq_fetch) > 64))
	       {
		  evq_alloc = 0;
		  Efree(evq_ptr);
		  evq_ptr = NULL;
	       }
	  }

	/* time2 = current time */
	time2 = GetTimeMs();
	dt = time2 - time1;
	Mode.events.time_ms = time1 = time2;
	/* dt = time spent since we last were here */

	/* Run all expired timers */
	TimersRun(time2);

	/* Run idlers */
	IdlersRun();

	if (Mode.wm.exit_mode)
	   break;

	if (XPending(disp))
	   continue;

	FD_ZERO(&fdset);
	fdsize = -1;
	for (i = 0; i < nfds; i++)
	  {
	     fd = pfds[i].fd;
	     if (fd < 0)
		continue;
	     if (fdsize < fd)
		fdsize = fd;
	     FD_SET(fd, &fdset);
	  }
	fdsize++;

	/* Get time to first non-expired (0 means none) */
	time2 = TimersRunNextIn(time2);
	if (time2 > 0.)
	  {
	     tval.tv_sec = (long)time2 / 1000;
	     tval.tv_usec = ((long)time2 - tval.tv_sec * 1000) * 1000;
	     count = select(fdsize, &fdset, NULL, NULL, &tval);
	  }
	else
	  {
	     count = select(fdsize, &fdset, NULL, NULL, NULL);
	  }

	if (EDebug(EDBUG_TYPE_EVENTS))
	   Eprintf
	      ("EventsMain - count=%d xfd=%d:%d dt=%.6lf time2=%.6lf\n",
	       count, pfds[0].fd, FD_ISSET(pfds[0].fd, &fdset), dt * 1e-3,
	       time2 * 1e-3);

	if (count <= 0)
	   continue;		/* Timeout (or error) */

	/* Excluding X fd */
	for (i = 1; i < nfds; i++)
	  {
	     fd = pfds[i].fd;
	     if ((fd >= 0) && (FD_ISSET(fd, &fdset)))
	       {
		  if (EDebug(EDBUG_TYPE_EVENTS))
		     Eprintf("Event fd %d\n", i);
		  pfds[i].handler();
	       }
	  }
     }
}
Ejemplo n.º 19
0
Archivo: events.c Proyecto: Limsik/e17
static void
EventsCompress(XEvent * evq, int count)
{
   XEvent             *ev, *ev2;
   int                 i, j, n;
   int                 xa, ya, xb, yb;
   int                 type;

#if ENABLE_DEBUG_EVENTS
   /* Debug - should be taken out */
   if (EDebug(EDBUG_TYPE_COMPRESSION))
      for (i = 0; i < count; i++)
	 if (evq[i].type)
	    Eprintf("EventsCompress-1 %3d %s w=%#lx\n", i,
		    EventName(evq[i].type), evq[i].xany.window);
#endif

   /* Loop through event list, starting with latest */
   for (i = count - 1; i >= 0; i--)
     {
	ev = evq + i;

	type = ev->type;
	switch (type)
	  {
	  case 0:
	     /* Already thrown away */
	  default:
	     break;

	  case MotionNotify:
	     /* Discard all but last motion event */
	     j = i - 1;
	     n = 0;
	     for (; j >= 0; j--)
	       {
		  ev2 = evq + j;
		  if (ev2->type == type)
		    {
		       n++;
		       ev2->type = 0;
		    }
	       }
#if ENABLE_DEBUG_EVENTS
	     if (n && EDebug(EDBUG_TYPE_COMPRESSION))
		Eprintf("EventsCompress n=%4d %s %#lx x,y = %d,%d\n",
			n, EventName(type), ev->xmotion.window,
			ev->xmotion.x, ev->xmotion.y);
#endif
	     break;

	  case LeaveNotify:
	     for (j = i - 1; j >= 0; j--)
	       {
		  ev2 = evq + j;
		  if (ev2->type == EnterNotify)
		    {
		       if (ev2->xcrossing.window == ev->xcrossing.window)
			  goto do_enter_leave_nuked;
		    }
	       }
	     break;
	   do_enter_leave_nuked:
	     ev2->type = ev->type = 0;
	     for (n = i - 1; n > j; n--)
	       {
		  ev2 = evq + n;
		  if (ev2->type == MotionNotify)
		    {
		       if (ev2->xmotion.window != ev->xmotion.window)
			  continue;
		       ev2->type = 0;
		    }
	       }
#if ENABLE_DEBUG_EVENTS
	     if (EDebug(EDBUG_TYPE_COMPRESSION))
		Eprintf("EventsCompress n=%4d %s %#lx\n",
			1, EventName(type), ev->xcrossing.window);
#endif
	     break;

	  case DestroyNotify:
	     for (j = i - 1; j >= 0; j--)
	       {
		  ev2 = evq + j;
		  switch (ev2->type)
		    {
		    case CreateNotify:
		       if (ev2->xcreatewindow.window !=
			   ev->xdestroywindow.window)
			  continue;
		       ev2->type = EX_EVENT_CREATE_GONE;
		       j = -1;	/* Break for() */
		       break;
		    case DestroyNotify:
		       break;
		    case UnmapNotify:
		       if (ev2->xunmap.window != ev->xdestroywindow.window)
			  continue;
		       ev2->type = EX_EVENT_UNMAP_GONE;
		       break;
		    case MapNotify:
		       if (ev2->xmap.window != ev->xdestroywindow.window)
			  continue;
		       ev2->type = EX_EVENT_MAP_GONE;
		       break;
		    case MapRequest:
		       if (ev2->xmaprequest.window != ev->xdestroywindow.window)
			  continue;
		       ev2->type = EX_EVENT_MAPREQUEST_GONE;
		       break;
		    case ReparentNotify:
		       if (ev2->xreparent.window != ev->xdestroywindow.window)
			  continue;
		       ev2->type = EX_EVENT_REPARENT_GONE;
		       break;
		    case ConfigureRequest:
		       if (ev2->xconfigurerequest.window !=
			   ev->xdestroywindow.window)
			  continue;
		       ev2->type = 0;
		       break;
		    default:
		       /* Nuke all other events on a destroyed window */
		       if (ev2->xany.window != ev->xdestroywindow.window)
			  continue;
		       ev2->type = 0;
		       break;
		    }
	       }
	     break;

	  case Expose:
	     n = 0;
	     xa = ev->xexpose.x;
	     xb = xa + ev->xexpose.width;
	     ya = ev->xexpose.y;
	     yb = ya + ev->xexpose.height;
	     for (j = i - 1; j >= 0; j--)
	       {
		  ev2 = evq + j;
		  if (ev2->type == type &&
		      ev2->xexpose.window == ev->xexpose.window)
		    {
		       n++;
		       ev2->type = 0;
		       if (xa > ev2->xexpose.x)
			  xa = ev2->xexpose.x;
		       if (xb < ev2->xexpose.x + ev2->xexpose.width)
			  xb = ev2->xexpose.x + ev2->xexpose.width;
		       if (ya > ev2->xexpose.y)
			  ya = ev2->xexpose.y;
		       if (yb < ev2->xexpose.y + ev2->xexpose.height)
			  yb = ev2->xexpose.y + ev2->xexpose.height;
		    }
	       }
	     if (n)
	       {
		  ev->xexpose.x = xa;
		  ev->xexpose.width = xb - xa;
		  ev->xexpose.y = ya;
		  ev->xexpose.height = yb - ya;
	       }
#if ENABLE_DEBUG_EVENTS
	     if (EDebug(EDBUG_TYPE_COMPRESSION))
		Eprintf("EventsCompress n=%4d %s %#lx x=%4d-%4d y=%4d-%4d\n",
			n, EventName(type), ev->xexpose.window, xa, xb, ya, yb);
#endif
	     break;

	  case EX_EVENT_SHAPE_NOTIFY:
	     n = 0;
	     for (j = i - 1; j >= 0; j--)
	       {
		  ev2 = evq + j;
		  if (ev2->type == type && ev2->xany.window == ev->xany.window)
		    {
		       n++;
		       ev2->type = 0;
		    }
	       }
#if ENABLE_DEBUG_EVENTS
	     if (n && EDebug(EDBUG_TYPE_COMPRESSION))
		Eprintf("EventsCompress n=%4d %s %#lx\n",
			n, EventName(type), ev->xmotion.window);
#endif
	     break;

	  case GraphicsExpose:
	  case NoExpose:
	     /* Not using these */
	     ev->type = 0;
	     break;
	  }
     }

#if ENABLE_DEBUG_EVENTS
   /* Debug - should be taken out */
   if (EDebug(EDBUG_TYPE_COMPRESSION))
      for (i = 0; i < count; i++)
	 if (evq[i].type)
	    Eprintf("EventsCompress-2 %3d %s w=%#lx\n", i,
		    EventName(evq[i].type), evq[i].xany.window);
#endif
}
Ejemplo n.º 20
0
static              Window
ExtInitWinMain(void)
{
   int                 i, loop, err;
   Ecore_X_Window      win;
   XGCValues           gcv;
   GC                  gc;
   Pixmap              pmap;
   Atom                a;
   EiwData             eiwd;
   EiwLoopFunc        *eiwc_loop_func;

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinMain enter\n");

   err = EDisplayOpen(NULL, -1);
   if (err)
      return None;

   EGrabServer();

   EImageInit();

   eiwd.attr.backing_store = NotUseful;
   eiwd.attr.override_redirect = True;
   eiwd.attr.colormap = WinGetCmap(VROOT);
   eiwd.attr.border_pixel = 0;
   eiwd.attr.background_pixel = 0;
   eiwd.attr.save_under = True;
   win = XCreateWindow(disp, WinGetXwin(VROOT),
		       0, 0, WinGetW(VROOT), WinGetH(VROOT),
		       0, CopyFromParent, InputOutput, CopyFromParent,
		       CWOverrideRedirect | CWSaveUnder | CWBackingStore |
		       CWColormap | CWBackPixel | CWBorderPixel, &eiwd.attr);

   pmap = XCreatePixmap(disp, win,
			WinGetW(VROOT), WinGetH(VROOT), WinGetDepth(VROOT));
   gcv.subwindow_mode = IncludeInferiors;
   gc = XCreateGC(disp, win, GCSubwindowMode, &gcv);
   XCopyArea(disp, WinGetXwin(VROOT), pmap, gc,
	     0, 0, WinGetW(VROOT), WinGetH(VROOT), 0, 0);
   XSetWindowBackgroundPixmap(disp, win, pmap);
   XMapRaised(disp, win);
   XFreePixmap(disp, pmap);
   XFreeGC(disp, gc);

   a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
   ecore_x_window_prop_window_set(WinGetXwin(VROOT), a, &win, 1);

   XSelectInput(disp, win, StructureNotifyMask);

   EUngrabServer();
   ESync(0);

#if USE_EIWC_WINDOW && USE_EIWC_RENDER
   eiwc_loop_func = _eiw_render_init(win, &eiwd);
   if (!eiwc_loop_func)
      eiwc_loop_func = _eiw_window_init(win, &eiwd);
#elif USE_EIWC_RENDER
   eiwc_loop_func = _eiw_render_init(win, &eiwd);
#elif USE_EIWC_WINDOW
   eiwc_loop_func = _eiw_window_init(win, &eiwd);
#endif
   if (!eiwc_loop_func)
      return None;

   {
      XWindowAttributes   xwa;
      char                s[1024];
      EImage             *im;

      for (i = loop = 1;; i++, loop++)
	{
	   if (i > 12)
	      i = 1;

	   /* If we get unmapped we are done */
	   XGetWindowAttributes(disp, win, &xwa);
	   if (xwa.map_state == IsUnmapped)
	      break;

	   Esnprintf(s, sizeof(s), "pix/wait%i.png", i);
	   if (EDebug(EDBUG_TYPE_SESSION) > 1)
	      Eprintf("ExtInitWinCreate - child %s\n", s);

	   im = ThemeImageLoad(s);
	   if (im)
	     {
		eiwc_loop_func(win, im, &eiwd);
		EImageFree(im);
	     }
	   ESync(0);
	   usleep(50000);

	   /* If we still are here after 5 sec something is wrong. */
	   if (loop > 100)
	      break;
	}
   }

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinMain exit\n");

   EDisplayClose();

   exit(0);
}
Ejemplo n.º 21
0
Archivo: iclass.c Proyecto: Limsik/e17
static void
ImagestateMakePmapMask(ImageState * is, Win win, PmapMask * pmm,
		       int pmapflags, int w, int h, int image_type)
{
#ifdef ENABLE_TRANSPARENCY
   EImage             *ii = NULL;
   int                 flags;
   Pixmap              pmap, mask;

   flags = pt_type_to_flags(image_type);

   /*
    * is->transparent flags:
    *   0x01: Use desktop background pixmap as base
    *   0x02: Use root window as base (use only for transients, if at all)
    *   0x04: Don't apply image mask to result
    */
   if (is->transparent && EImageHasAlpha(is->im))
      flags = is->transparent;

   if (flags != ICLASS_ATTR_OPAQUE)
     {
	ii = pt_get_bg_image(win, w, h, flags & ICLASS_ATTR_GLASS);
     }
   else
     {
#if 0
	Eprintf("ImagestateMakePmapMask %#lx %d %d\n", win, w, h);
#endif
     }

   if (ii)
     {
	EImageBlendCM(ii, is->im, (flags & ICLASS_ATTR_USE_CM) ? icm : NULL);

	pmm->type = 0;
	pmm->pmap = pmap = ECreatePixmap(win, w, h, 0);
	pmm->mask = None;
	pmm->w = w;
	pmm->h = h;
	EImageRenderOnDrawable(ii, win, pmap, 0, 0, 0, w, h);

	if ((pmapflags & IC_FLAG_MAKE_MASK) && !(flags & ICLASS_ATTR_NO_CLIP))
	  {
	     if (EImageHasAlpha(is->im))
	       {
		  /* Make the scaled clip mask to be used */
		  EImageRenderPixmaps(is->im, win, EIMAGE_ANTI_ALIAS, &pmap,
				      &mask, w, h);

		  /* Replace the mask with the correct one */
		  pmm->mask = EXCreatePixmapCopy(mask, w, h, 1);

		  EImagePixmapsFree(pmap, mask);
	       }
	  }
	EImageDecache(ii);
     }
   else
#else
   pmapflags = 0;
   image_type = 0;
#endif /* ENABLE_TRANSPARENCY */
   if (is->pixmapfillstyle == FILL_STRETCH)
     {
	pmm->type = 1;
	pmm->pmap = pmm->mask = None;
	pmm->w = w;
	pmm->h = h;
	EImageRenderPixmaps(is->im, win, EIMAGE_ANTI_ALIAS, &pmm->pmap,
			    &pmm->mask, w, h);
     }
   else
     {
	int                 ww, hh, cw, ch, pw, ph;

	EImageGetSize(is->im, &ww, &hh);

	pw = w;
	ph = h;
	if (is->pixmapfillstyle & FILL_TILE_H)
	   pw = ww;
	if (is->pixmapfillstyle & FILL_TILE_V)
	   ph = hh;
	if (is->pixmapfillstyle & FILL_INT_TILE_H)
	  {
	     cw = w / ww;
	     if (cw * ww < w)
		cw++;
	     if (cw < 1)
		cw = 1;
	     pw = w / cw;
	  }
	if (is->pixmapfillstyle & FILL_INT_TILE_V)
	  {
	     ch = h / hh;
	     if (ch * hh < h)
		ch++;
	     if (ch < 1)
		ch = 1;
	     ph = h / ch;
	  }
	pmm->type = 1;
	pmm->pmap = pmm->mask = None;
	pmm->w = pw;
	pmm->h = ph;
	EImageRenderPixmaps(is->im, win, EIMAGE_ANTI_ALIAS, &pmm->pmap,
			    &pmm->mask, pw, ph);
     }
}
Ejemplo n.º 22
0
//*******************************************************************
// command loop over tmp_file
static int plotit(HANDLE outDC, const GEN_PAR * pg, const OUT_PAR * po)
{
	PlotCmd cmd;
	HPGL_Pt pt1 = { 0 };
	int pen_no = 0, pencolor = 0, err = 0;
	PEN_W pensize;
	pensize = pt.width[DEFAULT_PEN_NO];	/* Default pen      */
	pencolor = pt.color[DEFAULT_PEN_NO];
	emf_new_pen(0, pt.clut[pencolor][0],	// no draw pen
		    pt.clut[pencolor][1], pt.clut[pencolor][2], &pt1,
		    outDC);

	emf_init(po, outDC);	// invisible boundingbox
	emf_new_pen(pensize, pt.clut[pencolor][0], pt.clut[pencolor][1],
		    pt.clut[pencolor][2], &pt1, outDC);

	/**
	** Command loop: While temporary file not empty: process command.
	**/

	while ((cmd = PlotCmd_from_tmpfile()) != CMD_EOF) {
		switch (cmd) {
		case NOP:
			break;
		case SET_PEN:
			if ((pen_no = fgetc(pg->td)) == EOF) {
				PError("Unexpected end of temp. file: ");
				err = ERROR;
				goto emf_exit;
			}
			pensize = pt.width[pen_no];
			pencolor = pt.color[pen_no];
			emf_new_pen(pensize, pt.clut[pencolor][0],
				    pt.clut[pencolor][1],
				    pt.clut[pencolor][2], &pt1, outDC);
			break;
		case DEF_PW:	// DEFine penwidth
			if (!load_pen_width_table(pg->td)) {
				PError("Unexpected end of temp. file");
				err = ERROR;
				goto emf_exit;
			}
			break;
		case DEF_PC:	//DEFpen color
			err = load_pen_color_table(pg->td);
			if (err < 0) {
				PError("Unexpected end of temp. file");
				err = ERROR;
				goto emf_exit;
			}
			if (err == pencolor)
				pencolor *= -1;	/*current pen changed */
			break;
		case DEF_LA:
			if (load_line_attr(pg->td) < 0) {
				PError("Unexpected end of temp. file");
				err = ERROR;
				goto emf_exit;
			}
			break;
		case MOVE_TO:	// Moveto

			HPGL_Pt_from_tmpfile(&pt1);
			if (pensize != 0)
				emf_move_to(&pt1, outDC);
			break;
		case DRAW_TO:	// Draw line
			HPGL_Pt_from_tmpfile(&pt1);
			if (pensize != 0)
				emf_line_to(&pt1, 'D', outDC);
			break;
		case PLOT_AT:
			HPGL_Pt_from_tmpfile(&pt1);
			if (pensize != 0) {
				emf_line_to(&pt1, 'M', outDC);
				emf_line_to(&pt1, 'D', outDC);
			}
			break;
		default:
			Eprintf("Illegal cmd in temp. file!");
			err = ERROR;
			goto emf_exit;
		}
	}
	/* Finish up */
      emf_exit:
	{
		HANDLE old =
		    SelectObject(outDC, GetStockObject(BLACK_PEN));
		DeleteObject(old);
	}
	return err;
}
Ejemplo n.º 23
0
Archivo: sim_io.c Proyecto: palmerc/lab
int stdio_io(int vec)
{
	union {
		double d;
		int    i[2];
	} db1, db2, db3;
	register int arg1, arg2, arg3, arg4;
	int i, j, k;
	char str1[150], str2[150], rdwrbuf[RDWRBUF];
	FILE *fp_out = stdout;

	arg1 = getarg(1);
	arg2 = getarg(2);
	arg3 = getarg(3);
	arg4 = getarg(4);

	switch(vec)
	{			/* unsupported trap */
		default: 
			 return(1);

		case 0x1fb:   /* Unix times */
/*			addr = m88000.Regs[2];			*/
			i = readtime();
			PPrintf("at clock = %d\n",i);
/*			membyte(addr+0) = (char) uext(i,0,8);	*/
/*			membyte(addr+1) = (char) uext(i,8,8);	*/
/*			membyte(addr+2) = (char) uext(i,16,8);	*/
/*			membyte(addr+3) = (char) uext(i,24,8);	*/
			break;	

		case S_PRINTF:        /* printf     */
			if(!copystr(1, str1))
			    return(-1);
			sim_printf(fp_out, str1, 2);
			break;	

		case S_FPRINTF:       /* fprintf:   */
			if(!copystr(2, str1))
			    return(-1);
			sim_printf(ckiob((TARGETFILE *)arg1), str1, 3);
			break;

		case S_SPRINTF:       /* _sprintf:  */
			Eprintf("sorry, sprintf not yet supported\n");
			break;

		case S_SCANF:         /* _scanf:    */
		case S_FSCANF:     /* _fscanf:   */
		case S_SSCANF:     /* _sscanf:   */
		    Eprintf("sorry, scanf not yet supported\n");
		    break;

		case S_FOPEN:
		    if(!copystr(1, str1) || !copystr(2, str2))
			return(-1);
		    m88000.Regs[2] = (int)fopen(str1, str2);
                           break;

		case S_FREOPEN:
		    if(!copystr(1, str1) || !copystr(2, str2))
			return(-1);
		    m88000.Regs[2] = (int)freopen(str1, str2, ckiob((TARGETFILE *)arg3));
                           break;

		case S_FDOPEN:
		    if(!copystr(2, str1))
			return(-1);
		    m88000.Regs[2] = (int)fdopen(arg1, str1);
		    break;

		case S_FREAD:
		    k = arg2 * arg3;
		    j = 0;
		    do
		    {
		 	i = fread(rdwrbuf, sizeof(char), RDWRBUF, ckiob((TARGETFILE *)getarg(4)));
		 	if(rdwr((M_DATA | M_RD), arg1, rdwrbuf, (i < k) ? k: i) == -1)
					return(-1);
			j += (i < k) ? k: i;
			arg1 += i;
		    }
		    while((k -= i) < 0);
		    m88000.Regs[2] = j;
		    break;

		case S_FWRITE:
		    k = arg2 * arg3;
		    j = 0;
		    do
		    {
			if((i = k / RDWRBUF) == 0)
				i = k % RDWRBUF;
		 	if(rdwr((M_DATA | M_WR), arg1, rdwrbuf, i) == -1)
				return(-1);
		 	if(i != fwrite(rdwrbuf, sizeof(char), i, ckiob((TARGETFILE *)getarg(4))))
			{
				j = 0;
				break;
			}
			j += i;
			arg1 += i;
		    }
		    while((k -= i) < 0);
		    m88000.Regs[2] = j;
		    break;

		case S_FCLOSE:
		    m88000.Regs[2] = (int)fclose(ckiob((TARGETFILE *)arg1));
		    break;

		case S_FFLUSH:
		    m88000.Regs[2] = (int)fflush(ckiob((TARGETFILE *)arg1));
		    break;

		case 0x203:
		case 0x204:
		case S__FILBUF:    /* __filbuf:  */
		case S__FLSBUF:    /* __flsbuf:  */
		case S_MALLOC:     /* _malloc:   */
		case S_SETBUF:
		case S_SETBUFFER:
		case S_SETLINEBUF:
		    Eprintf("unsupported trap\n");
		    break;

		case S_FSEEK:
		    m88000.Regs[2] = (int)fseek(ckiob((TARGETFILE *)arg1), arg2, arg3);
		    break;

		case S_GETS:
		    if(fgets(rdwrbuf, sizeof(rdwrbuf), stdin) == 0)
			m88000.Regs[2] = 0;
		    else
		    {
			i = strchr(rdwrbuf, '\0') - rdwrbuf + 1;
		 	if(rdwr((M_DATA | M_WR), arg1, rdwrbuf, i) == -1)
				return(-1);
		    }
		    break;

		case S_FGETS:
		    i = (arg2 < sizeof(rdwrbuf)) ? arg2: sizeof(rdwrbuf);
		    if(fgets(rdwrbuf, i, ckiob((TARGETFILE *)arg3)) == 0)
			m88000.Regs[2] = 0;
		    else
		    {
			i = strchr(rdwrbuf, '\0') - rdwrbuf + 1;
		 	if(rdwr((M_DATA | M_WR), arg1, rdwrbuf, i) == -1)
				return(-1);
		    }
		    break;

		case S_REWIND:
		    rewind(ckiob((TARGETFILE *)arg1));
			    break;

		case S_FTELL:
		    m88000.Regs[2] = (int)ftell(ckiob((TARGETFILE *)arg1));
		    break;

		case S_FEOF:
		    m88000.Regs[2] = feof((FILE *)ckiob((TARGETFILE *)arg1));
		    break;

		case S_FERROR:
		    m88000.Regs[2] = ferror((FILE *)ckiob((TARGETFILE *)arg1));
		    break;

		case S_CLEARERR:
		    clearerr((FILE *)ckiob((TARGETFILE *)arg1));
		    break;

		case S_FILENO:
		    m88000.Regs[2] = (int)fileno((FILE *)ckiob((TARGETFILE *)arg1));
		    break;

		case S_GETC:
		case S_FGETC:
		    m88000.Regs[2] = (int)getc((FILE *)ckiob((TARGETFILE *)arg1));
		    break;

		case S_GETCHAR:
		    m88000.Regs[2] = (int)getchar();
		    break;

		case S_GETW:
		    m88000.Regs[2] = (int)getw(ckiob((TARGETFILE *)arg1));
		    break;

		case S_PUTC:
		case S_FPUTC:
		    m88000.Regs[2] = (int)fputc(arg1,ckiob((TARGETFILE *)arg2));
		    break;

		case S_PUTCHAR:
		    m88000.Regs[2] = (int)putchar(arg1);
		    break;


		case S_PUTW:
		    m88000.Regs[2] = (int)putw(arg1,ckiob((TARGETFILE *)arg2));
		    break;

		case S_PUTS:
		    if(!copystr(1, str1))
			return(-1);
		    m88000.Regs[2] = (int)puts(str1);
		    break;

		case S_FPUTS:
		    if(!copystr(1, str1))
			return(-1);
		    m88000.Regs[2] = (int)fputs(str1, ckiob((TARGETFILE *)arg2));
		    break;

		case S_UNGETC:
		    m88000.Regs[2] = (int)ungetc(arg1, ckiob((TARGETFILE *)arg2));
		    break;
		case S_GETTIME:
			m88000.Regs[2] = (int)readtime();
			break;
		case S_SYSTEM:
			if(!copystr(1, str1))
				return(-1);
			m88000.Regs[2] = (int)system(str1);
			break;
		case S_EXP:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = exp(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_LOG:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = log(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_LOG10:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = log10(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_SQRT:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = sqrt(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_SINH:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = sinh(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_COSH:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = cosh(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_TANH:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = tanh(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
     			break;	
		case S_FLOOR:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = floor(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_CEIL:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.d = ceil(db1.d);
			m88000.Regs[2] = db2.i[0];
			m88000.Regs[3] = db2.i[1];
			break;
		case S_POW:
			db1.i[0] = arg1;
			db1.i[1] = arg2;
			db2.i[0] = arg3;
			db2.i[1] = arg4;
			db3.d = pow(db1.d,db2.d);
			m88000.Regs[2] = db3.i[0];
			m88000.Regs[3] = db3.i[1];
			break;
	}

	IP += 4;
	return(0);
}
Ejemplo n.º 24
0
int PicBuf_to_PNG(const GEN_PAR * pg, const OUT_PAR * po)
{
	FILE *fd;
	int row_c, /*byte_c, */ x;
	const RowBuf *row;
	const PicBuf *pb;
	int ppm[][3] = { {255, 255, 255}, {0, 0, 0} };
/*, {255,0,0}, {0,255,0},
		{0,0,255},{0,255,255},{255,0,255},{255,255,0}};
*/
	int colour;

/**
 ** gifdraw-parts
 **/
	pdImagePtr im;
	int pdcol;

	if (pg == NULL || po == NULL)
		return ERROR;
	pb = po->picbuf;
	if (pb == NULL)
		return ERROR;

	if (!pg->quiet)
		Eprintf("\nWriting PNG output: %s\n", po->outfile);
	if (*po->outfile != '-') {

/*
#ifdef VAX
	if ((fd = fopen(po->outfile, WRITE_BIN, "rfm=var", "mrs=512")) == NULL)
#else
*/
		if ((fd = fopen(po->outfile, WRITE_BIN)) == NULL)
/*
#endif
*/
			goto ERROR_EXIT;
	} else
		fd = stdout;

/**
 ** create image structure
 **/
	im = pdImageCreate(pb->nc, pb->nr);

	if (pb->depth > 1) {
/** 
 ** allocate some colors ( ?? eight colors supported by hp2xx ?? )
 **/
		for (colour = 0; colour < PDNCOL; colour++)
/*  pdcol = pdImageColorAllocate(im, ppm[colour][0], ppm[colour][1], 
				    ppm[colour][2]);
*/
			pdcol =
			    pdImageColorAllocate(im, pt.clut[colour][0],
						 pt.clut[colour][1],
						 pt.clut[colour][2]);
		for (row_c = 0; row_c < pb->nr; row_c++) {
			row = get_RowBuf(pb, pb->nr - row_c - 1);
			if (row == NULL)
				continue;

			for (x = 0; x < pb->nc; x++) {
				colour = index_from_RowBuf(row, x, pb);
				pdImageSetPixel(im, x, row_c, colour);
			}
			if ((!pg->quiet) && (row_c % 10 == 0))
				/* For the impatients among us ...   */
				Eprintf(".");
		}
	} else {
/** 
 ** allocate two colors ( ?? eight colors supported by hp2xx ?? )
 **/
		for (colour = 0; colour < 2; colour++)
			pdcol =
			    pdImageColorAllocate(im, ppm[colour][0],
						 ppm[colour][1],
						 ppm[colour][2]);

		for (row_c = 0; row_c < pb->nr; row_c++) {
			row = get_RowBuf(pb, pb->nr - row_c - 1);
			if (row == NULL)
				continue;

			for (x = 0; x < pb->nc; x++) {
				colour = index_from_RowBuf(row, x, pb);
				pdImageSetPixel(im, x, row_c, colour);
			}

			if ((!pg->quiet) && (row_c % 10 == 0))
				/* For the impatients among us ...   */
				Eprintf(".");
		}
	}

	pdImagePNG(im, fd);

	pdImageDestroy(im);

	fflush(fd);

	if (!pg->quiet)
		Eprintf("\n");
	if (fd != stdout)
		fclose(fd);
	return 0;

      ERROR_EXIT:
	PError("write_PNG");
	return ERROR;
}
Ejemplo n.º 25
0
static void
process_opts (int argc, char* argv[],
		const char* shortopts, struct option longopts[],
		GEN_PAR* pg, IN_PAR* pi, OUT_PAR* po)
{
int	c, i,j, longind;
char	*p, cdummy;

  while ((c=getopt_long(argc,argv, shortopts, longopts, &longind)) != EOF)
	switch (c)	/* Easy addition of options ... */
	{
	  case 'a':
		pi->aspectfactor = atof (optarg);
		if (pi->aspectfactor <= 0.0)
		{
			Eprintf("Aspect factor: %g illegal\n",
				pi->aspectfactor);
			exit(ERROR);
		}
		break;

	  case 'c':
		i = strlen(optarg);
		if ((i<1) || (i>8))
		{
			Eprintf("Invalid pencolor string: %s\n", optarg);
			exit(ERROR);
		}
		for (j=1, p = optarg; j <= i; j++, p++)
		{
		    switch (*p-'0')
		    {
			case xxBackground:pt.color[j] = xxBackground; break;
			case xxForeground:pt.color[j] = xxForeground; break;
			case xxRed:	  pt.color[j] = xxRed;	  break;
			case xxGreen:	  pt.color[j] = xxGreen;	  break;
			case xxBlue:	  pt.color[j] = xxBlue;	  break;
			case xxCyan:	  pt.color[j] = xxCyan;	  break;
			case xxMagenta:	  pt.color[j] = xxMagenta;  break;
			case xxYellow:	  pt.color[j] = xxYellow;	  break;
			default :
				  Eprintf(
				    "Invalid color of pen %d: %c\n", j, *p);
				  exit(ERROR);
		    }
		    if (pt.color[j] != xxBackground &&
			pt.color[j] != xxForeground)
				pg->is_color = TRUE;
		}
		pi->hwcolor=TRUE;
		break;

	  case 'C':
		pi->center_mode = TRUE;
		break;

	  case 'd':
		switch (po->dpi_x = atoi (optarg))
		{
		  case 75:
			break;
		  case 100:
		  case 150:
		  case 300:
		  case 600:
			if ((!pg->quiet) && (strcmp(pg->mode,"pcl")==0) &&
				po->specials == 0)
			Eprintf(
			  "Warning: DPI setting is no PCL level 3 feature!\n");
			break;
		  default:
			if ((!pg->quiet) && (strcmp(pg->mode,"pcl")==0))
			Eprintf(
			  "Warning: DPI value %d is invalid for PCL mode\n",
				po->dpi_x);
			break;
		}
		break;

	  case 'D':
		po->dpi_y = atoi (optarg);
		if ((!pg->quiet) && strcmp(pg->mode,"pcl")==0 && po->specials==0)
			Eprintf("Warning: %s\n",
			"Different DPI for x & y is invalid for PCL mode");
		break;

	  case 'F':
		po->formfeed = TRUE;
		break;

	  case 'f':
		po->outfile = optarg;
		break;

	  case 'h':
		pi->height = atof (optarg);
		if (pi->height < 0.1)
			Eprintf("Warning: Small height: %g mm\n", pi->height);
		if (pi->height > 300.0)
			Eprintf("Warning: Huge  height: %g mm\n", pi->height);
		break;

	  case 'i':
		po->init_p = TRUE;
		break;

	  case 'l':
		pg->logfile = optarg;
		if (freopen(pg->logfile, "w", stderr) == NULL)
		{
			PError ("Cannot open log file");
			Eprintf("Error redirecting stderr\n");
			Eprintf("Continuing with output to stderr\n");
		}
		else
			Logfile_flag = TRUE;
		break;

	  case 'm':
		pg->mode = optarg;
		for (i=0; ModeList[i].mode != XX_TERM; i++)
			if (strcmp(ModeList[i].modestr, pg->mode) == 0)
				break;
		if (ModeList[i].mode == XX_TERM)
		{
			Eprintf("'%s': unknown mode!\n", pg->mode);
			Eprintf("Supported are:\n\t");
			print_supported_modes();
			Send_Copyright();
		}
		break;

	  case 'n':
	  	pg->nofill = TRUE;
	  	break;

	  case 'N':
	  	pg->no_ps = TRUE;
	  	break;
	  		  	
	  case 'o':
		pi->xoff = atof (optarg);
		if (pi->xoff < 0.0)
		{
			Eprintf("Illegal X offset: %g < 0\n", pi->xoff);
			exit(ERROR);
		}
		if (pi->xoff > 210.0)	/* About DIN A4 width */
		{
			Eprintf("Illegal X offset: %g > 210\n", pi->xoff);
			exit(ERROR);
		}
		break;

	  case 'O':
		pi->yoff = atof (optarg);
		if (pi->yoff < 0.0)
		{
			Eprintf("Illegal Y offset: %g < 0\n", pi->yoff);
			exit(ERROR);
		}
		if (pi->yoff > 300.0)	/* About DIN A4 height */
		{
			Eprintf("Illegal Y offset: %g > 300\n", pi->yoff);
			exit(ERROR);
		}
		break;

	  case 'p':
		i = strlen(optarg);
		if ((i<1) || (i>8))
		{
			Eprintf("Invalid pensize string: %s\n", optarg);
			exit(ERROR);
		}
		for (j=1, p = optarg; j <= i; j++, p++)
		{
			if ((*p < '0') || (*p > '9'))
			{
				Eprintf("Invalid size of pen %d: %c\n",	j, *p);
				exit(ERROR);
			}
			pt.width[j] = *p - '0';
			if (pg->maxpensize < pt.width[j])
				pg->maxpensize = pt.width[j];
		}
		pi->hwsize=TRUE;
		break;

	  case 'P':
		if (*optarg == ':')
		{
			pi->first_page = 0;
			optarg++;
			if (sscanf(optarg,"%d", &pi->last_page) != 1)
				pi->last_page = 0;
		}
		else
			switch (sscanf(optarg,"%d%c%d",
				&pi->first_page, &cdummy, &pi->last_page))
			{
			  case 1:
				pi->last_page = pi->first_page;
				break;

			  case 2:
				if (cdummy == ':')
				{
					pi->last_page = 0;
					break;
				}
				/* not ':' Syntax error -- drop through	*/
			  case 3:
				if (cdummy == ':')
					break;
				/* not ':' Syntax error -- drop through	*/
			  default:
				Eprintf("Illegal page range.\n");
				usage_msg (pg, pi, po);
				exit(ERROR);
			}
		break;

	  case 'q':
		pg->quiet = TRUE;
		break;

	  case 'r':
		pi->rotation = atof(optarg);
		break;

	  case 'S':
		po->specials = atoi (optarg);
		break;

	  case 's':
		pg->swapfile = optarg;
		break;

	  case 't':
		pi->truesize = TRUE;
		break;

	  case 'V':
		po->vga_mode = atoi (optarg);
		break;

	  case 'w':
		pi->width = atof (optarg);
		if (pi->width < 0.1)
			Eprintf("Warning: Small width: %g mm\n", pi->width);
		if (pi->width > 300.0)
			Eprintf("Warning: Huge  width: %g mm\n", pi->width);
		break;

	  case 'v':
		Send_version();
		exit (NOERROR);

	  case 'x':
		pi->x0 = atof (optarg);
		break;

	  case 'X':
		pi->x1 = atof (optarg);
		break;

	  case 'y':
		pi->y0 = atof (optarg);
		break;

	  case 'Y':
		pi->y1 = atof (optarg);
		break;

	  case 'H':
	  case '?':
	  default:
		usage_msg (pg, pi, po);
		exit (ERROR);
	}
}
Ejemplo n.º 26
0
void	ps_init (const GEN_PAR *pg, const OUT_PAR *po, FILE *fd,
                 PEN_W pensize)
{
    long	left, right, low, high;
    double	hmxpenw;

    hmxpenw = pg->maxpensize / 2.0;	/* Half max. pen width, in mm	*/

    /**
     ** Header comments into PostScript file
     **/

    fprintf(fd,"%%!PS-Adobe-2.0 EPSF-2.0\n");
    fprintf(fd,"%%%%Title: %s\n", po->outfile);
    fprintf(fd,"%%%%Creator: hp2xx (c) 1991 - 1994 by  H. Werntges\n");
    fprintf(fd,"%%%%CreationDate: %s\n", Getdate());
    fprintf(fd,"%%%%Pages: 1\n");

    /**
     ** Bounding Box limits: Conversion factor: 2.834646 * 1/72" = 1 mm
     **
     ** (hmxpenw & floor/ceil corrections suggested by Eric Norum)
     **/
    left  = (long) floor(abs(po->xoff-hmxpenw)                * MM_TO_PS_POINT);
    low   = (long) floor(abs(po->yoff-hmxpenw)                * MM_TO_PS_POINT);
    right = (long) ceil ((po->xoff+po->width+hmxpenw)         * MM_TO_PS_POINT);
    high  = (long) ceil ((po->yoff+po->height+hmxpenw)        * MM_TO_PS_POINT);
    fprintf(fd,"%%%%BoundingBox: %ld %ld %ld %ld\n", left, low, right, high);
    if (!pg->quiet)
        Eprintf ("Bounding Box: [%ld %ld %ld %ld]\n",
                 left, low, right, high);

    fprintf(fd,"%%%%EndComments\n\n");

    /**
     ** Definitions
     **/

    fprintf(fd,"%%%%BeginProcSet:\n");
    fprintf(fd,"/PSSave save def\n");      /* save VM state */
    fprintf(fd,"/PSDict 200 dict def\n");  /* define a dictionary */
    fprintf(fd,"PSDict begin\n");          /* start using it */
    fprintf(fd,"/@restore /restore load def\n");
    fprintf(fd,"/restore\n");
    fprintf(fd,"   {vmstatus pop\n");
    fprintf(fd,"    dup @VMused lt {pop @VMused} if\n");
    fprintf(fd,"    exch pop exch @restore /@VMused exch def\n");
    fprintf(fd,"   } def\n");

    fprintf(fd,"/@pri\n");
    fprintf(fd,"   {\n");
    fprintf(fd,"    ( ) print\n");
    fprintf(fd,"    (                                       ) cvs print\n");
    fprintf(fd,"   } def\n");

    fprintf(fd,"/@start\n");    /* - @start -  -- start everything */
    fprintf(fd,"   {\n");
    fprintf(fd,"    vmstatus pop /@VMused exch def pop\n");
    fprintf(fd,"   } def\n");

    fprintf(fd,"/@end\n");      /* - @end -  -- finished */
    fprintf(fd,"   {");
    if (!pg->quiet)
    {
        fprintf(fd,    "(VM Used: ) print @VMused @pri\n");
        fprintf(fd,"    (. Unused: ) print vmstatus @VMused sub @pri pop pop\n");
        fprintf(fd,"    (\\n) print flush\n");

    }
    fprintf(fd,"    end\n");
    fprintf(fd,"    PSSave restore\n");
    fprintf(fd,"   } def\n");

    fprintf(fd,"/bop\n");       /* bop -  -- begin a new page */
    fprintf(fd,"   {\n");
    fprintf(fd,"    /SaveImage save def\n");
    fprintf(fd,"   } def\n");

    fprintf(fd,"/eop\n");       /* - eop -  -- end a page */
    fprintf(fd,"   {\n");
    fprintf(fd,"    showpage\n");
    fprintf(fd,"    SaveImage restore\n");
    fprintf(fd,"   } def\n");

    fprintf(fd,"/@line\n   {");     /* set line parameters */
    fprintf(fd,"  1 setlinejoin %%%% Replace 1 by 0 for cut-off lines\n");
    fprintf(fd,"%%%%    1 setmiterlimit    %%%%  Uncomment this for cut-off lines\n");
    fprintf(fd,"   } def\n");

    fprintf(fd,"/@SetPlot\n");
    fprintf(fd,"   {\n");
    fprintf(fd,"    %f %f scale\n",MM_TO_PS_POINT,MM_TO_PS_POINT);	/* 1/72"--> mm */
    fprintf(fd,"    %7.3f %7.3f translate\n", po->xoff+hmxpenw, po->yoff+hmxpenw);
    fprintf(fd,"    %6.3f setlinewidth\n", pensize);
    fprintf(fd,"   } def\n");
    fprintf(fd,"/C {setrgbcolor} def\n");
    fprintf(fd,"/D {lineto} def\n");
    fprintf(fd,"/M {moveto} def\n");
    fprintf(fd,"/S {stroke} def\n");
    fprintf(fd,"/W {setlinewidth} def\n");
    fprintf(fd,"/Z {stroke newpath} def\n");
    fprintf(fd,"end\n");      /* end of dictionary definition */
    fprintf(fd,"%%%%EndProcSet\n\n");

    /**
     ** Set up the plots
     **/

    fprintf(fd,"%%%%BeginSetup\n");
    fprintf(fd,"/#copies 1 def\n");
    fprintf(fd,"%%%%EndSetup\n");
    fprintf(fd,"%%%%Page: 1 1\n");
    fprintf(fd,"%%%%BeginPageSetup\n");
    fprintf(fd,"PSDict begin\n");
    fprintf(fd,"@start\n");
    fprintf(fd,"@line\n");
    fprintf(fd,"@SetPlot\n\n");
    fprintf(fd,"bop\n");
    fprintf(fd,"%%%%EndPageSetup\n");
}
Ejemplo n.º 27
0
//*******************************************************************
// Mesage handler for Preview Dialog.
static INT_PTR CALLBACK
Preview(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static const GEN_PAR *pg;
	static const OUT_PAR *po;
	static int first = 1;

	switch (message) {
	case WM_INITDIALOG:
		{
			HMENU meny;
			PGPO *p = (PGPO *) lParam;
			po = p->po;	// save them for print/draw later on
			pg = p->pg;
			SetWindowText(hDlg, "Preview Enter to close");
			meny = GetSystemMenu(hDlg, 0);
			// add print item to bottom of system menu
			InsertMenu(meny, (unsigned) -1, MF_BYPOSITION,
				   PRINT, "Print");
		}
		return TRUE;
	case WM_SIZE:
		InvalidateRect(hDlg, 0, TRUE);	// redraw all
		return TRUE;

	case WM_SYSCOMMAND:
		if (LOWORD(wParam) == PRINT) {
			reset_tmpfile();	//rewind so i can reuse the data  (in hpgl.c)
			to_emp(pg, po);
			return TRUE;
		}
		return FALSE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
			EndDialog(hDlg, LOWORD(wParam));
			return TRUE;
		}
		break;
	case WM_PAINT:
		{
			RECT rt;
			PAINTSTRUCT ps;
			HDC dc;
			dc = BeginPaint(hDlg, &ps);
			GetClientRect(hDlg, &rt);
			SetScale(dc, rt.bottom, rt.right, po);

			reset_tmpfile();	//rewind so i can redraw it in hpgl.c
			plotit(dc, pg, po);
			EndPaint(hDlg, &ps);
			if (first) {
				Eprintf("\nWaiting for preview to end\n");
				first = 0;
			}
		}
		return TRUE;
	case WM_ERASEBKGND:	// fix white background
		{
			RECT rt;
			GetClientRect(hDlg, &rt);
			rt.bottom += 1;
			rt.right += 1;
			FillRect((HDC) wParam, &rt,
				 GetStockObject(WHITE_BRUSH));
		}
		return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 28
0
int
to_eps (const GEN_PAR *pg, const OUT_PAR *po)
{
    PlotCmd	cmd;
    HPGL_Pt	pt1 = {0,0};
    FILE		*md;
    int		pen_no=0, pencolor=0, err;
    PEN_W		pensize;

    err = 0;
    if (!pg->quiet)
        Eprintf ("\n\n- Writing EPS code to \"%s\"\n",
                 *po->outfile == '-' ? "stdout" : po->outfile);

    /* Init. of PostScript file: */
    if (*po->outfile != '-')
    {
        if ((md = fopen(po->outfile, "w")) == NULL)
        {
            PError("hp2xx (eps)");
            return ERROR;
        }
    }
    else
        md = stdout;

    /* PS header */

    pensize = pt.width[DEFAULT_PEN_NO]; /* Default pen	*/
    ps_init (pg, po, md, pensize);

    if (pensize > 0.05)
        fprintf(md," %6.3f W\n", pensize);

    /* Factor for transformation of HP coordinates to mm	*/

    xcoord2mm = po->width  / (po->xmax - po->xmin);
    ycoord2mm = po->height / (po->ymax - po->ymin);
    xmin	    = po->xmin;
    ymin	    = po->ymin;

    /**
     ** Command loop: While temporary file not empty: process command.
     **/

    while ((cmd = PlotCmd_from_tmpfile()) != CMD_EOF)
    {
        switch (cmd)
        {
        case NOP:
            break;
        case SET_PEN:
            if ((pen_no = fgetc(pg->td)) == EOF)
            {
                PError("Unexpected end of temp. file: ");
                err = ERROR;
                goto EPS_exit;
            }
            pensize = pt.width[pen_no];
            pencolor = pt.color[pen_no];
            break;
        case DEF_PW:
            if(!load_pen_width_table(pg->td)) {
                PError("Unexpected end of temp. file");
                err = ERROR;
                goto EPS_exit;
            }
            pensize=pt.width[pen_no];
            break;
        case DEF_PC:
            err=load_pen_color_table(pg->td);
            if (err<0) {
                PError("Unexpected end of temp. file");
                err = ERROR;
                goto EPS_exit;
            }
            if (err==pencolor) pencolor *=-1; /*current pen changed*/
            break;
        case DEF_LA:
            if(load_line_attr(pg->td) <0) {
                PError("Unexpected end of temp. file");
                err = ERROR;
                goto EPS_exit;
            }
            break;
        case MOVE_TO:
            ps_set_linewidth(pensize, &pt1, md);
            ps_set_linecap(CurrentLineAttr.End, pensize, &pt1, md);

            if(pencolor <0) {
                pencolor=pt.color[pen_no];
                ps_set_color (  pt.clut[pencolor][0]/255.0,
                                pt.clut[pencolor][1]/255.0,
                                pt.clut[pencolor][2]/255.0,
                                &pt1, md);
            }

            HPGL_Pt_from_tmpfile (&pt1);
            if (pensize > 0.05)
                ps_stroke_and_move_to (&pt1, md);
            break;
        case DRAW_TO:
            ps_set_linewidth(pensize, &pt1, md);
            ps_set_linecap(CurrentLineAttr.End, pensize, &pt1, md);

            if(pencolor <0) {
                pencolor=pt.color[pen_no];
                ps_set_color (  pt.clut[pencolor][0]/255.0,
                                pt.clut[pencolor][1]/255.0,
                                pt.clut[pencolor][2]/255.0,
                                &pt1, md);
            }

            HPGL_Pt_from_tmpfile (&pt1);
            if (pensize > 0.05)
                ps_line_to (&pt1, 'D', md);
            break;
        case PLOT_AT:
            ps_set_linewidth(pensize, &pt1, md);
            ps_set_linecap(CurrentLineAttr.End, pensize, &pt1, md);

            if(pencolor<0) {
                pencolor=pt.color[pen_no];
                ps_set_color (  pt.clut[pencolor][0]/255.0,
                                pt.clut[pencolor][1]/255.0,
                                pt.clut[pencolor][2]/255.0,
                                &pt1, md);
            }

            HPGL_Pt_from_tmpfile (&pt1);
            if (pensize > 0.05) {
                ps_line_to (&pt1, 'M', md);
                ps_line_to (&pt1, 'D', md); /* not sure whether this is needed */
                ps_draw_dot(&pt1,pensize/2,md);
            }
            break;
        default:
            Eprintf ("Illegal cmd in temp. file!");
            err = ERROR;
            goto EPS_exit;
        }
    }

    /* Finish up */

    ps_end (md);

EPS_exit:
    if (md != stdout)
        fclose (md);

    if (!pg->quiet)
        Eprintf ("\n");
    return err;
}
Ejemplo n.º 29
0
static void noreturn parse_error(int line, char *msg)
{
	Eprintf("config file line %d: %s\n", line, msg);
	exit(1);
}
Ejemplo n.º 30
0
Archivo: dpath.c Proyecto: palmerc/lab
int Data_path (void)
{
	register struct mem_wrd *memaddr;
	register struct IR_FIELDS   *ir;
	register struct SIM_FLAGS   *f;
	int     retval,retval_cmmu;				/* return value */
	unsigned int	issue_latency = 0;	/* max time to issue instr(s) */


	if (ckbrkpts(IP, BRK_EXEC))		/* Check for breakpoint */
	{
		retval = -1;
		return(retval);
	}

	retval_cmmu = 0;
	if(usecmmu && (retval = cmmu_function1()))
		return(retval);

	if ((memaddr = getmemptr (IP, M_INSTR)) == 0)
		return (exception(E_TCACC, "Code Access Bus Error"));

	ir = &memaddr -> opcode;
	f = ((ir->p) ? &ir->p->flgs: &simdata.flgs);


	/* see if we can issue the instruction in this clock */

	if ( (retval = test_issue( ir, f )) == -1 )
	{
		return ( retval );
	}
	else
	{

		Statistics (ir);

		/* Issue the instruction to the appropriate FU */

		do_issue();
		issue_latency = f->is_latency;
		issue_latency += retval;
		prev_extime = issue_latency;

		if(debugflag)
			PPrintf(" after chk_SB : Dcmmutime = %d \n", Dcmmutime);

		if (usecmmu)
			cmmu_function2(ir);

		/*
		 * The data from the source 1 register is put onto the 
		 * source 1 bus, as an input to the ALU.
		 */

		m88000.S1bus = m88000.Regs[ir -> src1];

		/*
		 * The data from the source 2 register, or an immediate 
		 * value, is put on the source 2 bus, which is also an 
		 * input to the ALU.
		 */

		if (!f -> imm_flags)	/* if not immediate */
			m88000.S2bus = m88000.Regs[ir -> src2];
		else if (f -> imm_flags == i26bit)
			m88000.S2bus = sext (opword (IP), 0, 26);
		else if ((f -> imm_flags == i16bit) &&
				((ir -> op < (unsigned)JSR) || (ir -> op > (unsigned)BCND)))
			m88000.S2bus = uext (opword (IP), 0, 16);
		else if ((f -> imm_flags == i16bit) &&
				((ir -> op >= (unsigned)JSR) && (ir -> op <= (unsigned)BCND)))
			m88000.S2bus = sext (opword (IP), 0, 16);
		else if (f -> imm_flags == i10bit)
			m88000.S2bus = uext (opword (IP), 0, 10);
		else
		{
			Eprintf ("SYSTEM ERROR in dpath, funky sized immediate\n");
			return(-1);
		}

		/*
		 * The instruction has been issued and the busses have 
		 * been driven.  Now execute the instruction.
		 */

		if( retval = execute(ir, f, memaddr) ) return(retval);

   		if (usecmmu && debugflag)
			PPrintf(" Dcmmutime (total after store) = %d \n",Dcmmutime);

		/*
		 *	Adjust the program counter
		 */

		killtime ( issue_latency );
		if ( retval = Pc(memaddr, ir, f) )
			return ( retval );

	}


	return ( retval );
}