[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get the current screen

Calling tv:mouse-default-superior is a good answer.  Note that it takes a window as
an optional argument, defaulting to the value of *TERMINAL-IO*.

Another possibility is to send the :SCREEN message to a window to get the screen that
that window is on.  Both of these techniques assume that you want to put a window on
the same screen as another window, which is the normal case.  Using tv:mouse-default-superior
gives more robustness in the face of various unusual situations, for example if you have
a color screen and a monochrome screen sharing the same mouse, it will use the screen
the mouse is on even if the window you give is on the other screen; for menus you
generally would rather have them appear next to the mouse.

Using tv:selected-window is a bad idea, since it is the selected window of the primary
console.  It can be NIL if no window is selected right now.  In a multiple console
situation (as often happens when using X Client, for example), tv:selected-window can
only be the right answer for one of the consoles.  It is better to say "the same screen
as this other window of my application" than to use any kind of global variable such
as tv:selected-window.