Add documentation for horizontal scroll bars and fix some minor issues.
[emacs.git] / doc / lispref / frames.texi
blob464c5fccc4f0d167f2344757b559e8b4f4092582
1 @c -*-texinfo-*-
2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990-1995, 1998-1999, 2001-2014 Free Software
4 @c Foundation, Inc.
5 @c See the file elisp.texi for copying conditions.
6 @node Frames
7 @chapter Frames
8 @cindex frame
10   A @dfn{frame} is a screen object that contains one or more Emacs
11 windows (@pxref{Windows}).  It is the kind of object called a
12 ``window'' in the terminology of graphical environments; but we can't
13 call it a ``window'' here, because Emacs uses that word in a different
14 way.  In Emacs Lisp, a @dfn{frame object} is a Lisp object that
15 represents a frame on the screen.  @xref{Frame Type}.
17   A frame initially contains a single main window and/or a minibuffer
18 window; you can subdivide the main window vertically or horizontally
19 into smaller windows.  @xref{Splitting Windows}.
21 @cindex terminal
22   A @dfn{terminal} is a display device capable of displaying one or
23 more Emacs frames.  In Emacs Lisp, a @dfn{terminal object} is a Lisp
24 object that represents a terminal.  @xref{Terminal Type}.
26 @cindex text terminal
27 @cindex graphical terminal
28 @cindex graphical display
29   There are two classes of terminals: @dfn{text terminals} and
30 @dfn{graphical terminals}.  Text terminals are non-graphics-capable
31 displays, including @command{xterm} and other terminal emulators.  On
32 a text terminal, each Emacs frame occupies the terminal's entire
33 screen; although you can create additional frames and switch between
34 them, the terminal only shows one frame at a time.  Graphical
35 terminals, on the other hand, are managed by graphical display systems
36 such as the X Window System, which allow Emacs to show multiple frames
37 simultaneously on the same display.
39   On GNU and Unix systems, you can create additional frames on any
40 available terminal, within a single Emacs session, regardless of
41 whether Emacs was started on a text or graphical terminal.  Emacs can
42 display on both graphical and text terminals simultaneously.  This
43 comes in handy, for instance, when you connect to the same session
44 from several remote locations.  @xref{Multiple Terminals}.
46 @defun framep object
47 This predicate returns a non-@code{nil} value if @var{object} is a
48 frame, and @code{nil} otherwise.  For a frame, the value indicates which
49 kind of display the frame uses:
51 @table @code
52 @item t
53 The frame is displayed on a text terminal.
54 @item x
55 The frame is displayed on an X graphical terminal.
56 @item w32
57 The frame is displayed on a MS-Windows graphical terminal.
58 @item ns
59 The frame is displayed on a GNUstep or Macintosh Cocoa graphical
60 terminal.
61 @item pc
62 The frame is displayed on an MS-DOS terminal.
63 @end table
64 @end defun
66 @defun frame-terminal &optional frame
67 This function returns the terminal object that displays @var{frame}.
68 If @var{frame} is @code{nil} or unspecified, it defaults to the
69 selected frame.
70 @end defun
72 @defun terminal-live-p object
73 This predicate returns a non-@code{nil} value if @var{object} is a
74 terminal that is live (i.e., not deleted), and @code{nil} otherwise.
75 For live terminals, the return value indicates what kind of frames are
76 displayed on that terminal; the list of possible values is the same as
77 for @code{framep} above.
78 @end defun
80 @menu
81 * Creating Frames::             Creating additional frames.
82 * Multiple Terminals::          Displaying on several different devices.
83 * Frame Parameters::            Controlling frame size, position, font, etc.
84 * Terminal Parameters::         Parameters common for all frames on terminal.
85 * Frame Titles::                Automatic updating of frame titles.
86 * Deleting Frames::             Frames last until explicitly deleted.
87 * Finding All Frames::          How to examine all existing frames.
88 * Minibuffers and Frames::      How a frame finds the minibuffer to use.
89 * Input Focus::                 Specifying the selected frame.
90 * Visibility of Frames::        Frames may be visible or invisible, or icons.
91 * Raising and Lowering::        Raising a frame makes it hide other windows;
92                                   lowering it makes the others hide it.
93 * Frame Configurations::        Saving the state of all frames.
94 * Mouse Tracking::              Getting events that say when the mouse moves.
95 * Mouse Position::              Asking where the mouse is, or moving it.
96 * Pop-Up Menus::                Displaying a menu for the user to select from.
97 * Dialog Boxes::                Displaying a box to ask yes or no.
98 * Pointer Shape::               Specifying the shape of the mouse pointer.
99 * Window System Selections::    Transferring text to and from other X clients.
100 * Drag and Drop::               Internals of Drag-and-Drop implementation.
101 * Color Names::                 Getting the definitions of color names.
102 * Text Terminal Colors::        Defining colors for text terminals.
103 * Resources::                   Getting resource values from the server.
104 * Display Feature Testing::     Determining the features of a terminal.
105 @end menu
107 @node Creating Frames
108 @section Creating Frames
110 To create a new frame, call the function @code{make-frame}.
112 @deffn Command make-frame &optional alist
113 This function creates and returns a new frame, displaying the current
114 buffer.
116 The @var{alist} argument is an alist that specifies frame parameters
117 for the new frame.  @xref{Frame Parameters}.  If you specify the
118 @code{terminal} parameter in @var{alist}, the new frame is created on
119 that terminal.  Otherwise, if you specify the @code{window-system}
120 frame parameter in @var{alist}, that determines whether the frame
121 should be displayed on a text terminal or a graphical terminal.
122 @xref{Window Systems}.  If neither is specified, the new frame is
123 created in the same terminal as the selected frame.
125 Any parameters not mentioned in @var{alist} default to the values in
126 the alist @code{default-frame-alist} (@pxref{Initial Parameters});
127 parameters not specified there default from the X resources or its
128 equivalent on your operating system (@pxref{X Resources,, X Resources,
129 emacs, The GNU Emacs Manual}).  After the frame is created, Emacs
130 applies any parameters listed in @code{frame-inherited-parameters}
131 (see below) and not present in the argument, taking the values from
132 the frame that was selected when @code{make-frame} was called.
134 This function itself does not make the new frame the selected frame.
135 @xref{Input Focus}.  The previously selected frame remains selected.
136 On graphical terminals, however, the windowing system may select the
137 new frame for its own reasons.
138 @end deffn
140 @defvar before-make-frame-hook
141 A normal hook run by @code{make-frame} before it creates the frame.
142 @end defvar
144 @defvar after-make-frame-functions
145 An abnormal hook run by @code{make-frame} after it creates the frame.
146 Each function in @code{after-make-frame-functions} receives one argument, the
147 frame just created.
148 @end defvar
150 @defvar frame-inherited-parameters
151 This variable specifies the list of frame parameters that a newly
152 created frame inherits from the currently selected frame.  For each
153 parameter (a symbol) that is an element in the list and is not present
154 in the argument to @code{make-frame}, the function sets the value of
155 that parameter in the created frame to its value in the selected
156 frame.
157 @end defvar
159 @node Multiple Terminals
160 @section Multiple Terminals
161 @cindex multiple terminals
162 @cindex multi-tty
163 @cindex multiple X displays
164 @cindex displays, multiple
166   Emacs represents each terminal as a @dfn{terminal object} data type
167 (@pxref{Terminal Type}).  On GNU and Unix systems, Emacs can use
168 multiple terminals simultaneously in each session.  On other systems,
169 it can only use a single terminal.  Each terminal object has the
170 following attributes:
172 @itemize @bullet
173 @item
174 The name of the device used by the terminal (e.g., @samp{:0.0} or
175 @file{/dev/tty}).
177 @item
178 The terminal and keyboard coding systems used on the terminal.
179 @xref{Terminal I/O Encoding}.
181 @item
182 The kind of display associated with the terminal.  This is the symbol
183 returned by the function @code{terminal-live-p} (i.e., @code{x},
184 @code{t}, @code{w32}, @code{ns}, or @code{pc}).  @xref{Frames}.
186 @item
187 A list of terminal parameters.  @xref{Terminal Parameters}.
188 @end itemize
190   There is no primitive for creating terminal objects.  Emacs creates
191 them as needed, such as when you call @code{make-frame-on-display}
192 (described below).
194 @defun terminal-name &optional terminal
195 This function returns the file name of the device used by
196 @var{terminal}.  If @var{terminal} is omitted or @code{nil}, it
197 defaults to the selected frame's terminal.  @var{terminal} can also be
198 a frame, meaning that frame's terminal.
199 @end defun
201 @defun terminal-list
202 This function returns a list of all live terminal objects.
203 @end defun
205 @defun get-device-terminal device
206 This function returns a terminal whose device name is given by
207 @var{device}.  If @var{device} is a string, it can be either the file
208 name of a terminal device, or the name of an X display of the form
209 @samp{@var{host}:@var{server}.@var{screen}}.  If @var{device} is a
210 frame, this function returns that frame's terminal; @code{nil} means
211 the selected frame.  Finally, if @var{device} is a terminal object
212 that represents a live terminal, that terminal is returned.  The
213 function signals an error if its argument is none of the above.
214 @end defun
216 @defun delete-terminal &optional terminal force
217 This function deletes all frames on @var{terminal} and frees the
218 resources used by it.  It runs the abnormal hook
219 @code{delete-terminal-functions}, passing @var{terminal} as the
220 argument to each function.
222 If @var{terminal} is omitted or @code{nil}, it defaults to the
223 selected frame's terminal.  @var{terminal} can also be a frame,
224 meaning that frame's terminal.
226 Normally, this function signals an error if you attempt to delete the
227 sole active terminal, but if @var{force} is non-@code{nil}, you are
228 allowed to do so.  Emacs automatically calls this function when the
229 last frame on a terminal is deleted (@pxref{Deleting Frames}).
230 @end defun
232 @defvar delete-terminal-functions
233 An abnormal hook run by @code{delete-terminal}.  Each function
234 receives one argument, the @var{terminal} argument passed to
235 @code{delete-terminal}.  Due to technical details, the functions may
236 be called either just before the terminal is deleted, or just
237 afterwards.
238 @end defvar
240 @cindex terminal-local variables
241   A few Lisp variables are @dfn{terminal-local}; that is, they have a
242 separate binding for each terminal.  The binding in effect at any time
243 is the one for the terminal that the currently selected frame belongs
244 to.  These variables include @code{default-minibuffer-frame},
245 @code{defining-kbd-macro}, @code{last-kbd-macro}, and
246 @code{system-key-alist}.  They are always terminal-local, and can
247 never be buffer-local (@pxref{Buffer-Local Variables}).
249   On GNU and Unix systems, each X display is a separate graphical
250 terminal.  When Emacs is started from within the X window system, it
251 uses the X display specified by the @env{DISPLAY} environment
252 variable, or by the @samp{--display} option (@pxref{Initial Options,,,
253 emacs, The GNU Emacs Manual}).  Emacs can connect to other X displays
254 via the command @code{make-frame-on-display}.  Each X display has its
255 own selected frame and its own minibuffer windows; however, only one
256 of those frames is ``@emph{the} selected frame'' at any given moment
257 (@pxref{Input Focus}).  Emacs can even connect to other text
258 terminals, by interacting with the @command{emacsclient} program.
259 @xref{Emacs Server,,, emacs, The GNU Emacs Manual}.
261   A single X server can handle more than one display.  Each X display
262 has a three-part name, @samp{@var{host}:@var{server}.@var{screen}}.
263 The first two parts, @var{host} and @var{server}, identify the X
264 server; the third part, @var{screen}, identifies a screen number on
265 that X server.  When you use two or more screens belonging to one
266 server, Emacs knows by the similarity in their names that they share a
267 single keyboard.
269 @deffn Command make-frame-on-display display &optional parameters
270 This function creates and returns a new frame on @var{display}, taking
271 the other frame parameters from the alist @var{parameters}.
272 @var{display} should be the name of an X display (a string).
274 Before creating the frame, this function ensures that Emacs is ``set
275 up'' to display graphics.  For instance, if Emacs has not processed X
276 resources (e.g., if it was started on a text terminal), it does so at
277 this time.  In all other respects, this function behaves like
278 @code{make-frame} (@pxref{Creating Frames}).
279 @end deffn
281 @defun x-display-list
282 This function returns a list that indicates which X displays Emacs has
283 a connection to.  The elements of the list are strings, and each one
284 is a display name.
285 @end defun
287 @defun x-open-connection display &optional xrm-string must-succeed
288 This function opens a connection to the X display @var{display},
289 without creating a frame on that display.  Normally, Emacs Lisp
290 programs need not call this function, as @code{make-frame-on-display}
291 calls it automatically.  The only reason for calling it is to check
292 whether communication can be established with a given X display.
294 The optional argument @var{xrm-string}, if not @code{nil}, is a string
295 of resource names and values, in the same format used in the
296 @file{.Xresources} file.  @xref{X Resources,, X Resources, emacs, The
297 GNU Emacs Manual}.  These values apply to all Emacs frames created on
298 this display, overriding the resource values recorded in the X server.
299 Here's an example of what this string might look like:
301 @example
302 "*BorderWidth: 3\n*InternalBorder: 2\n"
303 @end example
305 If @var{must-succeed} is non-@code{nil}, failure to open the connection
306 terminates Emacs.  Otherwise, it is an ordinary Lisp error.
307 @end defun
309 @defun x-close-connection display
310 This function closes the connection to display @var{display}.  Before
311 you can do this, you must first delete all the frames that were open
312 on that display (@pxref{Deleting Frames}).
313 @end defun
315 @cindex multi-monitor
316   On some ``multi-monitor'' setups, a single X display outputs to more
317 than one physical monitor.  You can use the functions
318 @code{display-monitor-attributes-list} and @code{frame-monitor-attributes}
319 to obtain information about such setups.
321 @defun display-monitor-attributes-list &optional display
322 This function returns a list of physical monitor attributes on
323 @var{display}, which defaults to that of the selected frame.
324 Each element of the list is an association list, representing the
325 attributes of a physical monitor.  The first element corresponds to
326 the primary monitor.  The attribute keys and values are:
328 @table @samp
329 @item geometry
330 Position and size in pixels as @samp{(@var{x} @var{y}
331 @var{width} @var{height})}.
333 @item workarea
334 Position and size of the work area in pixels as
335 @samp{(@var{x} @var{y} @var{width} @var{height})}.
337 @item mm-size
338 Width and height in millimeters as @samp{(@var{width} @var{height})}
340 @item frames
341 List of frames that this physical monitor dominates (see below).
343 @item name
344 Name of the physical monitor as @var{string}.
345 @end table
347 @var{x}, @var{y}, @var{width}, and @var{height} are integers.
348 @samp{name} may not be present.
350 A frame is @dfn{dominated} by a physical monitor when either the
351 largest area of the frame resides in that monitor, or (if the frame
352 does not intersect any physical monitors) that monitor is the closest
353 to the frame.  Every (non-tooltip) frame (whether visible or not) in a
354 graphical display is dominated by exactly one physical monitor at a
355 time, though the frame can span multiple (or no) physical monitors.
356 @end defun
358 @defun frame-monitor-attributes &optional frame
359 This function returns the attributes of the physical monitor
360 dominating (see above) @var{frame}, which defaults to the selected frame.
361 @end defun
363 @node Frame Parameters
364 @section Frame Parameters
365 @cindex frame parameters
367   A frame has many parameters that control its appearance and behavior.
368 Just what parameters a frame has depends on what display mechanism it
369 uses.
371   Frame parameters exist mostly for the sake of graphical displays.
372 Most frame parameters have no effect when applied to a frame on a text
373 terminal; only the @code{height}, @code{width}, @code{name},
374 @code{title}, @code{menu-bar-lines}, @code{buffer-list} and
375 @code{buffer-predicate} parameters do something special.  If the
376 terminal supports colors, the parameters @code{foreground-color},
377 @code{background-color}, @code{background-mode} and
378 @code{display-type} are also meaningful.  If the terminal supports
379 frame transparency, the parameter @code{alpha} is also meaningful.
381 @menu
382 * Parameter Access::       How to change a frame's parameters.
383 * Initial Parameters::     Specifying frame parameters when you make a frame.
384 * Window Frame Parameters:: List of frame parameters for window systems.
385 * Size and Position::      Changing the size and position of a frame.
386 * Geometry::               Parsing geometry specifications.
387 @end menu
389 @node Parameter Access
390 @subsection Access to Frame Parameters
392 These functions let you read and change the parameter values of a
393 frame.
395 @defun frame-parameter frame parameter
396 This function returns the value of the parameter @var{parameter} (a
397 symbol) of @var{frame}.  If @var{frame} is @code{nil}, it returns the
398 selected frame's parameter.  If @var{frame} has no setting for
399 @var{parameter}, this function returns @code{nil}.
400 @end defun
402 @defun frame-parameters &optional frame
403 The function @code{frame-parameters} returns an alist listing all the
404 parameters of @var{frame} and their values.  If @var{frame} is
405 @code{nil} or omitted, this returns the selected frame's parameters
406 @end defun
408 @defun modify-frame-parameters frame alist
409 This function alters the parameters of frame @var{frame} based on the
410 elements of @var{alist}.  Each element of @var{alist} has the form
411 @code{(@var{parm} . @var{value})}, where @var{parm} is a symbol naming a
412 parameter.  If you don't mention a parameter in @var{alist}, its value
413 doesn't change.  If @var{frame} is @code{nil}, it defaults to the selected
414 frame.
415 @end defun
417 @defun set-frame-parameter frame parm value
418 This function sets the frame parameter @var{parm} to the specified
419 @var{value}.  If @var{frame} is @code{nil}, it defaults to the
420 selected frame.
421 @end defun
423 @defun modify-all-frames-parameters alist
424 This function alters the frame parameters of all existing frames
425 according to @var{alist}, then modifies @code{default-frame-alist}
426 (and, if necessary, @code{initial-frame-alist}) to apply the same
427 parameter values to frames that will be created henceforth.
428 @end defun
430 @node Initial Parameters
431 @subsection Initial Frame Parameters
433 You can specify the parameters for the initial startup frame by
434 setting @code{initial-frame-alist} in your init file (@pxref{Init
435 File}).
437 @defopt initial-frame-alist
438 This variable's value is an alist of parameter values used when
439 creating the initial frame.  You can set this variable to specify the
440 appearance of the initial frame without altering subsequent frames.
441 Each element has the form:
443 @example
444 (@var{parameter} . @var{value})
445 @end example
447 Emacs creates the initial frame before it reads your init
448 file.  After reading that file, Emacs checks @code{initial-frame-alist},
449 and applies the parameter settings in the altered value to the already
450 created initial frame.
452 If these settings affect the frame geometry and appearance, you'll see
453 the frame appear with the wrong ones and then change to the specified
454 ones.  If that bothers you, you can specify the same geometry and
455 appearance with X resources; those do take effect before the frame is
456 created.  @xref{X Resources,, X Resources, emacs, The GNU Emacs Manual}.
458 X resource settings typically apply to all frames.  If you want to
459 specify some X resources solely for the sake of the initial frame, and
460 you don't want them to apply to subsequent frames, here's how to achieve
461 this.  Specify parameters in @code{default-frame-alist} to override the
462 X resources for subsequent frames; then, to prevent these from affecting
463 the initial frame, specify the same parameters in
464 @code{initial-frame-alist} with values that match the X resources.
465 @end defopt
467 @cindex minibuffer-only frame
468 If these parameters include @code{(minibuffer . nil)}, that indicates
469 that the initial frame should have no minibuffer.  In this case, Emacs
470 creates a separate @dfn{minibuffer-only frame} as well.
472 @defopt minibuffer-frame-alist
473 This variable's value is an alist of parameter values used when
474 creating an initial minibuffer-only frame (i.e., the minibuffer-only
475 frame that Emacs creates if @code{initial-frame-alist} specifies a
476 frame with no minibuffer).
477 @end defopt
479 @defopt default-frame-alist
480 This is an alist specifying default values of frame parameters for all
481 Emacs frames---the first frame, and subsequent frames.  When using the X
482 Window System, you can get the same results by means of X resources
483 in many cases.
485 Setting this variable does not affect existing frames.  Furthermore,
486 functions that display a buffer in a separate frame may override the
487 default parameters by supplying their own parameters.
488 @end defopt
490 If you invoke Emacs with command-line options that specify frame
491 appearance, those options take effect by adding elements to either
492 @code{initial-frame-alist} or @code{default-frame-alist}.  Options
493 which affect just the initial frame, such as @samp{--geometry} and
494 @samp{--maximized}, add to @code{initial-frame-alist}; the others add
495 to @code{default-frame-alist}.  @pxref{Emacs Invocation,, Command Line
496 Arguments for Emacs Invocation, emacs, The GNU Emacs Manual}.
498 @node Window Frame Parameters
499 @subsection Window Frame Parameters
500 @cindex frame parameters for windowed displays
502   Just what parameters a frame has depends on what display mechanism
503 it uses.  This section describes the parameters that have special
504 meanings on some or all kinds of terminals.  Of these, @code{name},
505 @code{title}, @code{height}, @code{width}, @code{buffer-list} and
506 @code{buffer-predicate} provide meaningful information in terminal
507 frames, and @code{tty-color-mode} is meaningful only for frames on
508 text terminals.
510 @menu
511 * Basic Parameters::            Parameters that are fundamental.
512 * Position Parameters::         The position of the frame on the screen.
513 * Size Parameters::             Frame's size.
514 * Layout Parameters::           Size of parts of the frame, and
515                                   enabling or disabling some parts.
516 * Buffer Parameters::           Which buffers have been or should be shown.
517 * Management Parameters::       Communicating with the window manager.
518 * Cursor Parameters::           Controlling the cursor appearance.
519 * Font and Color Parameters::   Fonts and colors for the frame text.
520 @end menu
522 @node Basic Parameters
523 @subsubsection Basic Parameters
525   These frame parameters give the most basic information about the
526 frame.  @code{title} and @code{name} are meaningful on all terminals.
528 @table @code
529 @vindex display, a frame parameter
530 @item display
531 The display on which to open this frame.  It should be a string of the
532 form @code{"@var{host}:@var{dpy}.@var{screen}"}, just like the
533 @env{DISPLAY} environment variable.
535 @vindex display-type, a frame parameter
536 @item display-type
537 This parameter describes the range of possible colors that can be used
538 in this frame.  Its value is @code{color}, @code{grayscale} or
539 @code{mono}.
541 @vindex title, a frame parameter
542 @item title
543 If a frame has a non-@code{nil} title, it appears in the window
544 system's title bar at the top of the frame, and also in the mode line
545 of windows in that frame if @code{mode-line-frame-identification} uses
546 @samp{%F} (@pxref{%-Constructs}).  This is normally the case when
547 Emacs is not using a window system, and can only display one frame at
548 a time.  @xref{Frame Titles}.
550 @vindex name, a frame parameter
551 @item name
552 The name of the frame.  The frame name serves as a default for the frame
553 title, if the @code{title} parameter is unspecified or @code{nil}.  If
554 you don't specify a name, Emacs sets the frame name automatically
555 (@pxref{Frame Titles}).
557 If you specify the frame name explicitly when you create the frame, the
558 name is also used (instead of the name of the Emacs executable) when
559 looking up X resources for the frame.
561 @item explicit-name
562 If the frame name was specified explicitly when the frame was created,
563 this parameter will be that name.  If the frame wasn't explicitly
564 named, this parameter will be @code{nil}.
565 @end table
567 @node Position Parameters
568 @subsubsection Position Parameters
569 @cindex window position on display
571   Position parameters' values are normally measured in pixels, but on
572 text terminals they count characters or lines instead.
574 @table @code
575 @vindex left, a frame parameter
576 @item left
577 The position, in pixels, of the left (or right) edge of the frame with
578 respect to the left (or right) edge of the screen.  The value may be:
580 @table @asis
581 @item an integer
582 A positive integer relates the left edge of the frame to the left edge
583 of the screen.  A negative integer relates the right frame edge to the
584 right screen edge.
586 @item @code{(+ @var{pos})}
587 This specifies the position of the left frame edge relative to the left
588 screen edge.  The integer @var{pos} may be positive or negative; a
589 negative value specifies a position outside the screen.
591 @item @code{(- @var{pos})}
592 This specifies the position of the right frame edge relative to the right
593 screen edge.  The integer @var{pos} may be positive or negative; a
594 negative value specifies a position outside the screen.
595 @end table
597 Some window managers ignore program-specified positions.  If you want to
598 be sure the position you specify is not ignored, specify a
599 non-@code{nil} value for the @code{user-position} parameter as well.
601 @vindex top, a frame parameter
602 @item top
603 The screen position of the top (or bottom) edge, in pixels, with respect
604 to the top (or bottom) edge of the screen.  It works just like
605 @code{left}, except vertically instead of horizontally.
607 @vindex icon-left, a frame parameter
608 @item icon-left
609 The screen position of the left edge of the frame's icon, in pixels,
610 counting from the left edge of the screen.  This takes effect when the
611 frame is iconified, if the window manager supports this feature.  If
612 you specify a value for this parameter, then you must also specify a
613 value for @code{icon-top} and vice versa.
615 @vindex icon-top, a frame parameter
616 @item icon-top
617 The screen position of the top edge of the frame's icon, in pixels,
618 counting from the top edge of the screen.  This takes effect when the
619 frame is iconified, if the window manager supports this feature.
621 @vindex user-position, a frame parameter
622 @item user-position
623 When you create a frame and specify its screen position with the
624 @code{left} and @code{top} parameters, use this parameter to say whether
625 the specified position was user-specified (explicitly requested in some
626 way by a human user) or merely program-specified (chosen by a program).
627 A non-@code{nil} value says the position was user-specified.
629 @cindex window positions and window managers
630 Window managers generally heed user-specified positions, and some heed
631 program-specified positions too.  But many ignore program-specified
632 positions, placing the window in a default fashion or letting the user
633 place it with the mouse.  Some window managers, including @code{twm},
634 let the user specify whether to obey program-specified positions or
635 ignore them.
637 When you call @code{make-frame}, you should specify a non-@code{nil}
638 value for this parameter if the values of the @code{left} and @code{top}
639 parameters represent the user's stated preference; otherwise, use
640 @code{nil}.
641 @end table
643 @node Size Parameters
644 @subsubsection Size Parameters
645 @cindex window size on display
647   Frame parameters specify frame sizes in character units.  On
648 graphical displays, the @code{default} face determines the actual
649 pixel sizes of these character units (@pxref{Face Attributes}).
651 @table @code
652 @vindex height, a frame parameter
653 @item height
654 The height of the frame contents, in characters.  (To get the height in
655 pixels, call @code{frame-pixel-height}; see @ref{Size and Position}.)
657 @vindex width, a frame parameter
658 @item width
659 The width of the frame contents, in characters.  (To get the width in
660 pixels, call @code{frame-pixel-width}; see @ref{Size and Position}.)
662 @vindex user-size, a frame parameter
663 @item user-size
664 This does for the size parameters @code{height} and @code{width} what
665 the @code{user-position} parameter (@pxref{Position Parameters,
666 user-position}) does for the position parameters @code{top} and
667 @code{left}.
669 @cindex full-screen frames
670 @vindex fullscreen, a frame parameter
671 @item fullscreen
672 Specify that width, height or both shall be maximized.  The value
673 @code{fullwidth} specifies that width shall be as wide as possible.
674 The value @code{fullheight} specifies that height shall be as tall as
675 possible.  The value @code{fullboth} specifies that both the width and
676 the height shall be set to the size of the screen.  The value
677 @code{maximized} specifies that the frame shall be maximized.  The
678 difference between @code{maximized} and @code{fullboth} is that the
679 former can still be resized by dragging window manager decorations
680 with the mouse, while the latter really covers the whole screen and
681 does not allow resizing by mouse dragging.
683 With some window managers you may have to customize the variable
684 @code{frame-resize-pixelwise} to a non-@code{nil} value in order to make
685 a frame appear ``maximized'' or ``fullscreen''.
687 @end table
689 @node Layout Parameters
690 @subsubsection Layout Parameters
691 @cindex layout parameters of frames
692 @cindex frame layout parameters
694   These frame parameters enable or disable various parts of the
695 frame, or control their sizes.
697 @table @code
698 @vindex border-width, a frame parameter
699 @item border-width
700 The width in pixels of the frame's border.
702 @vindex internal-border-width, a frame parameter
703 @item internal-border-width
704 The distance in pixels between text (or fringe) and the frame's border.
706 @vindex vertical-scroll-bars, a frame parameter
707 @item vertical-scroll-bars
708 Whether the frame has scroll bars for vertical scrolling, and which side
709 of the frame they should be on.  The possible values are @code{left},
710 @code{right}, and @code{nil} for no scroll bars.
712 @vindex horizontal-scroll-bars, a frame parameter
713 @item horizontal-scroll-bars
714 Whether the frame has scroll bars for horizontal scrolling (@code{t} and
715 @code{bottom} mean yes, @code{nil} means no).
717 @vindex scroll-bar-width, a frame parameter
718 @item scroll-bar-width
719 The width of vertical scroll bars, in pixels, or @code{nil} meaning to
720 use the default width.
722 @vindex scroll-bar-height, a frame parameter
723 @item scroll-bar-height
724 The height of horizontal scroll bars, in pixels, or @code{nil} meaning
725 to use the default height.
727 @vindex left-fringe, a frame parameter
728 @vindex right-fringe, a frame parameter
729 @item left-fringe
730 @itemx right-fringe
731 The default width of the left and right fringes of windows in this
732 frame (@pxref{Fringes}).  If either of these is zero, that effectively
733 removes the corresponding fringe.
735 When you use @code{frame-parameter} to query the value of either of
736 these two frame parameters, the return value is always an integer.
737 When using @code{set-frame-parameter}, passing a @code{nil} value
738 imposes an actual default value of 8 pixels.
740 @vindex right-divider-width, a frame parameter
741 @item right-divider-width
742 The width (thickness) reserved for the right divider (@pxref{Window
743 Dividers}) of any window on the frame, in pixels.  A value of zero means
744 to not draw right dividers.
746 @vindex bottom-divider-width, a frame parameter
747 @item bottom-divider-width
748 The width (thickness) reserved for the bottom divider (@pxref{Window
749 Dividers}) of any window on the frame, in pixels.  A value of zero means
750 to not draw bottom dividers.
752 @vindex menu-bar-lines frame parameter
753 @item menu-bar-lines
754 The number of lines to allocate at the top of the frame for a menu
755 bar.  The default is 1 if Menu Bar mode is enabled, and 0 otherwise.
756 @xref{Menu Bars,,,emacs, The GNU Emacs Manual}.
758 @vindex tool-bar-lines frame parameter
759 @item tool-bar-lines
760 The number of lines to use for the tool bar.  The default is 1 if Tool
761 Bar mode is enabled, and 0 otherwise.  @xref{Tool Bars,,,emacs, The
762 GNU Emacs Manual}.
764 @vindex tool-bar-position frame parameter
765 @item tool-bar-position
766 The position of the tool bar.  Currently only for the GTK tool bar.
767 Value can be one of @code{top}, @code{bottom} @code{left}, @code{right}.
768 The default is  @code{top}.
770 @vindex line-spacing, a frame parameter
771 @item line-spacing
772 Additional space to leave below each text line, in pixels (a positive
773 integer).  @xref{Line Height}, for more information.
774 @end table
776 @node Buffer Parameters
777 @subsubsection Buffer Parameters
779   These frame parameters, meaningful on all kinds of terminals, deal
780 with which buffers have been, or should, be displayed in the frame.
782 @table @code
783 @vindex minibuffer, a frame parameter
784 @item minibuffer
785 Whether this frame has its own minibuffer.  The value @code{t} means
786 yes, @code{nil} means no, @code{only} means this frame is just a
787 minibuffer.  If the value is a minibuffer window (in some other
788 frame), the frame uses that minibuffer.
790 This frame parameter takes effect when the frame is created, and can
791 not be changed afterwards.
793 @vindex buffer-predicate, a frame parameter
794 @item buffer-predicate
795 The buffer-predicate function for this frame.  The function
796 @code{other-buffer} uses this predicate (from the selected frame) to
797 decide which buffers it should consider, if the predicate is not
798 @code{nil}.  It calls the predicate with one argument, a buffer, once for
799 each buffer; if the predicate returns a non-@code{nil} value, it
800 considers that buffer.
802 @vindex buffer-list, a frame parameter
803 @item buffer-list
804 A list of buffers that have been selected in this frame, ordered
805 most-recently-selected first.
807 @vindex unsplittable, a frame parameter
808 @item unsplittable
809 If non-@code{nil}, this frame's window is never split automatically.
810 @end table
812 @node Management Parameters
813 @subsubsection Window Management Parameters
814 @cindex window manager interaction, and frame parameters
816   The following frame parameters control various aspects of the
817 frame's interaction with the window manager.  They have no effect on
818 text terminals.
820 @table @code
821 @vindex visibility, a frame parameter
822 @item visibility
823 The state of visibility of the frame.  There are three possibilities:
824 @code{nil} for invisible, @code{t} for visible, and @code{icon} for
825 iconified.  @xref{Visibility of Frames}.
827 @vindex auto-raise, a frame parameter
828 @item auto-raise
829 If non-@code{nil}, Emacs automatically raises the frame when it is
830 selected.  Some window managers do not allow this.
832 @vindex auto-lower, a frame parameter
833 @item auto-lower
834 If non-@code{nil}, Emacs automatically lowers the frame when it is
835 deselected.  Some window managers do not allow this.
837 @vindex icon-type, a frame parameter
838 @item icon-type
839 The type of icon to use for this frame.  If the value is a string,
840 that specifies a file containing a bitmap to use; @code{nil} specifies
841 no icon (in which case the window manager decides what to show); any
842 other non-@code{nil} value specifies the default Emacs icon.
844 @vindex icon-name, a frame parameter
845 @item icon-name
846 The name to use in the icon for this frame, when and if the icon
847 appears.  If this is @code{nil}, the frame's title is used.
849 @vindex window-id, a frame parameter
850 @item window-id
851 The ID number which the graphical display uses for this frame.  Emacs
852 assigns this parameter when the frame is created; changing the
853 parameter has no effect on the actual ID number.
855 @vindex outer-window-id, a frame parameter
856 @item outer-window-id
857 The ID number of the outermost window-system window in which the frame
858 exists.  As with @code{window-id}, changing this parameter has no
859 actual effect.
861 @vindex wait-for-wm, a frame parameter
862 @item wait-for-wm
863 If non-@code{nil}, tell Xt to wait for the window manager to confirm
864 geometry changes.  Some window managers, including versions of Fvwm2
865 and KDE, fail to confirm, so Xt hangs.  Set this to @code{nil} to
866 prevent hanging with those window managers.
868 @vindex sticky, a frame parameter
869 @item sticky
870 If non-@code{nil}, the frame is visible on all virtual desktops on systems
871 with virtual desktops.
873 @ignore
874 @vindex parent-id, a frame parameter
875 @item parent-id
876 @c ??? Not yet working.
877 The X window number of the window that should be the parent of this one.
878 Specifying this lets you create an Emacs window inside some other
879 application's window.  (It is not certain this will be implemented; try
880 it and see if it works.)
881 @end ignore
882 @end table
884 @node Cursor Parameters
885 @subsubsection Cursor Parameters
886 @cindex cursor, and frame parameters
888   This frame parameter controls the way the cursor looks.
890 @table @code
891 @vindex cursor-type, a frame parameter
892 @item cursor-type
893 How to display the cursor.  Legitimate values are:
895 @table @code
896 @item box
897 Display a filled box.  (This is the default.)
898 @item hollow
899 Display a hollow box.
900 @item nil
901 Don't display a cursor.
902 @item bar
903 Display a vertical bar between characters.
904 @item (bar . @var{width})
905 Display a vertical bar @var{width} pixels wide between characters.
906 @item hbar
907 Display a horizontal bar.
908 @item (hbar . @var{height})
909 Display a horizontal bar @var{height} pixels high.
910 @end table
911 @end table
913 @vindex cursor-type
914 The @code{cursor-type} frame parameter may be overridden by the
915 variables @code{cursor-type} and
916 @code{cursor-in-non-selected-windows}:
918 @defvar cursor-type
919 This buffer-local variable controls how the cursor looks in a selected
920 window showing the buffer.  If its value is @code{t}, that means to
921 use the cursor specified by the @code{cursor-type} frame parameter.
922 Otherwise, the value should be one of the cursor types listed above,
923 and it overrides the @code{cursor-type} frame parameter.
924 @end defvar
926 @defopt cursor-in-non-selected-windows
927 This buffer-local variable controls how the cursor looks in a window
928 that is not selected.  It supports the same values as the
929 @code{cursor-type} frame parameter; also, @code{nil} means don't
930 display a cursor in nonselected windows, and @code{t} (the default)
931 means use a standard modification of the usual cursor type (solid box
932 becomes hollow box, and bar becomes a narrower bar).
933 @end defopt
935 @defopt blink-cursor-alist
936 This variable specifies how to blink the cursor.  Each element has the
937 form @code{(@var{on-state} . @var{off-state})}.  Whenever the cursor
938 type equals @var{on-state} (comparing using @code{equal}), the
939 corresponding @var{off-state} specifies what the cursor looks like
940 when it blinks ``off''.  Both @var{on-state} and @var{off-state}
941 should be suitable values for the @code{cursor-type} frame parameter.
943 There are various defaults for how to blink each type of cursor, if
944 the type is not mentioned as an @var{on-state} here.  Changes in this
945 variable do not take effect immediately, only when you specify the
946 @code{cursor-type} frame parameter.
947 @end defopt
949 @node Font and Color Parameters
950 @subsubsection Font and Color Parameters
951 @cindex font and color, frame parameters
953   These frame parameters control the use of fonts and colors.
955 @table @code
956 @vindex font-backend, a frame parameter
957 @item font-backend
958 A list of symbols, specifying the @dfn{font backends} to use for
959 drawing fonts in the frame, in order of priority.  On X, there are
960 currently two available font backends: @code{x} (the X core font
961 driver) and @code{xft} (the Xft font driver).  On MS-Windows, there are
962 currently two available font backends: @code{gdi} and
963 @code{uniscribe} (@pxref{Windows Fonts,,, emacs, The GNU Emacs
964 Manual}).  On other systems, there is only one available font backend,
965 so it does not make sense to modify this frame parameter.
967 @vindex background-mode, a frame parameter
968 @item background-mode
969 This parameter is either @code{dark} or @code{light}, according
970 to whether the background color is a light one or a dark one.
972 @vindex tty-color-mode, a frame parameter
973 @item tty-color-mode
974 @cindex standard colors for character terminals
975 This parameter overrides the terminal's color support as given by the
976 system's terminal capabilities database in that this parameter's value
977 specifies the color mode to use on a text terminal.  The value can be
978 either a symbol or a number.  A number specifies the number of colors
979 to use (and, indirectly, what commands to issue to produce each
980 color).  For example, @code{(tty-color-mode . 8)} specifies use of the
981 ANSI escape sequences for 8 standard text colors.  A value of -1 turns
982 off color support.
984 If the parameter's value is a symbol, it specifies a number through
985 the value of @code{tty-color-mode-alist}, and the associated number is
986 used instead.
988 @vindex screen-gamma, a frame parameter
989 @item screen-gamma
990 @cindex gamma correction
991 If this is a number, Emacs performs ``gamma correction'' which adjusts
992 the brightness of all colors.  The value should be the screen gamma of
993 your display.
995 Usual PC monitors have a screen gamma of 2.2, so color values in
996 Emacs, and in X windows generally, are calibrated to display properly
997 on a monitor with that gamma value.  If you specify 2.2 for
998 @code{screen-gamma}, that means no correction is needed.  Other values
999 request correction, designed to make the corrected colors appear on
1000 your screen the way they would have appeared without correction on an
1001 ordinary monitor with a gamma value of 2.2.
1003 If your monitor displays colors too light, you should specify a
1004 @code{screen-gamma} value smaller than 2.2.  This requests correction
1005 that makes colors darker.  A screen gamma value of 1.5 may give good
1006 results for LCD color displays.
1008 @vindex alpha, a frame parameter
1009 @item alpha
1010 @cindex opacity, frame
1011 @cindex transparency, frame
1012 @vindex frame-alpha-lower-limit
1013 This parameter specifies the opacity of the frame, on graphical
1014 displays that support variable opacity.  It should be an integer
1015 between 0 and 100, where 0 means completely transparent and 100 means
1016 completely opaque.  It can also have a @code{nil} value, which tells
1017 Emacs not to set the frame opacity (leaving it to the window manager).
1019 To prevent the frame from disappearing completely from view, the
1020 variable @code{frame-alpha-lower-limit} defines a lower opacity limit.
1021 If the value of the frame parameter is less than the value of this
1022 variable, Emacs uses the latter.  By default,
1023 @code{frame-alpha-lower-limit} is 20.
1025 The @code{alpha} frame parameter can also be a cons cell
1026 @code{(@samp{active} . @samp{inactive})}, where @samp{active} is the
1027 opacity of the frame when it is selected, and @samp{inactive} is the
1028 opacity when it is not selected.
1029 @end table
1031 The following frame parameters are semi-obsolete in that they are
1032 automatically equivalent to particular face attributes of particular
1033 faces (@pxref{Standard Faces,,, emacs, The Emacs Manual}):
1035 @table @code
1036 @vindex font, a frame parameter
1037 @item font
1038 The name of the font for displaying text in the frame.  This is a
1039 string, either a valid font name for your system or the name of an Emacs
1040 fontset (@pxref{Fontsets}).  It is equivalent to the @code{font}
1041 attribute of the @code{default} face.
1043 @vindex foreground-color, a frame parameter
1044 @item foreground-color
1045 The color to use for the image of a character.  It is equivalent to
1046 the @code{:foreground} attribute of the @code{default} face.
1048 @vindex background-color, a frame parameter
1049 @item background-color
1050 The color to use for the background of characters.  It is equivalent to
1051 the @code{:background} attribute of the @code{default} face.
1053 @vindex mouse-color, a frame parameter
1054 @item mouse-color
1055 The color for the mouse pointer.  It is equivalent to the @code{:background}
1056 attribute of the @code{mouse} face.
1058 @vindex cursor-color, a frame parameter
1059 @item cursor-color
1060 The color for the cursor that shows point.  It is equivalent to the
1061 @code{:background} attribute of the @code{cursor} face.
1063 @vindex border-color, a frame parameter
1064 @item border-color
1065 The color for the border of the frame.  It is equivalent to the
1066 @code{:background} attribute of the @code{border} face.
1068 @vindex scroll-bar-foreground, a frame parameter
1069 @item scroll-bar-foreground
1070 If non-@code{nil}, the color for the foreground of scroll bars.  It is
1071 equivalent to the @code{:foreground} attribute of the
1072 @code{scroll-bar} face.
1074 @vindex scroll-bar-background, a frame parameter
1075 @item scroll-bar-background
1076 If non-@code{nil}, the color for the background of scroll bars.  It is
1077 equivalent to the @code{:background} attribute of the
1078 @code{scroll-bar} face.
1079 @end table
1081 @node Size and Position
1082 @subsection Frame Size And Position
1083 @cindex size of frame
1084 @cindex screen size
1085 @cindex frame size
1086 @cindex resize frame
1088   You can read or change the size and position of a frame using the
1089 frame parameters @code{left}, @code{top}, @code{height}, and
1090 @code{width}.  Whatever geometry parameters you don't specify are chosen
1091 by the window manager in its usual fashion.
1093   Here are some special features for working with sizes and positions.
1094 (For the precise meaning of ``selected frame'' used by these functions,
1095 see @ref{Input Focus}.)
1097 @defun set-frame-position frame left top
1098 This function sets the position of the top left corner of @var{frame} to
1099 @var{left} and @var{top}.  These arguments are measured in pixels, and
1100 normally count from the top left corner of the screen.
1102 Negative parameter values position the bottom edge of the window up from
1103 the bottom edge of the screen, or the right window edge to the left of
1104 the right edge of the screen.  It would probably be better if the values
1105 were always counted from the left and top, so that negative arguments
1106 would position the frame partly off the top or left edge of the screen,
1107 but it seems inadvisable to change that now.
1108 @end defun
1110 @defun frame-height &optional frame
1111 @defunx frame-width &optional frame
1112 These functions return the height and width of @var{frame}, measured in
1113 lines and columns.  If you don't supply @var{frame}, they use the
1114 selected frame.
1115 @end defun
1117 @defun frame-pixel-height &optional frame
1118 @defunx frame-pixel-width &optional frame
1119 These functions return the height and width of the main display area
1120 of @var{frame}, measured in pixels.  If you don't supply @var{frame},
1121 they use the selected frame.  For a text terminal, the results are in
1122 characters rather than pixels.
1124 These values include the internal borders, and windows' scroll bars
1125 and fringes (which belong to individual windows, not to the frame
1126 itself).  The exact value of the heights depends on the window-system
1127 and toolkit in use.  With GTK+, the height does not include any tool
1128 bar or menu bar.  With the Motif or Lucid toolkits, it includes the
1129 tool bar but not the menu bar.  In a graphical version with no
1130 toolkit, it includes both the tool bar and menu bar.  For a text
1131 terminal, the result includes the menu bar.
1132 @end defun
1134 @defun frame-char-height &optional frame
1135 @defunx frame-char-width &optional frame
1136 These functions return the height and width of a character in
1137 @var{frame}, measured in pixels.  The values depend on the choice of
1138 font.  If you don't supply @var{frame}, these functions use the selected
1139 frame.
1140 @end defun
1142 @defopt frame-resize-pixelwise
1143 If this option is @code{nil}, a frame's size is usually rounded to a
1144 multiple of the current values of that frame's @code{frame-char-height}
1145 and @code{frame-char-width}.  If this is non-@code{nil}, no rounding
1146 occurs, hence frame sizes can increase/decrease by one pixel.
1148 Setting this causes the next resize operation to pass the corresponding
1149 size hints to the window manager.  This means that this variable should
1150 be set only in a user's initial file; applications should never bind it
1151 temporarily.
1153 The precise meaning of a value of @code{nil} for this option depends
1154 on the toolkit used.  Dragging the frame border with the mouse is usually
1155 done character-wise.  Calling @code{set-frame-size} (see below)
1156 with arguments that do not specify the frame size as an integer multiple
1157 of its character size, however, may: be ignored, cause a
1158 rounding (GTK+), or be accepted (Lucid, Motif, MS-Windows).
1160 With some window managers you may have to set this to non-@code{nil} in
1161 order to make a frame appear truly ``maximized'' or ``fullscreen''.
1162 @end defopt
1164 @defun set-frame-size frame width height pixelwise
1165 This function sets the size of @var{frame}, measured in characters;
1166 @var{width} and @var{height} specify the new width in columns and the
1167 new height in lines.
1169 The optional argument @var{pixelwise} non-@code{nil} means to measure
1170 the new width and height in units of pixels instead.  Note that if
1171 @code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
1172 fully honor the request if it does not increase/decrease the frame size
1173 to a multiple of its character size.
1174 @end defun
1176 @defun set-frame-height frame height &optional pretend pixelwise
1177 This function resizes @var{frame} to a height of @var{height} lines.  The
1178 sizes of existing windows in @var{frame} are altered proportionally to
1179 fit.
1181 If @var{pretend} is non-@code{nil}, then Emacs displays @var{height}
1182 lines of output in @var{frame}, but does not change its value for the
1183 actual height of the frame.  This is only useful on text terminals.
1184 Using a smaller height than the terminal actually implements may be
1185 useful to reproduce behavior observed on a smaller screen, or if the
1186 terminal malfunctions when using its whole screen.  Setting the frame
1187 height ``for real'' does not always work, because knowing the correct
1188 actual size may be necessary for correct cursor positioning on
1189 text terminals.
1191 The optional fourth argument @var{pixelwise} non-@code{nil} means that
1192 @var{frame} should be @var{height} pixels high.  Note that if
1193 @code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
1194 fully honor the request if it does not increase/decrease the frame
1195 height to a multiple of its character height.
1196 @end defun
1198 @defun set-frame-width frame width &optional pretend pixelwise
1199 This function sets the width of @var{frame}, measured in characters.
1200 The argument @var{pretend} has the same meaning as in
1201 @code{set-frame-height}.
1203 The optional fourth argument @var{pixelwise} non-@code{nil} means that
1204 @var{frame} should be @var{width} pixels wide.  Note that if
1205 @code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
1206 fully honor the request if it does not increase/decrease the frame width
1207 to a multiple of its character width.
1208 @end defun
1210 @c FIXME?  Belongs more in Emacs manual than here?
1211 @c But, e.g., fit-window-to-buffer is in this manual.
1212 If you have a frame that displays only one window, you can fit that
1213 frame to its buffer using the command @code{fit-frame-to-buffer}.
1215 @deffn Command fit-frame-to-buffer &optional frame max-height min-height max-width min-width only
1216 This command adjusts the size of @var{frame} to display the contents of
1217 its buffer exactly.  @var{frame} can be any live frame and defaults to
1218 the selected one.  Fitting is done only if @var{frame}'s root window is
1219 live.  The arguments @var{max-height}, @var{min-height}, @var{max-width}
1220 and @var{min-width} specify bounds on the new total size of
1221 @var{frame}'s root window.  @var{min-height} and @var{min-width} default
1222 to the values of @code{window-min-height} and @code{window-min-width}
1223 respectively.
1225 If the optional argument @var{only} is @code{vertically}, this function
1226 may resize the frame vertically only.  If @var{only} is
1227 @code{horizontally}, it may resize the frame horizontally only.
1228 @end deffn
1230 The behavior of @code{fit-frame-to-buffer} can be controlled with the
1231 help of the two options listed next.
1233 @defopt fit-frame-to-buffer-margins
1234 This option can be used to specify margins around frames to be fit by
1235 @code{fit-frame-to-buffer}.  Such margins can be useful to avoid, for
1236 example, that such frames overlap the taskbar.
1238 It specifies the numbers of pixels to be left free on the left, above,
1239 the right, and below a frame that shall be fit.  The default specifies
1240 @code{nil} for each which means to use no margins.  The value specified
1241 here can be overridden for a specific frame by that frame's
1242 @code{fit-frame-to-buffer-margins} parameter, if present.
1243 @end defopt
1245 @defopt fit-frame-to-buffer-sizes
1246 This option specifies size boundaries for @code{fit-frame-to-buffer}.
1247 It specifies the total maximum and minimum lines and maximum and minimum
1248 columns of the root window of any frame that shall be fit to its buffer.
1249 If any of these values is non-@code{nil}, it overrides the corresponding
1250 argument of @code{fit-frame-to-buffer}.
1251 @end defopt
1254 @node Geometry
1255 @subsection Geometry
1257   Here's how to examine the data in an X-style window geometry
1258 specification:
1260 @defun x-parse-geometry geom
1261 @cindex geometry specification
1262 The function @code{x-parse-geometry} converts a standard X window
1263 geometry string to an alist that you can use as part of the argument to
1264 @code{make-frame}.
1266 The alist describes which parameters were specified in @var{geom}, and
1267 gives the values specified for them.  Each element looks like
1268 @code{(@var{parameter} . @var{value})}.  The possible @var{parameter}
1269 values are @code{left}, @code{top}, @code{width}, and @code{height}.
1271 For the size parameters, the value must be an integer.  The position
1272 parameter names @code{left} and @code{top} are not totally accurate,
1273 because some values indicate the position of the right or bottom edges
1274 instead.  The @var{value} possibilities for the position parameters are:
1275 an integer, a list @code{(+ @var{pos})}, or a list @code{(- @var{pos})};
1276 as previously described (@pxref{Position Parameters}).
1278 Here is an example:
1280 @example
1281 (x-parse-geometry "35x70+0-0")
1282      @result{} ((height . 70) (width . 35)
1283          (top - 0) (left . 0))
1284 @end example
1285 @end defun
1287 @node Terminal Parameters
1288 @section Terminal Parameters
1289 @cindex terminal parameters
1291   Each terminal has a list of associated parameters.  These
1292 @dfn{terminal parameters} are mostly a convenient way of storage for
1293 terminal-local variables, but some terminal parameters have a special
1294 meaning.
1296   This section describes functions to read and change the parameter values
1297 of a terminal.  They all accept as their argument either a terminal or
1298 a frame; the latter means use that frame's terminal.  An argument of
1299 @code{nil} means the selected frame's terminal.
1301 @defun terminal-parameters &optional terminal
1302 This function returns an alist listing all the parameters of
1303 @var{terminal} and their values.
1304 @end defun
1306 @defun terminal-parameter terminal parameter
1307 This function returns the value of the parameter @var{parameter} (a
1308 symbol) of @var{terminal}.  If @var{terminal} has no setting for
1309 @var{parameter}, this function returns @code{nil}.
1310 @end defun
1312 @defun set-terminal-parameter terminal parameter value
1313 This function sets the parameter @var{parm} of @var{terminal} to the
1314 specified @var{value}, and returns the previous value of that
1315 parameter.
1316 @end defun
1318 Here's a list of a few terminal parameters that have a special
1319 meaning:
1321 @table @code
1322 @item background-mode
1323 The classification of the terminal's background color, either
1324 @code{light} or @code{dark}.
1325 @item normal-erase-is-backspace
1326 Value is either 1 or 0, depending on whether
1327 @code{normal-erase-is-backspace-mode} is turned on or off on this
1328 terminal.  @xref{DEL Does Not Delete,,, emacs, The Emacs Manual}.
1329 @item terminal-initted
1330 After the terminal is initialized, this is set to the
1331 terminal-specific initialization function.
1332 @item tty-mode-set-strings
1333 When present, a list of strings containing escape sequences that Emacs
1334 will output while configuring a tty for rendering.  Emacs emits these
1335 strings only when configuring a terminal: if you want to enable a mode
1336 on a terminal that is already active (for example, while in
1337 @code{tty-setup-hook}), explicitly output the necessary escape
1338 sequence using @code{send-string-to-terminal} in addition to adding
1339 the sequence to @code{tty-mode-set-strings}.
1340 @item tty-mode-reset-strings
1341 When present, a list of strings that undo the effects of the strings
1342 in @code{tty-mode-set-strings}.  Emacs emits these strings when
1343 exiting, deleting a terminal, or suspending itself.
1344 @end table
1346 @node Frame Titles
1347 @section Frame Titles
1348 @cindex frame title
1350   Every frame has a @code{name} parameter; this serves as the default
1351 for the frame title which window systems typically display at the top of
1352 the frame.  You can specify a name explicitly by setting the @code{name}
1353 frame property.
1355   Normally you don't specify the name explicitly, and Emacs computes the
1356 frame name automatically based on a template stored in the variable
1357 @code{frame-title-format}.  Emacs recomputes the name each time the
1358 frame is redisplayed.
1360 @defvar frame-title-format
1361 This variable specifies how to compute a name for a frame when you have
1362 not explicitly specified one.  The variable's value is actually a mode
1363 line construct, just like @code{mode-line-format}, except that the
1364 @samp{%c} and @samp{%l} constructs are ignored.  @xref{Mode Line
1365 Data}.
1366 @end defvar
1368 @defvar icon-title-format
1369 This variable specifies how to compute the name for an iconified frame,
1370 when you have not explicitly specified the frame title.  This title
1371 appears in the icon itself.
1372 @end defvar
1374 @defvar multiple-frames
1375 This variable is set automatically by Emacs.  Its value is @code{t} when
1376 there are two or more frames (not counting minibuffer-only frames or
1377 invisible frames).  The default value of @code{frame-title-format} uses
1378 @code{multiple-frames} so as to put the buffer name in the frame title
1379 only when there is more than one frame.
1381 The value of this variable is not guaranteed to be accurate except
1382 while processing @code{frame-title-format} or
1383 @code{icon-title-format}.
1384 @end defvar
1386 @node Deleting Frames
1387 @section Deleting Frames
1388 @cindex deleting frames
1390   A @dfn{live frame} is one that has not been deleted.  When a frame
1391 is deleted, it is removed from its terminal display, although it may
1392 continue to exist as a Lisp object until there are no more references
1393 to it.
1395 @deffn Command delete-frame &optional frame force
1396 @vindex delete-frame-functions
1397 This function deletes the frame @var{frame}.  Unless @var{frame} is a
1398 tooltip, it first runs the hook @code{delete-frame-functions} (each
1399 function gets one argument, @var{frame}).  By default, @var{frame} is
1400 the selected frame.
1402 A frame cannot be deleted if its minibuffer is used by other frames.
1403 Normally, you cannot delete a frame if all other frames are invisible,
1404 but if @var{force} is non-@code{nil}, then you are allowed to do so.
1405 @end deffn
1407 @defun frame-live-p frame
1408 The function @code{frame-live-p} returns non-@code{nil} if the frame
1409 @var{frame} has not been deleted.  The possible non-@code{nil} return
1410 values are like those of @code{framep}.  @xref{Frames}.
1411 @end defun
1413   Some window managers provide a command to delete a window.  These work
1414 by sending a special message to the program that operates the window.
1415 When Emacs gets one of these commands, it generates a
1416 @code{delete-frame} event, whose normal definition is a command that
1417 calls the function @code{delete-frame}.  @xref{Misc Events}.
1419 @node Finding All Frames
1420 @section Finding All Frames
1421 @cindex frames, scanning all
1423 @defun frame-list
1424 This function returns a list of all the live frames, i.e., those that
1425 have not been deleted.  It is analogous to @code{buffer-list} for
1426 buffers, and includes frames on all terminals.  The list that you get
1427 is newly created, so modifying the list doesn't have any effect on the
1428 internals of Emacs.
1429 @end defun
1431 @defun visible-frame-list
1432 This function returns a list of just the currently visible frames.
1433 @xref{Visibility of Frames}.  Frames on text terminals always count as
1434 ``visible'', even though only the selected one is actually displayed.
1435 @end defun
1437 @defun next-frame &optional frame minibuf
1438 This function lets you cycle conveniently through all the frames on
1439 the current display from an arbitrary starting point.  It returns the
1440 ``next'' frame after @var{frame} in the cycle.  If @var{frame} is
1441 omitted or @code{nil}, it defaults to the selected frame (@pxref{Input
1442 Focus}).
1444 The second argument, @var{minibuf}, says which frames to consider:
1446 @table @asis
1447 @item @code{nil}
1448 Exclude minibuffer-only frames.
1449 @item @code{visible}
1450 Consider all visible frames.
1451 @item 0
1452 Consider all visible or iconified frames.
1453 @item a window
1454 Consider only the frames using that particular window as their
1455 minibuffer.
1456 @item anything else
1457 Consider all frames.
1458 @end table
1459 @end defun
1461 @defun previous-frame &optional frame minibuf
1462 Like @code{next-frame}, but cycles through all frames in the opposite
1463 direction.
1464 @end defun
1466   See also @code{next-window} and @code{previous-window}, in @ref{Cyclic
1467 Window Ordering}.
1469 @node Minibuffers and Frames
1470 @section Minibuffers and Frames
1472 Normally, each frame has its own minibuffer window at the bottom, which
1473 is used whenever that frame is selected.  If the frame has a minibuffer,
1474 you can get it with @code{minibuffer-window} (@pxref{Definition of
1475 minibuffer-window}).
1477 However, you can also create a frame with no minibuffer.  Such a frame
1478 must use the minibuffer window of some other frame.  When you create the
1479 frame, you can explicitly specify the minibuffer window to use (in some
1480 other frame).  If you don't, then the minibuffer is found in the frame
1481 which is the value of the variable @code{default-minibuffer-frame}.  Its
1482 value should be a frame that does have a minibuffer.
1484 If you use a minibuffer-only frame, you might want that frame to raise
1485 when you enter the minibuffer.  If so, set the variable
1486 @code{minibuffer-auto-raise} to @code{t}.  @xref{Raising and Lowering}.
1488 @defvar default-minibuffer-frame
1489 This variable specifies the frame to use for the minibuffer window, by
1490 default.  It does not affect existing frames.  It is always local to
1491 the current terminal and cannot be buffer-local.  @xref{Multiple
1492 Terminals}.
1493 @end defvar
1495 @node Input Focus
1496 @section Input Focus
1497 @cindex input focus
1498 @c @cindex selected frame    Duplicates selected-frame, same for selected-window.
1500 At any time, one frame in Emacs is the @dfn{selected frame}.  The selected
1501 window always resides on the selected frame.
1503 When Emacs displays its frames on several terminals (@pxref{Multiple
1504 Terminals}), each terminal has its own selected frame.  But only one
1505 of these is ``@emph{the} selected frame'': it's the frame that belongs
1506 to the terminal from which the most recent input came.  That is, when
1507 Emacs runs a command that came from a certain terminal, the selected
1508 frame is the one of that terminal.  Since Emacs runs only a single
1509 command at any given time, it needs to consider only one selected
1510 frame at a time; this frame is what we call @dfn{the selected frame}
1511 in this manual.  The display on which the selected frame is shown is
1512 the @dfn{selected frame's display}.
1514 @defun selected-frame
1515 This function returns the selected frame.
1516 @end defun
1518 Some window systems and window managers direct keyboard input to the
1519 window object that the mouse is in; others require explicit clicks or
1520 commands to @dfn{shift the focus} to various window objects.  Either
1521 way, Emacs automatically keeps track of which frame has the focus.  To
1522 explicitly switch to a different frame from a Lisp function, call
1523 @code{select-frame-set-input-focus}.
1525 Lisp programs can also switch frames ``temporarily'' by calling the
1526 function @code{select-frame}.  This does not alter the window system's
1527 concept of focus; rather, it escapes from the window manager's control
1528 until that control is somehow reasserted.
1530 When using a text terminal, only one frame can be displayed at a time
1531 on the terminal, so after a call to @code{select-frame}, the next
1532 redisplay actually displays the newly selected frame.  This frame
1533 remains selected until a subsequent call to @code{select-frame}.  Each
1534 frame on a text terminal has a number which appears in the mode line
1535 before the buffer name (@pxref{Mode Line Variables}).
1537 @defun select-frame-set-input-focus frame &optional norecord
1538 This function selects @var{frame}, raises it (should it happen to be
1539 obscured by other frames) and tries to give it the X server's focus.
1540 On a text terminal, the next redisplay displays the new frame on the
1541 entire terminal screen.  The optional argument @var{norecord} has the
1542 same meaning as for @code{select-frame} (see below).  The return value
1543 of this function is not significant.
1544 @end defun
1546 @deffn Command select-frame frame &optional norecord
1547 This function selects frame @var{frame}, temporarily disregarding the
1548 focus of the X server if any.  The selection of @var{frame} lasts until
1549 the next time the user does something to select a different frame, or
1550 until the next time this function is called.  (If you are using a
1551 window system, the previously selected frame may be restored as the
1552 selected frame after return to the command loop, because it still may
1553 have the window system's input focus.)
1555 The specified @var{frame} becomes the selected frame, and its terminal
1556 becomes the selected terminal.  This function then calls
1557 @code{select-window} as a subroutine, passing the window selected
1558 within @var{frame} as its first argument and @var{norecord} as its
1559 second argument (hence, if @var{norecord} is non-@code{nil}, this
1560 avoids changing the order of recently selected windows nor the buffer
1561 list).  @xref{Selecting Windows}.
1563 This function returns @var{frame}, or @code{nil} if @var{frame} has
1564 been deleted.
1566 In general, you should never use @code{select-frame} in a way that
1567 could switch to a different terminal without switching back when
1568 you're done.
1569 @end deffn
1571 Emacs cooperates with the window system by arranging to select frames as
1572 the server and window manager request.  It does so by generating a
1573 special kind of input event, called a @dfn{focus} event, when
1574 appropriate.  The command loop handles a focus event by calling
1575 @code{handle-switch-frame}.  @xref{Focus Events}.
1577 @deffn Command handle-switch-frame frame
1578 This function handles a focus event by selecting frame @var{frame}.
1580 Focus events normally do their job by invoking this command.
1581 Don't call it for any other reason.
1582 @end deffn
1584 @defun redirect-frame-focus frame &optional focus-frame
1585 This function redirects focus from @var{frame} to @var{focus-frame}.
1586 This means that @var{focus-frame} will receive subsequent keystrokes and
1587 events intended for @var{frame}.  After such an event, the value of
1588 @code{last-event-frame} will be @var{focus-frame}.  Also, switch-frame
1589 events specifying @var{frame} will instead select @var{focus-frame}.
1591 If @var{focus-frame} is omitted or @code{nil}, that cancels any existing
1592 redirection for @var{frame}, which therefore once again receives its own
1593 events.
1595 One use of focus redirection is for frames that don't have minibuffers.
1596 These frames use minibuffers on other frames.  Activating a minibuffer
1597 on another frame redirects focus to that frame.  This puts the focus on
1598 the minibuffer's frame, where it belongs, even though the mouse remains
1599 in the frame that activated the minibuffer.
1601 Selecting a frame can also change focus redirections.  Selecting frame
1602 @code{bar}, when @code{foo} had been selected, changes any redirections
1603 pointing to @code{foo} so that they point to @code{bar} instead.  This
1604 allows focus redirection to work properly when the user switches from
1605 one frame to another using @code{select-window}.
1607 This means that a frame whose focus is redirected to itself is treated
1608 differently from a frame whose focus is not redirected.
1609 @code{select-frame} affects the former but not the latter.
1611 The redirection lasts until @code{redirect-frame-focus} is called to
1612 change it.
1613 @end defun
1615 @defvar focus-in-hook
1616 This is a normal hook run when an Emacs frame gains input focus.
1617 @end defvar
1619 @defvar focus-out-hook
1620 This is a normal hook run when an Emacs frame loses input focus.
1621 @end defvar
1623 @defopt focus-follows-mouse
1624 This option is how you inform Emacs whether the window manager transfers
1625 focus when the user moves the mouse.  Non-@code{nil} says that it does.
1626 When this is so, the command @code{other-frame} moves the mouse to a
1627 position consistent with the new selected frame.
1628 @end defopt
1630 @node Visibility of Frames
1631 @section Visibility of Frames
1632 @cindex visible frame
1633 @cindex invisible frame
1634 @cindex iconified frame
1635 @cindex minimized frame
1636 @cindex frame visibility
1638 A frame on a graphical display may be @dfn{visible}, @dfn{invisible},
1639 or @dfn{iconified}.  If it is visible, its contents are displayed in
1640 the usual manner.  If it is iconified, its contents are not displayed,
1641 but there is a little icon somewhere to bring the frame back into view
1642 (some window managers refer to this state as @dfn{minimized} rather
1643 than @dfn{iconified}, but from Emacs' point of view they are the same
1644 thing).  If a frame is invisible, it is not displayed at all.
1646   Visibility is meaningless on text terminals, since only the selected
1647 one is actually displayed in any case.
1649 @defun frame-visible-p frame
1650 This function returns the visibility status of frame @var{frame}.  The
1651 value is @code{t} if @var{frame} is visible, @code{nil} if it is
1652 invisible, and @code{icon} if it is iconified.
1654 On a text terminal, all frames are considered ``visible'' for the
1655 purposes of this function, even though only one frame is displayed.
1656 @xref{Raising and Lowering}.
1657 @end defun
1659 @deffn Command iconify-frame &optional frame
1660 This function iconifies frame @var{frame}.  If you omit @var{frame}, it
1661 iconifies the selected frame.
1662 @end deffn
1664 @deffn Command make-frame-visible &optional frame
1665 This function makes frame @var{frame} visible.  If you omit
1666 @var{frame}, it makes the selected frame visible.  This does not raise
1667 the frame, but you can do that with @code{raise-frame} if you wish
1668 (@pxref{Raising and Lowering}).
1669 @end deffn
1671 @deffn Command make-frame-invisible &optional frame force
1672 This function makes frame @var{frame} invisible.  If you omit
1673 @var{frame}, it makes the selected frame invisible.
1675 Unless @var{force} is non-@code{nil}, this function refuses to make
1676 @var{frame} invisible if all other frames are invisible..
1677 @end deffn
1679   The visibility status of a frame is also available as a frame
1680 parameter.  You can read or change it as such.  @xref{Management
1681 Parameters}.  The user can also iconify and deiconify frames with the
1682 window manager.  This happens below the level at which Emacs can exert
1683 any control, but Emacs does provide events that you can use to keep
1684 track of such changes.  @xref{Misc Events}.
1686 @node Raising and Lowering
1687 @section Raising and Lowering Frames
1689 @cindex raising a frame
1690 @cindex lowering a frame
1691   Most window systems use a desktop metaphor.  Part of this metaphor
1692 is the idea that system-level windows (e.g., Emacs frames) are
1693 stacked in a notional third dimension perpendicular to the screen
1694 surface.  Where two overlap, the one higher up covers the one
1695 underneath.  You can @dfn{raise} or @dfn{lower} a frame using the
1696 functions @code{raise-frame} and @code{lower-frame}.
1698 @deffn Command raise-frame &optional frame
1699 This function raises frame @var{frame} (default, the selected frame).
1700 If @var{frame} is invisible or iconified, this makes it visible.
1701 @end deffn
1703 @deffn Command lower-frame &optional frame
1704 This function lowers frame @var{frame} (default, the selected frame).
1705 @end deffn
1707 @defopt minibuffer-auto-raise
1708 If this is non-@code{nil}, activation of the minibuffer raises the frame
1709 that the minibuffer window is in.
1710 @end defopt
1712   On window systems, you can also enable auto-raising (on frame
1713 selection) or auto-lowering (on frame deselection) using frame
1714 parameters.  @xref{Management Parameters}.
1716 @cindex top frame
1717   The concept of raising and lowering frames also applies to text
1718 terminal frames.  On each text terminal, only the top frame is
1719 displayed at any one time.
1721 @defun tty-top-frame terminal
1722 This function returns the top frame on @var{terminal}.  @var{terminal}
1723 should be a terminal object, a frame (meaning that frame's terminal),
1724 or @code{nil} (meaning the selected frame's terminal).  If it does not
1725 refer to a text terminal, the return value is @code{nil}.
1726 @end defun
1728 @node Frame Configurations
1729 @section Frame Configurations
1730 @cindex frame configuration
1732   A @dfn{frame configuration} records the current arrangement of frames,
1733 all their properties, and the window configuration of each one.
1734 (@xref{Window Configurations}.)
1736 @defun current-frame-configuration
1737 This function returns a frame configuration list that describes
1738 the current arrangement of frames and their contents.
1739 @end defun
1741 @defun set-frame-configuration configuration &optional nodelete
1742 This function restores the state of frames described in
1743 @var{configuration}.  However, this function does not restore deleted
1744 frames.
1746 Ordinarily, this function deletes all existing frames not listed in
1747 @var{configuration}.  But if @var{nodelete} is non-@code{nil}, the
1748 unwanted frames are iconified instead.
1749 @end defun
1751 @node Mouse Tracking
1752 @section Mouse Tracking
1753 @cindex mouse tracking
1754 @c @cindex tracking the mouse   Duplicates track-mouse
1756   Sometimes it is useful to @dfn{track} the mouse, which means to display
1757 something to indicate where the mouse is and move the indicator as the
1758 mouse moves.  For efficient mouse tracking, you need a way to wait until
1759 the mouse actually moves.
1761   The convenient way to track the mouse is to ask for events to represent
1762 mouse motion.  Then you can wait for motion by waiting for an event.  In
1763 addition, you can easily handle any other sorts of events that may
1764 occur.  That is useful, because normally you don't want to track the
1765 mouse forever---only until some other event, such as the release of a
1766 button.
1768 @defspec track-mouse body@dots{}
1769 This special form executes @var{body}, with generation of mouse motion
1770 events enabled.  Typically, @var{body} would use @code{read-event} to
1771 read the motion events and modify the display accordingly.  @xref{Motion
1772 Events}, for the format of mouse motion events.
1774 The value of @code{track-mouse} is that of the last form in @var{body}.
1775 You should design @var{body} to return when it sees the up-event that
1776 indicates the release of the button, or whatever kind of event means
1777 it is time to stop tracking.
1778 @end defspec
1780 The usual purpose of tracking mouse motion is to indicate on the screen
1781 the consequences of pushing or releasing a button at the current
1782 position.
1784 In many cases, you can avoid the need to track the mouse by using
1785 the @code{mouse-face} text property (@pxref{Special Properties}).
1786 That works at a much lower level and runs more smoothly than
1787 Lisp-level mouse tracking.
1789 @ignore
1790 @c These are not implemented yet.
1792 These functions change the screen appearance instantaneously.  The
1793 effect is transient, only until the next ordinary Emacs redisplay.  That
1794 is OK for mouse tracking, since it doesn't make sense for mouse tracking
1795 to change the text, and the body of @code{track-mouse} normally reads
1796 the events itself and does not do redisplay.
1798 @defun x-contour-region window beg end
1799 This function draws lines to make a box around the text from @var{beg}
1800 to @var{end}, in window @var{window}.
1801 @end defun
1803 @defun x-uncontour-region window beg end
1804 This function erases the lines that would make a box around the text
1805 from @var{beg} to @var{end}, in window @var{window}.  Use it to remove
1806 a contour that you previously made by calling @code{x-contour-region}.
1807 @end defun
1809 @defun x-draw-rectangle frame left top right bottom
1810 This function draws a hollow rectangle on frame @var{frame} with the
1811 specified edge coordinates, all measured in pixels from the inside top
1812 left corner.  It uses the cursor color, the one used for indicating the
1813 location of point.
1814 @end defun
1816 @defun x-erase-rectangle frame left top right bottom
1817 This function erases a hollow rectangle on frame @var{frame} with the
1818 specified edge coordinates, all measured in pixels from the inside top
1819 left corner.  Erasure means redrawing the text and background that
1820 normally belong in the specified rectangle.
1821 @end defun
1822 @end ignore
1824 @node Mouse Position
1825 @section Mouse Position
1826 @cindex mouse position
1827 @cindex position of mouse
1829   The functions @code{mouse-position} and @code{set-mouse-position}
1830 give access to the current position of the mouse.
1832 @defun mouse-position
1833 This function returns a description of the position of the mouse.  The
1834 value looks like @code{(@var{frame} @var{x} . @var{y})}, where @var{x}
1835 and @var{y} are integers giving the position in characters relative to
1836 the top left corner of the inside of @var{frame}.
1837 @end defun
1839 @defvar mouse-position-function
1840 If non-@code{nil}, the value of this variable is a function for
1841 @code{mouse-position} to call.  @code{mouse-position} calls this
1842 function just before returning, with its normal return value as the
1843 sole argument, and it returns whatever this function returns to it.
1845 This abnormal hook exists for the benefit of packages like
1846 @file{xt-mouse.el} that need to do mouse handling at the Lisp level.
1847 @end defvar
1849 @defun set-mouse-position frame x y
1850 This function @dfn{warps the mouse} to position @var{x}, @var{y} in
1851 frame @var{frame}.  The arguments @var{x} and @var{y} are integers,
1852 giving the position in characters relative to the top left corner of the
1853 inside of @var{frame}.  If @var{frame} is not visible, this function
1854 does nothing.  The return value is not significant.
1855 @end defun
1857 @defun mouse-pixel-position
1858 This function is like @code{mouse-position} except that it returns
1859 coordinates in units of pixels rather than units of characters.
1860 @end defun
1862 @defun set-mouse-pixel-position frame x y
1863 This function warps the mouse like @code{set-mouse-position} except that
1864 @var{x} and @var{y} are in units of pixels rather than units of
1865 characters.  These coordinates are not required to be within the frame.
1867 If @var{frame} is not visible, this function does nothing.  The return
1868 value is not significant.
1869 @end defun
1871 @defun frame-pointer-visible-p &optional frame
1872 This predicate function returns non-@code{nil} if the mouse pointer
1873 displayed on @var{frame} is visible; otherwise it returns @code{nil}.
1874 @var{frame} omitted or @code{nil} means the selected frame.  This is
1875 useful when @code{make-pointer-invisible} is set to @code{t}: it
1876 allows to know if the pointer has been hidden.
1877 @xref{Mouse Avoidance,,,emacs, The Emacs Manual}.
1878 @end defun
1880 @need 3000
1882 @node Pop-Up Menus
1883 @section Pop-Up Menus
1885   A Lisp program can pop up a menu so that the user can choose an
1886 alternative with the mouse.  On a text terminal, if the mouse is not
1887 available, the user can choose an alternative using the keyboard
1888 motion keys---@kbd{C-n}, @kbd{C-p}, or up- and down-arrow keys.
1890 @defun x-popup-menu position menu
1891 This function displays a pop-up menu and returns an indication of
1892 what selection the user makes.
1894 The argument @var{position} specifies where on the screen to put the
1895 top left corner of the menu.  It can be either a mouse button event
1896 (which says to put the menu where the user actuated the button) or a
1897 list of this form:
1899 @example
1900 ((@var{xoffset} @var{yoffset}) @var{window})
1901 @end example
1903 @noindent
1904 where @var{xoffset} and @var{yoffset} are coordinates, measured in
1905 pixels, counting from the top left corner of @var{window}.  @var{window}
1906 may be a window or a frame.
1908 If @var{position} is @code{t}, it means to use the current mouse
1909 position (or the top-left corner of the frame if the mouse is not
1910 available on a text terminal).  If @var{position} is @code{nil}, it
1911 means to precompute the key binding equivalents for the keymaps
1912 specified in @var{menu}, without actually displaying or popping up the
1913 menu.
1915 The argument @var{menu} says what to display in the menu.  It can be a
1916 keymap or a list of keymaps (@pxref{Menu Keymaps}).  In this case, the
1917 return value is the list of events corresponding to the user's choice.
1918 This list has more than one element if the choice occurred in a
1919 submenu.  (Note that @code{x-popup-menu} does not actually execute the
1920 command bound to that sequence of events.)  On text terminals and
1921 toolkits that support menu titles, the title is taken from the prompt
1922 string of @var{menu} if @var{menu} is a keymap, or from the prompt
1923 string of the first keymap in @var{menu} if it is a list of keymaps
1924 (@pxref{Defining Menus}).
1926 Alternatively, @var{menu} can have the following form:
1928 @example
1929 (@var{title} @var{pane1} @var{pane2}...)
1930 @end example
1932 @noindent
1933 where each pane is a list of form
1935 @example
1936 (@var{title} @var{item1} @var{item2}...)
1937 @end example
1939 Each @var{item} should be a cons cell, @code{(@var{line} . @var{value})},
1940 where @var{line} is a string and @var{value} is the value to return if
1941 that @var{line} is chosen.  Unlike in a menu keymap, a @code{nil}
1942 @var{value} does not make the menu item non-selectable.
1943 Alternatively, each @var{item} can be a string rather than a cons
1944 cell; this makes a non-selectable menu item.
1946 If the user gets rid of the menu without making a valid choice, for
1947 instance by clicking the mouse away from a valid choice or by typing
1948 @kbd{C-g}, then this normally results in a quit and
1949 @code{x-popup-menu} does not return.  But if @var{position} is a mouse
1950 button event (indicating that the user invoked the menu with the
1951 mouse) then no quit occurs and @code{x-popup-menu} returns @code{nil}.
1952 @end defun
1954   @strong{Usage note:} Don't use @code{x-popup-menu} to display a menu
1955 if you could do the job with a prefix key defined with a menu keymap.
1956 If you use a menu keymap to implement a menu, @kbd{C-h c} and @kbd{C-h
1957 a} can see the individual items in that menu and provide help for them.
1958 If instead you implement the menu by defining a command that calls
1959 @code{x-popup-menu}, the help facilities cannot know what happens inside
1960 that command, so they cannot give any help for the menu's items.
1962   The menu bar mechanism, which lets you switch between submenus by
1963 moving the mouse, cannot look within the definition of a command to see
1964 that it calls @code{x-popup-menu}.  Therefore, if you try to implement a
1965 submenu using @code{x-popup-menu}, it cannot work with the menu bar in
1966 an integrated fashion.  This is why all menu bar submenus are
1967 implemented with menu keymaps within the parent menu, and never with
1968 @code{x-popup-menu}.  @xref{Menu Bar}.
1970   If you want a menu bar submenu to have contents that vary, you should
1971 still use a menu keymap to implement it.  To make the contents vary, add
1972 a hook function to @code{menu-bar-update-hook} to update the contents of
1973 the menu keymap as necessary.
1975 @node Dialog Boxes
1976 @section Dialog Boxes
1977 @cindex dialog boxes
1979   A dialog box is a variant of a pop-up menu---it looks a little
1980 different, it always appears in the center of a frame, and it has just
1981 one level and one or more buttons.  The main use of dialog boxes is
1982 for asking questions that the user can answer with ``yes'', ``no'',
1983 and a few other alternatives.  With a single button, they can also
1984 force the user to acknowledge important information.  The functions
1985 @code{y-or-n-p} and @code{yes-or-no-p} use dialog boxes instead of the
1986 keyboard, when called from commands invoked by mouse clicks.
1988 @defun x-popup-dialog position contents &optional header
1989 This function displays a pop-up dialog box and returns an indication of
1990 what selection the user makes.  The argument @var{contents} specifies
1991 the alternatives to offer; it has this format:
1993 @example
1994 (@var{title} (@var{string} . @var{value})@dots{})
1995 @end example
1997 @noindent
1998 which looks like the list that specifies a single pane for
1999 @code{x-popup-menu}.
2001 The return value is @var{value} from the chosen alternative.
2003 As for @code{x-popup-menu}, an element of the list may be just a
2004 string instead of a cons cell @code{(@var{string} . @var{value})}.
2005 That makes a box that cannot be selected.
2007 If @code{nil} appears in the list, it separates the left-hand items from
2008 the right-hand items; items that precede the @code{nil} appear on the
2009 left, and items that follow the @code{nil} appear on the right.  If you
2010 don't include a @code{nil} in the list, then approximately half the
2011 items appear on each side.
2013 Dialog boxes always appear in the center of a frame; the argument
2014 @var{position} specifies which frame.  The possible values are as in
2015 @code{x-popup-menu}, but the precise coordinates or the individual
2016 window don't matter; only the frame matters.
2018 If @var{header} is non-@code{nil}, the frame title for the box is
2019 @samp{Information}, otherwise it is @samp{Question}.  The former is used
2020 for @code{message-box} (@pxref{message-box}).  (On text terminals, the
2021 box title is not displayed.)
2023 In some configurations, Emacs cannot display a real dialog box; so
2024 instead it displays the same items in a pop-up menu in the center of the
2025 frame.
2027 If the user gets rid of the dialog box without making a valid choice,
2028 for instance using the window manager, then this produces a quit and
2029 @code{x-popup-dialog} does not return.
2030 @end defun
2032 @node Pointer Shape
2033 @section Pointer Shape
2034 @cindex pointer shape
2035 @cindex mouse pointer shape
2037   You can specify the mouse pointer style for particular text or
2038 images using the @code{pointer} text property, and for images with the
2039 @code{:pointer} and @code{:map} image properties.  The values you can
2040 use in these properties are @code{text} (or @code{nil}), @code{arrow},
2041 @code{hand}, @code{vdrag}, @code{hdrag}, @code{modeline}, and
2042 @code{hourglass}.  @code{text} stands for the usual mouse pointer
2043 style used over text.
2045   Over void parts of the window (parts that do not correspond to any
2046 of the buffer contents), the mouse pointer usually uses the
2047 @code{arrow} style, but you can specify a different style (one of
2048 those above) by setting @code{void-text-area-pointer}.
2050 @defopt void-text-area-pointer
2051 This variable specifies the mouse pointer style for void text areas.
2052 These include the areas after the end of a line or below the last line
2053 in the buffer.  The default is to use the @code{arrow} (non-text)
2054 pointer style.
2055 @end defopt
2057   When using X, you can specify what the @code{text} pointer style
2058 really looks like by setting the variable @code{x-pointer-shape}.
2060 @defvar x-pointer-shape
2061 This variable specifies the pointer shape to use ordinarily in the
2062 Emacs frame, for the @code{text} pointer style.
2063 @end defvar
2065 @defvar x-sensitive-text-pointer-shape
2066 This variable specifies the pointer shape to use when the mouse
2067 is over mouse-sensitive text.
2068 @end defvar
2070   These variables affect newly created frames.  They do not normally
2071 affect existing frames; however, if you set the mouse color of a
2072 frame, that also installs the current value of those two variables.
2073 @xref{Font and Color Parameters}.
2075   The values you can use, to specify either of these pointer shapes, are
2076 defined in the file @file{lisp/term/x-win.el}.  Use @kbd{M-x apropos
2077 @key{RET} x-pointer @key{RET}} to see a list of them.
2079 @node Window System Selections
2080 @section Window System Selections
2081 @cindex selection (for window systems)
2082 @cindex clipboard
2083 @cindex primary selection
2084 @cindex secondary selection
2086   In the X window system, data can be transferred between different
2087 applications by means of @dfn{selections}.  X defines an arbitrary
2088 number of @dfn{selection types}, each of which can store its own data;
2089 however, only three are commonly used: the @dfn{clipboard},
2090 @dfn{primary selection}, and @dfn{secondary selection}.  @xref{Cut and
2091 Paste,, Cut and Paste, emacs, The GNU Emacs Manual}, for Emacs
2092 commands that make use of these selections.  This section documents
2093 the low-level functions for reading and setting X selections.
2095 @deffn Command x-set-selection type data
2096 This function sets an X selection.  It takes two arguments: a
2097 selection type @var{type}, and the value to assign to it, @var{data}.
2099 @var{type} should be a symbol; it is usually one of @code{PRIMARY},
2100 @code{SECONDARY} or @code{CLIPBOARD}.  These are symbols with
2101 upper-case names, in accord with X Window System conventions.  If
2102 @var{type} is @code{nil}, that stands for @code{PRIMARY}.
2104 If @var{data} is @code{nil}, it means to clear out the selection.
2105 Otherwise, @var{data} may be a string, a symbol, an integer (or a cons
2106 of two integers or list of two integers), an overlay, or a cons of two
2107 markers pointing to the same buffer.  An overlay or a pair of markers
2108 stands for text in the overlay or between the markers.  The argument
2109 @var{data} may also be a vector of valid non-vector selection values.
2111 This function returns @var{data}.
2112 @end deffn
2114 @defun x-get-selection &optional type data-type
2115 This function accesses selections set up by Emacs or by other X
2116 clients.  It takes two optional arguments, @var{type} and
2117 @var{data-type}.  The default for @var{type}, the selection type, is
2118 @code{PRIMARY}.
2120 The @var{data-type} argument specifies the form of data conversion to
2121 use, to convert the raw data obtained from another X client into Lisp
2122 data.  Meaningful values include @code{TEXT}, @code{STRING},
2123 @code{UTF8_STRING}, @code{TARGETS}, @code{LENGTH}, @code{DELETE},
2124 @code{FILE_NAME}, @code{CHARACTER_POSITION}, @code{NAME},
2125 @code{LINE_NUMBER}, @code{COLUMN_NUMBER}, @code{OWNER_OS},
2126 @code{HOST_NAME}, @code{USER}, @code{CLASS}, @code{ATOM}, and
2127 @code{INTEGER}.  (These are symbols with upper-case names in accord
2128 with X conventions.)  The default for @var{data-type} is
2129 @code{STRING}.
2130 @end defun
2132 @defopt selection-coding-system
2133 This variable specifies the coding system to use when reading and
2134 writing selections or the clipboard.  @xref{Coding
2135 Systems}.  The default is @code{compound-text-with-extensions}, which
2136 converts to the text representation that X11 normally uses.
2137 @end defopt
2139 @cindex clipboard support (for MS-Windows)
2140 When Emacs runs on MS-Windows, it does not implement X selections in
2141 general, but it does support the clipboard.  @code{x-get-selection}
2142 and @code{x-set-selection} on MS-Windows support the text data type
2143 only; if the clipboard holds other types of data, Emacs treats the
2144 clipboard as empty.
2146 @node Drag and Drop
2147 @section Drag and Drop
2149 @vindex x-dnd-test-function
2150 @vindex x-dnd-known-types
2151   When a user drags something from another application over Emacs, that other
2152 application expects Emacs to tell it if Emacs can handle the data that is
2153 dragged.  The variable @code{x-dnd-test-function} is used by Emacs to determine
2154 what to reply.  The default value is @code{x-dnd-default-test-function}
2155 which accepts drops if the type of the data to be dropped is present in
2156 @code{x-dnd-known-types}.  You can customize @code{x-dnd-test-function} and/or
2157 @code{x-dnd-known-types} if you want Emacs to accept or reject drops based
2158 on some other criteria.
2160 @vindex x-dnd-types-alist
2161   If you want to change the way Emacs handles drop of different types
2162 or add a new type, customize @code{x-dnd-types-alist}.  This requires
2163 detailed knowledge of what types other applications use for drag and
2164 drop.
2166 @vindex dnd-protocol-alist
2167   When an URL is dropped on Emacs it may be a file, but it may also be
2168 another URL type (ftp, http, etc.).  Emacs first checks
2169 @code{dnd-protocol-alist} to determine what to do with the URL@.  If
2170 there is no match there and if @code{browse-url-browser-function} is
2171 an alist, Emacs looks for a match there.  If no match is found the
2172 text for the URL is inserted.  If you want to alter Emacs behavior,
2173 you can customize these variables.
2175 @node Color Names
2176 @section Color Names
2178 @cindex color names
2179 @cindex specify color
2180 @cindex numerical RGB color specification
2181   A color name is text (usually in a string) that specifies a color.
2182 Symbolic names such as @samp{black}, @samp{white}, @samp{red}, etc.,
2183 are allowed; use @kbd{M-x list-colors-display} to see a list of
2184 defined names.  You can also specify colors numerically in forms such
2185 as @samp{#@var{rgb}} and @samp{RGB:@var{r}/@var{g}/@var{b}}, where
2186 @var{r} specifies the red level, @var{g} specifies the green level,
2187 and @var{b} specifies the blue level.  You can use either one, two,
2188 three, or four hex digits for @var{r}; then you must use the same
2189 number of hex digits for all @var{g} and @var{b} as well, making
2190 either 3, 6, 9 or 12 hex digits in all.  (See the documentation of the
2191 X Window System for more details about numerical RGB specification of
2192 colors.)
2194   These functions provide a way to determine which color names are
2195 valid, and what they look like.  In some cases, the value depends on the
2196 @dfn{selected frame}, as described below; see @ref{Input Focus}, for the
2197 meaning of the term ``selected frame''.
2199   To read user input of color names with completion, use
2200 @code{read-color} (@pxref{High-Level Completion, read-color}).
2202 @defun color-defined-p color &optional frame
2203 This function reports whether a color name is meaningful.  It returns
2204 @code{t} if so; otherwise, @code{nil}.  The argument @var{frame} says
2205 which frame's display to ask about; if @var{frame} is omitted or
2206 @code{nil}, the selected frame is used.
2208 Note that this does not tell you whether the display you are using
2209 really supports that color.  When using X, you can ask for any defined
2210 color on any kind of display, and you will get some result---typically,
2211 the closest it can do.  To determine whether a frame can really display
2212 a certain color, use @code{color-supported-p} (see below).
2214 @findex x-color-defined-p
2215 This function used to be called @code{x-color-defined-p},
2216 and that name is still supported as an alias.
2217 @end defun
2219 @defun defined-colors &optional frame
2220 This function returns a list of the color names that are defined
2221 and supported on frame @var{frame} (default, the selected frame).
2222 If @var{frame} does not support colors, the value is @code{nil}.
2224 @findex x-defined-colors
2225 This function used to be called @code{x-defined-colors},
2226 and that name is still supported as an alias.
2227 @end defun
2229 @defun color-supported-p color &optional frame background-p
2230 This returns @code{t} if @var{frame} can really display the color
2231 @var{color} (or at least something close to it).  If @var{frame} is
2232 omitted or @code{nil}, the question applies to the selected frame.
2234 Some terminals support a different set of colors for foreground and
2235 background.  If @var{background-p} is non-@code{nil}, that means you are
2236 asking whether @var{color} can be used as a background; otherwise you
2237 are asking whether it can be used as a foreground.
2239 The argument @var{color} must be a valid color name.
2240 @end defun
2242 @defun color-gray-p color &optional frame
2243 This returns @code{t} if @var{color} is a shade of gray, as defined on
2244 @var{frame}'s display.  If @var{frame} is omitted or @code{nil}, the
2245 question applies to the selected frame.  If @var{color} is not a valid
2246 color name, this function returns @code{nil}.
2247 @end defun
2249 @defun color-values color &optional frame
2250 @cindex rgb value
2251 This function returns a value that describes what @var{color} should
2252 ideally look like on @var{frame}.  If @var{color} is defined, the
2253 value is a list of three integers, which give the amount of red, the
2254 amount of green, and the amount of blue.  Each integer ranges in
2255 principle from 0 to 65535, but some displays may not use the full
2256 range.  This three-element list is called the @dfn{rgb values} of the
2257 color.
2259 If @var{color} is not defined, the value is @code{nil}.
2261 @example
2262 (color-values "black")
2263      @result{} (0 0 0)
2264 (color-values "white")
2265      @result{} (65280 65280 65280)
2266 (color-values "red")
2267      @result{} (65280 0 0)
2268 (color-values "pink")
2269      @result{} (65280 49152 51968)
2270 (color-values "hungry")
2271      @result{} nil
2272 @end example
2274 The color values are returned for @var{frame}'s display.  If
2275 @var{frame} is omitted or @code{nil}, the information is returned for
2276 the selected frame's display.  If the frame cannot display colors, the
2277 value is @code{nil}.
2279 @findex x-color-values
2280 This function used to be called @code{x-color-values},
2281 and that name is still supported as an alias.
2282 @end defun
2284 @node Text Terminal Colors
2285 @section Text Terminal Colors
2286 @cindex colors on text terminals
2288   Text terminals usually support only a small number of colors, and
2289 the computer uses small integers to select colors on the terminal.
2290 This means that the computer cannot reliably tell what the selected
2291 color looks like; instead, you have to inform your application which
2292 small integers correspond to which colors.  However, Emacs does know
2293 the standard set of colors and will try to use them automatically.
2295   The functions described in this section control how terminal colors
2296 are used by Emacs.
2298   Several of these functions use or return @dfn{rgb values}, described
2299 in @ref{Color Names}.
2301   These functions accept a display (either a frame or the name of a
2302 terminal) as an optional argument.  We hope in the future to make
2303 Emacs support different colors on different text terminals; then this
2304 argument will specify which terminal to operate on (the default being
2305 the selected frame's terminal; @pxref{Input Focus}).  At present,
2306 though, the @var{frame} argument has no effect.
2308 @defun tty-color-define name number &optional rgb frame
2309 This function associates the color name @var{name} with
2310 color number @var{number} on the terminal.
2312 The optional argument @var{rgb}, if specified, is an rgb value, a list
2313 of three numbers that specify what the color actually looks like.
2314 If you do not specify @var{rgb}, then this color cannot be used by
2315 @code{tty-color-approximate} to approximate other colors, because
2316 Emacs will not know what it looks like.
2317 @end defun
2319 @defun tty-color-clear &optional frame
2320 This function clears the table of defined colors for a text terminal.
2321 @end defun
2323 @defun tty-color-alist &optional frame
2324 This function returns an alist recording the known colors supported by
2325 a text terminal.
2327 Each element has the form @code{(@var{name} @var{number} . @var{rgb})}
2328 or @code{(@var{name} @var{number})}.  Here, @var{name} is the color
2329 name, @var{number} is the number used to specify it to the terminal.
2330 If present, @var{rgb} is a list of three color values (for red, green,
2331 and blue) that says what the color actually looks like.
2332 @end defun
2334 @defun tty-color-approximate rgb &optional frame
2335 This function finds the closest color, among the known colors
2336 supported for @var{display}, to that described by the rgb value
2337 @var{rgb} (a list of color values).  The return value is an element of
2338 @code{tty-color-alist}.
2339 @end defun
2341 @defun tty-color-translate color &optional frame
2342 This function finds the closest color to @var{color} among the known
2343 colors supported for @var{display} and returns its index (an integer).
2344 If the name @var{color} is not defined, the value is @code{nil}.
2345 @end defun
2347 @node Resources
2348 @section X Resources
2350 This section describes some of the functions and variables for
2351 querying and using X resources, or their equivalent on your operating
2352 system.  @xref{X Resources,, X Resources, emacs, The GNU Emacs
2353 Manual}, for more information about X resources.
2355 @defun x-get-resource attribute class &optional component subclass
2356 The function @code{x-get-resource} retrieves a resource value from the X
2357 Window defaults database.
2359 Resources are indexed by a combination of a @dfn{key} and a @dfn{class}.
2360 This function searches using a key of the form
2361 @samp{@var{instance}.@var{attribute}} (where @var{instance} is the name
2362 under which Emacs was invoked), and using @samp{Emacs.@var{class}} as
2363 the class.
2365 The optional arguments @var{component} and @var{subclass} add to the key
2366 and the class, respectively.  You must specify both of them or neither.
2367 If you specify them, the key is
2368 @samp{@var{instance}.@var{component}.@var{attribute}}, and the class is
2369 @samp{Emacs.@var{class}.@var{subclass}}.
2370 @end defun
2372 @defvar x-resource-class
2373 This variable specifies the application name that @code{x-get-resource}
2374 should look up.  The default value is @code{"Emacs"}.  You can examine X
2375 resources for application names other than ``Emacs'' by binding this
2376 variable to some other string, around a call to @code{x-get-resource}.
2377 @end defvar
2379 @defvar x-resource-name
2380 This variable specifies the instance name that @code{x-get-resource}
2381 should look up.  The default value is the name Emacs was invoked with,
2382 or the value specified with the @samp{-name} or @samp{-rn} switches.
2383 @end defvar
2385 To illustrate some of the above, suppose that you have the line:
2387 @example
2388 xterm.vt100.background: yellow
2389 @end example
2391 @noindent
2392 in your X resources file (whose name is usually @file{~/.Xdefaults}
2393 or @file{~/.Xresources}).  Then:
2395 @example
2396 @group
2397 (let ((x-resource-class "XTerm") (x-resource-name "xterm"))
2398   (x-get-resource "vt100.background" "VT100.Background"))
2399      @result{} "yellow"
2400 @end group
2401 @group
2402 (let ((x-resource-class "XTerm") (x-resource-name "xterm"))
2403   (x-get-resource "background" "VT100" "vt100" "Background"))
2404      @result{} "yellow"
2405 @end group
2406 @end example
2408 @defvar inhibit-x-resources
2409 If this variable is non-@code{nil}, Emacs does not look up X
2410 resources, and X resources do not have any effect when creating new
2411 frames.
2412 @end defvar
2414 @node Display Feature Testing
2415 @section Display Feature Testing
2416 @cindex display feature testing
2418   The functions in this section describe the basic capabilities of a
2419 particular display.  Lisp programs can use them to adapt their behavior
2420 to what the display can do.  For example, a program that ordinarily uses
2421 a popup menu could use the minibuffer if popup menus are not supported.
2423   The optional argument @var{display} in these functions specifies which
2424 display to ask the question about.  It can be a display name, a frame
2425 (which designates the display that frame is on), or @code{nil} (which
2426 refers to the selected frame's display, @pxref{Input Focus}).
2428   @xref{Color Names}, @ref{Text Terminal Colors}, for other functions to
2429 obtain information about displays.
2431 @defun display-popup-menus-p &optional display
2432 This function returns @code{t} if popup menus are supported on
2433 @var{display}, @code{nil} if not.  Support for popup menus requires
2434 that the mouse be available, since the menu is popped up by clicking
2435 the mouse on some portion of the Emacs display.
2436 @end defun
2438 @defun display-graphic-p &optional display
2439 This function returns @code{t} if @var{display} is a graphic display
2440 capable of displaying several frames and several different fonts at
2441 once.  This is true for displays that use a window system such as X,
2442 and false for text terminals.
2443 @end defun
2445 @defun display-mouse-p &optional display
2446 @cindex mouse, availability
2447 This function returns @code{t} if @var{display} has a mouse available,
2448 @code{nil} if not.
2449 @end defun
2451 @defun display-color-p &optional display
2452 @findex x-display-color-p
2453 This function returns @code{t} if the screen is a color screen.
2454 It used to be called @code{x-display-color-p}, and that name
2455 is still supported as an alias.
2456 @end defun
2458 @defun display-grayscale-p &optional display
2459 This function returns @code{t} if the screen can display shades of gray.
2460 (All color displays can do this.)
2461 @end defun
2463 @defun display-supports-face-attributes-p attributes &optional display
2464 @anchor{Display Face Attribute Testing}
2465 This function returns non-@code{nil} if all the face attributes in
2466 @var{attributes} are supported (@pxref{Face Attributes}).
2468 The definition of `supported' is somewhat heuristic, but basically
2469 means that a face containing all the attributes in @var{attributes},
2470 when merged with the default face for display, can be represented in a
2471 way that's
2473 @enumerate
2474 @item
2475 different in appearance than the default face, and
2477 @item
2478 `close in spirit' to what the attributes specify, if not exact.
2479 @end enumerate
2481 Point (2) implies that a @code{:weight black} attribute will be
2482 satisfied by any display that can display bold, as will
2483 @code{:foreground "yellow"} as long as some yellowish color can be
2484 displayed, but @code{:slant italic} will @emph{not} be satisfied by
2485 the tty display code's automatic substitution of a `dim' face for
2486 italic.
2487 @end defun
2489 @defun display-selections-p &optional display
2490 This function returns @code{t} if @var{display} supports selections.
2491 Windowed displays normally support selections, but they may also be
2492 supported in some other cases.
2493 @end defun
2495 @defun display-images-p &optional display
2496 This function returns @code{t} if @var{display} can display images.
2497 Windowed displays ought in principle to handle images, but some
2498 systems lack the support for that.  On a display that does not support
2499 images, Emacs cannot display a tool bar.
2500 @end defun
2502 @defun display-screens &optional display
2503 This function returns the number of screens associated with the display.
2504 @end defun
2506 @defun display-pixel-height &optional display
2507 This function returns the height of the screen in pixels.
2508 On a character terminal, it gives the height in characters.
2510 For graphical terminals, note that on ``multi-monitor'' setups this
2511 refers to the pixel height for all physical monitors associated with
2512 @var{display}.  @xref{Multiple Terminals}.
2513 @end defun
2515 @defun display-pixel-width &optional display
2516 This function returns the width of the screen in pixels.
2517 On a character terminal, it gives the width in characters.
2519 For graphical terminals, note that on ``multi-monitor'' setups this
2520 refers to the pixel width for all physical monitors associated with
2521 @var{display}.  @xref{Multiple Terminals}.
2522 @end defun
2524 @defun display-mm-height &optional display
2525 This function returns the height of the screen in millimeters,
2526 or @code{nil} if Emacs cannot get that information.
2528 For graphical terminals, note that on ``multi-monitor'' setups this
2529 refers to the height for all physical monitors associated with
2530 @var{display}.  @xref{Multiple Terminals}.
2531 @end defun
2533 @defun display-mm-width &optional display
2534 This function returns the width of the screen in millimeters,
2535 or @code{nil} if Emacs cannot get that information.
2537 For graphical terminals, note that on ``multi-monitor'' setups this
2538 refers to the width for all physical monitors associated with
2539 @var{display}.  @xref{Multiple Terminals}.
2540 @end defun
2542 @defopt display-mm-dimensions-alist
2543 This variable allows the user to specify the dimensions of graphical
2544 displays returned by @code{display-mm-height} and
2545 @code{display-mm-width} in case the system provides incorrect values.
2546 @end defopt
2548 @cindex backing store
2549 @defun display-backing-store &optional display
2550 This function returns the backing store capability of the display.
2551 Backing store means recording the pixels of windows (and parts of
2552 windows) that are not exposed, so that when exposed they can be
2553 displayed very quickly.
2555 Values can be the symbols @code{always}, @code{when-mapped}, or
2556 @code{not-useful}.  The function can also return @code{nil}
2557 when the question is inapplicable to a certain kind of display.
2558 @end defun
2560 @cindex SaveUnder feature
2561 @defun display-save-under &optional display
2562 This function returns non-@code{nil} if the display supports the
2563 SaveUnder feature.  That feature is used by pop-up windows
2564 to save the pixels they obscure, so that they can pop down
2565 quickly.
2566 @end defun
2568 @defun display-planes &optional display
2569 This function returns the number of planes the display supports.
2570 This is typically the number of bits per pixel.
2571 For a tty display, it is log to base two of the number of colors supported.
2572 @end defun
2574 @defun display-visual-class &optional display
2575 This function returns the visual class for the screen.  The value is
2576 one of the symbols @code{static-gray} (a limited, unchangeable number
2577 of grays), @code{gray-scale} (a full range of grays),
2578 @code{static-color} (a limited, unchangeable number of colors),
2579 @code{pseudo-color} (a limited number of colors), @code{true-color} (a
2580 full range of colors), and @code{direct-color} (a full range of
2581 colors).
2582 @end defun
2584 @defun display-color-cells &optional display
2585 This function returns the number of color cells the screen supports.
2586 @end defun
2588   These functions obtain additional information specifically
2589 about X displays.
2591 @defun x-server-version &optional display
2592 This function returns the list of version numbers of the X server
2593 running the display.  The value is a list of three integers: the major
2594 and minor version numbers of the X protocol, and the
2595 distributor-specific release number of the X server software itself.
2596 @end defun
2598 @defun x-server-vendor &optional display
2599 This function returns the ``vendor'' that provided the X server
2600 software (as a string).  Really this means whoever distributes the X
2601 server.
2603 When the developers of X labeled software distributors as
2604 ``vendors'', they showed their false assumption that no system could
2605 ever be developed and distributed noncommercially.
2606 @end defun
2608 @ignore
2609 @defvar x-no-window-manager
2610 This variable's value is @code{t} if no X window manager is in use.
2611 @end defvar
2612 @end ignore
2614 @ignore
2615 @item
2616 The functions @code{x-pixel-width} and @code{x-pixel-height} return the
2617 width and height of an X Window frame, measured in pixels.
2618 @end ignore