Ejemplo n.º 1
0
extern void
initialiseCursors(int screen) {
	XColor red, white, exact;
	Colormap cmp;
	int i;
	
	cmp = DefaultColormap(dpy, screen);
	
	XAllocNamedColor(dpy, cmp, "red", &red, &exact);
	XAllocNamedColor(dpy, cmp, "white", &white, &exact);
	
	screens[screen].root_cursor = XCreateFontCursor(dpy, XC_left_ptr);
	XRecolorCursor(dpy, screens[screen].root_cursor, &red, &white);

	screens[screen].box_cursor = XCreateFontCursor(dpy, XC_draped_box);
	XRecolorCursor(dpy, screens[screen].box_cursor, &red, &white);
	
	for (i = 0; cursor_map[i].font_char != 0; i++) {
		Edge e = cursor_map[i].edge;
		screens[screen].cursor_map[e] =
			XCreateFontCursor(dpy, cursor_map[i].font_char);
		XRecolorCursor(dpy, screens[screen].cursor_map[e],
			&red, &white);
	}
}
Ejemplo n.º 2
0
static void
initCursor() {
    XColor red, white, exact;
    Colormap cmp = DefaultColormap(dpy, DefaultScreen(dpy));
    XAllocNamedColor(dpy, cmp, "red", &red, &exact);
    XAllocNamedColor(dpy, cmp, "white", &white, &exact);
    mouse_cursor = XCreateFontCursor(dpy, XC_left_ptr);
    XRecolorCursor(dpy, mouse_cursor, &red, &white);
}
Ejemplo n.º 3
0
void MSDisplayCursor::
create(MSDisplayServer *pServer_,const char *pName_,unsigned int shape_,unsigned long fg_,unsigned long bg_)
{
  Cursor c=XCreateFontCursor(pServer_->display(),shape_);
  _pData=new MSDisplayCursorData(pServer_,pName_,c,16,16,1,fg_,bg_,shape_);
  _pCursorHashTable->add(pName_,(void *)_pData);

  XColor fgColor,bgColor,screenColor;
  
  XLookupColor(pServer_->display(),pServer_->colormap(),pServer_->colorName(fg_),&fgColor,&screenColor);
  XLookupColor(pServer_->display(),pServer_->colormap(),pServer_->colorName(bg_),&bgColor,&screenColor);
  XRecolorCursor(pServer_->display(),cursor(),&fgColor,&bgColor);
}
Ejemplo n.º 4
0
void
rxvt_term::recolour_cursor ()
{
  XColor fg, bg;

  (ISSET_PIXCOLOR (Color_pointer_fg)
     ? pix_colors_focused[Color_pointer_fg]
     : pix_colors_focused[Color_fg]).get (fg);

  (ISSET_PIXCOLOR (Color_pointer_bg)
     ? pix_colors_focused[Color_pointer_bg]
     : pix_colors_focused[Color_bg]).get (bg);

  XRecolorCursor (dpy, TermWin_cursor, &fg, &bg);
}
Ejemplo n.º 5
0
void
_DtTermPrimRecolorPointer(Widget w)
{
    DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;

    XColor colordefs[2];        /* 0 is foreground, 1 is background */
    Display *dpy = XtDisplay(w);

    colordefs[0].pixel = tw->term.pointerColor;
    colordefs[1].pixel = tw->term.pointerColorBackground;
    XQueryColors (dpy, DefaultColormap (dpy, DefaultScreen (dpy)),
          colordefs, 2);
    XRecolorCursor (dpy, tw->term.pointerShape, colordefs, colordefs+1);
    return;
}
Ejemplo n.º 6
0
Archivo: util.c Proyecto: aosm/X11
void SetCursorColor(
    Widget		widget,
    Cursor		cursor,
    unsigned long	foreground)
{
    XColor	colors[2];
    Arg		args[2];
    Colormap	cmap;

    colors[0].pixel = foreground;
    XtSetArg(args[0], XtNbackground, &(colors[1].pixel));
    XtSetArg(args[1], XtNcolormap, &cmap);
    XtGetValues(widget, args, (Cardinal) 2);
    XQueryColors(XtDisplay(widget), cmap, colors, 2);
    XRecolorCursor(XtDisplay(widget), cursor, &colors[0], &colors[1]);
}
Ejemplo n.º 7
0
void
xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed)
{
  XColor fg_color, bg_color;
  
  fg_color.red = pCursor->foreRed;
  fg_color.green = pCursor->foreGreen;
  fg_color.blue = pCursor->foreBlue;
  
  bg_color.red = pCursor->backRed;
  bg_color.green = pCursor->backGreen;
  bg_color.blue = pCursor->backBlue;
  
  XRecolorCursor(xnestDisplay, 
		 xnestCursor(pCursor, pScreen),
		 &fg_color, &bg_color);
}
Ejemplo n.º 8
0
void
setPointerColor(GC color)
{
	XGCValues gcv;
	XColor fcolor, bcolor;

	XGetGCValues(DADisplay, color, GCForeground, &gcv);

	fcolor.pixel = gcv.foreground;
	fcolor.flags = DoRed | DoGreen | DoBlue;

	bcolor.red = 0;
	bcolor.green = 0;
	bcolor.blue = 0;

	XRecolorCursor(DADisplay, pointer, &fcolor, &bcolor);
}
Ejemplo n.º 9
0
void
CXCursor::
recolor(const CRGBA &bg, const CRGBA &fg)
{
  Display *display = screen_.getDisplay();

  XColor fg_xcolor;
  XColor bg_xcolor;

  fg_xcolor.red   = (int) (fg.getRed  ()*65535);
  fg_xcolor.green = (int) (fg.getGreen()*65535);
  fg_xcolor.blue  = (int) (fg.getBlue ()*65535);

  bg_xcolor.red   = (int) (bg.getRed  ()*65535);
  bg_xcolor.green = (int) (bg.getGreen()*65535);
  bg_xcolor.blue  = (int) (bg.getBlue ()*65535);

  XRecolorCursor(display, xcursor_, &fg_xcolor, &bg_xcolor);
}
Ejemplo n.º 10
0
/*ARGSUSED*/
Boolean
XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args,
			  XrmValuePtr fromVal, XrmValuePtr toVal,
			  XtPointer *converter_data)
{
    Cursor cursor;
    Screen *screen;
    Pixel fg, bg;
    Colormap c_map;
    XColor colors[2];
    Cardinal number;
    XrmValue ret_val;

    if (*num_args != 4) {
	XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
	    "wrongParameters","cvtStringToColorCursor","XmuError",
            "String to color cursor conversion needs four arguments",
	    (String *)NULL, (Cardinal *)NULL);
	return False;
    }

    screen = *((Screen **) args[0].addr);
    fg = *((Pixel *) args[1].addr);
    bg = *((Pixel *) args[2].addr);
    c_map = *((Colormap *) args[3].addr);

    number = 1;
    XmuCvtStringToCursor(args, &number, fromVal, &ret_val);

    cursor = *((Cursor *) ret_val.addr);

    if (cursor == None || (fg == BlackPixelOfScreen(screen)
			   && bg == WhitePixelOfScreen(screen)))
	new_done(Cursor, cursor);

    colors[0].pixel = fg;
    colors[1].pixel = bg;

    XQueryColors (dpy, c_map, colors, 2);
    XRecolorCursor(dpy, cursor, colors, colors + 1);
    new_done(Cursor, cursor);
}
Ejemplo n.º 11
0
/* ----- drag cursor ----- */
static void initDragCursor(WMDraggingInfo * info)
{
	WMScreen *scr = sourceScreen(info);
	XColor cursorFgColor, cursorBgColor;

	/* green */
	cursorFgColor.red = 0x4500;
	cursorFgColor.green = 0xb000;
	cursorFgColor.blue = 0x4500;

	/* white */
	cursorBgColor.red = 0xffff;
	cursorBgColor.green = 0xffff;
	cursorBgColor.blue = 0xffff;

	XDND_DRAG_CURSOR(info) = XCreateFontCursor(scr->display, XC_left_ptr);
	XRecolorCursor(scr->display, XDND_DRAG_CURSOR(info), &cursorFgColor, &cursorBgColor);

	XFlush(scr->display);
}
Ejemplo n.º 12
0
static int module_init(struct aDisplayInfo *dinfo) {

    if (!dinfo)
        return -1;

    Display *dpy = dinfo->display;
    Colormap colormap = dinfo->screens[0].colormap;
    XColor color_bg;
    XColor color_fg;

    data.dinfo = dinfo;
    alock_alloc_color(dpy, colormap, data.colorname_bg, "black", &color_bg);
    alock_alloc_color(dpy, colormap, data.colorname_fg, "white", &color_fg);

    /* create cursor from X11/cursorfont.h */
    if (!(data.cursor = XCreateFontCursor(dpy, data.shape))) {
        fprintf(stderr, "[glyph]: unable to create fontcursor\n");
        return -1;
    }

    XRecolorCursor(dpy, data.cursor, &color_fg, &color_bg);
    return 0;
}
Ejemplo n.º 13
0
void
fl_set_cursor_color( int      name,
                     FL_COLOR fg,
                     FL_COLOR bg )
{
    XColor xfg,
           xbg;
    int r,
        g,
        b;
    Cursor cur = fli_get_cursor_byname( name );

    fl_getmcolor( fg, &r, &g, &b );
    xfg.red   = ( r << 8 ) | 0xff;
    xfg.green = ( g << 8 ) | 0xff;
    xfg.blue  = ( b << 8 ) | 0xff;

    fl_getmcolor( bg, &r, &g, &b );
    xbg.red   = ( r << 8 ) | 0xff;
    xbg.green = ( g << 8 ) | 0xff;
    xbg.blue  = ( b << 8 ) | 0xff;

    XRecolorCursor( flx->display, cur, &xfg, &xbg );
}
Ejemplo n.º 14
0
static void WindowInitialize()
{
  Window root;
  XEvent event;
  int screennum;
  Cursor newcursor;

  screennum = DefaultScreen(m_display);
  root = DefaultRootWindow(m_display);
  
  if (BlackAndWhite) {
    WinAttr.background_pixel = BlackPixel(m_display, DefaultScreen(m_display));
    WinAttr.border_pixel = WhitePixel(m_display, DefaultScreen(m_display));
  } else {
    WinAttr.background_pixel = m_colors[0][m_black].pixel;
    WinAttr.border_pixel = m_colors[0][m_black].pixel;
  }
#if 0   /* simple cleanup ***mdg*** */
  WinAttr.background_pixel = m_colors[0][m_black].pixel;
  WinAttr.border_pixel = m_colors[m_black]->pixel;
#endif
  WinAttr.event_mask = WindowEventMask;
  WinAttr.cursor = XCreateFontCursor(m_display, XC_tcross);
  XRecolorCursor(m_display, WinAttr.cursor, &m_colors[0][15], 
		                            &m_colors[0][m_black]);
  WinSizeHints.max_width = XDisplayWidth(m_display, screennum);
  WinSizeHints.max_height = XDisplayHeight(m_display, screennum);

  /* This next section allows entries in .Xdefaults to set initial
     size and position of the newcrt window. 
     Jim Clark 7/13/92 */

  usrgeo = XGetDefault (m_display, "newcrt", "geometry");
   
  if (usrgeo == NULL)
    WinSizeHints.flags |= PPosition;
  else
    WinSizeHints.flags |= USPosition;

  x_pad = 0;
  y_pad = 0;


  XGeometry(m_display,screennum, usrgeo, defgeo, WinBorder, nc_fontwidth,
	    nc_fontheight, x_pad, y_pad, &jc_winX, &jc_winY,
	    &jc_winW, &jc_winH);

  nc_window = XCreateWindow(m_display, root, jc_winX, jc_winY,
			    jc_winW, jc_winH, WinBorder,
			    CopyFromParent, InputOutput, 
			    DefaultVisual(m_display, screennum),
			    WinAttrMask, &WinAttr);
 
  /* End of revised section. */

  XStoreName(m_display, nc_window, "newcrt");
  XSetIconName(m_display, nc_window, "newcrt");
  XSetCommand(m_display, nc_window, &progname, 1);
  XSetWMHints(m_display, nc_window, &WinWMHints);
  XSetNormalHints(m_display, nc_window, &WinSizeHints);

  XMapWindow(m_display, nc_window);

/*  nc_gc = XCreateGC(m_display, nc_window, 0, NULL);  */

  XWindowEvent(m_display, nc_window, ExposureMask, &event);
}
Ejemplo n.º 15
0
static void
set_window_color (int idx, const char *color)
{
  const char *const msg = "can't load color \"%s\"";
  XColor xcol;
  int i;

  if (color == NULL || *color == '\0')
    return;

  /* handle color aliases */
  if (isdigit (*color))
    {
      i = atoi (color);
      if (i >= 8 && i <= 15)	/* bright colors */
	{
	  i -= 8;
#ifndef NO_BRIGHTCOLOR
	  PixColors[idx] = PixColors[minBright + i];
	  goto Done;
#endif
	}
      if (i >= 0 && i <= 7)	/* normal colors */
	{
	  PixColors[idx] = PixColors[minColor + i];
	  goto Done;
	}
    }

  if (!XParseColor (Xdisplay, Xcmap, color, &xcol) ||
      !XAllocColor (Xdisplay, Xcmap, &xcol))
    {
      print_error (msg, color);
      return;
    }

  /* XStoreColor (Xdisplay, Xcmap, XColor*); */

  /*
   * FIXME: should free colors here, but no idea how to do it so instead,
   * so just keep gobbling up the colormap
   */
#if 0
  for (i = blackColor; i <= whiteColor; i++)
    if (PixColors[idx] == PixColors[i])
      break;
  if (i > whiteColor)
    {
      /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */
      XFreeColors (Xdisplay, Xcmap, (PixColors + idx), 1,
		   DisplayPlanes (Xdisplay, Xscreen));
    }
#endif

  PixColors[idx] = xcol.pixel;

  /* XSetWindowAttributes attr; */
  /* Cursor cursor; */
Done:
  if (idx == bgColor)
    XSetWindowBackground (Xdisplay, TermWin.vt, PixColors[bgColor]);

  /* handle colorBD, scrollbar background, etc. */

  set_colorfgbg ();
  {
    XColor fg, bg;
    fg.pixel = PixColors[fgColor];
    XQueryColor (Xdisplay, Xcmap, &fg);
    bg.pixel = PixColors[bgColor];
    XQueryColor (Xdisplay, Xcmap, &bg);
    XRecolorCursor (Xdisplay, TermWin_cursor, &fg, &bg);
  }
  /* the only reasonable way to enforce a clean update */
  scr_poweron ();
}
Ejemplo n.º 16
0
Archivo: misc.c Proyecto: aosm/X11apps
FILE *
Format(ManpageGlobals * man_globals, char * entry)
{
  FILE * file = NULL;
#ifdef HAS_MKSTEMP
  int fd;
#endif
  Widget manpage = man_globals->manpagewidgets.manpage;
  char cmdbuf[BUFSIZ], tmp[BUFSIZ], filename[BUFSIZ], error_buf[BUFSIZ];
  char path[BUFSIZ], sect[BUFSIZ];
  XEvent event;
  Position x,y;			/* location to pop up the
				   "would you like to save" widget. */

#ifndef HAS_MKSTEMP
  if ( !UncompressUnformatted(man_globals, entry, filename) ) {
#else
  if ( !UncompressUnformatted(man_globals, entry, filename, &file) ) {
#endif
    /* We Really could not find it, this should never happen, yea right. */
    snprintf(error_buf, sizeof(error_buf),
	     "Could not open manual page, %s", entry);
    PopupWarning(man_globals, error_buf);
    XtPopdown( XtParent(man_globals->standby) );
    return(NULL);
  }

#ifndef HAS_MKSTEMP
  if ((file = fopen(filename, "r")) != NULL) {
#else
  if (file != NULL) {
#endif
    char line[BUFSIZ];

    if (fgets(line, sizeof(line), file) != NULL) {
	if (strncmp(line, ".so ", 4) == 0) {
	  line[strlen(line) - 1] = '\0';
	  fclose(file);
	  unlink(filename);
	  if (line[4] != '/') {
	    char *ptr = NULL;

	    strcpy(tmp, entry);
	    if ((ptr = rindex(tmp, '/')) != NULL) {
	      *ptr = '\0';
	      if ((ptr = rindex(tmp, '/')) != NULL)
		ptr[1] = '\0';
	    }
	  }
	  else
	    *tmp = '\0';
	  snprintf(filename, sizeof(filename), "%s%s", tmp, line + 4);

	  return (Format(man_globals, filename));
	}
    }
    fclose(file);
  }

  Popup(XtParent(man_globals->standby), XtGrabExclusive);
  while ( !XCheckTypedWindowEvent(XtDisplay(man_globals->standby),
				  XtWindow(man_globals->standby),
				  Expose, &event) );
  XtDispatchEvent( &event );
  XFlush(XtDisplay(man_globals->standby));

  strcpy(tmp,MANTEMP);		          /* Get a temp file. */
#ifndef HAS_MKSTEMP
  (void) mktemp(tmp);
#else
  fd = mkstemp(tmp);
  file = fdopen(fd, "r");
#endif
  strcpy(man_globals->tempfile, tmp);

  ParseEntry(entry, path, sect, NULL);

#ifndef HANDLE_ROFFSEQ
#ifndef HAS_MKSTEMP
  snprintf(cmdbuf, sizeof(cmdbuf), "cd %s ; %s %s %s > %s %s", path, TBL,
	  filename, FORMAT, man_globals->tempfile, "2> /dev/null");
#else
  snprintf(cmdbuf, sizeof(cmdbuf), "cd %s ; %s %s %s >> %s %s", path, TBL,
	  filename, FORMAT, man_globals->tempfile, "2> /dev/null");
#endif
#else
  /* Handle more flexible way of specifying the formatting pipeline */
  if (! ConstructCommand(cmdbuf, path, filename, man_globals->tempfile)) {
     sprintf(error_buf, "Constructed command was too long!");
     PopupWarning(man_globals, error_buf);
     file = NULL;
  }
  else
#endif /* HANDLE_ROFFSEQ */

  if(system(cmdbuf) != 0) {	/* execute search. */
    snprintf(error_buf, sizeof(error_buf),
	    "Something went wrong trying to run the command: %s", cmdbuf);
    PopupWarning(man_globals, error_buf);
    file = NULL;
  }
  else {
#ifndef HAS_MKSTEMP
    if ((file = fopen(man_globals->tempfile,"r")) == NULL) {
      sprintf(error_buf, "Something went wrong in retrieving the %s",
	      "temp file, try cleaning up /tmp");
      PopupWarning(man_globals, error_buf);
    }
    else {
#endif

      XtPopdown( XtParent(man_globals->standby) );

      if ( (man_globals->save == NULL) ||
	   (man_globals->manpagewidgets.manpage == NULL) )
	unlink(man_globals->tempfile);
      else {
	char * ptr, catdir[BUFSIZ];

	/*
	 * If the catdir is writeable then ask the user if he/she wants to
	 * write the man page to it.
	 */

	strcpy(catdir, man_globals->save_file);
	if ( (ptr = rindex(catdir, '/')) != NULL) {
	  *ptr = '\0';

	  if ( access(catdir, W_OK) != 0 )
	    unlink(man_globals->tempfile);
	  else {
	    x = (Position) Width(man_globals->manpagewidgets.manpage)/2;
	    y = (Position) Height(man_globals->manpagewidgets.manpage)/2;
	    XtTranslateCoords(manpage, x, y, &x, &y);
	    PositionCenter( man_globals->save, (int) x, (int) y, 0, 0, 0, 0);
	    XtPopup( man_globals->save, XtGrabExclusive);
	  }
	}
	else
	  unlink(man_globals->tempfile);
      }
#ifndef HAS_MKSTEMP
    }
#endif
  }

 /*
  * If the original was compressed or in another format, delete temporary file.
  */
  if (man_globals->deletetempfile) 
    unlink(filename);

  return(file);
}

#ifdef HANDLE_ROFFSEQ
/*      Function Name: ConstructCommand
 *      Description: Constructs the pipeline of commands necessary to format
 *                   a manual page.
 *      Arguments: cmdbuf - the buffer into which to write the command
 *                 path - the directory in which the original man page resides
 *                 filename - the (uncompressed) manpage source file
 *                 tempfile - the name of a temporary file to direct the final
 *                  output of the pipeline into
 *      Returns: TRUE if the command fit into the buffer, FALSE if it would
 *               be too long (more than BUFSIZ characters)
 */
static Boolean
ConstructCommand(cmdbuf, path, filename, tempfile)
   char *cmdbuf, *path, *filename, *tempfile;
{
   /* The original code did the following to produce a command line:
    *   sprintf(cmdbuf,"cd %s ; %s %s %s > %s %s", path, TBL,
    *      filename, FORMAT, man_globals->tempfile, "2> /dev/null");
    * We are more flexible and follow more or less the algorithm used
    * by the Linux man command:
    *  + Obtain a string of letters from the following sources in order
    *    of preference:
    *    + a command line option (not implemented in xman; it's probably not
    *      useful)
    *    + the first line of the manpage source, if it is of the form:
    *      '\" <string>
    *    + the MANROFFSEQ environment variable
    *    + a default string; this is "".
    *  + Interpret the string as a pipeline of filters:
    *    + e = eqn   g = grap   p = pic   t = tbl   v = vgrind   r = refer
    *  + zsoelim is always run as the first preprocessor in any case.
    *
    * Strictly speaking we should save a catpage iff the string comes
    * from the file or is the default.
    *
    * You'll notice that we format a man page into ASCII text output and then
    * attempt to interpret things like L^HL as bold and so forth. This
    * is so obviously the Wrong Thing it's untrue.
    */
   char *c = cmdbuf;           /* current posn in buffer */
   int left = BUFSIZ;          /* space left in buffer */
   int used;
   char *fmt;
   FILE *file;
   char fmtbuf[128];
   int gotfmt = 0;             /* set to 1 if we got a directive from source */
   char *fname = NULL;
#ifdef __UNIXOS2__
   int i;
#endif

   fmt = NULL;
   /* If you have a command line option that gives a setting for fmt,
      set it here. */

   if (!fmt) {
      /* This is the tricky bit: extract a format string from the source file
       * Annoyingly, filename might be relative or absolute. We cheat and
       * use system to get the thing to a known absoute filename.
       */
      if (filename[0] == '/') {
         fname = filename;
      } else {
         fname = malloc(strlen(path) + 1 + strlen(filename) + 1);
         if (!fname)
            return FALSE;
         sprintf(fname, "%s/%s", path, filename);
      }
      if ((file = fopen(fname, "r")) &&
          (fgets(fmtbuf, sizeof(fmtbuf), file)) &&
          (!memcmp(fmtbuf, "'\\\" ", 4))) {
                              /* that's squote-backslash-dquote-space */
         int len;
         fmt = fmtbuf + 3;
         len = strlen(fmt);
         if (len && (fmt[len-1] == '\n')) {
            fmt[len-1] = 0;
            gotfmt++;
         }
      }
      if (fname && fname != filename)
         free(fname);
      if (!gotfmt)                                /* not there or some error */
      {
         fmt = getenv("MANROFFSEQ");
      }
   }

   if (!fmt)
   {
      fmt = DEFAULT_MANROFFSEQ;
   }


   /* Start with the first fixed part of the command line */
#ifdef __UNIXOS2__
   for (i = 0; i < strlen(path); i++) {
     if (path[i] == '/')
       path[i] = '\\';
   }
   used = snprintf(c, left, "cd %s & %s %s ", path, ZSOELIM, filename);
#else
   used = snprintf(c, left, "cd %s; %s %s ", path, ZSOELIM, filename);
#endif
   left -= used;
   c += used;
   if (left <= 1)
      return (FALSE);

   /* Now add preprocessors of the form '| processor' */
   for ( ; *fmt; fmt++)
   {
      char *filter;
      switch (*fmt)
      {
         case 'e':
            filter = EQN;
            break;
         case 'g':
            filter = GRAP;
            break;
         case 'p':
            filter = PIC;
            break;
         case 't':
            filter = TBL;
            break;
         case 'v':
            filter = VGRIND;
            break;
         case 'r':
            filter = REFER;
            break;
         default:
            filter = NULL;
            break;
      }
      if (filter)
      {
         used = snprintf(c, left, " | %s ", filter);
         left -= used;
         c += used;
         if (left <= 1)
            return (FALSE);
      }
   }

   /* Now add the fixed trailing part 'formatprog > tempfile 2> /dev/null' */
#ifdef __UNIXOS2__
   used = snprintf(c, left, " | %s > %s 2>NUL", FORMAT, tempfile);
#else
#ifndef HAS_MKSTEMP
   used = snprintf(c, left, " | %s > %s 2>/dev/null", FORMAT, tempfile);
#else
   used = snprintf(c, left, " | %s >> %s 2>/dev/null", FORMAT, tempfile);
#endif
#endif /* __UNIXOS2__ */
   left -= used;
   if (left <= 1)
      return (FALSE);

   return (TRUE);
}
#endif /* HANDLE_ROFFSEQ */

/*	Function Name: UncompressUnformatted
 *	Description: Finds an uncompressed unformatted manual page.
 *	Arguments: man_globals - the psuedo global structure.
 *                 entry - the manual page entry.
 * RETURNED        filename - location to put the name of the file.
 *	Returns: TRUE if the file was found.
 */

static Boolean
#ifndef HAS_MKSTEMP
UncompressUnformatted(ManpageGlobals * man_globals, char * entry,
		      char * filename)
#else
UncompressUnformatted(ManpageGlobals * man_globals, char * entry,
		      char * filename, FILE **file)
#endif
{
  char path[BUFSIZ], page[BUFSIZ], section[BUFSIZ], input[BUFSIZ];
  int len_cat = strlen(CAT), len_man = strlen(MAN);
#if defined(SMAN) && defined(SFORMAT)
  int len_sman = strlen(SMAN);
#endif

  ParseEntry(entry, path, section, page);

  man_globals->bzip2 = FALSE;
  man_globals->lzma = FALSE;

#if defined(__OpenBSD__) || defined(__NetBSD__)
  /*
   * look for uncompressed file in machine subdir first
   */
  snprintf(filename, BUFSIZ, "%s/%s%s/%s/%s", path, MAN,
	  section + len_cat, MACHINE, page);
  if ( access( filename, R_OK ) == 0 ) {
    man_globals->compress = FALSE;
    man_globals->gzip = FALSE;
    man_globals->deletetempfile = FALSE;
    snprintf(man_globals->save_file, sizeof(man_globals->save_file),
    	     "%s/%s%s/%s/%s", path, CAT, section + len_cat, MACHINE, page);
    return(TRUE);
  }
 /*
  * Then for compressed files in an uncompressed directory.
  */
  snprintf(input, sizeof(input), "%s.%s", filename, COMPRESSION_EXTENSION);
#ifndef HAS_MKSTEMP
  if ( UncompressNamed(man_globals, input, filename) ) {
#else
  if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif
    man_globals->compress = TRUE;
    man_globals->deletetempfile = TRUE;
    snprintf(man_globals->save_file, sizeof(man_globals->save_file),
	     "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, 
	     COMPRESSION_EXTENSION);
    return(TRUE);
  }
#ifdef GZIP_EXTENSION
  else {
    snprintf(input, sizeof(input), "%s.%s", filename, GZIP_EXTENSION);
#ifndef HAS_MKSTEMP
    if ( UncompressNamed(man_globals, input, filename) ) {
#else
    if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif
      man_globals->compress = TRUE;
      man_globals->gzip = TRUE;
      man_globals->deletetempfile = TRUE;
      snprintf(man_globals->save_file, sizeof(man_globals->save_file),
	       "%s/%s%s/%s.%s", path, CAT, section + len_cat, page,
	       GZIP_EXTENSION);
      return(TRUE);
    }
  }
#endif /* GZIP_EXTENSION */
#endif /* __OpenBSD__ || __NetBSD__ */

#ifdef BZIP2_EXTENSION
 {
    sprintf(input, "%s.%s", filename, BZIP2_EXTENSION);
#ifndef HAS_MKSTEMP
    if ( UncompressNamed(man_globals, input, filename) ) {
#else
    if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif
      man_globals->compress = TRUE;
      man_globals->gzip = FALSE;
      man_globals->bzip2 = TRUE;
      sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path,
	      CAT, section + len_cat, page, BZIP2_EXTENSION);
      return(TRUE);
    }
  }
#endif /* BZIP2_EXTENSION */

#ifdef LZMA_EXTENSION
 {
    sprintf(input, "%s.%s", filename, LZMA_EXTENSION);
#ifndef HAS_MKSTEMP
    if ( UncompressNamed(man_globals, input, filename) ) {
#else
    if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif
      man_globals->compress = TRUE;
      man_globals->gzip = FALSE;
      man_globals->lzma = TRUE;
      sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path,
	      CAT, section + len_cat, page, LZMA_EXTENSION);
      return(TRUE);
    }
  }
#endif /* LZMA_EXTENSION */

/*
 * Look for uncompressed file first.
 */

  snprintf(filename, BUFSIZ, "%s/%s%s/%s", path, MAN, section + len_man, page);
  if ( access( filename, R_OK ) == 0 ) {
    man_globals->compress = FALSE;
    man_globals->gzip = FALSE;
    man_globals->deletetempfile = FALSE;
    snprintf(man_globals->save_file, sizeof(man_globals->save_file), 
	     "%s/%s%s/%s", path, CAT, section + len_cat, page);
    return(TRUE);
  }

#if defined(SMAN) && defined(SFORMAT)
 /*
  * Look for uncompressed sgml file next.
  */

  snprintf(input, BUFSIZ, "%s/%s%s/%s", path, SMAN, section + len_sman, page);
#ifndef HAS_MKSTEMP
  if ( SgmlToRoffNamed(man_globals, input, filename) ) {
#else
  if ( SgmlToRoffNamed(man_globals, input, filename, file) ) {
#endif
    man_globals->compress = FALSE;
    man_globals->gzip = FALSE;
    man_globals->deletetempfile = TRUE;
    snprintf(man_globals->save_file, sizeof(man_globals->save_file),
            "%s/%s%s/%s", path, CAT, section + len_cat, page);
    return(TRUE);
  }
#endif

/*
 * Then for compressed files in an uncompressed directory.
 */

  snprintf(input, sizeof(input), "%s.%s", filename, COMPRESSION_EXTENSION);
#ifndef HAS_MKSTEMP
  if ( UncompressNamed(man_globals, input, filename) ) {
#else
  if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif
    man_globals->compress = TRUE;
    man_globals->deletetempfile = TRUE;
    snprintf(man_globals->save_file, sizeof(man_globals->save_file),
	     "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, 
	     COMPRESSION_EXTENSION);
    return(TRUE);
  }
#ifdef GZIP_EXTENSION
  else {
    snprintf(input, sizeof(input), "%s.%s", filename, GZIP_EXTENSION);
#ifndef HAS_MKSTEMP
    if ( UncompressNamed(man_globals, input, filename) ) {
#else
    if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif	
      man_globals->compress = TRUE;
      man_globals->gzip = TRUE;
      man_globals->deletetempfile = TRUE;
      snprintf(man_globals->save_file, sizeof(man_globals->save_file),
	       "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, 
	       GZIP_EXTENSION);
      return(TRUE);
    }
  }
#endif

#ifdef BZIP2_EXTENSION
  {
    sprintf(input, "%s.%s", filename, BZIP2_EXTENSION);
#ifndef HAS_MKSTEMP
    if ( UncompressNamed(man_globals, input, filename) ) {
#else
    if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif	
      man_globals->compress = TRUE;
      man_globals->gzip = TRUE;
      sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path,
	      CAT, section + len_cat, page, BZIP2_EXTENSION);
      return(TRUE);
    }
  }
#endif

#ifdef LZMA_EXTENSION
  {
    sprintf(input, "%s.%s", filename, LZMA_EXTENSION);
#ifndef HAS_MKSTEMP
    if ( UncompressNamed(man_globals, input, filename) ) {
#else
    if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif	
      man_globals->compress = TRUE;
      man_globals->lzma = TRUE;
      sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path,
	      CAT, section + len_cat, page, LZMA_EXTENSION);
      return(TRUE);
    }
  }
#endif

/*
 * And lastly files in a compressed directory.
 */

  snprintf(input, sizeof(input), "%s/%s%s.%s/%s", path,
	  MAN, section + len_man, COMPRESSION_EXTENSION, page);
#ifndef HAS_MKSTEMP
  if ( UncompressNamed(man_globals, input, filename) ) {
#else
  if ( UncompressNamed(man_globals, input, filename, file) ) {
#endif
    man_globals->compress = TRUE;
    man_globals->deletetempfile = TRUE;
    snprintf(man_globals->save_file, sizeof(man_globals->save_file),
	     "%s/%s%s.%s/%s", path, CAT, section + len_cat, 
    	     COMPRESSION_EXTENSION, page);
    return(TRUE);
  }
  return(FALSE);
}

/*	Function Name: AddCursor
 *	Description: This function adds the cursor to the window.
 *	Arguments: w - the widget to add the cursor to.
 *                 cursor - the cursor to add to this widget.
 *	Returns: none
 */

void
AddCursor(Widget w, Cursor cursor)
{
  XColor colors[2];
  Arg args[10];
  Cardinal num_args = 0;
  Colormap c_map;

  if (!XtIsRealized(w)) {
    PopupWarning(NULL, "Widget is not realized, no cursor added.\n");
    return;
  }

  XtSetArg( args[num_args], XtNcolormap, &c_map); num_args++;
  XtGetValues( w, args, num_args);

  colors[0].pixel = resources.cursors.fg_color;
  colors[1].pixel = resources.cursors.bg_color;

  XQueryColors (XtDisplay(w), c_map, colors, 2);
  XRecolorCursor(XtDisplay(w), cursor, colors, colors+1);
  XDefineCursor(XtDisplay(w),XtWindow(w),cursor);
}

/*	Function Name: ChangeLabel
 *	Description: This function changes the label field of the
 *                   given widget to the string in str.
 *	Arguments: w - the widget.
 *                 str - the string to change the label to.
 *	Returns: none
 */

void
ChangeLabel(Widget w, char * str)
{
  Arg arglist[3];		/* An argument list. */

  if (w == NULL) return;

  XtSetArg(arglist[0], XtNlabel, str);

/* shouldn't really have to do this. */
  XtSetArg(arglist[1], XtNwidth, 0);
  XtSetArg(arglist[2], XtNheight, 0);

  XtSetValues(w, arglist, (Cardinal) 1);
}

/*
 * In an ideal world this would be part of the XToolkit, and I would not
 * have to do it, but such is life sometimes.  Perhaps in X11R3.
 */

/*	Function Name: PositionCenter
 *	Description: This function positions the given widgets center
 *                   in the following location.
 *	Arguments: widget - the widget widget to postion
 *                 x,y - The location for the center of the widget
 *                 above - number of pixels above center to locate this widget
 *                 left - number of pixels left of center to locate this widget
 *                 h_space, v_space - how close to get to the edges of the
 *                                    parent window.
 *	Returns: none
 *      Note:  This should only be used with a popup widget that has override
 *             redirect set.
 */

void
PositionCenter(Widget widget, int x, int y, int above, int left, int v_space, int h_space)
{
  Arg wargs[2];
  int x_temp,y_temp;		/* location of the new window. */
  int parent_height,parent_width; /* Height and width of the parent widget or
				   the root window if it has no parent. */

  x_temp = x - left - Width(widget) / 2 + BorderWidth(widget);
  y_temp = y - above -  Height(widget) / 2 + BorderWidth(widget);

  parent_height = HeightOfScreen(XtScreen(widget));
  parent_width = WidthOfScreen(XtScreen(widget));

/*
 * Check to make sure that all edges are within the viewable part of the
 * root window, and if not then force them to be.
 */

  if (x_temp < h_space)
    x_temp = v_space;
  if (y_temp < v_space)
    (y_temp = 2);

  if ( y_temp + Height(widget) + v_space > parent_height )
      y_temp = parent_height - Height(widget) - v_space;

  if ( x_temp + Width(widget) + h_space > parent_width )
      x_temp = parent_width - Width(widget) - h_space;

  XtSetArg(wargs[0], XtNx, x_temp);
  XtSetArg(wargs[1], XtNy, y_temp);
  XtSetValues(widget, wargs, 2);
}

/*	Function Name: ParseEntry(entry, path, sect, page)
 *	Description: Parses the manual pages entry filenames.
 *	Arguments: str - the full path name.
 *                 path - the path name.      RETURNED
 *                 sect - the section name.   RETURNED
 *                 page - the page name.      RETURNED
 *	Returns: none.
 */

void
ParseEntry(char *entry, char *path, char *sect, char *page)
{
  char *c, temp[BUFSIZ];

  strcpy(temp, entry);

  c = rindex(temp, '/');
  if (c == NULL)
    PrintError("index failure in ParseEntry.");
  *c++ = '\0';
  if (page != NULL)
    strcpy(page, c);

  c = rindex(temp, '/');
  if (c == NULL)
    PrintError("index failure in ParseEntry.");
  *c++ = '\0';
#if defined(SFORMAT) && defined(SMAN)
  /* sgmltoroff sometimes puts an extra ./ in the path to .so entries */
  if (strcmp(c, ".") == 0) {
      c = rindex(temp, '/');
      if (c == NULL)
	  PrintError("index failure in ParseEntry.");
      *c++ = '\0';
  }
#endif      
#if defined(__OpenBSD__) || defined(__NetBSD__)
  /* Skip machine subdirectory if present */
  if (strcmp(c, MACHINE) == 0) {
      c = rindex(temp, '/');
      if (c == NULL)
	  PrintError("index failure in ParseEntry.");
      *c++ = '\0';
  }
#endif
  if (sect != NULL)
    strcpy(sect, c);

  if (path != NULL)
    strcpy(path, temp);
}

/*      Function Name: GetGlobals
 *      Description: Gets the psuedo globals associated with the
 *                   manpage associated with this widget.
 *      Arguments: w - a widget in the manpage.
 *      Returns: the psuedo globals.
 *      Notes: initial_widget is a globals variable.
 *             manglobals_context is a global variable.
 */

ManpageGlobals *
GetGlobals(Widget w)
{
  Widget temp;
  caddr_t data;

  while ( (temp = XtParent(w)) != initial_widget && (temp != NULL))
    w = temp;

  if (temp == NULL)
    XtAppError(XtWidgetToApplicationContext(w),
	       "Xman: Could not locate widget in tree, exiting");

  if (XFindContext(XtDisplay(w), XtWindow(w),
		   manglobals_context, &data) != XCSUCCESS)
    XtAppError(XtWidgetToApplicationContext(w),
	       "Xman: Could not find global data, exiting");

  return( (ManpageGlobals *) data);
}

/*      Function Name: SaveGlobals
 *      Description: Saves the psuedo globals on the widget passed
 *                   to this function, although GetGlobals assumes that
 *                   the data is associated with the popup child of topBox.
 *      Arguments: w - the widget to associate the data with.
 *                 globals - data to associate with this widget.
 *      Returns: none.
 *      Notes: WIDGET MUST BE REALIZED.
 *             manglobals_context is a global variable.
 */

void
SaveGlobals(Widget w, ManpageGlobals * globals)
{
  if (XSaveContext(XtDisplay(w), XtWindow(w), manglobals_context,
		   (caddr_t) globals) != XCSUCCESS)
    XtAppError(XtWidgetToApplicationContext(w),
	       "Xman: Could not save global data, are you out of memory?");
}

/*      Function Name: RemoveGlobals
 *      Description: Removes the psuedo globals from the widget passed
 *                   to this function.
 *      Arguments: w - the widget to remove the data from.
 *      Returns: none.
 *      Notes: WIDGET MUST BE REALIZED.
 *             manglobals_context is a global variable.
 */

void
RemoveGlobals(Widget w)
{
  if (XDeleteContext(XtDisplay(w), XtWindow(w),
		     manglobals_context) != XCSUCCESS)
    XtAppError(XtWidgetToApplicationContext(w),
	       "Xman: Could not remove global data?");
}
Ejemplo n.º 17
0
/*{{{ Create_Windows() - Open and map the window */
static void
Create_Windows (int argc, char *argv[])
{
  Cursor cursor;
  XClassHint classHint;
  XWMHints wmHint;
  int i, x, y, flags;
  unsigned int width, height;

  /*
   * grab colors before netscape does
   */
  for (i = 0;
       i < (Xdepth <= 2 ? 2 : NRS_COLORS);
       i++)
    {
      const char *const msg = "can't load color \"%s\"";
      XColor xcol;

      if (!rs_color[i])
	continue;

      if (!XParseColor (Xdisplay, Xcmap, rs_color[i], &xcol) ||
	  !XAllocColor (Xdisplay, Xcmap, &xcol))
	{
	  print_error (msg, rs_color[i]);
	  rs_color[i] = def_colorName[i];
	  if (!rs_color[i])
	    continue;
	  if (!XParseColor (Xdisplay, Xcmap, rs_color[i], &xcol) ||
	      !XAllocColor (Xdisplay, Xcmap, &xcol))
	    {
	      print_error (msg, rs_color[i]);
	      switch (i)
		{
		case fgColor:
		case bgColor:
		  /* fatal: need bg/fg color */
		  print_error ("aborting");
		  exit (EXIT_FAILURE);
		  break;
#ifndef NO_CURSORCOLOR
		case cursorColor:
		  xcol.pixel = PixColors[bgColor];
		  break;
		case cursorColor2:
		  xcol.pixel = PixColors[fgColor];
		  break;
#endif /* NO_CURSORCOLOR */
		default:
		  xcol.pixel = PixColors[bgColor];	/* None */
		  break;
		}
	    }
	}
      PixColors[i] = xcol.pixel;
    }

#ifndef NO_CURSORCOLOR
  if (Xdepth <= 2 || !rs_color[cursorColor])
    PixColors[cursorColor] = PixColors[bgColor];
  if (Xdepth <= 2 || !rs_color[cursorColor2])
    PixColors[cursorColor2] = PixColors[fgColor];
#endif /* NO_CURSORCOLOR */

#ifndef NO_BOLDUNDERLINE
  if (Xdepth <= 2 || !rs_color[colorBD])
    PixColors[colorBD] = PixColors[fgColor];
  if (Xdepth <= 2 || !rs_color[colorUL])
    PixColors[colorUL] = PixColors[fgColor];
#endif /* NO_BOLDUNDERLINE */

  /*
   * get scrollBar/menuBar shadow colors
   *
   * The calculations of topShadow/bottomShadow values are adapted
   * from the fvwm window manager.
   */
#ifndef XTERM_SCROLLBAR
  if (Xdepth <= 2)		/* Monochrome */
    {
      PixColors[scrollColor] = PixColors[bgColor];
      PixColors[topShadowColor] = PixColors[fgColor];
      PixColors[bottomShadowColor] = PixColors[fgColor];
    }
  else
    {
      XColor xcol, white;

      /* bottomShadowColor */
      xcol.pixel = PixColors[scrollColor];
      XQueryColor (Xdisplay, Xcmap, &xcol);

      xcol.red = ((xcol.red) / 2);
      xcol.green = ((xcol.green) / 2);
      xcol.blue = ((xcol.blue) / 2);

      if (!XAllocColor (Xdisplay, Xcmap, &xcol))
	{
	  print_error ("can't allocate %s", "bottomShadowColor");
	  xcol.pixel = PixColors[minColor];
	}
      PixColors[bottomShadowColor] = xcol.pixel;

      /* topShadowColor */
      white.pixel = WhitePixel (Xdisplay, Xscreen);
      XQueryColor (Xdisplay, Xcmap, &white);

      xcol.pixel = PixColors[scrollColor];
      XQueryColor (Xdisplay, Xcmap, &xcol);

#ifndef min
#define min(a,b) (((a)<(b)) ? (a) : (b))
#define max(a,b) (((a)>(b)) ? (a) : (b))
#endif
      xcol.red = max ((white.red / 5), xcol.red);
      xcol.green = max ((white.green / 5), xcol.green);
      xcol.blue = max ((white.blue / 5), xcol.blue);

      xcol.red = min (white.red, (xcol.red * 7) / 5);
      xcol.green = min (white.green, (xcol.green * 7) / 5);
      xcol.blue = min (white.blue, (xcol.blue * 7) / 5);

      if (!XAllocColor (Xdisplay, Xcmap, &xcol))
	{
	  print_error ("can't allocate %s", "topShadowColor");
	  xcol.pixel = PixColors[whiteColor];
	}
      PixColors[topShadowColor] = xcol.pixel;
    }
#endif /* XTERM_SCROLLBAR */

  szHint.base_width = (2 * TermWin_internalBorder +
		       (Options & Opt_scrollBar ? SB_WIDTH : 0));
  szHint.base_height = (2 * TermWin_internalBorder);

  flags = (rs_geometry ?
	   XParseGeometry (rs_geometry, &x, &y, &width, &height) : 0);

  if (flags & WidthValue)
    {
      szHint.width = width;
      szHint.flags |= USSize;
    }
  if (flags & HeightValue)
    {
      szHint.height = height;
      szHint.flags |= USSize;
    }

  TermWin.ncol = szHint.width;
  TermWin.nrow = szHint.height;

  change_font (1, NULL);

  if (flags & XValue)
    {
      if (flags & XNegative)
	{
	  x += (DisplayWidth (Xdisplay, Xscreen)
		- (szHint.width + TermWin_internalBorder));
	  szHint.win_gravity = NorthEastGravity;
	}
      szHint.x = x;
      szHint.flags |= USPosition;
    }
  if (flags & YValue)
    {
      if (flags & YNegative)
	{
	  y += (DisplayHeight (Xdisplay, Xscreen)
		- (szHint.height + TermWin_internalBorder));
	  szHint.win_gravity = (szHint.win_gravity == NorthEastGravity ?
				SouthEastGravity : SouthWestGravity);
	}
      szHint.y = y;
      szHint.flags |= USPosition;
    }

  /* parent window - reverse video so we can see placement errors
   * sub-window placement & size in resize_subwindows()
   */

  TermWin.parent = XCreateSimpleWindow (Xdisplay, Xroot,
					szHint.x, szHint.y,
					szHint.width, szHint.height,
					BORDERWIDTH,
					PixColors[bgColor],
					PixColors[fgColor]);

  xterm_seq (XTerm_title, rs_title);
  xterm_seq (XTerm_iconName, rs_iconName);
  /* ignore warning about discarded `const' */
  classHint.res_name = rs_name;
  classHint.res_class = APL_CLASS;
  wmHint.input = True;
  wmHint.initial_state = (Options & Opt_iconic ? IconicState : NormalState);
  wmHint.flags = (InputHint | StateHint);

  XSetWMProperties (Xdisplay, TermWin.parent, NULL, NULL, argv, argc,
		    &szHint, &wmHint, &classHint);

  XSelectInput (Xdisplay, TermWin.parent,
		(KeyPressMask | FocusChangeMask |
		 StructureNotifyMask | VisibilityChangeMask)
    );

  /* vt cursor: Black-on-White is standard, but this is more popular */
  TermWin_cursor = XCreateFontCursor (Xdisplay, XC_xterm);
  {
    XColor fg, bg;
    fg.pixel = PixColors[fgColor];
    XQueryColor (Xdisplay, Xcmap, &fg);
    bg.pixel = PixColors[bgColor];
    XQueryColor (Xdisplay, Xcmap, &bg);
    XRecolorCursor (Xdisplay, TermWin_cursor, &fg, &bg);
  }

  /* cursor (menuBar/scrollBar): Black-on-White */
  cursor = XCreateFontCursor (Xdisplay, XC_left_ptr);

  /* the vt window */
  TermWin.vt = XCreateSimpleWindow (Xdisplay, TermWin.parent,
				    0, 0,
				    szHint.width, szHint.height,
				    0,
				    PixColors[fgColor],
				    PixColors[bgColor]);

  XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor);
  XSelectInput (Xdisplay, TermWin.vt,
		(ExposureMask | ButtonPressMask | ButtonReleaseMask |
		 Button1MotionMask | Button3MotionMask));

  XMapWindow (Xdisplay, TermWin.vt);
  XMapWindow (Xdisplay, TermWin.parent);

  /* scrollBar: size doesn't matter */
  scrollBar.win = XCreateSimpleWindow (Xdisplay, TermWin.parent,
				       0, 0,
				       1, 1,
				       0,
				       PixColors[fgColor],
				       PixColors[bgColor]);

  XDefineCursor (Xdisplay, scrollBar.win, cursor);
  XSelectInput (Xdisplay, scrollBar.win,
		(ExposureMask | ButtonPressMask | ButtonReleaseMask |
		 Button1MotionMask | Button2MotionMask | Button3MotionMask)
    );

#ifndef NO_MENUBAR
  /* menuBar: size doesn't matter */
  menuBar.win = XCreateSimpleWindow (Xdisplay, TermWin.parent,
				     0, 0,
				     1, 1,
				     0,
				     PixColors[fgColor],
				     PixColors[scrollColor]);
  XDefineCursor (Xdisplay, menuBar.win, cursor);
  XSelectInput (Xdisplay, menuBar.win,
		(ExposureMask | ButtonPressMask | ButtonReleaseMask |
		 Button1MotionMask)
    );
#endif /* NO_MENUBAR */

#ifdef XPM_BACKGROUND
  if (rs_backgroundPixmap != NULL)
    {
      char *p = rs_backgroundPixmap;
      if ((p = strchr (p, ';')) != NULL)
	{
	  p++;
	  scale_pixmap (p);
	}

      set_bgPixmap (rs_backgroundPixmap);
    }
#endif /* XPM_BACKGROUND */

  /* graphics context for the vt window */
  {
    XGCValues gcvalue;
    gcvalue.font = TermWin.font->fid;
    gcvalue.foreground = PixColors[fgColor];
    gcvalue.background = PixColors[bgColor];
    TermWin.gc = XCreateGC (Xdisplay, TermWin.vt,
			    GCForeground | GCBackground | GCFont,
			    &gcvalue);
  }
}
Ejemplo n.º 18
0
void
x_gram_init(Display *dpy)
{
    char *temp;
    XSizeHints sizehints;
    XWMHints wmhints;
    unsigned long rv,tc;

    default_fgcolor = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
    default_bgcolor = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
    rv = get_bool_resource("reverseVideo", "ReverseVideo", 0);
    if (rv) {
       tc = default_fgcolor;
       default_fgcolor = default_bgcolor;
       default_bgcolor = tc;
    }
    temp = get_string_resource("foreground", "Foreground");
    if (temp)
      default_fgcolor = x_string_to_color(temp, default_fgcolor);
    temp = get_string_resource("background", "Background");
    if (temp)
      default_bgcolor = x_string_to_color(temp, default_bgcolor);
    default_bordercolor = default_fgcolor;
    temp = get_string_resource("borderColor", "BorderColor");
    if (temp)
      default_bordercolor = x_string_to_color(temp, default_bordercolor);

    temp = get_string_resource("minTimeToLive", "MinTimeToLive");
    if (temp && atoi(temp)>=0)
       ttl = atoi(temp);

#ifdef CMU_ZWGCPLUS
    if (ttl == 0) {
      temp = get_string_resource("lifespan", "LifeSpan");
      if (temp && atoi(temp)>=0)
        ttl = atoi(temp);
    }

    get_full_names = get_bool_resource("getFullNames", "GetFullNames", 0);
#endif

    reverse_stack = get_bool_resource("reverseStack", "ReverseStack", 0);
    reset_saver =  get_bool_resource("resetSaver", "ResetSaver", 1);
    /* The default here should be 1, but mwm sucks */
    set_transient = get_bool_resource("transient", "Transient", 0);
    enable_delete = get_bool_resource("enableDelete", "EnableDelete", 1);

    temp = get_string_resource("borderWidth", "BorderWidth");
    /* <<<>>> */
    if (temp && atoi(temp)>=0)
      border_width = atoi(temp);

    temp = get_string_resource("internalBorder", "InternalBorder");
    /* <<<>>> */
    if (temp && atoi(temp)>=0)
      internal_border_width = atoi(temp);

    temp = get_string_resource("cursorCode", "CursorCode");
    /* <<<>>> */
    if (temp && atoi(temp))
      cursor_code = atoi(temp);

    cursor = XCreateFontCursor(dpy, cursor_code);
    if (!cursor)
      cursor = XCreateFontCursor(dpy, XC_sailboat);

    temp = get_string_resource("pointerColor", "Foreground");
    if (temp) {
        char *temp2;
        XColor cursor_fore, cursor_back;
        /* XXX need to do our own parsing here, since the RecolorCursor
           routine requires an XColor, not an unsigned long (pixel) */
        if (!(temp2 = get_string_resource("background","Background"))) {
            if (default_bgcolor == WhitePixelOfScreen(DefaultScreenOfDisplay(dpy)))
                temp2 = "white";
            else
                temp2 = "black";
        }
        if (XParseColor(dpy,
                        DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)),
                        temp, &cursor_fore) &&
            XParseColor(dpy,
                        DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)),
                        temp2, &cursor_back)) {
              XRecolorCursor(dpy, cursor, &cursor_fore, &cursor_back);
          }
    }
    if (!(title_name=get_string_resource("title","Title")))
      if (!(title_name=get_string_resource("name","Name")))
        title_name=app_instance;

    if (!(icon_name=get_string_resource("iconName","IconName")))
      if (!(icon_name=get_string_resource("name","Name")))
        icon_name=app_instance;

    if (!(temp=get_string_resource("name","Name")))
      if (!(temp=(char *) getenv("RESOURCE_NAME")))
        temp=app_instance;
    classhint.res_name=string_Copy(temp);
    classhint.res_class="Zwgc";

    if (set_transient) {
       group_leader=XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,100,100,
                                        0,default_bordercolor,default_bgcolor);
       sizehints.x = 0;
       sizehints.y = 0;
       sizehints.width = 100;
       sizehints.height = 100;
       sizehints.flags = PPosition | PSize;

       wmhints.input = False;
       wmhints.initial_state = DontCareState;
       wmhints.flags = InputHint | StateHint;

       x_set_icccm_hints(dpy,group_leader,"ZwgcGroup","ZwgcGroup",&sizehints,
                         &wmhints,0);
    }
    xattributes.border_pixel = default_bordercolor;
    xattributes.cursor = cursor;
    xattributes.event_mask = (ExposureMask|ButtonReleaseMask|ButtonPressMask
                              |LeaveWindowMask|Button1MotionMask
#ifdef CMU_ZWGCPLUS
                              |KeyPressMask
#endif
                              |Button3MotionMask|StructureNotifyMask);
    xattributes_mask = (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor);

    set_all_desktops = get_bool_resource("allDesktops", "AllDesktops", True);
    net_wm_desktop = XInternAtom(dpy, "_NET_WM_DESKTOP", False);
    net_wm_window_type = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
    net_wm_window_type_utility = XInternAtom(dpy,
                                             "_NET_WM_WINDOW_TYPE_UTILITY",
                                             False);

    temp = get_string_resource ("backingStore", "BackingStore");
    if (!temp)
        return;
    xattributes_mask |= CWBackingStore;
    if (!strcasecmp (temp, "notuseful"))
        xattributes.backing_store = NotUseful;
    else if (!strcasecmp (temp, "whenmapped"))
        xattributes.backing_store = WhenMapped;
    else if (!strcasecmp (temp, "always"))
        xattributes.backing_store = Always;
    else if (!strcasecmp (temp, "default"))
        xattributes_mask &= ~CWBackingStore;
    else {
        switch (get_bool_resource ("backingStore", "BackingStore", -1)) {
        case 0:
            xattributes.backing_store = NotUseful;
            break;
        case 1:
            xattributes.backing_store = WhenMapped;
            break;
        case -1:
            fprintf (stderr,
                 "zwgc: Cannot interpret backing-store resource value `%s'.\n",
                     temp);
            xattributes_mask &= ~CWBackingStore;
            break;
        }
    }
}
Ejemplo n.º 19
0
void NxmCursor_createCursor ( int ref )
/************************************************************************
 * NxmCursor_createCursor						*
 *									*
 * This function creates the cursor for a specific reference index	*
 *									*
 * void NxmCursor_createCursor(ref)			                *
 *									*
 * Input parameters:							*
 *	ref           int	   reference # of cursor		*
 *									*
 * Output parameters:							*
 * Return parameters:							*
 *			NONE						*
 *									*
 **									*
 * Log:									*
 * H. Zeng/EAI          04/00   initial coding                          *
 * H. Zeng/EAI          05/00   added incorrect info. handling          *
 ***********************************************************************/
{
    int		   ii, x_hot, y_hot;
    int            cursor_id = IMPVAL, iret1, iret2;
    long int       no_use;
    unsigned int   width, height;       
    Pixmap         cursor_pixmap, mask_pixmap;
    XColor         fgcolr, bgcolr, ignore;
    char           cursor_name[20], pix_name[25], cursor_file[128]; 
    char           cursor_mask[128], cursor_color[10];
    char           bg_color[] = "black", *ptr;
    Status         status;
/*---------------------------------------------------------------------*/
/*
 * Find cursor type and cursor color according to the reference #.
 */
    strcpy(cursor_name, _currefTbl.currefs[ref].typ_name);
    strcpy(cursor_color, _currefTbl.currefs[ref].color);

    for(ii = 0; ii < _curtypTbl.ntyp; ii++) {
       if( strcmp(cursor_name,_curtypTbl.curtyps[ii].ext_name)==0 ) {
         strcpy(pix_name, _curtypTbl.curtyps[ii].int_name);
         cursor_id = _curtypTbl.curtyps[ii].id;
         break; 
       }
    }

/*
 * For garbage cursor_name
 */
    if(cursor_id == IMPVAL) {
      switch(ref) {
         case 0:
            cursor_id = 132;
            break;
         case 1:
            cursor_id = 34;
            break;
         case 2:
            cursor_id = 0;
            break;
         default:
            cursor_id = 132;
            break;
      }

    }

/*
 * Get foreground color and background color.
 */
    fgcolr.flags = DoRed | DoBlue | DoGreen;
    status = XAllocNamedColor (NXMdisplay, NXMcmap, cursor_color, 
                               &fgcolr, &ignore);

/*
 * For garbage cursor_color
 */
    if(status == 0) {
       XAllocNamedColor (NXMdisplay, NXMcmap, "white", 
                         &fgcolr, &ignore);
    }

    bgcolr.flags = DoRed | DoBlue | DoGreen;
    XAllocNamedColor (NXMdisplay, NXMcmap, bg_color, 
                      &bgcolr, &ignore);


/*
 * According to whether cursor_id is -1 or not, create 
 * pixmap cursor or standard cursor.
 */
    if( cursor_id != -1 ) {

/*
 * create standard cursor
 */
      if( _cursorRef[ref] != (Cursor)0 ) {
         XFreeCursor(NXMdisplay, _cursorRef[ref]);
      }

      _cursorRef[ref] = XCreateFontCursor(NXMdisplay, (Cardinal)cursor_id);

      XRecolorCursor (NXMdisplay, _cursorRef[ref], &fgcolr, &bgcolr);

    }
    else {

      strcat(pix_name, ".xbm");
      cfl_inqr (pix_name, ICON_DIR, &no_use, cursor_file, &iret1 ); 
      ptr = strstr(pix_name, ".xbm");
      sprintf (ptr, "_mask.xbm");
      cfl_inqr (pix_name, ICON_DIR, &no_use, cursor_mask, &iret2 ); 

      if( (iret1 != 0) || (iret2 != 0) ) {
  
/*
 * File not found !
 */
         fprintf(stderr, "\nPixmap file not found!\n");
         fprintf(stderr, "Please check the cursor type table.\n\n");
         switch(ref) {
	    case 0:
              cfl_inqr ("lg_arrow.xbm", ICON_DIR, &no_use, 
                        cursor_file, &iret1 );
              cfl_inqr ("lg_arrow_mask.xbm", ICON_DIR, &no_use, 
                        cursor_mask, &iret2 );
              break;
	    case 1:  
              cfl_inqr ("lg_cross.xbm", ICON_DIR, &no_use, 
                        cursor_file, &iret1 );
              cfl_inqr ("lg_cross_mask.xbm", ICON_DIR, &no_use, 
                        cursor_mask, &iret2 );
              break;
	    case 2:
              cfl_inqr ("lg_x.xbm", ICON_DIR, &no_use, 
                        cursor_file, &iret1 );
              cfl_inqr ("lg_x_mask.xbm", ICON_DIR, &no_use, 
                        cursor_mask, &iret2 );
              break;
	    default:
              cfl_inqr ("lg_arrow.xbm", ICON_DIR, &no_use, 
                        cursor_file, &iret1 );
              cfl_inqr ("lg_arrow_mask.xbm", ICON_DIR, &no_use, 
                        cursor_mask, &iret2 );
              break;

         }

      }  

      XReadBitmapFile(NXMdisplay, _bxmWin, cursor_mask,	
	              &width, &height, &mask_pixmap, 
		      &x_hot, &y_hot );

      XReadBitmapFile(NXMdisplay, _bxmWin, cursor_file,	
	              &width, &height, &cursor_pixmap, 
		      &x_hot, &y_hot );

      if( _cursorRef[ref] != (Cursor)0 ) {
         XFreeCursor(NXMdisplay, _cursorRef[ref]);
      }

      _cursorRef[ref] = XCreatePixmapCursor(NXMdisplay, cursor_pixmap, 
                                            mask_pixmap, &fgcolr, &bgcolr, 
                                            (Cardinal)x_hot, (Cardinal)y_hot );

      XFreePixmap(NXMdisplay, mask_pixmap);
      XFreePixmap(NXMdisplay, cursor_pixmap);

    }/* the end of else part */

}
Ejemplo n.º 20
0
static int alock_cursor_glyph_init(const char* args, struct aXInfo* xinfo) {

    char* color_bg_name = strdup("steelblue3");
    char* color_fg_name = strdup("grey25");
    unsigned int shape = 0; /* XC_X_cursor */

    if (!xinfo || !args)
        return 0;

    if (strstr(args, "glyph:") == args && strlen(&args[6]) > 0) {
        char* arguments = strdup(&args[6]);
        char* tmp;
        char* arg = NULL;
        for (tmp = arguments; tmp; ) {
            arg = strsep(&tmp, ",");
            if (arg) {
                const struct CursorFontName* cursor_glyph_name;

                if (!strcmp(arg, "list")) {
                    for (cursor_glyph_name = cursor_names; cursor_glyph_name->name; ++cursor_glyph_name) {
                        printf("%s\n", cursor_glyph_name->name);
                    }
                    free(color_fg_name);
                    free(color_bg_name);
                    free(arguments);
                    exit(0);
                } else if (strstr(arg, "fg=") == arg && strlen(arg) > 4) {
                    free(color_fg_name);
                    color_fg_name = strdup(&arg[3]);
                } else if (strstr(arg, "bg=") == arg && strlen(arg) > 4) {
                    free(color_bg_name);
                    color_bg_name = strdup(&arg[3]);
                } else if (strstr(arg, "name=") == arg && strlen(arg) > 6) {
                    for (cursor_glyph_name = cursor_names; cursor_glyph_name->name; ++cursor_glyph_name) {
                        if(!strcmp(cursor_glyph_name->name, &arg[5])) {
                            shape = cursor_glyph_name->shape;
                            break;
                        }
                    }
                    if (!cursor_glyph_name->name) {
                        printf("alock: error, couldnt find [%s]\n", &arg[5]);
                        free(color_bg_name);
                        free(color_fg_name);
                        free(arguments);
                        return 0;
                    }
                }
            }
        }
        free(arguments);
    }

    {
        cursor = (Cursor*)calloc(xinfo->nr_screens, sizeof(Cursor));
        color_fg = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
        color_bg = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
    }

    {
        int scr;
        for (scr = 0; scr < xinfo->nr_screens; scr++) {

            alock_alloc_color(xinfo, scr, color_bg_name, "black", &color_bg[scr]);
            alock_alloc_color(xinfo, scr, color_fg_name, "white", &color_fg[scr]);

            /* create cursor from X11/cursorfont.h */
            if ((cursor[scr] = XCreateFontCursor(xinfo->display, shape))) {
                XRecolorCursor(xinfo->display, cursor[scr], &color_fg[scr], &color_bg[scr]);
                xinfo->cursor[scr] = cursor[scr];
            } else {
                printf("alock: error, couldnt create fontcursor [%d].\n", shape);
                return 0;
            }
        }

        free(color_fg_name);
        free(color_bg_name);
    }

    return 1;
}
Ejemplo n.º 21
0
static Object P_Recolor_Cursor (Object c, Object f, Object b) {
    Check_Type (c, T_Cursor);
    XRecolorCursor (CURSOR(c)->dpy, CURSOR(c)->cursor, Get_Color (f),
        Get_Color (b));
    return Void;
}
Ejemplo n.º 22
0
/**
 * parse the .twmrc file
 *  \param filename the filename to parse.  NULL indicates $HOME/.twmrc
 */
static int doparse (int (*ifunc)(void), char *srctypename, char*srcname)
{
    mods = 0;
    ptr = 0;
    len = 0;
    yylineno = 1;
    ParseError = FALSE;
    twmInputFunc = ifunc;
    overflowlen = 0;

    yyparse();

    if (Scr->PointerForeground.pixel != Scr->Black ||
	Scr->PointerBackground.pixel != Scr->White)
    {
	XRecolorCursor(dpy, UpperLeftCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, RightButt,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, LeftButt,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, MiddleButt,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->FrameCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->TitleCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->IconCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->IconMgrCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->MoveCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->ResizeCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->MenuCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->ButtonCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->WaitCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->SelectCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
	XRecolorCursor(dpy, Scr->DestroyCursor,
		       &Scr->PointerForeground, &Scr->PointerBackground);
    }
    if (ParseError) {
	fprintf (stderr, "%s:  errors found in twm %s",
		 ProgramName, srctypename);
	if (srcname) fprintf (stderr, " \"%s\"", srcname);
	fprintf (stderr, "\n");
    }
    return (ParseError ? 0 : 1);
}
Ejemplo n.º 23
0
main()
{
      Window w2;

      Display *dpy = XOpenDisplay(NIL);
      assert(dpy);
      Screen *scr = DefaultScreenOfDisplay(dpy);

      // CreateWindow

      Window w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent,
			       CopyFromParent, CopyFromParent,
			       0, NIL);

      XDestroyWindow(dpy, w);

      // CreateWindow with arguments

      XSetWindowAttributes swa;
      swa.background_pixel = WhitePixelOfScreen(scr);
      swa.bit_gravity = NorthWestGravity;
      swa.border_pixel = BlackPixelOfScreen(scr);
      swa.colormap = DefaultColormapOfScreen(scr);
      swa.cursor = None;
      swa.win_gravity = NorthGravity;

      w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent,
			CopyFromParent, CopyFromParent,
			CWBackPixel | CWBitGravity | CWBorderPixel | CWColormap | CWCursor | CWWinGravity, 
			&swa);
      
      // CreateWindow with other arguments

      XDestroyWindow(dpy, w);

      Pixmap pixmap = XCreatePixmap(dpy, RootWindowOfScreen(scr), 45, 25, DefaultDepthOfScreen(scr));
      assert(pixmap);

      swa.background_pixmap = pixmap;
      swa.border_pixmap = pixmap;

      w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent,
			CopyFromParent, CopyFromParent,
			CWBackPixmap | CWBorderPixmap,
			&swa);
      
      // ChangeWindowAttributes

      swa.backing_planes = 0x1;
      swa.backing_pixel = WhitePixelOfScreen(scr);
      swa.save_under = True;
      swa.event_mask = KeyPressMask | KeyReleaseMask;
      swa.do_not_propagate_mask = ButtonPressMask | Button4MotionMask;
      swa.override_redirect = False;
      XChangeWindowAttributes(dpy, w, CWBackingPlanes | CWBackingPixel | CWSaveUnder | CWEventMask
			      | CWDontPropagate | CWOverrideRedirect, &swa);

      // GetWindowAttributes

      XWindowAttributes wa;
      Status success = XGetWindowAttributes(dpy, w, &wa);

      // DestroyWindow (done)

      // DestroySubwindows

      w2 = XCreateWindow(dpy, w, 20, 30, 40, 50, 3, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL);
      XDestroySubwindows(dpy, w);

      // ChangeSaveSet

//        Display *dpy2 = XOpenDisplay(NIL);
//        assert(dpy2);
//        XAddToSaveSet(dpy2, w);
//        XCloseDisplay(dpy2);

      // ReparentWindow

      w2 = XCreateWindow(dpy, RootWindowOfScreen(scr), 20, 30, 40, 50, 3, 
			 CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL);
      XReparentWindow(dpy, w2, w, 10, 5);

      // MapWindow

      XMapWindow(dpy, w);

      // MapSubwindows
      
      XMapSubwindows(dpy, w);

      // UnmapWindow
      
      XUnmapWindow(dpy, w);

      // UnmapSubwindows

      XMapWindow(dpy, w);
      XUnmapSubwindows(dpy, w2);
      XMapSubwindows(dpy, w);

      // ConfigureWindow

      Window w3 = XCreateWindow(dpy, w, 10, 50, 100, 10, 2,
			 CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL);

      XMapWindow(dpy, w3);

      XWindowChanges wc;
      wc.x = -5;
      wc.y = -10;
      wc.width = 50;
      wc.height = 40;
      wc.border_width = 7;
      wc.sibling = w2;
      wc.stack_mode = Opposite;
      XConfigureWindow(dpy, w3, 
		       CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWSibling | CWStackMode, 
		       &wc);

      // CirculateWindow

      XCirculateSubwindows(dpy, w, RaiseLowest);

      // GetGeometry

      Window root;
      int x, y;
      unsigned width, height, border_width, depth;
      XGetGeometry(dpy, w, &root, &x, &y, &width, &height, &border_width, &depth);

      // QueryTree

      Window parent;
      Window *children;
      unsigned nchildren;
      success = XQueryTree(dpy, w, &root, &parent, &children, &nchildren);
      XFree(children);

      // InternAtom

      Atom a = XInternAtom(dpy, "WM_PROTOCOLS", True);

      // GetAtomName

      char *string = XGetAtomName(dpy, XA_PRIMARY);
      XFree(string);

      // ChangeProperty

      XStoreName(dpy, w, "test window");

      // DeleteProperty

      XDeleteProperty(dpy, w, XA_WM_NAME);

      // GetProperty
      // TODO

      // ListProperties

      int num_prop;
      Atom *list = XListProperties(dpy, w, &num_prop);
      XFree(list);

      // SetSelectionOwner

      XSetSelectionOwner(dpy, XA_PRIMARY, w, 12000);
      XSetSelectionOwner(dpy, XA_SECONDARY, w, CurrentTime);

      // GetSelectionOwner

      Window wx = XGetSelectionOwner(dpy, XA_PRIMARY);

      // ConvertSelection

      XConvertSelection(dpy, XA_SECONDARY, XA_CURSOR, XA_POINT, w, CurrentTime);

      // SendEvent

      // GrabPointer

      std::cerr << "Grabbing" << std::endl;
      int res = XGrabPointer(dpy, w, False, Button5MotionMask | PointerMotionHintMask,
			     GrabModeSync, GrabModeAsync, w, None, CurrentTime);
      XSync(dpy, False);
//      sleep(5);

      // UngrabPointer

      std::cerr << "Ungrabbing" << std::endl;
      XUngrabPointer(dpy, CurrentTime);

      // GrabButton

      XGrabButton(dpy, 3, ShiftMask | ControlMask, w, False, PointerMotionHintMask | Button2MotionMask, 
		  GrabModeAsync, GrabModeSync, None, None);
		  
      XGrabButton(dpy, 2, AnyModifier, w, False, PointerMotionHintMask | Button2MotionMask, 
		  GrabModeAsync, GrabModeSync, None, None);
		  
      // UngrabButton

      XUngrabButton(dpy, 2, LockMask, w);

      // ChangeActivePointerGrab

      XChangeActivePointerGrab(dpy, ButtonPressMask, None, CurrentTime);

      // GrabKeyboard

      XGrabKeyboard(dpy, w, True, GrabModeSync, GrabModeSync, 12000);

      // UngrabKeyboard

      XUngrabKeyboard(dpy, 13000);

      // GrabKey

      XGrabKey(dpy, XKeysymToKeycode(dpy, XK_Tab), ShiftMask | Mod3Mask, w, True, GrabModeSync,
	       GrabModeSync);

      // UngrabKey

      XUngrabKey(dpy, AnyKey, AnyModifier, w);

      // AllowEvents

      XAllowEvents(dpy, AsyncPointer, 14000);

      // GrabServer

      XGrabServer(dpy);

      // UngrabServer

      XUngrabServer(dpy);

      // QueryPointer

      Window child;
      int root_x, root_y, win_x, win_y;
      unsigned mask;
      Bool bres = XQueryPointer(dpy, w, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask);

      // GetMotionEvents

      int nevents;
      XGetMotionEvents(dpy, w, 15000, 16000, &nevents);

      // TranslateCoordinates

      int dest_x, dest_y;

      XTranslateCoordinates(dpy, w, w2, 10, 20, &dest_x, &dest_y, &child);

      // WarpPointer

      XWarpPointer(dpy, w, w2, 0, 0, 100, 100, 20, 30);

      // SetInputFocus

      XSetInputFocus(dpy,w, RevertToPointerRoot, 17000);
      XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, 17000);

      // GetInputFocus

      Window focus;
      int revert_to;
      XGetInputFocus(dpy, &focus, &revert_to);

      // QueryKeymap

      char keys_return[32];
      XQueryKeymap(dpy, keys_return);

      // OpenFont

      Font fid = XLoadFont(dpy, "cursor");

      // CloseFont

      XUnloadFont(dpy, fid);

      // QueryFont

      XFontStruct *fs = XLoadQueryFont(dpy, "cursor");
      assert(fs);

      // QueryTextExtents

      int direction, font_ascent, font_descent;
      XCharStruct overall;
      XQueryTextExtents(dpy, fs -> fid, "toto", 4, &direction, &font_ascent, &font_descent, &overall);
      XQueryTextExtents(dpy, fs -> fid, "odd__length", 11, &direction, &font_ascent, &font_descent, &overall);

      XChar2b c2bs;
      c2bs.byte1 = '$';
      c2bs.byte2 = 'B';
      XQueryTextExtents16(dpy, fs -> fid, &c2bs, 1, &direction, &font_ascent, &font_descent, &overall);

      XQueryTextExtents(dpy, fs -> fid, longString, strlen(longString), &direction, &font_ascent, 
			&font_descent, &overall);

      // ListFonts

      int actual_count;
      char **fontList = XListFonts(dpy, "*", 100, &actual_count);
      XFree((char *)fontList);

      // ListFontsWithInfo

      int count;
      XFontStruct *info;
      char **names = XListFontsWithInfo(dpy, "*", 100, &count, &info);
      XFreeFontInfo(names, info, count);

      // SetFontPath
      // GetFontPath

      int npaths;
      char **charList = XGetFontPath(dpy, &npaths);

      char **charList2 = new char *[npaths + 1];
      memcpy(charList2, charList, npaths * sizeof(char *));
      charList2[npaths] = charList2[0];

      XSetFontPath(dpy, charList2, npaths + 1);
      XSetFontPath(dpy, charList, npaths); // Reset to some reasonnable value

      XFreeFontPath(charList);
      delete [] charList2;

      // CreatePixmap

      Pixmap pix2 = XCreatePixmap(dpy, w, 100, 200, DefaultDepthOfScreen(scr));

      // FreePixmap

      XFreePixmap(dpy, pix2);

      // CreateGC

      Pixmap bitmap = XCreateBitmapFromData(dpy, RootWindowOfScreen(scr), 
					    "\000\000\001\000\000\001\000\000\001\377\377\377", 3, 4);

      XGCValues gcv;
      gcv.function = GXand;
      gcv.plane_mask = 0x1;
      gcv.foreground = WhitePixelOfScreen(scr);
      gcv.background = BlackPixelOfScreen(scr);
      gcv.line_width = 2;
      gcv.line_style = LineDoubleDash;
      gcv.cap_style = CapProjecting;
      gcv.join_style = JoinRound;
      gcv.fill_style = FillStippled;
      gcv.fill_rule = EvenOddRule;
      gcv.arc_mode = ArcPieSlice;
      gcv.tile = pixmap;
      gcv.stipple = bitmap;
      gcv.ts_x_origin = 3;
      gcv.ts_y_origin = 4;
      gcv.font = fs -> fid;
      gcv.subwindow_mode = ClipByChildren;
      gcv.graphics_exposures = True;
      gcv.clip_x_origin = 5;
      gcv.clip_y_origin = 6;
      gcv.clip_mask = bitmap;
      gcv.dash_offset = 1;
      gcv.dashes = 0xc2;
      
      GC gc = XCreateGC(dpy, w, 
			  GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth
			| GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | GCTile
			| GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont | GCSubwindowMode
			| GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCDashOffset
			| GCDashList | GCArcMode,
			&gcv);

      // ChangeGC

      gcv.function = GXandReverse;

      // Only a few of these should appear, since the values are cached on the client side by the Xlib.

      XChangeGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, &gcv);

      // CopyGC
      
      GC gc2 = XCreateGC(dpy, w, 0, NIL);
      XCopyGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, gc2);

      // SetDashes

      XSetDashes(dpy, gc, 3, "\001\377\001", 3);

      // SetClipRectangles

      XRectangle rectangles[] = { { 10, 20, 30, 40 }, { 100, 200, 5, 3 }, { -5, 1, 12, 24 } };
      XSetClipRectangles(dpy, gc, 12, 9, rectangles, SIZEOF(rectangles), Unsorted);

      // FreeGC

	    // done already

      // ClearArea

      XClearArea(dpy, w, 30, 10, 10, 100, False);

      // CopyArea

      XCopyArea(dpy, w, pixmap, gc, 0, 0, 100, 100, 10, 10);

      // CopyPlane

      // This won't work if the Screen doesn't have at least 3 planes
      XCopyPlane(dpy, pixmap, w, gc, 20, 10, 40, 30, 0, 0, 0x4);

      // PolyPoint

      XDrawPoint(dpy, w, gc, 1, 2);

      XPoint points[] = { { 3, 4 }, { 5, 6 } };
      XDrawPoints(dpy, w, gc, points, SIZEOF(points), CoordModeOrigin);

      // PolyLine

      XDrawLines(dpy, w, gc, points, SIZEOF(points), CoordModePrevious);

      // PolySegment

      XSegment segments[] = { { 7, 8, 9, 10 }, { 11, 12, 13, 14 }, { 15, 16, 17, 18 } };
      XDrawSegments(dpy, w, gc, segments, SIZEOF(segments));

      // PolyRectangle

      XDrawRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles));

      // PolyArc

      XArc arcs[] = { { 10, 20, 30, 40, 50, 60 }, { -70, 80, 90, 100, 110, 120 }, 
		      { 10, 20, 30, 40, 50, -30 } };

      XDrawArcs(dpy, w, gc, arcs, SIZEOF(arcs));

      // FillPoly

      XFillPolygon(dpy, w, gc, points, SIZEOF(points), Convex, CoordModePrevious);

      // PolyFillRectangle
      
      XFillRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles));

      // PolyFillArc
      
      XFillArcs(dpy, w, gc, arcs, SIZEOF(arcs));

      // PutImage
      // GetImage

      XImage *image = XGetImage(dpy, w, 10, 20, 40, 30, AllPlanes, ZPixmap);
      XPutImage(dpy, w, gc, image, 0, 0, 50, 60, 40, 30);
      XSync(dpy, False); // Make the next request starts at the beginning of a packet

      // PolyText8
      XTextItem textItems[3];
      textItems[0].chars = "toto";
      textItems[0].nchars = strlen(textItems[0].chars);
      textItems[0].delta = -3;
      textItems[0].font = fs->fid;
      textItems[1].chars = "titi";
      textItems[1].nchars = strlen(textItems[1].chars);
      textItems[1].delta = 3;
      textItems[1].font = None;
      textItems[2].chars = "tutu";
      textItems[2].nchars = strlen(textItems[2].chars);
      textItems[2].delta = 0;
      textItems[2].font = fs->fid;

      XDrawText(dpy, w, gc, 10, 10, textItems, 3);


      XTextItem textItems2[3];
      textItems2[0].chars = "totox";
      textItems2[0].nchars = strlen(textItems2[0].chars);
      textItems2[0].delta = -3;
      textItems2[0].font = fs->fid;
      textItems2[1].chars = "titi";
      textItems2[1].nchars = strlen(textItems2[1].chars);
      textItems2[1].delta = 3;
      textItems2[1].font = None;
      textItems2[2].chars = "tutu";
      textItems2[2].nchars = strlen(textItems2[2].chars);
      textItems2[2].delta = 0;
      textItems2[2].font = fs->fid;

      XDrawText(dpy, w, gc, 10, 10, textItems2, 3);

      // PolyText16

      XChar2b c2b2[] = { 0, 't', 0, 'x' };

      XTextItem16 items16[] = { { &c2bs, 1, -5, None }, { NULL, 0, 0, None }, { c2b2, 2, 0, fs -> fid } };
      XDrawText16(dpy, w, gc, 10, 0, items16, SIZEOF(items16));

      // ImageText8

      XDrawImageString(dpy, w, gc, 10, 10, "toto", 4);

      // ImageText16

      XDrawImageString16(dpy, w, gc, 10, 10, &c2bs, 1);
      XDrawImageString16(dpy, w, gc, 10, 20, c2b2, 2);

      // CreateColormap
      // Don't forget to tell the kids how it was when we had only 8 bits per pixel.

      Colormap colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None);

      // FreeColormap

      XFreeColormap(dpy, colormap);
      colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None);

      // CopyColormapAndFree

      Colormap colormap2 = XCopyColormapAndFree(dpy, colormap);

      // InstallColormap

      XInstallColormap(dpy, colormap2);

      // UninstallColormap

      XUninstallColormap(dpy, colormap2);

      // ListInstalledColormaps

      int num;
      Colormap *colormapList = XListInstalledColormaps(dpy, w, &num);

      // AllocColor

      XColor screen;
      screen.red = 0;
      screen.green = 32767;
      screen.blue = 65535;
      screen.flags = DoRed | DoGreen | DoBlue;
      success = XAllocColor(dpy, colormap, &screen);

      // AllocNamedColor

      XColor screen2, exact;
      success = XAllocNamedColor(dpy, colormap, "Wheat", &screen2, &exact);

      // AllocColorCells

      unsigned long plane_masks, pixels;
      success = XAllocColorCells(dpy, colormap, False, &plane_masks, 1, &pixels, 1);

      // AllocColorPlanes

      unsigned long rmask, gmask, bmask;
      success = XAllocColorPlanes(dpy, colormap, False, &pixels, 1, 0, 0, 0, &rmask, &gmask, &bmask);

      // FreeColors

      unsigned long pixels2[2] = { screen.pixel, screen2.pixel };
      XFreeColors(dpy, colormap, pixels2, 2, 0);

      // StoreColors

      success = XAllocColorCells(dpy, colormap, False, NIL, 0, pixels2, 2);

      // On many contemporary (that is, year 2000) video cards, you can't allocate read / write cells
      // I want my requests to be sent, however.
      if (!success) {
	    XSetErrorHandler(errorHandler);
      }

      XColor colors[2];
      colors[0] = screen;  colors[0].pixel = pixels2[0];
      colors[1] = screen2; colors[1].pixel = pixels2[1];
      XStoreColors(dpy, colormap, colors, 2);

      // StoreNamedColor

      XStoreNamedColor(dpy, colormap, "Wheat", colors[0].pixel, DoBlue);

      XSync(dpy, False);
      XSetErrorHandler(NIL); // Restore the default handler

      // QueryColors

      screen2.pixel = WhitePixelOfScreen(scr);
      XQueryColor(dpy, colormap, &screen2);

      // LookupColor

      success = XLookupColor(dpy, colormap, "DarkCyan", &exact, &screen);

      // CreateCursor

      Cursor cursor = XCreatePixmapCursor(dpy, pixmap, None, &exact, colors, 10, 10);

      // CreateGlyphCursor
      
      Cursor cursor2 = XCreateGlyphCursor(dpy, fs -> fid, fs -> fid, 'X', 0, &exact, colors);

      // FreeCursor
      
      XFreeCursor(dpy, cursor2);

      // RecolorCursor

      XRecolorCursor(dpy, cursor, colors, &exact);

      // QueryBestSize

      success = XQueryBestSize(dpy, CursorShape, RootWindowOfScreen(scr), 100, 20, &width, &height);

      // QueryExtension

      int major_opcode, first_event, first_error;
      XQueryExtension(dpy, "toto", &major_opcode, &first_event, &first_error);

      // ListExtensions

      int nextensions;
      char **extensionList = XListExtensions(dpy, &nextensions);
      for(char **p = extensionList; nextensions; nextensions--, p++) std::cout << *p << std::endl;
      XFree(extensionList);

      // ChangeKeyboardMapping
      // GetKeyboardMapping

      int min_keycodes, max_keycodes;
      XDisplayKeycodes(dpy, &min_keycodes, &max_keycodes);

      int keysyms_per_keycode;
      KeySym *keysyms = XGetKeyboardMapping(dpy, min_keycodes, max_keycodes - min_keycodes + 1,
					    &keysyms_per_keycode);
      XChangeKeyboardMapping(dpy, min_keycodes, keysyms_per_keycode, keysyms, 
			     max_keycodes - min_keycodes + 1);

      // ChangeKeyboardControl
      // GetKeyboardControl

      XKeyboardState keyboardState;
      XGetKeyboardControl(dpy, &keyboardState);

      XKeyboardControl keyboardValues;
      keyboardValues.key_click_percent = keyboardState.key_click_percent;
      keyboardValues.bell_percent = keyboardState.bell_percent;
      keyboardValues.bell_pitch = keyboardState.bell_pitch;
      keyboardValues.bell_duration = keyboardState.bell_duration;
      keyboardValues.led = 1;
      keyboardValues.led_mode = LedModeOn;
      keyboardValues.key = min_keycodes;
      keyboardValues.auto_repeat_mode = AutoRepeatModeDefault;
      XChangeKeyboardControl(dpy, 
			       KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration
			     | KBLed | KBLedMode | KBKey | KBAutoRepeatMode,
			     &keyboardValues);

      // Bell

      XBell(dpy, 90);

      // ChangePointerControl
      // GetPointerControl

      int accel_numerator, accel_denominator, threshold;
      XGetPointerControl(dpy, &accel_numerator, &accel_denominator, &threshold);

      XChangePointerControl(dpy, True, True, accel_numerator, accel_denominator, threshold);

      // SetScreenSaver
      // GetScreenSaver

      int timeout, interval, prefer_blanking, allow_exposures;
      XGetScreenSaver(dpy, &timeout, &interval, &prefer_blanking, &allow_exposures);
      XSetScreenSaver(dpy, timeout, interval, prefer_blanking, allow_exposures);

      // ChangeHosts
      // ListHosts

      int nhosts;
      Bool state;
      XHostAddress *hostList = XListHosts(dpy, &nhosts, &state);

      XHostAddress host;
      host.family = FamilyInternet;
      host.length = 4;
      host.address = "\001\002\003\004";
      XAddHost(dpy, &host);

      // SetAccessControl

      XSetAccessControl(dpy, EnableAccess);

      // SetCloseDownMode

      XSetCloseDownMode(dpy, RetainTemporary);

      // KillClient

      XKillClient(dpy, AllTemporary);

      // RotateProperties

      Atom properties[] = { XInternAtom(dpy, "CUT_BUFFER0", False), 
			    XInternAtom(dpy, "CUT_BUFFER1", False),
			    XInternAtom(dpy, "CUT_BUFFER2", False) };
      XRotateWindowProperties(dpy, RootWindowOfScreen(scr), properties, SIZEOF(properties), -1);

      // ForceScreenSaver

      XForceScreenSaver(dpy, ScreenSaverReset);

      // SetPointerMapping
      // GetPointerMapping

      unsigned char map[64];
      int map_length = XGetPointerMapping(dpy, map, 64);
      XSetPointerMapping(dpy, map, map_length);

      // SetModifierMapping
      // GetModifierMapping

      XModifierKeymap *modmap = XGetModifierMapping(dpy);
      XSetModifierMapping(dpy, modmap);

      // NoOperation

      XNoOp(dpy);

      for(;;) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    std::cout << "Got an event of type " << e.type << std::endl;
      }
}
Ejemplo n.º 24
0
void xopenw ( char win_name[], int win_index, float xsize,
              float ysize, int *ixsize, int *iysize, int *iret )
/************************************************************************
 * xopenw								*
 *									*
 * This subroutine opens one xw window and sets the initial		*
 * graphics context along with basic window attributes.			*
 *									*
 * xopenw ( win_name, win_index, xsize, ysize, ixsize, iysize, iret )	*
 *									*
 * Input parameters:							*
 *	win_name[]	char		window name			*
 *	win_index	int		window index			*
 *	xsize		float		Right edge of window		*
 *	ysize		float		Bottom edge of window		*
 *									*
 * Output parameters:							*
 *	*ixsize		int		Right edge of window		*
 *	*iysize		int		Bottom edge of window		*
 *	*iret		int		Return code			*
 *					G_NORMAL = normal return	*
 **									*
 * Log:									*
 * A. Hardy/GSC          2/01   Copied from the XW driver and           *
 *                              removed size limitations                *
 ***********************************************************************/
{
    int			dhght, dwdth, gemscreen, xpos, ypos, ier;
    unsigned int	xwdth, xhght, xbord, xdpth;
    char		gemname [WNAME_LEN];

    Cursor		curs;
    Window		gwin;
    GC			gemgc;

    XGCValues		 values;
    XSizeHints		 gemhint;
    XSetWindowAttributes gemxswa;
    XColor		 cred;

    Window_str      	*cwin;
    winloop_t		*cloop;
    /*---------------------------------------------------------------------*/

    *iret = G_NORMAL;

    current_window = win_index;

    cwin  = &(gemwindow[current_window]);
    cloop = &(cwin->loop[cwin->curr_loop]);

    strcpy(cwin->name, win_name);

    strcpy(gemname, win_name);

    gemscreen = DefaultScreen( (XtPointer)gemdisplay );

    /*
     * Determine window height and width.
     */

    dwdth = DisplayWidth( (XtPointer)gemdisplay, gemscreen );
    dhght = DisplayHeight( (XtPointer)gemdisplay, gemscreen );

    if ( G_ABS ( xsize - RMISSD ) < RDIFFD )
        gemhint.width = 0.7 * (float) dwdth ;
    else if ( ( xsize > 0.0 ) && ( xsize <= 1.0 ) )
        gemhint.width = (float) dwdth * xsize ;
    else if ( xsize < 100.0 ) gemhint.width = 100 ;
    else gemhint.width = (int) xsize ;

    if ( G_ABS ( ysize - RMISSD ) < RDIFFD )
        gemhint.height = 0.7 * (float) dhght ;
    else if ( ( ysize > 0.0 ) && ( ysize <= 1.0 ) )
        gemhint.height = (float) dhght * ysize ;
    else if ( ysize < 100.0 ) gemhint.height = 100 ;
    else gemhint.height = (int) ysize ;

    if ( gemhint.width  < 100 ) gemhint.width  = 100 ;
    if ( gemhint.height < 100 ) gemhint.height = 100 ;

    /*
     * Determine window location.
     */

    gemhint.x = dwdth - ( gemhint.width ) - ( current_window * 30 ) - 20;
    if ( gemhint.x < 0 ) gemhint.x = 0;

    gemhint.y = ( current_window * 30 );

    gemhint.flags  = USPosition | USSize;

    /*
     * Create the window and set standard properties and attributes.
     */

    gwin = XCreateSimpleWindow( gemdisplay, root, gemhint.x, gemhint.y,
                                gemhint.width, gemhint.height, 5,
                                WhitePixel ( (XtPointer)gemdisplay, gemscreen ),
                                BlackPixel ( (XtPointer)gemdisplay, gemscreen ) );

    cwin->window = gwin;

    XSetStandardProperties( gemdisplay, gwin, gemname, gemname, None,
                            NULL, 0, &gemhint );

    gemxswa.bit_gravity = CenterGravity;

    XChangeWindowAttributes (gemdisplay, gwin, (CWBitGravity), &gemxswa );

    /*
     * Get the geometry and window size information.
     */
    XGetGeometry( gemdisplay, gwin, &root, &xpos,
                  &ypos, &xwdth, &xhght, &xbord, &xdpth );

    cwin->width  = xwdth;
    cwin->height = xhght;
    cwin->depth  = xdpth;

    /*
     * Create graphics contexts.
     */
    gemgc = XCreateGC( gemdisplay, gwin, 0, 0 );

    /*
     * Turn of NoExpose and GraphicsExpose events.  They
     * don't seem to be needed and were causing many events
     * to seen in xxevent().
     */
    values.graphics_exposures = False;
    XChangeGC( gemdisplay, gemgc, GCGraphicsExposures, &values);

    cwin->gc = gemgc;

    /*
     * Set backgound colors.
     */
    XSetBackground( gemdisplay, gemgc,
                    BlackPixel ( (XtPointer)gemdisplay, gemscreen ) ) ;

    /*
     * Set fill rule.
     */
    XSetFillRule ( gemdisplay, gemgc, EvenOddRule );

    /*
     * Create one pixmap.
     */
    cwin->pxms[cwin->curr_loop][0] =
        XCreatePixmap(gemdisplay, root, xwdth, xhght, xdpth);

    cwin->curpxm[cwin->curr_loop] = 0;
    cloop->pxm_wdth	= xwdth;
    cloop->pxm_hght	= xhght;
    cloop->roamflg	= 0;
    cloop->xoffset	= 0;
    cloop->yoffset	= 0;

    cloop->pxm_x	= 0;
    cloop->pxm_y	= 0;
    cwin->area_w	= xwdth;
    cwin->area_h	= xhght;
    cwin->win_x		= 0;
    cwin->win_y		= 0;

    /*
     * return device size
     */
    *ixsize = xwdth;
    *iysize = xhght;

    /*
     * clear the pixmap,
     */
    xclrpxm(&(cwin->curpxm[cwin->curr_loop]), &ier);

    /*
     * Select the events to be processed.
     */
    XSelectInput ( gemdisplay, gwin, ExposureMask );

    /*
     * Set the cursor to be the customary red arrow.
     */
    curs = XCreateFontCursor ( gemdisplay, XC_top_left_arrow );
    XDefineCursor ( gemdisplay, gwin, curs );
    cred.red	= 65535;
    cred.blue	= 0;
    cred.green	= 0;
    cred.flags	= DoRed | DoBlue | DoGreen;
    XRecolorCursor ( gemdisplay, curs, &cred, &cred );

}
Ejemplo n.º 25
0
void
recolor_cursors(void)
{
    register Display *d = tool_d;

    XRecolorCursor(d, arrow_cursor,     &x_fg_color, &x_bg_color);
    XRecolorCursor(d, bull_cursor,      &x_fg_color, &x_bg_color);
    XRecolorCursor(d, buster_cursor,    &x_fg_color, &x_bg_color);
    XRecolorCursor(d, crosshair_cursor, &x_fg_color, &x_bg_color);
    XRecolorCursor(d, null_cursor,      &x_fg_color, &x_bg_color);
    XRecolorCursor(d, text_cursor,      &x_fg_color, &x_bg_color);
    XRecolorCursor(d, pick15_cursor,    &x_fg_color, &x_bg_color);
    XRecolorCursor(d, pick9_cursor,     &x_fg_color, &x_bg_color);
    XRecolorCursor(d, wait_cursor,      &x_fg_color, &x_bg_color);
    XRecolorCursor(d, panel_cursor,     &x_fg_color, &x_bg_color);
    XRecolorCursor(d, l_arrow_cursor,   &x_fg_color, &x_bg_color);
    XRecolorCursor(d, r_arrow_cursor,   &x_fg_color, &x_bg_color);
    XRecolorCursor(d, lr_arrow_cursor,  &x_fg_color, &x_bg_color);
    XRecolorCursor(d, u_arrow_cursor,   &x_fg_color, &x_bg_color);
    XRecolorCursor(d, d_arrow_cursor,   &x_fg_color, &x_bg_color);
    XRecolorCursor(d, ud_arrow_cursor,  &x_fg_color, &x_bg_color);
    XRecolorCursor(d, magnify_cursor,   &x_fg_color, &x_bg_color);
}