Path: utzoo!attcan!uunet!cs.utexas.edu!asuvax!noao!ncar!ico!auto-trol!marbru From: marbru@auto-trol.UUCP (Martin Brunecky) Newsgroups: comp.windows.x Subject: Re: Adding event handlers to windows Message-ID: <1223@auto-trol.UUCP> Date: 13 Jun 90 18:27:54 GMT References: <1445.9006120916@kheops.cmi.no> <9006121416.AA07750@expo.lcs.mit.edu> Reply-To: marbru@auto-trol.UUCP (Martin Brunecky) Organization: Auto-trol Technology, Denver Lines: 51 In article <9006121416.AA07750@expo.lcs.mit.edu> kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) writes: > >> Is there a way to add Xt R4 event handlers to windows and not just widgets? >> I would rather avoid open up the XtAppMainLoop() and dispatch non-widget >> events myself if possible. I'm using properties to share data among loosely >> coupled processes, registering the property in the root window which is not >> a widget. Would it possible to convert a window to widget using >> XtWindowToWidget() and than using the XtAddEventHandler() mechanism. > >The is no "officially" supported way to do this, but I have been thinking about >this problem, and believe that I have a hack that should do the trick. Please >keep in mind that I have not tried this, and am not sure it will work, but it >does seem reasonable. > >The trick is that in order for Xt to be able to process events for the window it >must have a widget associated with it. If we can figure out a way to assign a >widget structure to a window that already exists, then we should be just fine. > >What I suggest is that you instanciate a widget of class "widgetClass" this is a >Core widget...(description of kluge deleted).... A'v been looking into the same issue, primarilly to allow me write a widget that could use a window provided by another application. Contrary to Chris, I do not consider window geometry management an issue. If the window has been provided from the outside, the configuration requests performed by the Intrinsics can be prevented by not managing the widget (which makes sense since this window is already managed by someone else). Any configuration requests from XtSetValues can be prevented by making the required, current and new geometry always the same (following the window size). What I do consider important is the ability to hook my window into the toolkit event dispatch, i.e. enable use of the translation management (which also dispatches to any explicitly added event handlers for that matter). There is a private routine _XtRegisterWindow (Event.c), which seems to be the key to the problem. Once the window is registered, XtDispatchEvent will know what to do with events on this window. Since I haven't tried it, I suspect there may be some "gotcha's" with selecting input and, in particular, what happens when I call XtDestroyWidget ? Anyway. Since my case is probbably not the only instance where applications want to share window, XtIntrinsics should be enhanced to deal with this case. Or, at least, support widgets that want to deal with such a scenario. -- =*= Opinions presented here are solely of my own and not those of Auto-trol =*= Martin Brunecky marbru@auto-trol.COM (303) 252-2499 {...}ncar!ico!auto-trol!marbru Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404