erik@sravd.sra.JUNET (Erik M. van der Poel) (11/21/89)
In article <8911202222.20499@munnari.oz.au> munnari!arp.anu.OZ.AU!gustav@uunet.uu.net writes: > However, > when I try to close the window by pressing the "close window" command > button, the window takes the keyboard focus with it, and it cannot be > transferred to the main command panel, unless the pop-up window is popped > up again. Here are a couple of work-arounds: 1. NoTitleFocus If you use twm, setting NoTitleFocus in your .twmrc may solve the problem. Advantage: This is very simple. Disadvantage: If you are distributing your application, you will need to tell your end-users about this too, so this solution is unreliable. (End-users are inherently unreliable. :-) 2. X Toolkit Apply the appended unofficial patch in lib/Xt. Advantage: This is reliable, because it gets compiled into your application. Disadvantage: You have to find and compile lib/Xt. *** /tmp/,RCSt1007774 Tue Nov 21 20:59:14 1989 --- Event.c Tue Nov 21 20:58:48 1989 *************** *** 864,871 **** "grabError","xtRemoveGrab","XtToolkitError", "XtRemoveGrab asked to remove a widget not on the list", (String *)NULL, (Cardinal *)NULL); } ! return False; } if (keyboard_focus) { --- 864,883 ---- "grabError","xtRemoveGrab","XtToolkitError", "XtRemoveGrab asked to remove a widget not on the list", (String *)NULL, (Cardinal *)NULL); + return False; } ! else { ! if (focusList) { ! /* ! * If there is an attempt to remove a widget that is ! * not on the list, assume that we really want to ! * remove one that IS on the list. ! */ ! gl = focusList; ! } else { ! return False; ! } ! } } if (keyboard_focus) {
gustav@arp.anu.OZ.AU (11/21/89)
Dear Xpert, I have a problem with the keyboard focus in my application. What happens is as follows: On pressing a button in the main "control panel" of my application (this "control panel" is also the top level shell of the application created by XtInitialize) a new window appears which consists of two dialog boxes, some lists, and a few command widgets - one of them being "close window". There are no problems at this stage with trasferring the keyboard focus between various dialog boxes of the application and between its various top level windows. The focus is given to the window automatically when the cursor enters the area of the window. However, when I try to close the window by pressing the "close window" command button, the window takes the keyboard focus with it, and it cannot be transferred to the main command panel, unless the pop-up window is popped up again. The popup is popped up using XtPopup (popup_shell, XtGrabNone), and then it is popped down using XtPopdown (popup_shell). The popup_shell itself is a child of the top level shell. The application has been written using Athena Widgets, X11/R3, vanilla distribution. The widgets used in the offending windows are dialog widget, command widget, list widget, and label widget. I've been experimenting with various kinds of "grabs" but to no avail. Best regards, Gustav Meglicki, Automated Reasoning Project Research School of Social Sciences Australian National University, GPO Box 4, Canberra, ACT, 2601, Australia gustav@arp.anu.oz.au
erik@sravd.sra.JUNET (Erik M. van der Poel) (11/22/89)
In article <1283@sragwa.sra.JUNET> I wrote: >In article <8911202222.20499@munnari.oz.au> munnari!arp.anu.OZ.AU!gustav@uunet.uu.net writes: >> However, >> when I try to close the window by pressing the "close window" command >> button, the window takes the keyboard focus with it, and it cannot be >> transferred to the main command panel, unless the pop-up window is popped >> up again. > >Here are a couple of work-arounds: > >1. NoTitleFocus > > ... > >2. X Toolkit > > ... And here are a few more solutions: 3. Focus events This is another disgusting hack which involves patching FocusOut events. Instead of XtMainLoop(), use: while (1) { static Window window; XEvent event; XtNextEvent(&event); switch (event.type) { case FocusIn: window = event.xfocus.window; break; case FocusOut: event.xfocus.window = window; break; default: break; } XtDispatchEvent(&event); } Advantage: This solution can be used if you plan to distribute your application in source form. (The Xt patch is for the binary form, and then only if you don't use dynamic linking.) Disadvantage: This may not work for everyone. (However, it does work for xfig.) 4. Destroy popup Destroying the popup instead of popping it down also solves the problem, as Rick Spickelmier said in an earlier article. Advantage: This solution, like the NoTitleFocus solution, does not seem to be "illegal" in any way. Disadvantage: You have to create the popup every time you need it, and this can be time-consuming, depending on the complexity of the popup. [5. Wait Wait until someone fixes the bug, rather than using work-arounds. Or fix it yourself. GOOD LUCK!]