focus functions
XgrGetMouseInfo ( @window, @grid, @xWin, @yWin, @state, @time )
XgrGetSelectedWindow ( @window )
XgrSetSelectedWindow ( window )

XgrGetMouseInfo  ( @window, @grid, @xWin, @yWin, @state, @time ) 

XgrGetMouseInfo() returns the grid that has mouse focus, otherwise the grid that currently contains the mouse cursor. Also returned is the (xWin,yWin) position of the mouse cursor in window, and the mouse state . If the mouse cursor is not in a window and/or grid, then window and/or grid=0 . 

XgrGetSelectedWindow  ( @window ) 

XgrGetSelectedWindow() returns the window that is currently selected on the default display, which is the window to which keyboard messages are directed. If no window created by the program is currently selected, a 0 is returned in window. Since many programs can have windows on the display at the same time, a value of 0 in window is not a rare occurrence.

XgrSetSelectedWindow  ( window ) 

XgrSetSelectedWindow() displays window if it is hidden or minimized, then selects window if it is not already selected. 

Selecting window gives it keyboard focus, so the window argument of subsequent keyboard messages will be window .