home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / Linux / Apps / xanim.tgz / xanim / xanim27064 / proptest.c < prev    next >
C/C++ Source or Header  |  1997-01-26  |  1KB  |  45 lines

  1. #include <termios.h>
  2. #include <unistd.h>
  3. #include <X11/Xlib.h>
  4. #include <X11/Xatom.h>
  5.  
  6. int main(argc, argv)
  7. int argc;
  8. char *argv[];
  9. {
  10.   struct termios save_termios;
  11.   struct termios buf;
  12.   Display *dpy;
  13.   Window window;
  14.   unsigned long window_atom;
  15.   char c;
  16.   if (argc < 2) {
  17.     printf("Usage: %s windowid\n", argv[0]);
  18.     exit(-1);
  19.   }
  20.   window = (Window)strtol(argv[1], NULL, 0);
  21.   dpy = XOpenDisplay(NULL);
  22.   if (dpy == NULL)
  23.     exit(-1);
  24.   window_atom = XInternAtom(dpy, "XANIM_PROPERTY", 0);
  25.  
  26.   if (tcgetattr(0, &save_termios) < 0)
  27.     exit(-1);
  28.   buf = save_termios;
  29.   buf.c_lflag &= ~(ECHO | ICANON);
  30.   buf.c_cc[VMIN] = 1;
  31.   buf.c_cc[VTIME] = 0;
  32.   if (tcsetattr(0, TCSAFLUSH, &buf) < 0)
  33.     exit(-1);
  34.   do {
  35.     c = getchar();
  36.     printf("sending char %c\n", c);
  37.     XChangeProperty(dpy, window, window_atom, XA_STRING, 8,
  38.             PropModeReplace, (unsigned char *)&c, 1);
  39.     XFlush(dpy);
  40.   } while (c != 'q');
  41.   XCloseDisplay(dpy);
  42.   if (tcsetattr(0, TCSAFLUSH, &save_termios) < 0)
  43.     exit(-1);
  44. }
  45.