grogers@uiucdcsm.cs.uiuc.edu (11/11/87)
I am writing an application that cannot follow the usually X11 model of polling for events, e.g. for(;;) { while (XPending(dpy)) { XNextEvent( dpy, &xevent); switch( xevent.type) { ... process events ... } } do non-event processing. } Yet, I still need to know when some events happen (e.g. expose). So, what I am currently doing is using SIGIO on the dpy->fd. This all seems to work ok, but I have a few questions: - Is there a better solution than using SIGIO? (Here's the really important one...) - Does the server send ALL events to the client and let the Xlib filter out the events not requested by the application or does the mask get applied at the server level? Really I'm asking if it costs me anything to enable events and then ignore them (especially expensive if the event causes a SIGIO interrupt and then is ignored). - I'm I supposed to be able to change the event mask after a ButtonPress event but before a ButtonReleased event? For example, after a ButtonPress I want to drag something across the screen by watching the MotionNotify events until a ButtonReleased event. My problem is this, after the ButtonPress event, if I change the event mask via XGetWindowAttributes, and XSelectInput or XChangeWindowAttributes I do not get any MotionNotify events. [I've verified that the new mask is set correctly by a second call to XGetWindowAttributes.] However, if I accept MotionNotify events before the ButtonPress event comes, everything works as expected (i.e. I get the events.) Anyway, Since I'm using ButtonMotionMask it doesn't really matter if this mask is enabled before a ButtonPress event because MotionEvents will only come when the button is down and that's just what I want. Greg Rogers University of Illinois at Urbana-Champaign Department of Computer Science UUCP: {pur-ee,convex,inhp4}!uiucdcs!grogers ARPA: grogers@m.cs.uiuc.edu CSNET: grogers%uiuc@csnet-relay
karlton@decwrl.dec.com (Philip Karlton) (11/11/87)
In article <26900019@uiucdcsm> grogers@uiucdcsm.cs.uiuc.edu writes: ... >- Does the server send ALL events to the client and let the Xlib filter out the > events not requested by the application or does the mask get applied > at the server level? Really I'm asking if it costs me anything to > enable events and then ignore them (especially expensive if the event > causes a SIGIO interrupt and then is ignored). The events are filtered at the server on a per client basis. >- I'm I supposed to be able to change the event mask after a ButtonPress event > but before a ButtonReleased event? For example, after a ButtonPress > I want to drag something across the screen by watching the MotionNotify > events until a ButtonReleased event. My problem is this, after the > ButtonPress event, if I change the event mask via > XGetWindowAttributes, and XSelectInput or XChangeWindowAttributes I > do not get any MotionNotify events. This is because a "grab" is active while the button is down. If you want to change what events are being delivered, then call ChangeActivePointerGrab. The ButtonMotionMask was intended to be used in just the manner you are using it. That is why the event-mask of the automatic grab is copied from the selected pointer events of the event window. PK