Download Linux/UNIX Platform Ref
Transcript
Appendix B Window A is a top-level window, and thus it can get focus from the window manager. If the application does nothing to move the focus (i.e., does not call xvt_scr_set_focus), X delivers keyboard events as if a pointer-driven model is in effect, even though the window manager is not changing input focus. A.2. XVT/XM Focus Policy The Motif Window Manager always gives focus to the outermost widget (or TopLevelShell widget) of the window hierarchy. Motif then uses a virtual focus model to deliver keyboard events. In other words, Motif uses the X Intrinsics toolkit to redirect keyboard events to the object (window or control) that has been assigned as the focus object (even though the X server’s idea of who has focus hasn’t changed). Consequently, if your application is using ATTR_EVENT_HOOK to watch for KeyPress or KeyRelease events, they can be delivered to any X Window in your application. The Xt Intrinsics library will redirect the events appropriately. A.2.1. Default Focus Model In XVT/XM (as well as Motif), the focus model defaults to a clickto-type model. For example, in Figure A.1, if window A has focus, all character events are delivered to window A, regardless of the position of the mouse pointer. See Also: For a comparison of the two focus models used by Motif, refer to section A.1.1. A.2.2. Changing Focus To give focus to one of the other windows, the user must move the pointer and click the mouse button in it. The application then receives an E_FOCUS event with the active field equal to FALSE for the previous focus window, and a subsequent E_FOCUS event with the active field equal to TRUE for the window in which the mouse was clicked. The new focus window receives all subsequent E_CHAR events. Clicking on a control also gives it focus and ensures that its parent receives the correct E_FOCUS event, if necessary. If focus leaves the window hierarchy and then returns, the focus is restored to the last window or control that had the focus. (The focus is not returned to the client area of the top-level window.) A-3