Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!adobe!asente From: asente@adobe.com (Paul Asente) Newsgroups: comp.windows.x Subject: Re: Xt Intrinsics, extensions, and event handlers Keywords: Xt,X extensions,multibuffering,nonmaskable event handlers Message-ID: <15815@adobe.UUCP> Date: 30 May 91 18:29:22 GMT References: <1224@mdavcr.UUCP> Sender: news@adobe.COM Distribution: na Organization: Adobe Systems Inc. Lines: 75 In article <1224@mdavcr.UUCP> furr@mdavcr.UUCP (Steven Furr) writes: >I would like to know if there is any way of providing Xt Event handlers >to handle events that come from X extensions. The event type of these >events is not known until the extension is initialized, and the event >cannot be selected with XSelectInput. This is correct; Xt does not handle events from extensions. >Shouldn't event types outside the range of the X standard protocol be >considered nonmaskable events by Xt? (i.e. those that get assigned to >extension events) That would be a simple but not very helpful solution. The Xt working group prefers to come up with a solution that is more well integrated with the rest of the Intrinsics, particularly the translation manager. >Since this appears not to be the case is there any possibility that this >will change with X11.R5? Nope. What you have to do now is not use XtAppMainLoop or XtAppProcessEvent. XtAppMainLoop should be replaced with something like while (1) { XEvent ev; XtAppNextEvent(app, &ev); if (!XtDispatchEvent(&ev)) { /* Must be an extension event; dispatch it myself */ } } Note that because of a bug in the R4 Xt, this will not currently work, but it has been fixed in R5. The R4 XtDispatchEvent may croak if passed a non-standard event; you need to do something like while (1) { XEvent ev; XtAppNextEvent(app, &ev); if (/* ev is an extension event */) { /* Dispatch it myself */ } else { if (!XtDispatchEvent(&ev)) { /* Shouldn't normally happen */ } } } XtAppProcessEvent is more problematical. If you call it with a mask of XtIMAll or XtIMXEvent and it encounters an extension event, it will quietly drop the event on the floor (or possibly croak in XtDispatchEvent under R4). You need to do something like (exact details depend on why you're using XtAppProcessEvent instead of XtAppNextEvent and XtDispatchEvent): XtInputMask mask; mask = XtAppPending(app); if (mask & XtIMXEvent /* && I-want-to-handle-it-now */) { /* Get event and process as above */ mask &= !XtIMXEvent; /* mask it out */ } XtAppProcessEvent(app, mask); /* won't handle X events */ This problem with XtAppProcessEvent will not go away in R5. -paul asente asente@adobe.com ...decwrl!adobe!asente Ratz put a bucket of liquid in front of me. "I wanted a glass of docs, Ratz. What the hell is this?" I barked. "Motif don't fit in a glass anymore," he barked back. I looked at the liquid. It was totally opaque to me.