Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!aero!usasoc.soc.mil!sparkyfs!san18.erg.sri.com!frivold From: frivold@san18.erg.sri.com (Thane J. Frivold) Newsgroups: comp.windows.x Subject: XSendEvent question Message-ID: <32797@sparkyfs.istc.sri.com> Date: 6 Nov 90 07:02:27 GMT Sender: news@sparkyfs.istc.sri.com Reply-To: frivold@erg.sri.com.UUCP (Thane J. Frivold) Organization: SRI International, Menlo Park CA Lines: 129 I am currently working on an application (a modified `twm' to be exact) that allows for a certain amount of `remote control' of X11 applications. Once a common application has been determined, a controlling user's host replicates the pertinent X11 events to all the listening hosts. All event delivery to the selected application is done via calls to XSendEvent(). The event capture is done by creating an InputOnly `capture window' whose parent is the selected application (target) window and whose event mask has all bits set, except `PointerMotionHintMask'. The intent is to intercept all events normally destined for the selected application in order to decide, as a function of control state, whether or not the event should be propogated to the other hosts (as well as delivered locally). Currently, the application *does* work for client applications that have a *single* X11 window, but I have been unable to deliver the events to *multiple* window applications (e.g. xcalc or xwebster). Could someone please help me see either 1) the futility of my aspirations or preferably 2) the flaw in my approach and the required solution. Here is the code I am using to select the application window: /* NOTE: Select_Window() is taken, as is, from the file `dsimple.c' * found with the standard application `xwd'. */ Window SelectWindowFromUser(display) Display *display; { Window target = Select_Window(display); if( target != None ) { Window root; int result; int idummy; unsigned int udummy; result = XGetGeometry(display, target, &root, &idummy, &idummy, &udummy, &udummy, &udummy, &udummy); /* Look for the true `client' window */ if( result && target != root) target = XmuClientWindow(display, target); /* Make sure we didn't get the `root' window lest we render * the window manager itself useless by intercepting all events. */ if( target == root ) target = None; } return target; } The code fragment that handles the control case is: . . . /* Was this event `captured' from the target application? */ if( Event.xany.window == captureWindow ) { Bool ProcessRemoteXEvent(); /* Should this event be propogated to the listeners? */ if (ProcessRemoteXEvent(&Event) ) { /* If so, deliver the event locally as well */ XSendEvent(dpy, targetWindow, False, 0L, &Event); } } /* Otherwise handle the event as usual */ else DispatchEvent(); . . . And the code to handle the listen case is: . . . /* Insert the display for the local host */ Event.xany.display = dpy; XSendEvent(dpy, targetWindow, False, 0L, &Event); . . . Thank you in advance for any light you can shed on my problem. -Thane J. Frivold Software Engineer Geoscience & Engineering Center SRI International 333 Ravenswood Avenue Menlo Park, CA 94025 Mail Stop: EJ329 Office: (415) 859-2786 FAX: (415) 325-4812 EMAIL: frivold@erg.sri.com -or- frivold@unix.sri.com -Thane J. Frivold frivold@erg.sri.com