# #define MAXUSERS 4 #include #include #include #include #define TRUE 1 #define FALSE 0 main(argc,argv) int argc; char **argv; { Display *display[MAXUSERS]; Window root[MAXUSERS], window[MAXUSERS]; long fgcolor, bgcolor; int screen; int eventmask = KeyPressMask|ExposureMask|ButtonMotionMask|ButtonPressMask|ButtonReleaseMask; long gcmask = GCForeground | GCBackground | GCLineWidth | GCCapStyle | GCJoinStyle; XEvent event; XGCValues gcval; GC draw[MAXUSERS]; int NC; int i, j; int oldx, oldy, curx, cury; if (argc == 1) NC = argc; else NC = argc-1; for (i=0; i< NC; i++){ if (!(display[i] = XOpenDisplay(argv[i+1]))) { perror("XOpenDisplay"); exit(1); } root[i] = RootWindow(display[i],screen = DefaultScreen(display[i])); fgcolor = BlackPixel(display[i],screen); bgcolor = WhitePixel(display[i],screen); window[i] = XCreateSimpleWindow(display[i],root[i],0,0,200,200,2, fgcolor,bgcolor); /* XSetWindowBackgroundPixmap(display[i],window[i],NULL); */ gcval.foreground = fgcolor; gcval.background = bgcolor; gcval.line_width = 7; gcval.cap_style = CapRound; gcval.join_style = JoinRound; draw[i] = XCreateGC(display[i],window[i], gcmask,&gcval); XMapWindow(display[i],window[i]); XFlush(display[i]); XGrabButton(display[i], AnyButton, AnyModifier, window[i], TRUE, ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, window[i], XCreateFontCursor(display[i], XC_crosshair)); XSelectInput(display[i],window[i],eventmask); } for (;;) { for(j=0; j < NC; j++) { if (XCheckWindowEvent(display[j],window[j],eventmask,&event)) switch (event.type) { case ButtonPress: oldx=event.xbutton.x; oldy= event.xbutton.y; case MotionNotify: for (i=0; i