Subject: Re: Multiple Virtual Monochrome Screens for Sun CG2

From: [email-masked] (Bill Janssen)
Date: 1 Dec 88 21:02:15 GMT

Another way to move to a desired screen when running Jim Peterson's
virtual screen variation of X11 is to simply warp the mouse to the
desired X screen.  The following is a simple program which takes
a single integer argument, the number of the screen to be selected,
and warps the mouse to it.  It can be called as a shell function
from twm or rtl, allowing them to work with the virtual screen
system.

  #include <stdio.h>
  
  #define TRUE  1
  #define FALSE 0
  typedef int Boolean;
  
  #define AND  &&
  #define OR   ||
  #define NOT  !
  
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
  #include <ctype.h>		/* for isdigit */
  
  main (ac, av, envp)
  
  int ac;
  char **av;
  char **envp;
  
  {
    Window root, child;
    int root_x, root_y, win_x, win_y;
    unsigned int mask;
    int newscreen;
    Display *disp;
  
    freopen ("/dev/console", "a", stderr);
  
    if (ac < 2 OR NOT(isdigit(*av[1])))
      {
        fprintf (stderr, "Usage:  warptoscreen <screen-number>\n");
        return 1;
      }
  
    newscreen = atoi(av[1]);
  
    disp = XOpenDisplay (NULL);
  
    if (disp == NULL)
      {
        fprintf (stderr, "Usage:  can't access X11 display\n");
        return 1;
      }
  
    if (newscreen >= ScreenCount(disp))
      {
        fprintf (stderr, "Can't warp to screen %d; only %d screens\n",
  	       newscreen, ScreenCount(disp));
        return 1;
      }
        
    /* get current mouse position */
    XQueryPointer (disp, DefaultRootWindow(disp),
  		 &root, &child, &root_x, &root_y,
  		 &win_x, &win_y, &mask);
  
    XWarpPointer (disp, None, RootWindow(disp, newscreen),
  		0, 0, 0, 0, root_x, root_y);
  
    XCloseDisplay (disp);
  
    return 0;
  }
--