Fix @findex and @vindex entries in manuals
[emacs.git] / doc / lispref / frames.texi
blobc2fa1094821d9f6c0b82aafefa1bf0eb472e6d00
1 @c -*-texinfo-*-
2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990-1995, 1998-1999, 2001-2018 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 @cindex top-level frame
81 On a graphical terminal we distinguish two types of frames: A normal
82 @dfn{top-level frame} is a frame whose window-system window is a child
83 of the window-system's root window for that terminal.  A child frame is
84 a frame whose window-system window is the child of the window-system
85 window of another Emacs frame.  @xref{Child Frames}.
87 @menu
88 * Creating Frames::             Creating additional frames.
89 * Multiple Terminals::          Displaying on several different devices.
90 * Frame Geometry::              Geometric properties of frames.
91 * Frame Parameters::            Controlling frame size, position, font, etc.
92 * Terminal Parameters::         Parameters common for all frames on terminal.
93 * Frame Titles::                Automatic updating of frame titles.
94 * Deleting Frames::             Frames last until explicitly deleted.
95 * Finding All Frames::          How to examine all existing frames.
96 * Minibuffers and Frames::      How a frame finds the minibuffer to use.
97 * Input Focus::                 Specifying the selected frame.
98 * Visibility of Frames::        Frames may be visible or invisible, or icons.
99 * Raising and Lowering::        Raising, Lowering and Restacking Frames.
100 * Frame Configurations::        Saving the state of all frames.
101 * Child Frames::                Making a frame the child of another.
102 * Mouse Tracking::              Getting events that say when the mouse moves.
103 * Mouse Position::              Asking where the mouse is, or moving it.
104 * Pop-Up Menus::                Displaying a menu for the user to select from.
105 * Dialog Boxes::                Displaying a box to ask yes or no.
106 * Pointer Shape::               Specifying the shape of the mouse pointer.
107 * Window System Selections::    Transferring text to and from other X clients.
108 * Drag and Drop::               Internals of Drag-and-Drop implementation.
109 * Color Names::                 Getting the definitions of color names.
110 * Text Terminal Colors::        Defining colors for text terminals.
111 * Resources::                   Getting resource values from the server.
112 * Display Feature Testing::     Determining the features of a terminal.
113 @end menu
116 @node Creating Frames
117 @section Creating Frames
118 @cindex frame creation
120 To create a new frame, call the function @code{make-frame}.
122 @deffn Command make-frame &optional parameters
123 This function creates and returns a new frame, displaying the current
124 buffer.
126 The @var{parameters} argument is an alist that specifies frame
127 parameters for the new frame.  @xref{Frame Parameters}.  If you specify
128 the @code{terminal} parameter in @var{parameters}, the new frame is
129 created on that terminal.  Otherwise, if you specify the
130 @code{window-system} frame parameter in @var{parameters}, that
131 determines whether the frame should be displayed on a text terminal or a
132 graphical terminal.  @xref{Window Systems}.  If neither is specified,
133 the new frame is created in the same terminal as the selected frame.
135 Any parameters not mentioned in @var{parameters} default to the values
136 in the alist @code{default-frame-alist} (@pxref{Initial Parameters});
137 parameters not specified there default from the X resources or its
138 equivalent on your operating system (@pxref{X Resources,, X Resources,
139 emacs, The GNU Emacs Manual}).  After the frame is created, this
140 function applies any parameters specified in
141 @code{frame-inherited-parameters} (see below) it has no assigned yet,
142 taking the values from the frame that was selected when
143 @code{make-frame} was called.
145 Note that on multi-monitor displays (@pxref{Multiple Terminals}), the
146 window manager might position the frame differently than specified by
147 the positional parameters in @var{parameters} (@pxref{Position
148 Parameters}).  For example, some window managers have a policy of
149 displaying the frame on the monitor that contains the largest part of
150 the window (a.k.a.@: the @dfn{dominating} monitor).
152 This function itself does not make the new frame the selected frame.
153 @xref{Input Focus}.  The previously selected frame remains selected.
154 On graphical terminals, however, the windowing system may select the
155 new frame for its own reasons.
156 @end deffn
158 @defvar before-make-frame-hook
159 A normal hook run by @code{make-frame} before it creates the frame.
160 @end defvar
162 @defvar after-make-frame-functions
163 An abnormal hook run by @code{make-frame} after it created the frame.
164 Each function in @code{after-make-frame-functions} receives one
165 argument, the frame just created.
166 @end defvar
168 Note that any functions added to these hooks by your initial file are
169 usually not run for the initial frame, since Emacs reads the initial
170 file only after creating that frame.  However, if the initial frame is
171 specified to use a separate minibuffer frame (@pxref{Minibuffers and
172 Frames}), the functions will be run for both, the minibuffer-less and
173 the minibuffer frame.
175 @defvar frame-inherited-parameters
176 This variable specifies the list of frame parameters that a newly
177 created frame inherits from the currently selected frame.  For each
178 parameter (a symbol) that is an element in this list and has not been
179 assigned earlier when processing @code{make-frame}, the function sets
180 the value of that parameter in the created frame to its value in the
181 selected frame.
182 @end defvar
185 @node Multiple Terminals
186 @section Multiple Terminals
187 @cindex multiple terminals
188 @cindex multi-tty
189 @cindex multiple X displays
190 @cindex displays, multiple
192   Emacs represents each terminal as a @dfn{terminal object} data type
193 (@pxref{Terminal Type}).  On GNU and Unix systems, Emacs can use
194 multiple terminals simultaneously in each session.  On other systems,
195 it can only use a single terminal.  Each terminal object has the
196 following attributes:
198 @itemize @bullet
199 @item
200 The name of the device used by the terminal (e.g., @samp{:0.0} or
201 @file{/dev/tty}).
203 @item
204 The terminal and keyboard coding systems used on the terminal.
205 @xref{Terminal I/O Encoding}.
207 @item
208 The kind of display associated with the terminal.  This is the symbol
209 returned by the function @code{terminal-live-p} (i.e., @code{x},
210 @code{t}, @code{w32}, @code{ns}, or @code{pc}).  @xref{Frames}.
212 @item
213 A list of terminal parameters.  @xref{Terminal Parameters}.
214 @end itemize
216   There is no primitive for creating terminal objects.  Emacs creates
217 them as needed, such as when you call @code{make-frame-on-display}
218 (described below).
220 @defun terminal-name &optional terminal
221 This function returns the file name of the device used by
222 @var{terminal}.  If @var{terminal} is omitted or @code{nil}, it
223 defaults to the selected frame's terminal.  @var{terminal} can also be
224 a frame, meaning that frame's terminal.
225 @end defun
227 @defun terminal-list
228 This function returns a list of all live terminal objects.
229 @end defun
231 @defun get-device-terminal device
232 This function returns a terminal whose device name is given by
233 @var{device}.  If @var{device} is a string, it can be either the file
234 name of a terminal device, or the name of an X display of the form
235 @samp{@var{host}:@var{server}.@var{screen}}.  If @var{device} is a
236 frame, this function returns that frame's terminal; @code{nil} means
237 the selected frame.  Finally, if @var{device} is a terminal object
238 that represents a live terminal, that terminal is returned.  The
239 function signals an error if its argument is none of the above.
240 @end defun
242 @defun delete-terminal &optional terminal force
243 This function deletes all frames on @var{terminal} and frees the
244 resources used by it.  It runs the abnormal hook
245 @code{delete-terminal-functions}, passing @var{terminal} as the
246 argument to each function.
248 If @var{terminal} is omitted or @code{nil}, it defaults to the
249 selected frame's terminal.  @var{terminal} can also be a frame,
250 meaning that frame's terminal.
252 Normally, this function signals an error if you attempt to delete the
253 sole active terminal, but if @var{force} is non-@code{nil}, you are
254 allowed to do so.  Emacs automatically calls this function when the
255 last frame on a terminal is deleted (@pxref{Deleting Frames}).
256 @end defun
258 @defvar delete-terminal-functions
259 An abnormal hook run by @code{delete-terminal}.  Each function
260 receives one argument, the @var{terminal} argument passed to
261 @code{delete-terminal}.  Due to technical details, the functions may
262 be called either just before the terminal is deleted, or just
263 afterwards.
264 @end defvar
266 @cindex terminal-local variables
267   A few Lisp variables are @dfn{terminal-local}; that is, they have a
268 separate binding for each terminal.  The binding in effect at any time
269 is the one for the terminal that the currently selected frame belongs
270 to.  These variables include @code{default-minibuffer-frame},
271 @code{defining-kbd-macro}, @code{last-kbd-macro}, and
272 @code{system-key-alist}.  They are always terminal-local, and can
273 never be buffer-local (@pxref{Buffer-Local Variables}).
275   On GNU and Unix systems, each X display is a separate graphical
276 terminal.  When Emacs is started from within the X window system, it
277 uses the X display specified by the @env{DISPLAY} environment
278 variable, or by the @samp{--display} option (@pxref{Initial Options,,,
279 emacs, The GNU Emacs Manual}).  Emacs can connect to other X displays
280 via the command @code{make-frame-on-display}.  Each X display has its
281 own selected frame and its own minibuffer windows; however, only one
282 of those frames is @emph{the} selected frame at any given moment
283 (@pxref{Input Focus}).  Emacs can even connect to other text
284 terminals, by interacting with the @command{emacsclient} program.
285 @xref{Emacs Server,,, emacs, The GNU Emacs Manual}.
287 @cindex X display names
288 @cindex display name on X
289   A single X server can handle more than one display.  Each X display
290 has a three-part name,
291 @samp{@var{hostname}:@var{displaynumber}.@var{screennumber}}.  The
292 first part, @var{hostname}, specifies the name of the machine to which
293 the display is physically connected.  The second part,
294 @var{displaynumber}, is a zero-based number that identifies one or
295 more monitors connected to that machine that share a common keyboard
296 and pointing device (mouse, tablet, etc.).  The third part,
297 @var{screennumber}, identifies a zero-based screen number (a separate
298 monitor) that is part of a single monitor collection on that X server.
299 When you use two or more screens belonging to one server, Emacs knows
300 by the similarity in their names that they share a single keyboard.
302   Systems that don't use the X window system, such as MS-Windows,
303 don't support the notion of X displays, and have only one display on
304 each host.  The display name on these systems doesn't follow the above
305 3-part format; for example, the display name on MS-Windows systems is
306 a constant string @samp{w32}, and exists for compatibility, so that
307 you could pass it to functions that expect a display name.
309 @deffn Command make-frame-on-display display &optional parameters
310 This function creates and returns a new frame on @var{display}, taking
311 the other frame parameters from the alist @var{parameters}.
312 @var{display} should be the name of an X display (a string).
314 Before creating the frame, this function ensures that Emacs is set
315 up to display graphics.  For instance, if Emacs has not processed X
316 resources (e.g., if it was started on a text terminal), it does so at
317 this time.  In all other respects, this function behaves like
318 @code{make-frame} (@pxref{Creating Frames}).
319 @end deffn
321 @defun x-display-list
322 This function returns a list that indicates which X displays Emacs has
323 a connection to.  The elements of the list are strings, and each one
324 is a display name.
325 @end defun
327 @defun x-open-connection display &optional xrm-string must-succeed
328 This function opens a connection to the X display @var{display},
329 without creating a frame on that display.  Normally, Emacs Lisp
330 programs need not call this function, as @code{make-frame-on-display}
331 calls it automatically.  The only reason for calling it is to check
332 whether communication can be established with a given X display.
334 The optional argument @var{xrm-string}, if not @code{nil}, is a string
335 of resource names and values, in the same format used in the
336 @file{.Xresources} file.  @xref{X Resources,, X Resources, emacs, The
337 GNU Emacs Manual}.  These values apply to all Emacs frames created on
338 this display, overriding the resource values recorded in the X server.
339 Here's an example of what this string might look like:
341 @example
342 "*BorderWidth: 3\n*InternalBorder: 2\n"
343 @end example
345 If @var{must-succeed} is non-@code{nil}, failure to open the connection
346 terminates Emacs.  Otherwise, it is an ordinary Lisp error.
347 @end defun
349 @defun x-close-connection display
350 This function closes the connection to display @var{display}.  Before
351 you can do this, you must first delete all the frames that were open
352 on that display (@pxref{Deleting Frames}).
353 @end defun
355 @cindex multi-monitor
356   On some multi-monitor setups, a single X display outputs to more
357 than one physical monitor.  You can use the functions
358 @code{display-monitor-attributes-list} and @code{frame-monitor-attributes}
359 to obtain information about such setups.
361 @defun display-monitor-attributes-list &optional display
362 This function returns a list of physical monitor attributes on
363 @var{display}, which can be a display name (a string), a terminal, or
364 a frame; if omitted or @code{nil}, it defaults to the selected frame's
365 display.  Each element of the list is an association list,
366 representing the attributes of a physical monitor.  The first element
367 corresponds to the primary monitor.  The attribute keys and values
368 are:
370 @table @samp
371 @item geometry
372 Position of the top-left corner of the monitor's screen and its size,
373 in pixels, as @samp{(@var{x} @var{y} @var{width} @var{height})}.  Note
374 that, if the monitor is not the primary monitor, some of the
375 coordinates might be negative.
377 @item workarea
378 Position of the top-left corner and size of the work area (usable
379 space) in pixels as @samp{(@var{x} @var{y} @var{width} @var{height})}.
380 This may be different from @samp{geometry} in that space occupied by
381 various window manager features (docks, taskbars, etc.)@: may be
382 excluded from the work area.  Whether or not such features actually
383 subtract from the work area depends on the platform and environment.
384 Again, if the monitor is not the primary monitor, some of the
385 coordinates might be negative.
387 @item mm-size
388 Width and height in millimeters as @samp{(@var{width} @var{height})}
390 @item frames
391 List of frames that this physical monitor dominates (see below).
393 @item name
394 Name of the physical monitor as @var{string}.
396 @item source
397 Source of the multi-monitor information as @var{string};
398 e.g., @samp{XRandr} or @samp{Xinerama}.
399 @end table
401 @var{x}, @var{y}, @var{width}, and @var{height} are integers.
402 @samp{name} and @samp{source} may be absent.
404 A frame is @dfn{dominated} by a physical monitor when either the
405 largest area of the frame resides in that monitor, or (if the frame
406 does not intersect any physical monitors) that monitor is the closest
407 to the frame.  Every (non-tooltip) frame (whether visible or not) in a
408 graphical display is dominated by exactly one physical monitor at a
409 time, though the frame can span multiple (or no) physical monitors.
411 Here's an example of the data produced by this function on a 2-monitor
412 display:
414 @lisp
415   (display-monitor-attributes-list)
416   @result{}
417   (((geometry 0 0 1920 1080) ;; @r{Left-hand, primary monitor}
418     (workarea 0 0 1920 1050) ;; @r{A taskbar occupies some of the height}
419     (mm-size 677 381)
420     (name . "DISPLAY1")
421     (frames #<frame emacs@@host *Messages* 0x11578c0>
422             #<frame emacs@@host *scratch* 0x114b838>))
423    ((geometry 1920 0 1680 1050) ;; @r{Right-hand monitor}
424     (workarea 1920 0 1680 1050) ;; @r{Whole screen can be used}
425     (mm-size 593 370)
426     (name . "DISPLAY2")
427     (frames)))
428 @end lisp
430 @end defun
432 @defun frame-monitor-attributes &optional frame
433 This function returns the attributes of the physical monitor
434 dominating (see above) @var{frame}, which defaults to the selected frame.
435 @end defun
438 @node Frame Geometry
439 @section Frame Geometry
440 @cindex frame geometry
441 @cindex frame position
442 @cindex position of frame
443 @cindex frame size
444 @cindex size of frame
446 The geometry of a frame depends on the toolkit that was used to build
447 this instance of Emacs and the terminal that displays the frame.  This
448 chapter describes these dependencies and some of the functions to deal
449 with them.  Note that the @var{frame} argument of all of these functions
450 has to specify a live frame (@pxref{Deleting Frames}).  If omitted or
451 @code{nil}, it specifies the selected frame (@pxref{Input Focus}).
453 @menu
454 * Frame Layout::            Basic layout of frames.
455 * Frame Font::              The default font of a frame and how to set it.
456 * Frame Position::          The position of a frame on its display.
457 * Frame Size::              Specifying and retrieving a frame's size.
458 * Implied Frame Resizing::  Implied resizing of frames and how to prevent it.
459 @end menu
462 @node Frame Layout
463 @subsection Frame Layout
464 @cindex frame layout
465 @cindex layout of frame
467 A visible frame occupies a rectangular area on its terminal's display.
468 This area may contain a number of nested rectangles, each serving a
469 different purpose.  The drawing below sketches the layout of a frame on
470 a graphical terminal:
471 @smallexample
472 @group
474         <------------ Outer Frame Width ----------->
475         ____________________________________________
476      ^(0)  ________ External/Outer Border _______   |
477      | |  |_____________ Title Bar ______________|  |
478      | | (1)_____________ Menu Bar ______________|  | ^
479      | | (2)_____________ Tool Bar ______________|  | ^
480      | | (3) _________ Internal Border ________  |  | ^
481      | |  | |   ^                              | |  | |
482      | |  | |   |                              | |  | |
483 Outer  |  | | Inner                            | |  | Native
484 Frame  |  | | Frame                            | |  | Frame
485 Height |  | | Height                           | |  | Height
486      | |  | |   |                              | |  | |
487      | |  | |<--+--- Inner Frame Width ------->| |  | |
488      | |  | |   |                              | |  | |
489      | |  | |___v______________________________| |  | |
490      | |  |___________ Internal Border __________|  | v
491      v |___________ External/Outer Border __________|
492            <-------- Native Frame Width -------->
494 @end group
495 @end smallexample
497 In practice not all of the areas shown in the drawing will or may be
498 present.  The meaning of these areas is described below.
500 @table @samp
501 @item Outer Frame
502 @cindex outer frame
503 @cindex outer edges
504 @cindex outer width
505 @cindex outer height
506 @cindex outer size
507 The @dfn{outer frame} is a rectangle comprising all areas shown in the
508 drawing.  The edges of that rectangle are called the @dfn{outer edges}
509 of the frame.  Together, the @dfn{outer width} and @dfn{outer height} of
510 the frame specify the @dfn{outer size} of that rectangle.
512 Knowing the outer size of a frame is useful for fitting a frame into the
513 working area of its display (@pxref{Multiple Terminals}) or for placing
514 two frames adjacent to each other on the screen.  Usually, the outer
515 size of a frame is available only after the frame has been mapped (made
516 visible, @pxref{Visibility of Frames}) at least once.  For the initial
517 frame or a frame that has not been created yet, the outer size can be
518 only estimated or must be calculated from the window-system's or window
519 manager's defaults.  One workaround is to obtain the differences of the
520 outer and native (see below) sizes of a mapped frame and use them for
521 calculating the outer size of the new frame.
523 @cindex outer position
524 The position of the upper left corner of the outer frame (indicated by
525 @samp{(0)} in the drawing above) is the @dfn{outer position} of the
526 frame.  The outer position of a graphical frame is also referred to as
527 ``the position'' of the frame because it usually remains unchanged on
528 its display whenever the frame is resized or its layout is changed.
530 The outer position is specified by and can be set via the @code{left}
531 and @code{top} frame parameters (@pxref{Position Parameters}).  For a
532 normal, top-level frame these parameters usually represent its absolute
533 position (see below) with respect to its display's origin.  For a child
534 frame (@pxref{Child Frames}) these parameters represent its position
535 relative to the native position (see below) of its parent frame.  For
536 frames on text terminals the values of these parameters are meaningless
537 and always zero.
539 @item External Border
540 @cindex external border
541 The @dfn{external border} is part of the decorations supplied by the
542 window manager.  It is typically used for resizing the frame with the
543 mouse and is therefore not shown on ``fullboth'' and maximized frames
544 (@pxref{Size Parameters}).  Its width is determined by the window
545 manager and cannot be changed by Emacs' functions.
547 External borders don't exist on text terminal frames.  For graphical
548 frames, their display can be suppressed by setting the
549 @code{override-redirect} or @code{undecorated} frame parameter
550 (@pxref{Management Parameters}).
552 @item Outer Border
553 @cindex outer border
554 The @dfn{outer border} is a separate border whose width can be specified
555 with the @code{border-width} frame parameter (@pxref{Layout
556 Parameters}).  In practice, either the external or the outer border of a
557 frame are displayed but never both at the same time.  Usually, the outer
558 border is shown only for special frames that are not (fully) controlled
559 by the window manager like tooltip frames (@pxref{Tooltips}), child
560 frames (@pxref{Child Frames}) and @code{undecorated} or
561 @code{override-redirect} frames (@pxref{Management Parameters}).
563 Outer borders are never shown on text terminal frames and on frames
564 generated by GTK+ routines.  On MS-Windows, the outer border is emulated
565 with the help of a one pixel wide external border.  Non-toolkit builds
566 on X allow to change the color of the outer border by setting the
567 @code{border-color} frame parameter (@pxref{Layout Parameters}).
569 @item Title Bar
570 @cindex title bar
571 @cindex caption bar
572 The @dfn{title bar}, a.k.a.@ @dfn{caption bar}, is also part of the
573 window manager's decorations and typically displays the title of the
574 frame (@pxref{Frame Titles}) as well as buttons for minimizing,
575 maximizing and deleting the frame.  It can be also used for dragging
576 the frame with the mouse.  The title bar is usually not displayed for
577 fullboth (@pxref{Size Parameters}), tooltip (@pxref{Tooltips}) and
578 child frames (@pxref{Child Frames}) and doesn't exist for terminal
579 frames.  Display of the title bar can be suppressed by setting the
580 @code{override-redirect} or the @code{undecorated} frame parameters
581 (@pxref{Management Parameters}).
583 @item Menu Bar
584 @cindex internal menu bar
585 @cindex external menu bar
586 The menu bar (@pxref{Menu Bar}) can be either internal (drawn by Emacs
587 itself) or external (drawn by the toolkit).  Most builds (GTK+, Lucid,
588 Motif and MS-Windows) rely on an external menu bar.  NS also uses an
589 external menu bar which, however, is not part of the outer frame.
590 Non-toolkit builds can provide an internal menu bar.  On text terminal
591 frames, the menu bar is part of the frame's root window (@pxref{Windows
592 and Frames}).  As a rule, menu bars are never shown on child frames
593 (@pxref{Child Frames}).  Display of the menu bar can be suppressed by
594 setting the @code{menu-bar-lines} parameter (@pxref{Layout Parameters})
595 to zero.
597 Whether the menu bar is wrapped or truncated whenever its width
598 becomes too large to fit on its frame depends on the toolkit .
599 Usually, only Motif and MS-Windows builds can wrap the menu bar.  When
600 they (un-)wrap the menu bar, they try to keep the outer height of the
601 frame unchanged, so the native height of the frame (see below) will
602 change instead.
604 @item Tool Bar
605 @cindex internal tool bar
606 @cindex external tool bar
607 Like the menu bar, the tool bar (@pxref{Tool Bar}) can be either
608 internal (drawn by Emacs itself) or external (drawn by a toolkit).  The
609 GTK+ and NS builds have the tool bar drawn by the toolkit.  The
610 remaining builds use internal tool bars.  With GTK+ the tool bar can be
611 located on either side of the frame, immediately outside the internal
612 border, see below.  Tool bars are usually not shown for child frames
613 (@pxref{Child Frames}).  Display of the tool bar can be suppressed by
614 setting the @code{tool-bar-lines} parameter (@pxref{Layout
615 Parameters}) to zero.
617 If the variable @code{auto-resize-tool-bars} is non-@code{nil}, Emacs
618 wraps the internal tool bar when its width becomes too large for its
619 frame.  If and when Emacs (un-)wraps the internal tool bar, it by
620 default keeps the outer height of the frame unchanged, so the native
621 height of the frame (see below) will change instead.  Emacs built with
622 GTK+, on the other hand, never wraps the tool bar but may
623 automatically increase the outer width of a frame in order to
624 accommodate an overlong tool bar.
626 @item Native Frame
627 @cindex native frame
628 @cindex native edges
629 @cindex native width
630 @cindex native height
631 @cindex native size
632 The @dfn{native frame} is a rectangle located entirely within the outer
633 frame.  It excludes the areas occupied by an external or outer border,
634 the title bar and any external menu or tool bar.  The edges of the
635 native frame are called the @dfn{native edges} of the frame.  Together,
636 the @dfn{native width} and @dfn{native height} of a frame specify the
637 @dfn{native size} of the frame.
639 The native size of a frame is the size Emacs passes to the window-system
640 or window manager when creating or resizing the frame from within Emacs.
641 It is also the size Emacs receives from the window-system or window
642 manager whenever these resize the frame's window-system window, for
643 example, after maximizing the frame by clicking on the corresponding
644 button in the title bar or when dragging its external border with the
645 mouse.
647 @cindex native position
648 The position of the top left corner of the native frame specifies the
649 @dfn{native position} of the frame.  (1)--(3) in the drawing above
650 indicate that position for the various builds:
652 @itemize @w{}
653 @item (1) non-toolkit and terminal frames
655 @item (2) Lucid, Motif and MS-Windows frames
657 @item (3) GTK+ and NS frames
658 @end itemize
660 Accordingly, the native height of a frame may include the height of the
661 tool bar but not that of the menu bar (Lucid, Motif, MS-Windows) or
662 those of the menu bar and the tool bar (non-toolkit and text terminal
663 frames).
665 The native position of a frame is the reference position for functions
666 that set or return the current position of the mouse (@pxref{Mouse
667 Position}) and for functions dealing with the position of windows like
668 @code{window-edges}, @code{window-at} or @code{coordinates-in-window-p}
669 (@pxref{Coordinates and Windows}).  It also specifies the (0, 0) origin
670 for locating and positioning child frames within this frame
671 (@pxref{Child Frames}).
673 Note also that the native position of a frame usually remains unaltered
674 on its display when removing or adding the window manager decorations by
675 changing the frame's @code{override-redirect} or @code{undecorated}
676 parameter (@pxref{Management Parameters}).
678 @item Internal Border
679 The internal border is a border drawn by Emacs around the inner frame
680 (see below).  Its width is specified by the @code{internal-border-width}
681 frame parameter (@pxref{Layout Parameters}).  Its color is specified by
682 the background of the @code{internal-border} face.
684 @item Inner Frame
685 @cindex inner frame
686 @cindex inner edges
687 @cindex inner width
688 @cindex inner height
689 @cindex inner size
690 @cindex display area
691 The @dfn{inner frame} is the rectangle reserved for the frame's windows.
692 It's enclosed by the internal border which, however, is not part of the
693 inner frame.  Its edges are called the @dfn{inner edges} of the frame.
694 The @dfn{inner width} and @dfn{inner height} specify the @dfn{inner
695 size} of the rectangle.  The inner frame is sometimes also referred to
696 as the @dfn{display area} of the frame.
698 @cindex minibuffer-less frame
699 @cindex minibuffer-only frame
700 As a rule, the inner frame is subdivided into the frame's root window
701 (@pxref{Windows and Frames}) and the frame's minibuffer window
702 (@pxref{Minibuffer Windows}).  There are two notable exceptions to this
703 rule: A @dfn{minibuffer-less frame} contains a root window only and does
704 not contain a minibuffer window.  A @dfn{minibuffer-only frame} contains
705 only a minibuffer window which also serves as that frame's root window.
706 See @ref{Initial Parameters} for how to create such frame
707 configurations.
709 @item Text Area
710 @cindex text area
711 The @dfn{text area} of a frame is a somewhat fictitious area that can be
712 embedded in the native frame.  Its position is unspecified.  Its width
713 can be obtained by removing from that of the native width the widths of
714 the internal border, one vertical scroll bar, and one left and one right
715 fringe if they are specified for this frame, see @ref{Layout
716 Parameters}.  Its height can be obtained by removing from that of the
717 native height the widths of the internal border and the heights of the
718 frame's internal menu and tool bars and one horizontal scroll bar if
719 specified for this frame.
720 @end table
722 @cindex absolute position
723 @cindex absolute frame position
724 @cindex absolute edges
725 @cindex absolute frame edges
726 @cindex display origin
727 @cindex origin of display
728 The @dfn{absolute position} of a frame is given as a pair (X, Y) of
729 horizontal and vertical pixel offsets relative to an origin (0, 0) of
730 the frame's display.  Correspondingly, the @dfn{absolute edges} of a
731 frame are given as pixel offsets from that origin.
733   Note that with multiple monitors, the origin of the display does not
734 necessarily coincide with the top-left corner of the entire usable
735 display area of the terminal.  Hence the absolute position of a frame
736 can be negative in such an environment even when that frame is
737 completely visible.
739   By convention, vertical offsets increase ``downwards''.  This means
740 that the height of a frame is obtained by subtracting the offset of its
741 top edge from that of its bottom edge.  Horizontal offsets increase
742 ``rightwards'', as expected, so a frame's width is calculated by
743 subtracting the offset of its left edge from that of its right edge.
745   For a frame on a graphical terminal the following function returns the
746 sizes of the areas described above:
748 @defun frame-geometry &optional frame
749 This function returns geometric attributes of @var{frame}.  The return
750 value is an association list of the attributes listed below.  All
751 coordinate, height and width values are integers counting pixels.  Note
752 that if @var{frame} has not been mapped yet, (@pxref{Visibility of
753 Frames}) some of the return values may only represent approximations of
754 the actual values---those that can be seen after the frame has been
755 mapped.
757 @table @code
758 @item outer-position
759 A cons representing the absolute position of the outer @var{frame},
760 relative to the origin at position (0, 0) of @var{frame}'s display.
762 @item outer-size
763 A cons of the outer width and height of @var{frame}.
765 @item external-border-size
766 A cons of the horizontal and vertical width of @var{frame}'s external
767 borders as supplied by the window manager.  If the window manager
768 doesn't supply these values, Emacs will try to guess them from the
769 coordinates of the outer and inner frame.
771 @item outer-border-width
772 The width of the outer border of @var{frame}.  The value is meaningful
773 for non-GTK+ X builds only.
775 @item title-bar-size
776 A cons of the width and height of the title bar of @var{frame} as
777 supplied by the window manager or operating system.  If both of them are
778 zero, the frame has no title bar.  If only the width is zero, Emacs was
779 not able to retrieve the width information.
781 @item menu-bar-external
782 If non-@code{nil}, this means the menu bar is external (not part of the
783 native frame of @var{frame}).
785 @item menu-bar-size
786 A cons of the width and height of the menu bar of @var{frame}.
788 @item tool-bar-external
789 If non-@code{nil}, this means the tool bar is external (not part of the
790 native frame of @var{frame}).
792 @item tool-bar-position
793 This tells on which side the tool bar on @var{frame} is and can be one
794 of @code{left}, @code{top}, @code{right} or @code{bottom}.  The only
795 toolkit that currently supports a value other than @code{top} is GTK+.
797 @item tool-bar-size
798 A cons of the width and height of the tool bar of @var{frame}.
800 @item internal-border-width
801 The width of the internal border of @var{frame}.
802 @end table
803 @end defun
805 The following function can be used to retrieve the edges of the outer,
806 native and inner frame.
808 @defun frame-edges &optional frame type
809 This function returns the absolute edges of the outer, native or inner
810 frame of @var{frame}.  @var{frame} must be a live frame and defaults to
811 the selected one.  The returned list has the form @w{@code{(@var{left}
812 @var{top} @var{right} @var{bottom})}} where all values are in pixels
813 relative to the origin of @var{frame}'s display.  For terminal frames
814 the values returned for @var{left} and @var{top} are always zero.
816 Optional argument @var{type} specifies the type of the edges to return:
817 @code{outer-edges} means to return the outer edges of @var{frame},
818 @code{native-edges} (or @code{nil}) means to return its native edges and
819 @code{inner-edges} means to return its inner edges.
821 By convention, the pixels of the display at the values returned for
822 @var{left} and @var{top} are considered to be inside (part of)
823 @var{frame}.  Hence, if @var{left} and @var{top} are both zero, the
824 pixel at the display's origin is part of @var{frame}.  The pixels at
825 @var{bottom} and @var{right}, on the other hand, are considered to lie
826 immediately outside @var{frame}.  This means that if you have, for
827 example, two side-by-side frames positioned such that the right outer
828 edge of the frame on the left equals the left outer edge of the frame on
829 the right, the pixels at that edge show a part of the frame on the
830 right.
831 @end defun
834 @node Frame Font
835 @subsection Frame Font
836 @cindex default font
837 @cindex default character size
838 @cindex default character width
839 @cindex default width of character
840 @cindex default character height
841 @cindex default height of character
842 Each frame has a @dfn{default font} which specifies the default
843 character size for that frame.  This size is meant when retrieving or
844 changing the size of a frame in terms of columns or lines
845 (@pxref{Size Parameters}).  It is also used when resizing (@pxref{Window
846 Sizes}) or splitting (@pxref{Splitting Windows}) windows.
848 @cindex line height
849 @cindex column width
850 @cindex canonical character height
851 @cindex canonical character width
852 The terms @dfn{line height} and @dfn{canonical character height} are
853 sometimes used instead of ``default character height''.  Similarly, the
854 terms @dfn{column width} and @dfn{canonical character width} are used
855 instead of ``default character width''.
857 @defun frame-char-height &optional frame
858 @defunx frame-char-width &optional frame
859 These functions return the default height and width of a character in
860 @var{frame}, measured in pixels.  Together, these values establish the
861 size of the default font on @var{frame}.  The values depend on the
862 choice of font for @var{frame}, see @ref{Font and Color Parameters}.
863 @end defun
865 The default font can be also set directly with the following function:
867 @deffn Command set-frame-font font &optional keep-size frames
868 This sets the default font to @var{font}.  When called interactively, it
869 prompts for the name of a font, and uses that font on the selected
870 frame.  When called from Lisp, @var{font} should be a font name (a
871 string), a font object, font entity, or a font spec.
873 If the optional argument @var{keep-size} is @code{nil}, this keeps the
874 number of frame lines and columns fixed.  (If non-@code{nil}, the option
875 @code{frame-inhibit-implied-resize} described in the next section will
876 override this.)  If @var{keep-size} is non-@code{nil} (or with a prefix
877 argument), it tries to keep the size of the display area of the current
878 frame fixed by adjusting the number of lines and columns.
880 If the optional argument @var{frames} is @code{nil}, this applies the
881 font to the selected frame only.  If @var{frames} is non-@code{nil}, it
882 should be a list of frames to act upon, or @code{t} meaning all existing
883 and all future graphical frames.
884 @end deffn
887 @node Frame Position
888 @subsection Frame Position
889 @cindex frame position
890 @cindex position of frame
892 On graphical systems, the position of a normal top-level frame is
893 specified as the absolute position of its outer frame (@pxref{Frame
894 Geometry}).  The position of a child frame (@pxref{Child Frames}) is
895 specified via pixel offsets of its outer edges relative to the native
896 position of its parent frame.
898   You can access or change the position of a frame using the frame
899 parameters @code{left} and @code{top} (@pxref{Position Parameters}).
900 Here are two additional functions for working with the positions of an
901 existing, visible frame.  For both functions, the argument @var{frame}
902 must denote a live frame and defaults to the selected frame.
904 @defun frame-position &optional frame
905 For a normal, non-child frame this function returns a cons of the pixel
906 coordinates of its outer position (@pxref{Frame Layout}) with respect to
907 the origin @code{(0, 0)} of its display.  For a child frame
908 (@pxref{Child Frames}) this function returns the pixel coordinates of
909 its outer position with respect to an origin @code{(0, 0)} at the native
910 position of @var{frame}'s parent.
912 Negative values never indicate an offset from the right or bottom
913 edge of @var{frame}'s display or parent frame.  Rather, they mean that
914 @var{frame}'s outer position is on the left and/or above the origin of
915 its display or the native position of its parent frame.  This usually
916 means that @var{frame} is only partially visible (or completely
917 invisible).  However, on systems where the display's origin does not
918 coincide with its top-left corner, the frame may be visible on a
919 secondary monitor.
921 On a text terminal frame both values are zero.
922 @end defun
924 @defun set-frame-position frame x y
925 This function sets the outer frame position of @var{frame} to (@var{x},
926 @var{y}).  The latter arguments specify pixels and normally count from
927 the origin at the position (0, 0) of @var{frame}'s display.  For child
928 frames, they count from the native position of @var{frame}'s parent
929 frame.
931 Negative parameter values position the right edge of the outer frame by
932 @var{-x} pixels left from the right edge of the screen (or the parent
933 frame's native rectangle) and the bottom edge by @var{-y} pixels up from
934 the bottom edge of the screen (or the parent frame's native rectangle).
936 Note that negative values do not permit to align the right or bottom
937 edge of @var{frame} exactly at the right or bottom edge of its display
938 or parent frame.  Neither do they allow to specify a position that does
939 not lie within the edges of the display or parent frame.  The frame
940 parameters @code{left} and @code{top} (@pxref{Position Parameters})
941 allow to do that, but may still fail to provide good results for the
942 initial or a new frame.
944 This function has no effect on text terminal frames.
945 @end defun
947 @defvar move-frame-functions
948 @cindex frame position changes, a hook
949 This hook specifies the functions that are run when an Emacs frame is moved
950 (assigned a new position) by the window-system or window manager.  The
951 functions are run with one argument, the frame that moved.  For a child
952 frame (@pxref{Child Frames}), the functions are run only when the
953 position of the frame changes in relation to that of its parent frame.
954 @end defvar
957 @node Frame Size
958 @subsection Frame Size
959 @cindex frame size
960 @cindex text width of a frame
961 @cindex text height of a frame
962 @cindex text size of a frame
963 The canonical way to specify the @dfn{size of a frame} from within Emacs
964 is by specifying its @dfn{text size}---a tuple of the width and height
965 of the frame's text area (@pxref{Frame Layout}).  It can be measured
966 either in pixels or in terms of the frame's canonical character size
967 (@pxref{Frame Font}).
969   For frames with an internal menu or tool bar, the frame's native
970 height cannot be told exactly before the frame has been actually drawn.
971 This means that in general you cannot use the native size to specify the
972 initial size of a frame.  As soon as you know the native size of a
973 visible frame, you can calculate its outer size (@pxref{Frame Layout})
974 by adding in the remaining components from the return value of
975 @code{frame-geometry}.  For invisible frames or for frames that have
976 yet to be created, however, the outer size can only be estimated.  This
977 also means that calculating an exact initial position of a frame
978 specified via offsets from the right or bottom edge of the screen
979 (@pxref{Frame Position}) is impossible.
981   The text size of any frame can be set and retrieved with the help of
982 the @code{height} and @code{width} frame parameters (@pxref{Size
983 Parameters}).  The text size of the initial frame can be also set with
984 the help of an X-style geometry specification.  @xref{Emacs Invocation,,
985 Command Line Arguments for Emacs Invocation, emacs, The GNU Emacs
986 Manual}.  Below we list some functions to access and set the size of an
987 existing, visible frame, by default the selected one.
989 @defun frame-height &optional frame
990 @defunx frame-width &optional frame
991 These functions return the height and width of the text area of
992 @var{frame}, measured in units of the default font height and width of
993 @var{frame} (@pxref{Frame Font}).  These functions are plain shorthands
994 for writing @code{(frame-parameter frame 'height)} and
995 @code{(frame-parameter frame 'width)}.
997 If the text area of @var{frame} measured in pixels is not a multiple of
998 its default font size, the values returned by these functions are
999 rounded down to the number of characters of the default font that fully
1000 fit into the text area.
1001 @end defun
1003 The functions following next return the pixel widths and heights of the
1004 native, outer and inner frame and the text area (@pxref{Frame Layout})
1005 of a given frame.  For a text terminal, the results are in characters
1006 rather than pixels.
1008 @defun frame-outer-width &optional frame
1009 @defunx frame-outer-height &optional frame
1010 These functions return the outer width and height of @var{frame} in
1011 pixels.
1012 @end defun
1014 @defun frame-native-height &optional frame
1015 @defunx frame-native-width &optional frame
1016 These functions return the native width and height of @var{frame} in
1017 pixels.
1018 @end defun
1020 @defun frame-inner-width &optional frame
1021 @defunx frame-inner-height &optional frame
1022 These functions return the inner width and height of @var{frame} in
1023 pixels.
1024 @end defun
1026 @defun frame-text-width &optional frame
1027 @defunx frame-text-height &optional frame
1028 These functions return the width and height of the text area of
1029 @var{frame} in pixels.
1030 @end defun
1032 On window systems that support it, Emacs tries by default to make the
1033 text size of a frame measured in pixels a multiple of the frame's
1034 character size.  This, however, usually means that a frame can be
1035 resized only in character size increments when dragging its external
1036 borders.  It also may break attempts to truly maximize the frame or
1037 making it ``fullheight'' or ``fullwidth'' (@pxref{Size Parameters})
1038 leaving some empty space below and/or on the right of the frame.  The
1039 following option may help in that case.
1041 @defopt frame-resize-pixelwise
1042 If this option is @code{nil} (the default), a frame's text pixel size is
1043 usually rounded to a multiple of the current values of that frame's
1044 @code{frame-char-height} and @code{frame-char-width} whenever the frame
1045 is resized.  If this is non-@code{nil}, no rounding occurs, hence frame
1046 sizes can increase/decrease by one pixel.
1048 Setting this variable usually causes the next resize operation to pass
1049 the corresponding size hints to the window manager.  This means that
1050 this variable should be set only in a user's initial file; applications
1051 should never bind it temporarily.
1053 The precise meaning of a value of @code{nil} for this option depends on
1054 the toolkit used.  Dragging the external border with the mouse is done
1055 character-wise provided the window manager is willing to process the
1056 corresponding size hints.  Calling @code{set-frame-size} (see below)
1057 with arguments that do not specify the frame size as an integer multiple
1058 of its character size, however, may: be ignored, cause a rounding
1059 (GTK+), or be accepted (Lucid, Motif, MS-Windows).
1061 With some window managers you may have to set this to non-@code{nil} in
1062 order to make a frame appear truly maximized or full-screen.
1063 @end defopt
1065 @defun set-frame-size frame width height &optional pixelwise
1066 This function sets the size of the text area of @var{frame}, measured in
1067 terms of the canonical height and width of a character on @var{frame}
1068 (@pxref{Frame Font}).
1070 The optional argument @var{pixelwise} non-@code{nil} means to measure
1071 the new width and height in units of pixels instead.  Note that if
1072 @code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
1073 truly honor the request if it does not increase/decrease the frame size
1074 to a multiple of its character size.
1075 @end defun
1077 @defun set-frame-height frame height &optional pretend pixelwise
1078 This function resizes the text area of @var{frame} to a height of
1079 @var{height} lines.  The sizes of existing windows in @var{frame} are
1080 altered proportionally to fit.
1082 If @var{pretend} is non-@code{nil}, then Emacs displays @var{height}
1083 lines of output in @var{frame}, but does not change its value for the
1084 actual height of the frame.  This is only useful on text terminals.
1085 Using a smaller height than the terminal actually implements may be
1086 useful to reproduce behavior observed on a smaller screen, or if the
1087 terminal malfunctions when using its whole screen.  Setting the frame
1088 height directly does not always work, because knowing the correct
1089 actual size may be necessary for correct cursor positioning on
1090 text terminals.
1092 The optional fourth argument @var{pixelwise} non-@code{nil} means that
1093 @var{frame} should be @var{height} pixels high.  Note that if
1094 @code{frame-resize-pixelwise} is @code{nil}, some window managers may
1095 refuse to truly honor the request if it does not increase/decrease the
1096 frame height to a multiple of its character height.
1097 @end defun
1099 @defun set-frame-width frame width &optional pretend pixelwise
1100 This function sets the width of the text area of @var{frame}, measured
1101 in characters.  The argument @var{pretend} has the same meaning as in
1102 @code{set-frame-height}.
1104 The optional fourth argument @var{pixelwise} non-@code{nil} means that
1105 @var{frame} should be @var{width} pixels wide.  Note that if
1106 @code{frame-resize-pixelwise} is @code{nil}, some window managers may
1107 refuse to fully honor the request if it does not increase/decrease the
1108 frame width to a multiple of its character width.
1109 @end defun
1111 None of these three functions will make a frame smaller than needed to
1112 display all of its windows together with their scroll bars, fringes,
1113 margins, dividers, mode and header lines.  This contrasts with requests
1114 by the window manager triggered, for example, by dragging the external
1115 border of a frame with the mouse.  Such requests are always honored by
1116 clipping, if necessary, portions that cannot be displayed at the right,
1117 bottom corner of the frame.  The parameters @code{min-width} and
1118 @code{min-height} (@pxref{Size Parameters}) can be used to obtain a
1119 similar behavior when changing the frame size from within Emacs.
1121 @cindex tracking frame size changes
1122   The abnormal hook @code{window-size-change-functions} (@pxref{Window
1123 Hooks}) tracks all changes of the inner size of a frame including those
1124 induced by request of the window-system or window manager.  To rule out
1125 false positives that might occur when changing only the sizes of a
1126 frame's windows without actually changing the size of the inner frame,
1127 use the following function.
1129 @defun frame-size-changed-p &optional frame
1130 This function returns non-@code{nil} when the inner width or height of
1131 @var{frame} has changed since @code{window-size-change-functions} was
1132 run the last time for @var{frame}.  It always returns @code{nil}
1133 immediately after running @code{window-size-change-functions} for
1134 @var{frame}.
1135 @end defun
1138 @node Implied Frame Resizing
1139 @subsection Implied Frame Resizing
1140 @cindex implied frame resizing
1141 @cindex implied resizing of frame
1143 By default, Emacs tries to keep the number of lines and columns of a
1144 frame's text area unaltered when, for example, adding or removing the
1145 menu bar, changing the default font or setting the width of the frame's
1146 scroll bars.  This means, however, that in such case Emacs must ask the
1147 window manager to resize the outer frame in order to accommodate the
1148 size change.  Note that wrapping a menu or tool bar usually does not
1149 resize the frame's outer size, hence this will alter the number of
1150 displayed lines.
1152   Occasionally, such @dfn{implied frame resizing} may be unwanted, for
1153 example, when the frame is maximized or made full-screen (where it's
1154 turned off by default).  In other cases you can disable implied resizing
1155 with the following option:
1157 @defopt frame-inhibit-implied-resize
1158 If this option is @code{nil}, changing font, menu bar, tool bar,
1159 internal borders, fringes or scroll bars of a specific frame may
1160 implicitly resize the frame's display area in order to preserve the
1161 number of columns or lines the frame displays.  If this option is
1162 non-@code{nil}, no implied resizing is done.
1164 The value of this option can be also a list of frame parameters.  In
1165 that case, implied resizing is inhibited when changing a parameter that
1166 appears in this list.  The frame parameters currently handled by this
1167 option are: @code{font}, @code{font-backend},
1168 @code{internal-border-width}, @code{menu-bar-lines} and
1169 @code{tool-bar-lines}.
1171 Changing any of the @code{scroll-bar-width}, @code{scroll-bar-height},
1172 @code{vertical-scroll-bars}, @code{horizontal-scroll-bars},
1173 @code{left-fringe} and @code{right-fringe} frame parameters is handled
1174 as if the frame contained just one live window.  This means, for
1175 example, that removing vertical scroll bars on a frame containing
1176 several side by side windows will shrink the outer frame width by the
1177 width of one scroll bar provided this option is @code{nil} and keep it
1178 unchanged if this option is either @code{t} or a list containing
1179 @code{vertical-scroll-bars}.
1181 The default value is @code{'(tool-bar-lines)} for Lucid, Motif and
1182 MS-Windows (which means that adding/removing a tool bar there does not
1183 change the outer frame height), @code{nil} on all other window systems
1184 including GTK+ (which means that changing any of the parameters listed
1185 above may change the size of the outer frame), and @code{t} otherwise
1186 (which means the outer frame size never changes implicitly when there's
1187 no window system support).
1189 Note that when a frame is not large enough to accommodate a change of
1190 any of the parameters listed above, Emacs may try to enlarge the frame
1191 even if this option is non-@code{nil}.
1192 @end defopt
1195 @node Frame Parameters
1196 @section Frame Parameters
1197 @cindex frame parameters
1199   A frame has many parameters that control its appearance and behavior.
1200 Just what parameters a frame has depends on what display mechanism it
1201 uses.
1203   Frame parameters exist mostly for the sake of graphical displays.
1204 Most frame parameters have no effect when applied to a frame on a text
1205 terminal; only the @code{height}, @code{width}, @code{name},
1206 @code{title}, @code{menu-bar-lines}, @code{buffer-list} and
1207 @code{buffer-predicate} parameters do something special.  If the
1208 terminal supports colors, the parameters @code{foreground-color},
1209 @code{background-color}, @code{background-mode} and
1210 @code{display-type} are also meaningful.  If the terminal supports
1211 frame transparency, the parameter @code{alpha} is also meaningful.
1213   By default, frame parameters are saved and restored by the desktop
1214 library functions (@pxref{Desktop Save Mode}) when the variable
1215 @code{desktop-restore-frames} is non-@code{nil}.  It's the
1216 responsibility of applications that their parameters are included in
1217 @code{frameset-persistent-filter-alist} to avoid that they get
1218 meaningless or even harmful values in restored sessions.
1220 @menu
1221 * Parameter Access::       How to change a frame's parameters.
1222 * Initial Parameters::     Specifying frame parameters when you make a frame.
1223 * Window Frame Parameters:: List of frame parameters for window systems.
1224 * Geometry::               Parsing geometry specifications.
1225 @end menu
1227 @node Parameter Access
1228 @subsection Access to Frame Parameters
1230 These functions let you read and change the parameter values of a
1231 frame.
1233 @defun frame-parameter frame parameter
1234 This function returns the value of the parameter @var{parameter} (a
1235 symbol) of @var{frame}.  If @var{frame} is @code{nil}, it returns the
1236 selected frame's parameter.  If @var{frame} has no setting for
1237 @var{parameter}, this function returns @code{nil}.
1238 @end defun
1240 @defun frame-parameters &optional frame
1241 The function @code{frame-parameters} returns an alist listing all the
1242 parameters of @var{frame} and their values.  If @var{frame} is
1243 @code{nil} or omitted, this returns the selected frame's parameters
1244 @end defun
1246 @defun modify-frame-parameters frame alist
1247 This function alters the frame @var{frame} based on the elements of
1248 @var{alist}.  Each element of @var{alist} has the form
1249 @code{(@var{parm} . @var{value})}, where @var{parm} is a symbol naming
1250 a parameter.  If you don't mention a parameter in @var{alist}, its
1251 value doesn't change.  If @var{frame} is @code{nil}, it defaults to
1252 the selected frame.
1254 Some parameters are only meaningful for frames on certain kinds of
1255 display (@pxref{Frames}).  If @var{alist} includes parameters that are
1256 not meaningful for the @var{frame}'s display, this function will
1257 change its value in the frame's parameter list, but will otherwise
1258 ignore it.
1260 When @var{alist} specifies more than one parameter whose value can
1261 affect the new size of @var{frame}, the final size of the frame may
1262 differ according to the toolkit used.  For example, specifying that a
1263 frame should from now on have a menu and/or tool bar instead of none and
1264 simultaneously specifying the new height of the frame will inevitably
1265 lead to a recalculation of the frame's height.  Conceptually, in such
1266 case, this function will try to have the explicit height specification
1267 prevail.  It cannot be excluded, however, that the addition (or removal)
1268 of the menu or tool bar, when eventually performed by the toolkit, will
1269 defeat this intention.
1271 Sometimes, binding @code{frame-inhibit-implied-resize} (@pxref{Implied
1272 Frame Resizing}) to a non-@code{nil} value around calls to this function
1273 may fix the problem sketched here.  Sometimes, however, exactly such
1274 binding may be hit by the problem.
1275 @end defun
1277 @defun set-frame-parameter frame parm value
1278 This function sets the frame parameter @var{parm} to the specified
1279 @var{value}.  If @var{frame} is @code{nil}, it defaults to the selected
1280 frame.
1281 @end defun
1283 @defun modify-all-frames-parameters alist
1284 This function alters the frame parameters of all existing frames
1285 according to @var{alist}, then modifies @code{default-frame-alist}
1286 (and, if necessary, @code{initial-frame-alist}) to apply the same
1287 parameter values to frames that will be created henceforth.
1288 @end defun
1290 @node Initial Parameters
1291 @subsection Initial Frame Parameters
1292 @cindex parameters of initial frame
1294 You can specify the parameters for the initial startup frame by
1295 setting @code{initial-frame-alist} in your init file (@pxref{Init
1296 File}).
1298 @defopt initial-frame-alist
1299 This variable's value is an alist of parameter values used when
1300 creating the initial frame.  You can set this variable to specify the
1301 appearance of the initial frame without altering subsequent frames.
1302 Each element has the form:
1304 @example
1305 (@var{parameter} . @var{value})
1306 @end example
1308 Emacs creates the initial frame before it reads your init
1309 file.  After reading that file, Emacs checks @code{initial-frame-alist},
1310 and applies the parameter settings in the altered value to the already
1311 created initial frame.
1313 If these settings affect the frame geometry and appearance, you'll see
1314 the frame appear with the wrong ones and then change to the specified
1315 ones.  If that bothers you, you can specify the same geometry and
1316 appearance with X resources; those do take effect before the frame is
1317 created.  @xref{X Resources,, X Resources, emacs, The GNU Emacs Manual}.
1319 X resource settings typically apply to all frames.  If you want to
1320 specify some X resources solely for the sake of the initial frame, and
1321 you don't want them to apply to subsequent frames, here's how to achieve
1322 this.  Specify parameters in @code{default-frame-alist} to override the
1323 X resources for subsequent frames; then, to prevent these from affecting
1324 the initial frame, specify the same parameters in
1325 @code{initial-frame-alist} with values that match the X resources.
1326 @end defopt
1328 @cindex minibuffer-only frame
1329 If these parameters include @code{(minibuffer . nil)}, that indicates
1330 that the initial frame should have no minibuffer.  In this case, Emacs
1331 creates a separate @dfn{minibuffer-only frame} as well.
1333 @defopt minibuffer-frame-alist
1334 This variable's value is an alist of parameter values used when
1335 creating an initial minibuffer-only frame (i.e., the minibuffer-only
1336 frame that Emacs creates if @code{initial-frame-alist} specifies a
1337 frame with no minibuffer).
1338 @end defopt
1340 @defopt default-frame-alist
1341 This is an alist specifying default values of frame parameters for all
1342 Emacs frames---the first frame, and subsequent frames.  When using the X
1343 Window System, you can get the same results by means of X resources
1344 in many cases.
1346 Setting this variable does not affect existing frames.  Furthermore,
1347 functions that display a buffer in a separate frame may override the
1348 default parameters by supplying their own parameters.
1349 @end defopt
1351 If you invoke Emacs with command-line options that specify frame
1352 appearance, those options take effect by adding elements to either
1353 @code{initial-frame-alist} or @code{default-frame-alist}.  Options
1354 which affect just the initial frame, such as @samp{--geometry} and
1355 @samp{--maximized}, add to @code{initial-frame-alist}; the others add
1356 to @code{default-frame-alist}.  @pxref{Emacs Invocation,, Command Line
1357 Arguments for Emacs Invocation, emacs, The GNU Emacs Manual}.
1359 @node Window Frame Parameters
1360 @subsection Window Frame Parameters
1361 @cindex frame parameters for windowed displays
1363   Just what parameters a frame has depends on what display mechanism
1364 it uses.  This section describes the parameters that have special
1365 meanings on some or all kinds of terminals.  Of these, @code{name},
1366 @code{title}, @code{height}, @code{width}, @code{buffer-list} and
1367 @code{buffer-predicate} provide meaningful information in terminal
1368 frames, and @code{tty-color-mode} is meaningful only for frames on
1369 text terminals.
1371 @menu
1372 * Basic Parameters::            Parameters that are fundamental.
1373 * Position Parameters::         The position of the frame on the screen.
1374 * Size Parameters::             Frame's size.
1375 * Layout Parameters::           Size of parts of the frame, and
1376                                   enabling or disabling some parts.
1377 * Buffer Parameters::           Which buffers have been or should be shown.
1378 * Frame Interaction Parameters::  Parameters for interacting with other
1379                                   frames.
1380 * Mouse Dragging Parameters::   Parameters for resizing and moving
1381                                   frames with the mouse.
1382 * Management Parameters::       Communicating with the window manager.
1383 * Cursor Parameters::           Controlling the cursor appearance.
1384 * Font and Color Parameters::   Fonts and colors for the frame text.
1385 @end menu
1387 @node Basic Parameters
1388 @subsubsection Basic Parameters
1390   These frame parameters give the most basic information about the
1391 frame.  @code{title} and @code{name} are meaningful on all terminals.
1393 @table @code
1394 @vindex display@r{, a frame parameter}
1395 @item display
1396 The display on which to open this frame.  It should be a string of the
1397 form @samp{@var{host}:@var{dpy}.@var{screen}}, just like the
1398 @env{DISPLAY} environment variable.  @xref{Multiple Terminals}, for
1399 more details about display names.
1401 @vindex display-type@r{, a frame parameter}
1402 @item display-type
1403 This parameter describes the range of possible colors that can be used
1404 in this frame.  Its value is @code{color}, @code{grayscale} or
1405 @code{mono}.
1407 @vindex title@r{, a frame parameter}
1408 @item title
1409 If a frame has a non-@code{nil} title, it appears in the window
1410 system's title bar at the top of the frame, and also in the mode line
1411 of windows in that frame if @code{mode-line-frame-identification} uses
1412 @samp{%F} (@pxref{%-Constructs}).  This is normally the case when
1413 Emacs is not using a window system, and can only display one frame at
1414 a time.  @xref{Frame Titles}.
1416 @vindex name@r{, a frame parameter}
1417 @item name
1418 The name of the frame.  The frame name serves as a default for the frame
1419 title, if the @code{title} parameter is unspecified or @code{nil}.  If
1420 you don't specify a name, Emacs sets the frame name automatically
1421 (@pxref{Frame Titles}).
1423 If you specify the frame name explicitly when you create the frame, the
1424 name is also used (instead of the name of the Emacs executable) when
1425 looking up X resources for the frame.
1427 @vindex explicit-name@r{, a frame parameter}
1428 @item explicit-name
1429 If the frame name was specified explicitly when the frame was created,
1430 this parameter will be that name.  If the frame wasn't explicitly
1431 named, this parameter will be @code{nil}.
1432 @end table
1435 @node Position Parameters
1436 @subsubsection Position Parameters
1437 @cindex window position on display
1438 @cindex frame position
1440 Parameters describing the X- and Y-offsets of a frame are always
1441 measured in pixels.  For a normal, non-child frame they specify the
1442 frame's outer position (@pxref{Frame Geometry}) relative to its
1443 display's origin.  For a child frame (@pxref{Child Frames}) they specify
1444 the frame's outer position relative to the native position of the
1445 frame's parent frame.  (Note that none of these parameters is meaningful
1446 on TTY frames.)
1448 @table @code
1449 @vindex left@r{, a frame parameter}
1450 @item left
1451 The position, in pixels, of the left outer edge of the frame with
1452 respect to the left edge of the frame's display or parent frame.  It can
1453 be specified in one of the following ways.
1455 @table @asis
1456 @item an integer
1457 A positive integer always relates the left edge of the frame to the left
1458 edge of its display or parent frame.  A negative integer relates the
1459 right frame edge to the right edge of the display or parent frame.
1461 @item @code{(+ @var{pos})}
1462 This specifies the position of the left frame edge relative to the left
1463 edge of its display or parent frame.  The integer @var{pos} may be
1464 positive or negative; a negative value specifies a position outside the
1465 screen or parent frame or on a monitor other than the primary one (for
1466 multi-monitor displays).
1468 @item @code{(- @var{pos})}
1469 This specifies the position of the right frame edge relative to the
1470 right edge of the display or parent frame.  The integer @var{pos} may be
1471 positive or negative; a negative value specifies a position outside the
1472 screen or parent frame or on a monitor other than the primary one (for
1473 multi-monitor displays).
1475 @cindex left position ratio
1476 @cindex top position ratio
1477 @item a floating-point value
1478 A floating-point value in the range 0.0 to 1.0 specifies the left edge's
1479 offset via the @dfn{left position ratio} of the frame---the ratio of the
1480 left edge of its outer frame to the width of the frame's workarea
1481 (@pxref{Multiple Terminals}) or its parent's native frame (@pxref{Child
1482 Frames}) minus the width of the outer frame.  Thus, a left position
1483 ratio of 0.0 flushes a frame to the left, a ratio of 0.5 centers it and
1484 a ratio of 1.0 flushes it to the right of its display or parent frame.
1485 Similarly, the @dfn{top position ratio} of a frame is the ratio of the
1486 frame's top position to the height of its workarea or parent frame minus
1487 the height of the frame.
1489 Emacs will try to keep the position ratios of a child frame unaltered if
1490 that frame has a non-@code{nil} @code{keep-ratio} parameter
1491 (@pxref{Frame Interaction Parameters}) and its parent frame is resized.
1493 Since the outer size of a frame (@pxref{Frame Geometry}) is usually
1494 unavailable before a frame has been made visible, it is generally not
1495 advisable to use floating-point values when creating decorated frames.
1496 Floating-point values are more suited for ensuring that an (undecorated)
1497 child frame is positioned nicely within the area of its parent frame.
1498 @end table
1500 Some window managers ignore program-specified positions.  If you want to
1501 be sure the position you specify is not ignored, specify a
1502 non-@code{nil} value for the @code{user-position} parameter as in the
1503 following example:
1505 @example
1506 (modify-frame-parameters
1507   nil '((user-position . t) (left . (+ -4))))
1508 @end example
1510 In general, it is not a good idea to position a frame relative to the
1511 right or bottom edge of its display.  Positioning the initial or a new
1512 frame is either not accurate (because the size of the outer frame is not
1513 yet fully known before the frame has been made visible) or will cause
1514 additional flicker (if the frame has to be repositioned after becoming
1515 visible).
1517   Note also, that positions specified relative to the right/bottom edge
1518 of a display, workarea or parent frame as well as floating-point offsets
1519 are stored internally as integer offsets relative to the left/top edge
1520 of the display, workarea or parent frame edge.  They are also returned
1521 as such by functions like @code{frame-parameters} and restored as such
1522 by the desktop saving routines.
1524 @vindex top@r{, a frame parameter}
1525 @item top
1526 The screen position of the top (or bottom) edge, in pixels, with respect
1527 to the top (or bottom) edge of the display or parent frame.  It works
1528 just like @code{left}, except vertically instead of horizontally.
1530 @vindex icon-left@r{, a frame parameter}
1531 @item icon-left
1532 The screen position of the left edge of the frame's icon, in pixels,
1533 counting from the left edge of the screen.  This takes effect when the
1534 frame is iconified, if the window manager supports this feature.  If
1535 you specify a value for this parameter, then you must also specify a
1536 value for @code{icon-top} and vice versa.
1538 @vindex icon-top@r{, a frame parameter}
1539 @item icon-top
1540 The screen position of the top edge of the frame's icon, in pixels,
1541 counting from the top edge of the screen.  This takes effect when the
1542 frame is iconified, if the window manager supports this feature.
1544 @vindex user-position@r{, a frame parameter}
1545 @item user-position
1546 When you create a frame and specify its screen position with the
1547 @code{left} and @code{top} parameters, use this parameter to say whether
1548 the specified position was user-specified (explicitly requested in some
1549 way by a human user) or merely program-specified (chosen by a program).
1550 A non-@code{nil} value says the position was user-specified.
1552 @cindex window positions and window managers
1553 Window managers generally heed user-specified positions, and some heed
1554 program-specified positions too.  But many ignore program-specified
1555 positions, placing the window in a default fashion or letting the user
1556 place it with the mouse.  Some window managers, including @code{twm},
1557 let the user specify whether to obey program-specified positions or
1558 ignore them.
1560 When you call @code{make-frame}, you should specify a non-@code{nil}
1561 value for this parameter if the values of the @code{left} and @code{top}
1562 parameters represent the user's stated preference; otherwise, use
1563 @code{nil}.
1565 @vindex z-group@r{, a frame parameter}
1566 @item z-group
1567 This parameter specifies a relative position of the frame's
1568 window-system window in the stacking (Z-) order of the frame's display.
1570 If this is @code{above}, the frame's window-system window is displayed
1571 above all other window-system windows that do not have the @code{above}
1572 property set.  If this is @code{nil}, the frame's window is displayed below all
1573 windows that have the @code{above} property set and above all windows
1574 that have the @code{below} property set.  If this is @code{below}, the
1575 frame's window is displayed below all windows that do not have the
1576 @code{below} property set.
1578 To position the frame above or below a specific other frame use the
1579 function @code{frame-restack} (@pxref{Raising and Lowering}).
1580 @end table
1583 @node Size Parameters
1584 @subsubsection Size Parameters
1585 @cindex window size on display
1587 Frame parameters usually specify frame sizes in character units.  On
1588 graphical displays, the @code{default} face determines the actual pixel
1589 sizes of these character units (@pxref{Face Attributes}).
1591 @table @code
1592 @vindex width@r{, a frame parameter}
1593 @item width
1594 This parameter specifies the width of the frame.  It can be specified as
1595 in the following ways:
1597 @table @asis
1598 @item an integer
1599 A positive integer specifies the width of the frame's text area
1600 (@pxref{Frame Geometry}) in characters.
1602 @item a cons cell
1603 If this is a cons cell with the symbol @code{text-pixels} in its
1604 @sc{car}, the @sc{cdr} of that cell specifies the width of the frame's
1605 text area in pixels.
1607 @cindex frame width ratio
1608 @cindex frame height ratio
1609 @item a floating-point value
1610 A floating-point number between 0.0 and 1.0 can be used to specify the
1611 width of a frame via its @dfn{width ratio}---the ratio of its outer
1612 width (@pxref{Frame Geometry}) to the width of the frame's workarea
1613 (@pxref{Multiple Terminals}) or its parent frame's (@pxref{Child
1614 Frames}) native frame.  Thus, a value of 0.5 makes the frame occupy half
1615 of the width of its workarea or parent frame, a value of 1.0 the full
1616 width.  Similarly, the @dfn{height ratio} of a frame is the ratio of its
1617 outer height to the height of its workarea or its parent's native frame.
1619 Emacs will try to keep the width and height ratio of a child frame
1620 unaltered if that frame has a non-@code{nil} @code{keep-ratio} parameter
1621 (@pxref{Frame Interaction Parameters}) and its parent frame is resized.
1623 Since the outer size of a frame is usually unavailable before a frame
1624 has been made visible, it is generally not advisable to use
1625 floating-point values when creating decorated frames.  Floating-point
1626 values are more suited to ensure that a child frame always fits within
1627 the area of its parent frame as, for example, when customizing
1628 @code{display-buffer-alist} (@pxref{Choosing Window}) via
1629 @code{display-buffer-in-child-frame}.
1630 @end table
1632 Regardless of how this parameter was specified, functions reporting the
1633 value of this parameter like @code{frame-parameters} always report the
1634 width of the frame's text area in characters as an integer rounded, if
1635 necessary, to a multiple of the frame's default character width.  That
1636 value is also used by the desktop saving routines.
1638 @vindex height@r{, a frame parameter}
1639 @item height
1640 This parameter specifies the height of the frame.  It works just like
1641 @code{width}, except vertically instead of horizontally.
1643 @vindex user-size@r{, a frame parameter}
1644 @item user-size
1645 This does for the size parameters @code{height} and @code{width} what
1646 the @code{user-position} parameter (@pxref{Position Parameters,
1647 user-position}) does for the position parameters @code{top} and
1648 @code{left}.
1650 @vindex min-width@r{, a frame parameter}
1651 @item min-width
1652 This parameter specifies the minimum native width (@pxref{Frame
1653 Geometry}) of the frame, in characters.  Normally, the functions that
1654 establish a frame's initial width or resize a frame horizontally make
1655 sure that all the frame's windows, vertical scroll bars, fringes,
1656 margins and vertical dividers can be displayed.  This parameter, if
1657 non-@code{nil} allows to make a frame narrower than that with the
1658 consequence that any components that do not fit will be clipped by the
1659 window manager.
1661 @vindex min-height@r{, a frame parameter}
1662 @item min-height
1663 This parameter specifies the minimum native height (@pxref{Frame
1664 Geometry}) of the frame, in characters.  Normally, the functions that
1665 establish a frame's initial size or resize a frame make sure that all
1666 the frame's windows, horizontal scroll bars and dividers, mode and
1667 header lines, the echo area and the internal menu and tool bar can be
1668 displayed.  This parameter, if non-@code{nil} allows to make a frame
1669 smaller than that with the consequence that any components that do not
1670 fit will be clipped by the window manager.
1672 @cindex fullboth frames
1673 @cindex fullheight frames
1674 @cindex fullwidth frames
1675 @cindex maximized frames
1676 @vindex fullscreen@r{, a frame parameter}
1677 @item fullscreen
1678 This parameter specifies whether to maximize the frame's width, height
1679 or both.  Its value can be @code{fullwidth}, @code{fullheight},
1680 @code{fullboth}, or @code{maximized}.  A @dfn{fullwidth} frame is as
1681 wide as possible, a @dfn{fullheight} frame is as tall as possible, and
1682 a @dfn{fullboth} frame is both as wide and as tall as possible.  A
1683 @dfn{maximized} frame is like a ``fullboth'' frame, except that it usually
1684 keeps its title bar and the buttons for resizing
1685 and closing the frame.  Also, maximized frames typically avoid hiding
1686 any task bar or panels displayed on the desktop.  A ``fullboth'' frame,
1687 on the other hand, usually omits the title bar and occupies the entire
1688 available screen space.
1690 Full-height and full-width frames are more similar to maximized
1691 frames in this regard.  However, these typically display an external
1692 border which might be absent with maximized frames.  Hence the heights
1693 of maximized and full-height frames and the widths of maximized and
1694 full-width frames often differ by a few pixels.
1696 With some window managers you may have to customize the variable
1697 @code{frame-resize-pixelwise} (@pxref{Frame Size}) in order to make a
1698 frame truly appear maximized or full-screen.  Moreover, some window
1699 managers might not support smooth transition between the various
1700 full-screen or maximization states.  Customizing the variable
1701 @code{x-frame-normalize-before-maximize} can help to overcome that.
1703 Full-screen on macOS hides both the tool-bar and the menu-bar, however
1704 both will be displayed if the mouse pointer is moved to the top of the
1705 screen.
1707 @vindex fullscreen-restore@r{, a frame parameter}
1708 @item fullscreen-restore
1709 This parameter specifies the desired fullscreen state of the frame
1710 after invoking the @code{toggle-frame-fullscreen} command (@pxref{Frame
1711 Commands,,, emacs, The GNU Emacs Manual}) in the ``fullboth'' state.
1712 Normally this parameter is installed automatically by that command when
1713 toggling the state to fullboth.  If, however, you start Emacs in the
1714 ``fullboth'' state, you have to specify the desired behavior in your initial
1715 file as, for example
1717 @example
1718 (setq default-frame-alist
1719     '((fullscreen . fullboth)
1720       (fullscreen-restore . fullheight)))
1721 @end example
1723 This will give a new frame full height after typing in it @key{F11} for
1724 the first time.
1726 @vindex fit-frame-to-buffer-margins@r{, a frame parameter}
1727 @item fit-frame-to-buffer-margins
1728 This parameter allows to override the value of the option
1729 @code{fit-frame-to-buffer-margins} when fitting this frame to the buffer
1730 of its root window with @code{fit-frame-to-buffer} (@pxref{Resizing
1731 Windows}).
1733 @vindex fit-frame-to-buffer-sizes@r{, a frame parameter}
1734 @item fit-frame-to-buffer-sizes
1735 This parameter allows to override the value of the option
1736 @code{fit-frame-to-buffer-sizes} when fitting this frame to the buffer
1737 of its root window with @code{fit-frame-to-buffer} (@pxref{Resizing
1738 Windows}).
1739 @end table
1742 @node Layout Parameters
1743 @subsubsection Layout Parameters
1744 @cindex layout parameters of frames
1745 @cindex frame layout parameters
1747   These frame parameters enable or disable various parts of the
1748 frame, or control their sizes.
1750 @table @code
1751 @vindex border-width@r{, a frame parameter}
1752 @item border-width
1753 The width in pixels of the frame's outer border (@pxref{Frame Geometry}).
1755 @vindex internal-border-width@r{, a frame parameter}
1756 @item internal-border-width
1757 The width in pixels of the frame's internal border (@pxref{Frame
1758 Geometry}).
1760 @vindex vertical-scroll-bars@r{, a frame parameter}
1761 @item vertical-scroll-bars
1762 Whether the frame has scroll bars (@pxref{Scroll Bars}) for vertical
1763 scrolling, and which side of the frame they should be on.  The possible
1764 values are @code{left}, @code{right}, and @code{nil} for no scroll bars.
1766 @vindex horizontal-scroll-bars@r{, a frame parameter}
1767 @item horizontal-scroll-bars
1768 Whether the frame has scroll bars for horizontal scrolling (@code{t} and
1769 @code{bottom} mean yes, @code{nil} means no).
1771 @vindex scroll-bar-width@r{, a frame parameter}
1772 @item scroll-bar-width
1773 The width of vertical scroll bars, in pixels, or @code{nil} meaning to
1774 use the default width.
1776 @vindex scroll-bar-height@r{, a frame parameter}
1777 @item scroll-bar-height
1778 The height of horizontal scroll bars, in pixels, or @code{nil} meaning
1779 to use the default height.
1781 @vindex left-fringe@r{, a frame parameter}
1782 @vindex right-fringe@r{, a frame parameter}
1783 @item left-fringe
1784 @itemx right-fringe
1785 The default width of the left and right fringes of windows in this
1786 frame (@pxref{Fringes}).  If either of these is zero, that effectively
1787 removes the corresponding fringe.
1789 When you use @code{frame-parameter} to query the value of either of
1790 these two frame parameters, the return value is always an integer.
1791 When using @code{set-frame-parameter}, passing a @code{nil} value
1792 imposes an actual default value of 8 pixels.
1794 @vindex right-divider-width@r{, a frame parameter}
1795 @item right-divider-width
1796 The width (thickness) reserved for the right divider (@pxref{Window
1797 Dividers}) of any window on the frame, in pixels.  A value of zero means
1798 to not draw right dividers.
1800 @vindex bottom-divider-width@r{, a frame parameter}
1801 @item bottom-divider-width
1802 The width (thickness) reserved for the bottom divider (@pxref{Window
1803 Dividers}) of any window on the frame, in pixels.  A value of zero means
1804 to not draw bottom dividers.
1806 @vindex menu-bar-lines@r{, a frame parameter}
1807 @item menu-bar-lines
1808 The number of lines to allocate at the top of the frame for a menu bar
1809 (@pxref{Menu Bar}).  The default is one if Menu Bar mode is enabled and
1810 zero otherwise.  @xref{Menu Bars,,,emacs, The GNU Emacs Manual}.  For an
1811 external menu bar (@pxref{Frame Layout}), this value remains unchanged
1812 even when the menu bar wraps to two or more lines.  In that case, the
1813 @code{menu-bar-size} value returned by @code{frame-geometry}
1814 (@pxref{Frame Geometry}) allows to derive whether the menu bar actually
1815 occupies one or more lines.
1817 @vindex tool-bar-lines@r{, a frame parameter}
1818 @item tool-bar-lines
1819 The number of lines to use for the tool bar (@pxref{Tool Bar}).  The
1820 default is one if Tool Bar mode is enabled and zero otherwise.
1821 @xref{Tool Bars,,,emacs, The GNU Emacs Manual}.  This value may change
1822 whenever the tool bar wraps (@pxref{Frame Layout}).
1824 @vindex tool-bar-position@r{, a frame parameter}
1825 @item tool-bar-position
1826 The position of the tool bar when Emacs was built with GTK+.  Its value
1827 can be one of @code{top}, @code{bottom} @code{left}, @code{right}.  The
1828 default is @code{top}.
1830 @vindex line-spacing@r{, a frame parameter}
1831 @item line-spacing
1832 Additional space to leave below each text line, in pixels (a positive
1833 integer).  @xref{Line Height}, for more information.
1835 @vindex no-special-glyphs@r{, a frame parameter}
1836 @item no-special-glyphs
1837 If this is non-@code{nil}, it suppresses the display of any truncation
1838 and continuation glyphs (@pxref{Truncation}) for all buffers displayed
1839 by this frame.  This is useful to eliminate such glyphs when fitting a
1840 frame to its buffer via @code{fit-frame-to-buffer} (@pxref{Resizing
1841 Windows}).
1842 @end table
1845 @node Buffer Parameters
1846 @subsubsection Buffer Parameters
1847 @cindex frame, which buffers to display
1848 @cindex buffers to display on frame
1850   These frame parameters, meaningful on all kinds of terminals, deal
1851 with which buffers have been, or should, be displayed in the frame.
1853 @table @code
1854 @vindex minibuffer@r{, a frame parameter}
1855 @item minibuffer
1856 Whether this frame has its own minibuffer.  The value @code{t} means
1857 yes, @code{nil} means no, @code{only} means this frame is just a
1858 minibuffer.  If the value is a minibuffer window (in some other
1859 frame), the frame uses that minibuffer.
1861 This parameter takes effect when the frame is created.  If specified as
1862 @code{nil}, Emacs will try to set it to the minibuffer window of
1863 @code{default-minibuffer-frame} (@pxref{Minibuffers and Frames}).  For
1864 an existing frame, this parameter can be used exclusively to specify
1865 another minibuffer window.  It is not allowed to change it from a
1866 minibuffer window to @code{t} and vice-versa, or from @code{t} to
1867 @code{nil}.  If the parameter specifies a minibuffer window already,
1868 setting it to @code{nil} has no effect.
1870 @vindex buffer-predicate@r{, a frame parameter}
1871 @item buffer-predicate
1872 The buffer-predicate function for this frame.  The function
1873 @code{other-buffer} uses this predicate (from the selected frame) to
1874 decide which buffers it should consider, if the predicate is not
1875 @code{nil}.  It calls the predicate with one argument, a buffer, once for
1876 each buffer; if the predicate returns a non-@code{nil} value, it
1877 considers that buffer.
1879 @vindex buffer-list@r{, a frame parameter}
1880 @item buffer-list
1881 A list of buffers that have been selected in this frame, ordered
1882 most-recently-selected first.
1884 @vindex unsplittable@r{, a frame parameter}
1885 @item unsplittable
1886 If non-@code{nil}, this frame's window is never split automatically.
1887 @end table
1890 @node Frame Interaction Parameters
1891 @subsubsection Frame Interaction Parameters
1892 @cindex frame interaction parameters
1893 @cindex interaction parameters between frames
1895 These parameters supply forms of interactions between different frames.
1897 @table @code
1898 @vindex parent-frame@r{, a frame parameter}
1899 @item parent-frame
1900 If non-@code{nil}, this means that this frame is a child frame
1901 (@pxref{Child Frames}), and this parameter specifies its parent frame.
1902 If @code{nil}, this means that this frame is a normal, top-level frame.
1904 @vindex delete-before@r{, a frame parameter}
1905 @item delete-before
1906 If non-@code{nil}, this parameter specifies another frame whose deletion
1907 will automatically trigger the deletion of this frame.  @xref{Deleting
1908 Frames}.
1910 @vindex mouse-wheel-frame@r{, a frame parameter}
1911 @item mouse-wheel-frame
1912 If non-@code{nil}, this parameter specifies the frame whose windows will
1913 be scrolled whenever the mouse wheel is scrolled with the mouse pointer
1914 hovering over this frame, see @ref{Mouse Commands,,, emacs, The GNU
1915 Emacs Manual}.
1917 @vindex no-other-frame@r{, a frame parameter}
1918 @item no-other-frame
1919 If this is non-@code{nil}, then this frame is not eligible as candidate
1920 for the functions @code{next-frame}, @code{previous-frame}
1921 (@pxref{Finding All Frames}) and @code{other-frame}, see @ref{Frame
1922 Commands,,, emacs, The GNU Emacs Manual}.
1924 @vindex auto-hide-function@r{, a frame parameter}
1925 @item auto-hide-function
1926 When this parameter specifies a function, that function will be called
1927 instead of the function specified by the variable
1928 @code{frame-auto-hide-function} when quitting the frame's only window
1929 (@pxref{Quitting Windows}) and there are other frames left.
1931 @vindex minibuffer-exit@r{, a frame parameter}
1932 @item minibuffer-exit
1933 When this parameter is non-@code{nil}, Emacs will by default make this
1934 frame invisible whenever the minibuffer (@pxref{Minibuffers}) is exited.
1935 Alternatively, it can specify the functions @code{iconify-frame} and
1936 @code{delete-frame}.  This parameter is useful to make a child frame
1937 disappear automatically (similar to how Emacs deals with a window) when
1938 exiting the minibuffer.
1940 @vindex keep-ratio@r{, a frame parameter}
1941 @item keep-ratio
1942 This parameter is currently meaningful for child frames (@pxref{Child
1943 Frames}) only.  If it is non-@code{nil}, then Emacs will try to keep the
1944 frame's size (width and height) ratios (@pxref{Size Parameters}) as well
1945 as its left and right position ratios (@pxref{Position Parameters})
1946 unaltered whenever its parent frame is resized.
1948 If the value of this parameter is @code{nil}, the frame's position and
1949 size remain unaltered when the parent frame is resized, so the position
1950 and size ratios may change.  If the value of this parameter is @code{t},
1951 Emacs will try to preserve the frame's size and position ratios, hence
1952 the frame's size and position relative to its parent frame may change.
1954 More individual control is possible by using a cons cell: In that case
1955 the frame's width ratio is preserved if the @sc{car} of the cell is
1956 either @code{t} or @code{width-only}.  The height ratio is preserved if
1957 the @sc{car} of the cell is either @code{t} or @code{height-only}.  The
1958 left position ratio is preserved if the @sc{cdr} of the cell is either
1959 @code{t} or @code{left-only}.  The top position ratio is preserved if
1960 the @sc{cdr} of the cell is either @code{t} or @code{top-only}.
1961 @end table
1964 @node Mouse Dragging Parameters
1965 @subsubsection Mouse Dragging Parameters
1966 @cindex mouse dragging parameters
1967 @cindex parameters for resizing frames with the mouse
1968 @cindex parameters for moving frames with the mouse
1970 The parameters described below provide support for resizing a frame by
1971 dragging its internal borders with the mouse.  They also allow moving a
1972 frame with the mouse by dragging the header line of its topmost or the
1973 mode line of its bottommost window.
1975 These parameters are mostly useful for child frames (@pxref{Child
1976 Frames}) that come without window manager decorations.  If necessary,
1977 they can be used for undecorated top-level frames as well.
1979 @table @code
1980 @vindex drag-internal-border@r{, a frame parameter}
1981 @item drag-internal-border
1982 If non-@code{nil}, the frame can be resized by dragging its internal
1983 borders, if present, with the mouse.
1985 @vindex drag-with-header-line@r{, a frame parameter}
1986 @item drag-with-header-line
1987 If non-@code{nil}, the frame can be moved with the mouse by dragging the
1988 header line of its topmost window.
1990 @vindex drag-with-mode-line@r{, a frame parameter}
1991 @item drag-with-mode-line
1992 If non-@code{nil}, the frame can be moved with the mouse by dragging the
1993 mode line of its bottommost window.  Note that such a frame is not
1994 allowed to have its own minibuffer window.
1996 @vindex snap-width@r{, a frame parameter}
1997 @item snap-width
1998 A frame that is moved with the mouse will ``snap'' at the border(s) of
1999 the display or its parent frame whenever it is dragged as near to such
2000 an edge as the number of pixels specified by this parameter.
2002 @vindex top-visible@r{, a frame parameter}
2003 @item top-visible
2004 If this parameter is a number, the top edge of the frame never appears
2005 above the top edge of its display or parent frame.  Moreover, as many
2006 pixels of the frame as specified by that number will remain visible when
2007 the frame is moved against any of the remaining edges of its display or
2008 parent frame.  Setting this parameter is useful to guard against
2009 dragging a child frame with a non-@code{nil}
2010 @code{drag-with-header-line} parameter completely out of the area
2011 of its parent frame.
2013 @vindex bottom-visible@r{, a frame parameter}
2014 @item bottom-visible
2015 If this parameter is a number, the bottom edge of the frame never
2016 appears below the bottom edge of its display or parent frame.  Moreover,
2017 as many pixels of the frame as specified by that number will remain
2018 visible when the frame is moved against any of the remaining edges of
2019 its display or parent frame.  Setting this parameter is useful to guard
2020 against dragging a child frame with a non-@code{nil}
2021 @code{drag-with-mode-line} parameter completely out of the area of
2022 its parent frame.
2023 @end table
2026 @node Management Parameters
2027 @subsubsection Window Management Parameters
2028 @cindex window manager interaction, and frame parameters
2030   The following frame parameters control various aspects of the frame's
2031 interaction with the window manager or window system.  They have no
2032 effect on text terminals.
2034 @table @code
2035 @vindex visibility@r{, a frame parameter}
2036 @item visibility
2037 The state of visibility of the frame.  There are three possibilities:
2038 @code{nil} for invisible, @code{t} for visible, and @code{icon} for
2039 iconified.  @xref{Visibility of Frames}.
2041 @vindex auto-raise@r{, a frame parameter}
2042 @item auto-raise
2043 If non-@code{nil}, Emacs automatically raises the frame when it is
2044 selected.  Some window managers do not allow this.
2046 @vindex auto-lower@r{, a frame parameter}
2047 @item auto-lower
2048 If non-@code{nil}, Emacs automatically lowers the frame when it is
2049 deselected.  Some window managers do not allow this.
2051 @vindex icon-type@r{, a frame parameter}
2052 @item icon-type
2053 The type of icon to use for this frame.  If the value is a string,
2054 that specifies a file containing a bitmap to use; @code{nil} specifies
2055 no icon (in which case the window manager decides what to show); any
2056 other non-@code{nil} value specifies the default Emacs icon.
2058 @vindex icon-name@r{, a frame parameter}
2059 @item icon-name
2060 The name to use in the icon for this frame, when and if the icon
2061 appears.  If this is @code{nil}, the frame's title is used.
2063 @vindex window-id@r{, a frame parameter}
2064 @item window-id
2065 The ID number which the graphical display uses for this frame.  Emacs
2066 assigns this parameter when the frame is created; changing the
2067 parameter has no effect on the actual ID number.
2069 @vindex outer-window-id@r{, a frame parameter}
2070 @item outer-window-id
2071 The ID number of the outermost window-system window in which the frame
2072 exists.  As with @code{window-id}, changing this parameter has no
2073 actual effect.
2075 @vindex wait-for-wm@r{, a frame parameter}
2076 @item wait-for-wm
2077 If non-@code{nil}, tell Xt to wait for the window manager to confirm
2078 geometry changes.  Some window managers, including versions of Fvwm2
2079 and KDE, fail to confirm, so Xt hangs.  Set this to @code{nil} to
2080 prevent hanging with those window managers.
2082 @vindex sticky@r{, a frame parameter}
2083 @item sticky
2084 If non-@code{nil}, the frame is visible on all virtual desktops on systems
2085 with virtual desktops.
2087 @vindex inhibit-double-buffering@r{, a frame parameter}
2088 @item inhibit-double-buffering
2089 If non-@code{nil}, the frame is drawn to the screen without double
2090 buffering.  Emacs normally attempts to use double buffering, where
2091 available, to reduce flicker.  Set this property if you experience
2092 display bugs or pine for that retro, flicker-y feeling.
2094 @vindex skip-taskbar@r{, a frame parameter}
2095 @item skip-taskbar
2096 If non-@code{nil}, this tells the window manager to remove the frame's
2097 icon from the taskbar associated with the frame's display and inhibit
2098 switching to the frame's window via the combination @kbd{Alt-@key{TAB}}.
2099 On MS-Windows, iconifying such a frame will "roll in" its window-system
2100 window at the bottom of the desktop.  Some window managers may not honor
2101 this parameter.
2103 @vindex no-focus-on-map@r{, a frame parameter}
2104 @item no-focus-on-map
2105 If non-@code{nil}, this means that the frame does not want to receive
2106 input focus when it is mapped (@pxref{Visibility of Frames}).  Some
2107 window managers may not honor this parameter.
2109 @vindex no-accept-focus@r{, a frame parameter}
2110 @item no-accept-focus
2111 If non-@code{nil}, this means that the frame does not want to receive
2112 input focus via explicit mouse clicks or when moving the mouse into it
2113 either via @code{focus-follows-mouse} (@pxref{Input Focus}) or
2114 @code{mouse-autoselect-window} (@pxref{Mouse Window Auto-selection}).
2115 This may have the unwanted side-effect that a user cannot scroll a
2116 non-selected frame with the mouse.  Some window managers may not honor
2117 this parameter.
2119 @vindex undecorated@r{, a frame parameter}
2120 @item undecorated
2121 If non-@code{nil}, this frame's window-system window is drawn without
2122 decorations, like the title, minimize/maximize boxes and external
2123 borders.  This usually means that the window cannot be dragged, resized,
2124 iconified, maximized or deleted with the mouse.  If @code{nil}, the frame's
2125 window is usually drawn with all the elements listed above unless their
2126 display has been suspended via window manager settings.
2128 Under X, Emacs uses the Motif window manager hints to turn off
2129 decorations.  Some window managers may not honor these hints.
2131 NS builds consider the tool bar to be a decoration, and therefore hide
2132 it on an undecorated frame.
2134 @vindex override-redirect@r{, a frame parameter}
2135 @item override-redirect
2136 @cindex override redirect frames
2137 If non-@code{nil}, this means that this is an @dfn{override redirect}
2138 frame---a frame not handled by window managers under X.  Override
2139 redirect frames have no window manager decorations, can be positioned
2140 and resized only via Emacs' positioning and resizing functions and are
2141 usually drawn on top of all other frames.  Setting this parameter has
2142 no effect on MS-Windows.
2144 @ignore
2145 @vindex parent-id@r{, a frame parameter}
2146 @item parent-id
2147 @c ??? Not yet working.
2148 The X window number of the window that should be the parent of this one.
2149 Specifying this lets you create an Emacs window inside some other
2150 application's window.  (It is not certain this will be implemented; try
2151 it and see if it works.)
2152 @end ignore
2154 @vindex ns-appearance@r{, a frame parameter}
2155 @item ns-appearance
2156 Only available on macOS, if set to @code{dark} draw this frame's
2157 window-system window using the ``vibrant dark'' theme, otherwise use
2158 the system default.  The ``vibrant dark'' theme can be used to set the
2159 toolbar and scrollbars to a dark appearance when using an Emacs theme
2160 with a dark background.
2162 @vindex ns-transparent-titlebar@r{, a frame parameter}
2163 @item ns-transparent-titlebar
2164 Only available on macOS, if non-@code{nil}, set the titlebar and
2165 toolbar to be transparent.  This effectively sets the background color
2166 of both to match the Emacs background color.
2167 @end table
2170 @node Cursor Parameters
2171 @subsubsection Cursor Parameters
2172 @cindex cursor, and frame parameters
2174   This frame parameter controls the way the cursor looks.
2176 @table @code
2177 @vindex cursor-type@r{, a frame parameter}
2178 @item cursor-type
2179 How to display the cursor.  Legitimate values are:
2181 @table @code
2182 @item box
2183 Display a filled box.  (This is the default.)
2184 @item hollow
2185 Display a hollow box.
2186 @item nil
2187 Don't display a cursor.
2188 @item bar
2189 Display a vertical bar between characters.
2190 @item (bar . @var{width})
2191 Display a vertical bar @var{width} pixels wide between characters.
2192 @item hbar
2193 Display a horizontal bar.
2194 @item (hbar . @var{height})
2195 Display a horizontal bar @var{height} pixels high.
2196 @end table
2197 @end table
2199 @vindex cursor-type
2200 The @code{cursor-type} frame parameter may be overridden by the
2201 variables @code{cursor-type} and
2202 @code{cursor-in-non-selected-windows}:
2204 @defopt cursor-type
2205 This buffer-local variable controls how the cursor looks in a selected
2206 window showing the buffer.  If its value is @code{t}, that means to
2207 use the cursor specified by the @code{cursor-type} frame parameter.
2208 Otherwise, the value should be one of the cursor types listed above,
2209 and it overrides the @code{cursor-type} frame parameter.
2210 @end defopt
2212 @defopt cursor-in-non-selected-windows
2213 This buffer-local variable controls how the cursor looks in a window
2214 that is not selected.  It supports the same values as the
2215 @code{cursor-type} frame parameter; also, @code{nil} means don't
2216 display a cursor in nonselected windows, and @code{t} (the default)
2217 means use a standard modification of the usual cursor type (solid box
2218 becomes hollow box, and bar becomes a narrower bar).
2219 @end defopt
2221 @defopt x-stretch-cursor
2222 This variable controls the width of the block cursor displayed on
2223 extra-wide glyphs such as a tab or a stretch of white space.  By
2224 default, the block cursor is only as wide as the font's default
2225 character, and will not cover all of the width of the glyph under it
2226 if that glyph is extra-wide.  A non-@code{nil} value of this variable
2227 means draw the block cursor as wide as the glyph under it.  The
2228 default value is @code{nil}.
2230 This variable has no effect on text-mode frames, since the text-mode
2231 cursor is drawn by the terminal out of Emacs's control.
2232 @end defopt
2234 @defopt blink-cursor-alist
2235 This variable specifies how to blink the cursor.  Each element has the
2236 form @code{(@var{on-state} . @var{off-state})}.  Whenever the cursor
2237 type equals @var{on-state} (comparing using @code{equal}), the
2238 corresponding @var{off-state} specifies what the cursor looks like
2239 when it blinks off.  Both @var{on-state} and @var{off-state}
2240 should be suitable values for the @code{cursor-type} frame parameter.
2242 There are various defaults for how to blink each type of cursor, if
2243 the type is not mentioned as an @var{on-state} here.  Changes in this
2244 variable do not take effect immediately, only when you specify the
2245 @code{cursor-type} frame parameter.
2246 @end defopt
2248 @node Font and Color Parameters
2249 @subsubsection Font and Color Parameters
2250 @cindex font and color, frame parameters
2252   These frame parameters control the use of fonts and colors.
2254 @table @code
2255 @vindex font-backend@r{, a frame parameter}
2256 @item font-backend
2257 A list of symbols, specifying the @dfn{font backends} to use for
2258 drawing fonts in the frame, in order of priority.  On X, there are
2259 currently two available font backends: @code{x} (the X core font
2260 driver) and @code{xft} (the Xft font driver).  On MS-Windows, there are
2261 currently two available font backends: @code{gdi} and
2262 @code{uniscribe} (@pxref{Windows Fonts,,, emacs, The GNU Emacs
2263 Manual}).  On other systems, there is only one available font backend,
2264 so it does not make sense to modify this frame parameter.
2266 @vindex background-mode@r{, a frame parameter}
2267 @item background-mode
2268 This parameter is either @code{dark} or @code{light}, according
2269 to whether the background color is a light one or a dark one.
2271 @vindex tty-color-mode@r{, a frame parameter}
2272 @item tty-color-mode
2273 @cindex standard colors for character terminals
2274 This parameter overrides the terminal's color support as given by the
2275 system's terminal capabilities database in that this parameter's value
2276 specifies the color mode to use on a text terminal.  The value can be
2277 either a symbol or a number.  A number specifies the number of colors
2278 to use (and, indirectly, what commands to issue to produce each
2279 color).  For example, @code{(tty-color-mode . 8)} specifies use of the
2280 ANSI escape sequences for 8 standard text colors.  A value of -1 turns
2281 off color support.
2283 If the parameter's value is a symbol, it specifies a number through
2284 the value of @code{tty-color-mode-alist}, and the associated number is
2285 used instead.
2287 @vindex screen-gamma@r{, a frame parameter}
2288 @item screen-gamma
2289 @cindex gamma correction
2290 If this is a number, Emacs performs gamma correction which adjusts
2291 the brightness of all colors.  The value should be the screen gamma of
2292 your display.
2294 Usual PC monitors have a screen gamma of 2.2, so color values in
2295 Emacs, and in X windows generally, are calibrated to display properly
2296 on a monitor with that gamma value.  If you specify 2.2 for
2297 @code{screen-gamma}, that means no correction is needed.  Other values
2298 request correction, designed to make the corrected colors appear on
2299 your screen the way they would have appeared without correction on an
2300 ordinary monitor with a gamma value of 2.2.
2302 If your monitor displays colors too light, you should specify a
2303 @code{screen-gamma} value smaller than 2.2.  This requests correction
2304 that makes colors darker.  A screen gamma value of 1.5 may give good
2305 results for LCD color displays.
2307 @vindex alpha@r{, a frame parameter}
2308 @item alpha
2309 @cindex opacity, frame
2310 @cindex transparency, frame
2311 @vindex frame-alpha-lower-limit
2312 This parameter specifies the opacity of the frame, on graphical
2313 displays that support variable opacity.  It should be an integer
2314 between 0 and 100, where 0 means completely transparent and 100 means
2315 completely opaque.  It can also have a @code{nil} value, which tells
2316 Emacs not to set the frame opacity (leaving it to the window manager).
2318 To prevent the frame from disappearing completely from view, the
2319 variable @code{frame-alpha-lower-limit} defines a lower opacity limit.
2320 If the value of the frame parameter is less than the value of this
2321 variable, Emacs uses the latter.  By default,
2322 @code{frame-alpha-lower-limit} is 20.
2324 The @code{alpha} frame parameter can also be a cons cell
2325 @code{(@var{active} . @var{inactive})}, where @var{active} is the
2326 opacity of the frame when it is selected, and @var{inactive} is the
2327 opacity when it is not selected.
2329 Some window systems do not support the @code{alpha} parameter for child
2330 frames (@pxref{Child Frames}).
2331 @end table
2333 The following frame parameters are semi-obsolete in that they are
2334 automatically equivalent to particular face attributes of particular
2335 faces (@pxref{Standard Faces,,, emacs, The Emacs Manual}):
2337 @table @code
2338 @vindex font@r{, a frame parameter}
2339 @item font
2340 The name of the font for displaying text in the frame.  This is a
2341 string, either a valid font name for your system or the name of an Emacs
2342 fontset (@pxref{Fontsets}).  It is equivalent to the @code{font}
2343 attribute of the @code{default} face.
2345 @vindex foreground-color@r{, a frame parameter}
2346 @item foreground-color
2347 The color to use for the image of a character.  It is equivalent to
2348 the @code{:foreground} attribute of the @code{default} face.
2350 @vindex background-color@r{, a frame parameter}
2351 @item background-color
2352 The color to use for the background of characters.  It is equivalent to
2353 the @code{:background} attribute of the @code{default} face.
2355 @vindex mouse-color@r{, a frame parameter}
2356 @item mouse-color
2357 The color for the mouse pointer.  It is equivalent to the @code{:background}
2358 attribute of the @code{mouse} face.
2360 @vindex cursor-color@r{, a frame parameter}
2361 @item cursor-color
2362 The color for the cursor that shows point.  It is equivalent to the
2363 @code{:background} attribute of the @code{cursor} face.
2365 @vindex border-color@r{, a frame parameter}
2366 @item border-color
2367 The color for the border of the frame.  It is equivalent to the
2368 @code{:background} attribute of the @code{border} face.
2370 @vindex scroll-bar-foreground@r{, a frame parameter}
2371 @item scroll-bar-foreground
2372 If non-@code{nil}, the color for the foreground of scroll bars.  It is
2373 equivalent to the @code{:foreground} attribute of the
2374 @code{scroll-bar} face.
2376 @vindex scroll-bar-background@r{, a frame parameter}
2377 @item scroll-bar-background
2378 If non-@code{nil}, the color for the background of scroll bars.  It is
2379 equivalent to the @code{:background} attribute of the
2380 @code{scroll-bar} face.
2381 @end table
2384 @node Geometry
2385 @subsection Geometry
2387   Here's how to examine the data in an X-style window geometry
2388 specification:
2390 @defun x-parse-geometry geom
2391 @cindex geometry specification
2392 The function @code{x-parse-geometry} converts a standard X window
2393 geometry string to an alist that you can use as part of the argument to
2394 @code{make-frame}.
2396 The alist describes which parameters were specified in @var{geom}, and
2397 gives the values specified for them.  Each element looks like
2398 @code{(@var{parameter} . @var{value})}.  The possible @var{parameter}
2399 values are @code{left}, @code{top}, @code{width}, and @code{height}.
2401 For the size parameters, the value must be an integer.  The position
2402 parameter names @code{left} and @code{top} are not totally accurate,
2403 because some values indicate the position of the right or bottom edges
2404 instead.  The @var{value} possibilities for the position parameters are:
2405 an integer, a list @code{(+ @var{pos})}, or a list @code{(- @var{pos})};
2406 as previously described (@pxref{Position Parameters}).
2408 Here is an example:
2410 @example
2411 (x-parse-geometry "35x70+0-0")
2412      @result{} ((height . 70) (width . 35)
2413          (top - 0) (left . 0))
2414 @end example
2415 @end defun
2417 @node Terminal Parameters
2418 @section Terminal Parameters
2419 @cindex terminal parameters
2421   Each terminal has a list of associated parameters.  These
2422 @dfn{terminal parameters} are mostly a convenient way of storage for
2423 terminal-local variables, but some terminal parameters have a special
2424 meaning.
2426   This section describes functions to read and change the parameter values
2427 of a terminal.  They all accept as their argument either a terminal or
2428 a frame; the latter means use that frame's terminal.  An argument of
2429 @code{nil} means the selected frame's terminal.
2431 @defun terminal-parameters &optional terminal
2432 This function returns an alist listing all the parameters of
2433 @var{terminal} and their values.
2434 @end defun
2436 @defun terminal-parameter terminal parameter
2437 This function returns the value of the parameter @var{parameter} (a
2438 symbol) of @var{terminal}.  If @var{terminal} has no setting for
2439 @var{parameter}, this function returns @code{nil}.
2440 @end defun
2442 @defun set-terminal-parameter terminal parameter value
2443 This function sets the parameter @var{parameter} of @var{terminal} to the
2444 specified @var{value}, and returns the previous value of that
2445 parameter.
2446 @end defun
2448 Here's a list of a few terminal parameters that have a special
2449 meaning:
2451 @table @code
2452 @item background-mode
2453 The classification of the terminal's background color, either
2454 @code{light} or @code{dark}.
2455 @item normal-erase-is-backspace
2456 Value is either 1 or 0, depending on whether
2457 @code{normal-erase-is-backspace-mode} is turned on or off on this
2458 terminal.  @xref{DEL Does Not Delete,,, emacs, The Emacs Manual}.
2459 @item terminal-initted
2460 After the terminal is initialized, this is set to the
2461 terminal-specific initialization function.
2462 @item tty-mode-set-strings
2463 When present, a list of strings containing escape sequences that Emacs
2464 will output while configuring a tty for rendering.  Emacs emits these
2465 strings only when configuring a terminal: if you want to enable a mode
2466 on a terminal that is already active (for example, while in
2467 @code{tty-setup-hook}), explicitly output the necessary escape
2468 sequence using @code{send-string-to-terminal} in addition to adding
2469 the sequence to @code{tty-mode-set-strings}.
2470 @item tty-mode-reset-strings
2471 When present, a list of strings that undo the effects of the strings
2472 in @code{tty-mode-set-strings}.  Emacs emits these strings when
2473 exiting, deleting a terminal, or suspending itself.
2474 @end table
2476 @node Frame Titles
2477 @section Frame Titles
2478 @cindex frame title
2480   Every frame has a @code{name} parameter; this serves as the default
2481 for the frame title which window systems typically display at the top of
2482 the frame.  You can specify a name explicitly by setting the @code{name}
2483 frame property.
2485   Normally you don't specify the name explicitly, and Emacs computes the
2486 frame name automatically based on a template stored in the variable
2487 @code{frame-title-format}.  Emacs recomputes the name each time the
2488 frame is redisplayed.
2490 @defvar frame-title-format
2491 This variable specifies how to compute a name for a frame when you have
2492 not explicitly specified one.  The variable's value is actually a mode
2493 line construct, just like @code{mode-line-format}, except that the
2494 @samp{%c}, @samp{%C}, and @samp{%l} constructs are ignored.  @xref{Mode Line
2495 Data}.
2496 @end defvar
2498 @defvar icon-title-format
2499 This variable specifies how to compute the name for an iconified frame,
2500 when you have not explicitly specified the frame title.  This title
2501 appears in the icon itself.
2502 @end defvar
2504 @defvar multiple-frames
2505 This variable is set automatically by Emacs.  Its value is @code{t} when
2506 there are two or more frames (not counting minibuffer-only frames or
2507 invisible frames).  The default value of @code{frame-title-format} uses
2508 @code{multiple-frames} so as to put the buffer name in the frame title
2509 only when there is more than one frame.
2511 The value of this variable is not guaranteed to be accurate except
2512 while processing @code{frame-title-format} or
2513 @code{icon-title-format}.
2514 @end defvar
2516 @node Deleting Frames
2517 @section Deleting Frames
2518 @cindex deleting frames
2520 A @dfn{live frame} is one that has not been deleted.  When a frame is
2521 deleted, it is removed from its terminal display, although it may
2522 continue to exist as a Lisp object until there are no more references to
2525 @deffn Command delete-frame &optional frame force
2526 @vindex delete-frame-functions
2527 This function deletes the frame @var{frame}.  The argument @var{frame}
2528 must specify a live frame (see below) and defaults to the selected
2529 frame.
2531 It first deletes any child frame of @var{frame} (@pxref{Child Frames})
2532 and any frame whose @code{delete-before} frame parameter (@pxref{Frame
2533 Interaction Parameters}) specifies @var{frame}.  All such deletions are
2534 performed recursively; so this step makes sure that no other frames with
2535 @var{frame} as their ancestor will exist.  Then, unless @var{frame}
2536 specifies a tooltip, this function runs the hook
2537 @code{delete-frame-functions} (each function getting one argument,
2538 @var{frame}) before actually killing the frame.
2540 Note that a frame cannot be deleted as long as its minibuffer serves as
2541 surrogate minibuffer for another frame (@pxref{Minibuffers and Frames}).
2542 Normally, you cannot delete a frame if all other frames are invisible,
2543 but if @var{force} is non-@code{nil}, then you are allowed to do so.
2544 @end deffn
2546 @defun frame-live-p frame
2547 This function returns non-@code{nil} if the frame @var{frame} has not
2548 been deleted.  The possible non-@code{nil} return values are like those
2549 of @code{framep}.  @xref{Frames}.
2550 @end defun
2552   Some window managers provide a command to delete a window.  These work
2553 by sending a special message to the program that operates the window.
2554 When Emacs gets one of these commands, it generates a
2555 @code{delete-frame} event, whose normal definition is a command that
2556 calls the function @code{delete-frame}.  @xref{Misc Events}.
2558 @deffn Command delete-other-frames &optional frame
2559 This command deletes all frames on @var{frame}'s terminal, except
2560 @var{frame}.  If @var{frame} uses another frame's minibuffer, that
2561 minibuffer frame is left untouched.  The argument @var{frame} must
2562 specify a live frame and defaults to the selected frame.  Internally,
2563 this command works by calling @code{delete-frame} with @var{force}
2564 @code{nil} for all frames that shall be deleted.
2566 This function does not delete any of @var{frame}'s child frames
2567 (@pxref{Child Frames}).  If @var{frame} is a child frame, it deletes
2568 @var{frame}'s siblings only.
2569 @end deffn
2572 @node Finding All Frames
2573 @section Finding All Frames
2574 @cindex frames, scanning all
2576 @defun frame-list
2577 This function returns a list of all the live frames, i.e., those that
2578 have not been deleted.  It is analogous to @code{buffer-list} for
2579 buffers, and includes frames on all terminals.  The list that you get
2580 is newly created, so modifying the list doesn't have any effect on the
2581 internals of Emacs.
2582 @end defun
2584 @defun visible-frame-list
2585 This function returns a list of just the currently visible frames.
2586 @xref{Visibility of Frames}.  Frames on text terminals always count as
2587 visible, even though only the selected one is actually displayed.
2588 @end defun
2590 @defun frame-list-z-order &optional display
2591 This function returns a list of Emacs' frames, in Z (stacking) order
2592 (@pxref{Raising and Lowering}).  The optional argument @var{display}
2593 specifies which display to poll.  @var{display} should be either a frame
2594 or a display name (a string).  If omitted or @code{nil}, that stands for
2595 the selected frame's display.  It returns @code{nil} if @var{display}
2596 contains no Emacs frame.
2598 Frames are listed from topmost (first) to bottommost (last).  As a
2599 special case, if @var{display} is non-@code{nil} and specifies a live
2600 frame, it returns the child frames of that frame in Z (stacking) order.
2602 This function is not meaningful on text terminals.
2603 @end defun
2605 @defun next-frame &optional frame minibuf
2606 This function lets you cycle conveniently through all the frames on a
2607 specific terminal from an arbitrary starting point.  It returns the
2608 frame following @var{frame}, in the list of all live frames, on
2609 @var{frame}'s terminal.  The argument @var{frame} must specify a live
2610 frame and defaults to the selected frame.  It never returns a frame
2611 whose @code{no-other-frame} parameter (@pxref{Frame Interaction
2612 Parameters}) is non-@code{nil}.
2614 The second argument, @var{minibuf}, says which frames to consider:
2616 @table @asis
2617 @item @code{nil}
2618 Exclude minibuffer-only frames.
2619 @item @code{visible}
2620 Consider all visible frames.
2621 @item 0
2622 Consider all visible or iconified frames.
2623 @item a window
2624 Consider only the frames using that particular window as their
2625 minibuffer.
2626 @item anything else
2627 Consider all frames.
2628 @end table
2629 @end defun
2631 @defun previous-frame &optional frame minibuf
2632 Like @code{next-frame}, but cycles through all frames in the opposite
2633 direction.
2634 @end defun
2636   See also @code{next-window} and @code{previous-window}, in @ref{Cyclic
2637 Window Ordering}.
2639 @node Minibuffers and Frames
2640 @section Minibuffers and Frames
2642 Normally, each frame has its own minibuffer window at the bottom, which
2643 is used whenever that frame is selected.  You can get that window with
2644 the function @code{minibuffer-window} (@pxref{Minibuffer Windows}).
2646 @cindex frame without a minibuffer
2647 @cindex surrogate minibuffer frame
2648 However, you can also create a frame without a minibuffer.  Such a frame
2649 must use the minibuffer window of some other frame.  That other frame
2650 will serve as @dfn{surrogate minibuffer frame} for this frame and cannot
2651 be deleted via @code{delete-frame} (@pxref{Deleting Frames}) as long as
2652 this frame is live.
2654 When you create the frame, you can explicitly specify its minibuffer
2655 window (in some other frame) with the @code{minibuffer} frame parameter
2656 (@pxref{Buffer Parameters}).  If you don't, then the minibuffer is found
2657 in the frame which is the value of the variable
2658 @code{default-minibuffer-frame}.  Its value should be a frame that does
2659 have a minibuffer.
2661 If you use a minibuffer-only frame, you might want that frame to raise
2662 when you enter the minibuffer.  If so, set the variable
2663 @code{minibuffer-auto-raise} to @code{t}.  @xref{Raising and Lowering}.
2665 @defvar default-minibuffer-frame
2666 This variable specifies the frame to use for the minibuffer window, by
2667 default.  It does not affect existing frames.  It is always local to
2668 the current terminal and cannot be buffer-local.  @xref{Multiple
2669 Terminals}.
2670 @end defvar
2673 @node Input Focus
2674 @section Input Focus
2675 @cindex input focus
2676 @cindex selected frame
2678 At any time, one frame in Emacs is the @dfn{selected frame}.  The
2679 selected window always resides on the selected frame.
2681 When Emacs displays its frames on several terminals (@pxref{Multiple
2682 Terminals}), each terminal has its own selected frame.  But only one
2683 of these is @emph{the} selected frame: it's the frame that belongs
2684 to the terminal from which the most recent input came.  That is, when
2685 Emacs runs a command that came from a certain terminal, the selected
2686 frame is the one of that terminal.  Since Emacs runs only a single
2687 command at any given time, it needs to consider only one selected
2688 frame at a time; this frame is what we call @dfn{the selected frame}
2689 in this manual.  The display on which the selected frame is shown is
2690 the @dfn{selected frame's display}.
2692 @defun selected-frame
2693 This function returns the selected frame.
2694 @end defun
2696 Some window systems and window managers direct keyboard input to the
2697 window object that the mouse is in; others require explicit clicks or
2698 commands to @dfn{shift the focus} to various window objects.  Either
2699 way, Emacs automatically keeps track of which frame has the focus.  To
2700 explicitly switch to a different frame from a Lisp function, call
2701 @code{select-frame-set-input-focus}.
2703 Lisp programs can also switch frames temporarily by calling the
2704 function @code{select-frame}.  This does not alter the window system's
2705 concept of focus; rather, it escapes from the window manager's control
2706 until that control is somehow reasserted.
2708 When using a text terminal, only one frame can be displayed at a time
2709 on the terminal, so after a call to @code{select-frame}, the next
2710 redisplay actually displays the newly selected frame.  This frame
2711 remains selected until a subsequent call to @code{select-frame}.  Each
2712 frame on a text terminal has a number which appears in the mode line
2713 before the buffer name (@pxref{Mode Line Variables}).
2715 @defun select-frame-set-input-focus frame &optional norecord
2716 This function selects @var{frame}, raises it (should it happen to be
2717 obscured by other frames) and tries to give it the X server's focus.
2718 On a text terminal, the next redisplay displays the new frame on the
2719 entire terminal screen.  The optional argument @var{norecord} has the
2720 same meaning as for @code{select-frame} (see below).  The return value
2721 of this function is not significant.
2722 @end defun
2724 Ideally, the function described next should focus a frame without also
2725 raising it above other frames.  Unfortunately, many window-systems or
2726 window managers may refuse to comply.
2728 @defun x-focus-frame frame &optional noactivate
2729 This function gives @var{frame} the focus of the X server without
2730 necessarily raising it.  @var{frame} @code{nil} means use the selected
2731 frame.  Under X, the optional argument @var{noactivate}, if
2732 non-@code{nil}, means to avoid making @var{frame}'s window-system window
2733 the ``active'' window which should insist a bit more on avoiding to
2734 raise @var{frame} above other frames.
2736 On MS-Windows the @var{noactivate} argument has no effect.  However, if
2737 @var{frame} is a child frame (@pxref{Child Frames}), this function
2738 usually focuses @var{frame} without raising it above other child
2739 frames.
2741 If there is no window system support, this function does nothing.
2742 @end defun
2744 @deffn Command select-frame frame &optional norecord
2745 This function selects frame @var{frame}, temporarily disregarding the
2746 focus of the X server if any.  The selection of @var{frame} lasts until
2747 the next time the user does something to select a different frame, or
2748 until the next time this function is called.  (If you are using a
2749 window system, the previously selected frame may be restored as the
2750 selected frame after return to the command loop, because it still may
2751 have the window system's input focus.)
2753 The specified @var{frame} becomes the selected frame, and its terminal
2754 becomes the selected terminal.  This function then calls
2755 @code{select-window} as a subroutine, passing the window selected
2756 within @var{frame} as its first argument and @var{norecord} as its
2757 second argument (hence, if @var{norecord} is non-@code{nil}, this
2758 avoids changing the order of recently selected windows and the buffer
2759 list).  @xref{Selecting Windows}.
2761 This function returns @var{frame}, or @code{nil} if @var{frame} has
2762 been deleted.
2764 In general, you should never use @code{select-frame} in a way that
2765 could switch to a different terminal without switching back when
2766 you're done.
2767 @end deffn
2769 Emacs cooperates with the window system by arranging to select frames as
2770 the server and window manager request.  It does so by generating a
2771 special kind of input event, called a @dfn{focus} event, when
2772 appropriate.  The command loop handles a focus event by calling
2773 @code{handle-switch-frame}.  @xref{Focus Events}.
2775 @deffn Command handle-switch-frame frame
2776 This function handles a focus event by selecting frame @var{frame}.
2778 Focus events normally do their job by invoking this command.
2779 Don't call it for any other reason.
2780 @end deffn
2782 @defun redirect-frame-focus frame &optional focus-frame
2783 This function redirects focus from @var{frame} to @var{focus-frame}.
2784 This means that @var{focus-frame} will receive subsequent keystrokes and
2785 events intended for @var{frame}.  After such an event, the value of
2786 @code{last-event-frame} will be @var{focus-frame}.  Also, switch-frame
2787 events specifying @var{frame} will instead select @var{focus-frame}.
2789 If @var{focus-frame} is omitted or @code{nil}, that cancels any existing
2790 redirection for @var{frame}, which therefore once again receives its own
2791 events.
2793 One use of focus redirection is for frames that don't have minibuffers.
2794 These frames use minibuffers on other frames.  Activating a minibuffer
2795 on another frame redirects focus to that frame.  This puts the focus on
2796 the minibuffer's frame, where it belongs, even though the mouse remains
2797 in the frame that activated the minibuffer.
2799 Selecting a frame can also change focus redirections.  Selecting frame
2800 @code{bar}, when @code{foo} had been selected, changes any redirections
2801 pointing to @code{foo} so that they point to @code{bar} instead.  This
2802 allows focus redirection to work properly when the user switches from
2803 one frame to another using @code{select-window}.
2805 This means that a frame whose focus is redirected to itself is treated
2806 differently from a frame whose focus is not redirected.
2807 @code{select-frame} affects the former but not the latter.
2809 The redirection lasts until @code{redirect-frame-focus} is called to
2810 change it.
2811 @end defun
2813 @defvar focus-in-hook
2814 This is a normal hook run when an Emacs frame gains input focus.  The
2815 frame gaining focus is selected when this hook is run.
2816 @end defvar
2818 @defvar focus-out-hook
2819 This is a normal hook run when an Emacs frame has lost input focus and
2820 no other Emacs frame has gained input focus instead.
2821 @end defvar
2823 @defopt focus-follows-mouse
2824 This option informs Emacs whether and how the window manager transfers
2825 focus when you move the mouse pointer into a frame.  It can have three
2826 meaningful values:
2828 @table @asis
2829 @item @code{nil}
2830 The default value @code{nil} should be used when your window manager
2831 follows a ``click-to-focus'' policy where you have to click the mouse
2832 inside of a frame in order for that frame to gain focus.
2834 @item @code{t}
2835 The value @code{t} should be used when your window manager has the focus
2836 automatically follow the position of the mouse pointer but a frame that
2837 gains focus is not raised automatically and may even remain occluded by
2838 other window-system windows.
2840 @item @code{auto-raise}
2841 The value @code{auto-raise} should be used when your window manager has
2842 the focus automatically follow the position of the mouse pointer and a
2843 frame that gains focus is raised automatically.
2844 @end table
2846 If this option is non-@code{nil}, Emacs moves the mouse pointer to the
2847 frame selected by @code{select-frame-set-input-focus}.  That function is
2848 used by a number of commands like, for example, @code{other-frame} and
2849 @code{pop-to-buffer}.
2851 The distinction between the values @code{t} and @code{auto-raise} is not
2852 needed for ``normal'' frames because the window manager usually takes
2853 care of raising them.  It is useful to automatically raise child frames
2854 via @code{mouse-autoselect-window} (@pxref{Mouse Window
2855 Auto-selection}).
2857 Note that this option does not distinguish ``sloppy'' focus (where the
2858 frame that previously had focus retains focus as long as the mouse
2859 pointer does not move into another window manager window) from
2860 ``strict'' focus (where a frame immediately loses focus when it's left
2861 by the mouse pointer).  Neither does it recognize whether your window
2862 manager supports delayed focusing or auto-raising where you can
2863 explicitly specify the time until a new frame gets focus or is
2864 auto-raised.
2866 You can supply a ``focus follows mouse'' policy for individual Emacs
2867 windows by customizing the variable @code{mouse-autoselect-window}
2868 (@pxref{Mouse Window Auto-selection}).
2869 @end defopt
2872 @node Visibility of Frames
2873 @section Visibility of Frames
2874 @cindex visible frame
2875 @cindex invisible frame
2876 @cindex iconified frame
2877 @cindex minimized frame
2878 @cindex frame visibility
2880 A frame on a graphical display may be @dfn{visible}, @dfn{invisible}, or
2881 @dfn{iconified}.  If it is visible, its contents are displayed in the
2882 usual manner.  If it is iconified, its contents are not displayed, but
2883 there is a little icon somewhere to bring the frame back into view (some
2884 window managers refer to this state as @dfn{minimized} rather than
2885 @dfn{iconified}, but from Emacs' point of view they are the same thing).
2886 If a frame is invisible, it is not displayed at all.
2888 @cindex mapped frame
2889 @cindex unmapped frame
2890   The concept of visibility is strongly related to that of (un-)mapped
2891 frames.  A frame (or, more precisely, its window-system window) is and
2892 becomes @dfn{mapped} when it is displayed for the first time and
2893 whenever it changes its state of visibility from @code{iconified} or
2894 @code{invisible} to @code{visible}.  Conversely, a frame is and becomes
2895 @dfn{unmapped} whenever it changes its status from @code{visible} to
2896 @code{iconified} or @code{invisible}.
2898   Visibility is meaningless on text terminals, since only the selected
2899 frame is actually displayed in any case.
2901 @defun frame-visible-p frame
2902 This function returns the visibility status of frame @var{frame}.  The
2903 value is @code{t} if @var{frame} is visible, @code{nil} if it is
2904 invisible, and @code{icon} if it is iconified.
2906 On a text terminal, all frames are considered visible for the
2907 purposes of this function, even though only one frame is displayed.
2908 @xref{Raising and Lowering}.
2909 @end defun
2911 @deffn Command iconify-frame &optional frame
2912 This function iconifies frame @var{frame}.  If you omit @var{frame}, it
2913 iconifies the selected frame.  This usually makes all child frames of
2914 @var{frame} (and their descendants) invisible (@pxref{Child Frames}).
2915 @end deffn
2917 @deffn Command make-frame-visible &optional frame
2918 This function makes frame @var{frame} visible.  If you omit @var{frame},
2919 it makes the selected frame visible.  This does not raise the frame, but
2920 you can do that with @code{raise-frame} if you wish (@pxref{Raising and
2921 Lowering}).
2923 Making a frame visible usually makes all its child frames (and their
2924 descendants) visible as well (@pxref{Child Frames}).
2925 @end deffn
2927 @deffn Command make-frame-invisible &optional frame force
2928 This function makes frame @var{frame} invisible.  If you omit
2929 @var{frame}, it makes the selected frame invisible.  Usually, this makes
2930 all child frames of @var{frame} (and their descendants) invisible too
2931 (@pxref{Child Frames}).
2933 Unless @var{force} is non-@code{nil}, this function refuses to make
2934 @var{frame} invisible if all other frames are invisible.
2935 @end deffn
2937   The visibility status of a frame is also available as a frame
2938 parameter.  You can read or change it as such.  @xref{Management
2939 Parameters}.  The user can also iconify and deiconify frames with the
2940 window manager.  This happens below the level at which Emacs can exert
2941 any control, but Emacs does provide events that you can use to keep
2942 track of such changes.  @xref{Misc Events}.
2944 @defun x-double-buffered-p &optional frame
2945 This function returns non-@code{nil} if @var{frame} is currently
2946 being rendered with double buffering.  @var{frame} defaults to the
2947 selected frame.
2948 @end defun
2951 @node Raising and Lowering
2952 @section Raising, Lowering and Restacking Frames
2954 @cindex raising a frame
2955 @cindex lowering a frame
2956 @cindex restacking a frame
2957 @cindex frame stacking order
2958 @cindex frame Z-order
2959 @cindex Z-order
2960   Most window systems use a desktop metaphor.  Part of this metaphor is
2961 the idea that system-level windows (representing, e.g., Emacs frames)
2962 are stacked in a notional third dimension perpendicular to the screen
2963 surface.  The order induced by stacking is total and usually referred to
2964 as stacking (or Z-) order.  Where the areas of two windows overlap, the
2965 one higher up in that order will (partially) cover the one underneath.
2967   You can @dfn{raise} a frame to the top of that order or @dfn{lower} a
2968 frame to its bottom by using the functions @code{raise-frame} and
2969 @code{lower-frame}.  You can @dfn{restack} a frame directly above or
2970 below another frame using the function @code{frame-restack}.
2972   Note that all functions described below will respect the adherence of
2973 frames (and all other window-system windows) to their respective z-group
2974 (@pxref{Position Parameters}).  For example, you usually cannot lower a
2975 frame below that of the desktop window and you cannot raise a frame
2976 whose @code{z-group} parameter is @code{nil} above the window-system's
2977 taskbar or tooltip window.
2979 @deffn Command raise-frame &optional frame
2980 This function raises frame @var{frame} (default, the selected frame)
2981 above all other frames belonging to the same or a lower z-group as
2982 @var{frame}.  If @var{frame} is invisible or iconified, this makes it
2983 visible.  If @var{frame} is a child frame (@pxref{Child Frames}), this
2984 raises @var{frame} above all other child frames of its parent.
2985 @end deffn
2987 @deffn Command lower-frame &optional frame
2988 This function lowers frame @var{frame} (default, the selected frame)
2989 below all other frames belonging to the same or a higher z-group as
2990 @var{frame}.  If @var{frame} is a child frame (@pxref{Child Frames}),
2991 this lowers @var{frame} below all other child frames of its parent.
2992 @end deffn
2994 @defun frame-restack frame1 frame2 &optional above
2995 This function restacks @var{frame1} below @var{frame2}.  This implies
2996 that if both frames are visible and their display areas overlap,
2997 @var{frame2} will (partially) obscure @var{frame1}.  If the optional
2998 third argument @var{above} is non-@code{nil}, this function restacks
2999 @var{frame1} above @var{frame2}.  This means that if both frames are
3000 visible and their display areas overlap, @var{frame1} will (partially)
3001 obscure @var{frame2}.
3003 Technically, this function may be thought of as an atomic action
3004 performed in two steps: The first step removes @var{frame1}'s
3005 window-system window from the display.  The second step reinserts
3006 @var{frame1}'s window into the display below (above if @var{above} is
3007 true) that of @var{frame2}.  Hence the position of @var{frame2} in its
3008 display's Z (stacking) order relative to all other frames excluding
3009 @var{frame1} remains unaltered.
3011 Some window managers may refuse to restack windows.
3012 @end defun
3014 Note that the effect of restacking will only hold as long as neither of
3015 the involved frames is iconified or made invisible.  You can use the
3016 @code{z-group} (@pxref{Position Parameters}) frame parameter to add a
3017 frame to a group of frames permanently shown above or below other
3018 frames.  As long as a frame belongs to one of these groups, restacking
3019 it will only affect its relative stacking position within that group.
3020 The effect of restacking frames belonging to different z-groups is
3021 undefined.  You can list frames in their current stacking order with the
3022 function @code{frame-list-z-order} (@pxref{Finding All Frames}).
3024 @defopt minibuffer-auto-raise
3025 If this is non-@code{nil}, activation of the minibuffer raises the frame
3026 that the minibuffer window is in.
3027 @end defopt
3029   On window systems, you can also enable auto-raising (on frame
3030 selection) or auto-lowering (on frame deselection) using frame
3031 parameters.  @xref{Management Parameters}.
3033 @cindex top frame
3034   The concept of raising and lowering frames also applies to text
3035 terminal frames.  On each text terminal, only the top frame is
3036 displayed at any one time.
3038 @defun tty-top-frame &optional terminal
3039 This function returns the top frame on @var{terminal}.  @var{terminal}
3040 should be a terminal object, a frame (meaning that frame's terminal),
3041 or @code{nil} (meaning the selected frame's terminal).  If it does not
3042 refer to a text terminal, the return value is @code{nil}.
3043 @end defun
3046 @node Frame Configurations
3047 @section Frame Configurations
3048 @cindex frame configuration
3050   A @dfn{frame configuration} records the current arrangement of frames,
3051 all their properties, and the window configuration of each one.
3052 (@xref{Window Configurations}.)
3054 @defun current-frame-configuration
3055 This function returns a frame configuration list that describes
3056 the current arrangement of frames and their contents.
3057 @end defun
3059 @defun set-frame-configuration configuration &optional nodelete
3060 This function restores the state of frames described in
3061 @var{configuration}.  However, this function does not restore deleted
3062 frames.
3064 Ordinarily, this function deletes all existing frames not listed in
3065 @var{configuration}.  But if @var{nodelete} is non-@code{nil}, the
3066 unwanted frames are iconified instead.
3067 @end defun
3070 @node Child Frames
3071 @section Child Frames
3072 @cindex child frames
3073 @cindex parent frames
3075 Child frames are objects halfway between windows (@pxref{Windows}) and
3076 ``normal'' frames.  Like windows, they are attached to an owning frame.
3077 Unlike windows, they may overlap each other---changing the size or
3078 position of one child frame does not change the size or position of any
3079 of its sibling child frames.
3081   By design, operations to make or modify child frames are implemented
3082 with the help of frame parameters (@pxref{Frame Parameters}) without any
3083 specialized functions or customizable variables.  Note that child frames
3084 are meaningful on graphical terminals only.
3086   To create a new child frame or to convert a normal frame into a child
3087 frame, set that frame's @code{parent-frame} parameter (@pxref{Frame
3088 Interaction Parameters}) to that of an already existing frame.  The
3089 frame specified by that parameter will then be the frame's parent frame
3090 as long as the parameter is not changed or reset.  Technically, this
3091 makes the child frame's window-system window a child window of the
3092 parent frame's window-system window.
3094 @cindex reparent frame
3095 @cindex nest frame
3096   The @code{parent-frame} parameter can be changed at any time.  Setting
3097 it to another frame @dfn{reparents} the child frame.  Setting it to
3098 another child frame makes the frame a @dfn{nested} child frame.  Setting
3099 it to @code{nil} restores the frame's status as a top-level frame---a
3100 frame whose window-system window is a child of its display's root
3101 window.
3103   Since child frames can be arbitrarily nested, a frame can be both a
3104 child and a parent frame.  Also, the relative roles of child and parent
3105 frame may be reversed at any time (though it's usually a good idea to
3106 keep the size of a child frame sufficiently smaller than that of its
3107 parent).  An error will be signaled for the attempt to make a frame an
3108 ancestor of itself.
3110    Most window-systems clip a child frame at the native edges
3111 (@pxref{Frame Geometry}) of its parent frame---everything outside these
3112 edges is usually invisible.  A child frame's @code{left} and @code{top}
3113 parameters specify a position relative to the top-left corner of its
3114 parent's native frame.  When the parent frame is resized, this position
3115 remains conceptually unaltered.
3117   NS builds do not clip child frames at the parent frame's edges,
3118 allowing them to be positioned so they do not obscure the parent frame
3119 while still being visible themselves.
3121   Usually, moving a parent frame moves along all its child frames and
3122 their descendants as well, keeping their relative positions unaltered.
3123 Note that the hook @code{move-frame-functions} (@pxref{Frame Position})
3124 is run for a child frame only when the position of the child frame
3125 relative to its parent frame changes.
3127   When a parent frame is resized, its child frames conceptually retain
3128 their previous sizes and their positions relative to the left upper
3129 corner of the parent.  This means that a child frame may become
3130 (partially) invisible when its parent frame shrinks.  The parameter
3131 @code{keep-ratio} (@pxref{Frame Interaction Parameters}) can be used to
3132 resize and reposition a child frame proportionally whenever its parent
3133 frame is resized.  This may avoid obscuring parts of a frame when its
3134 parent frame is shrunk.
3136   A visible child frame always appears on top of its parent frame thus
3137 obscuring parts of it, except on NS builds where it may be positioned
3138 beneath the parent.  This is comparable to the window-system window of a
3139 top-level frame which also always appears on top of its parent
3140 window---the desktop's root window.  When a parent frame is iconified or
3141 made invisible (@pxref{Visibility of Frames}), its child frames are made
3142 invisible.  When a parent frame is deiconified or made visible, its
3143 child frames are made visible.  When a parent frame is about to be
3144 deleted (@pxref{Deleting Frames}), its child frames are recursively
3145 deleted before it.
3147   Whether a child frame can have a menu or tool bar is window-system or
3148 window manager dependent.  Most window-systems explicitly disallow menus
3149 bars for child frames.  It seems advisable to disable both, menu and
3150 tool bars, via the frame's initial parameters settings.
3152   Usually, child frames do not exhibit window manager decorations like a
3153 title bar or external borders (@pxref{Frame Geometry}).  When the child
3154 frame does not show a menu or tool bar, any other of the frame's borders
3155 (@pxref{Layout Parameters}) can be used instead of the external borders.
3157   In particular, under X (but not when building with GTK+), the frame's
3158 outer border can be used.  On MS-Windows, specifying a non-zero outer
3159 border width will show a one-pixel wide external border.  Under all
3160 window-systems, the internal border can be used.  In either case, it's
3161 advisable to disable a child frame's window manager decorations with the
3162 @code{undecorated} frame parameter (@pxref{Management Parameters}).
3164   To resize or move an undecorated child frame with the mouse, special
3165 frame parameters (@pxref{Mouse Dragging Parameters}) have to be used.
3166 The internal border of a child frame, if present, can be used to resize
3167 the frame with the mouse, provided that frame has a non-@code{nil}
3168 @code{drag-internal-border} parameter.  If set, the @code{snap-width}
3169 parameter indicates the number of pixels where the frame @dfn{snaps} at
3170 the respective edge or corner of its parent frame.
3172   There are two ways to drag an entire child frame with the mouse: The
3173 @code{drag-with-mode-line} parameter, if non-@code{nil}, allows to drag
3174 a frame without minibuffer window (@pxref{Minibuffer Windows}) via the
3175 mode line area of its bottommost window.  The
3176 @code{drag-with-header-line} parameter, if non-@code{nil}, allows to
3177 drag the frame via the header line area of its topmost window.
3179   In order to give a child frame a draggable header or mode line, the
3180 window parameters @code{mode-line-format} and @code{header-line-format}
3181 are handy (@pxref{Window Parameters}).  These allow to remove an
3182 unwanted mode line (when @code{drag-with-header-line} is chosen) and to
3183 remove mouse-sensitive areas which might interfere with frame dragging.
3185   To avoid that dragging moves a frame completely out of its parent's
3186 native frame, something which might happen when the mouse cursor
3187 overshoots and makes the frame difficult to retrieve once the mouse
3188 button has been released, it is advisable to set the frame's
3189 @code{top-visible} or @code{bottom-visible} parameter correspondingly.
3191   The @code{top-visible} parameter specifies the number of pixels at the
3192 top of the frame that always remain visible within the parent's native
3193 frame during dragging and should be set when specifying a non-@code{nil}
3194 @code{drag-with-header-line} parameter.  The @code{bottom-visible}
3195 parameter specifies the number of pixels at the bottom of the frame that
3196 always remain visible within the parent's native frame during dragging
3197 and should be preferred when specifying a non-@code{nil}
3198 @code{drag-with-mode-line} parameter.
3200   When a child frame is used for displaying a buffer via
3201 @code{display-buffer-in-child-frame} (@pxref{Display Action Functions}),
3202 the frame's @code{auto-hide-function} parameter (@pxref{Frame
3203 Interaction Parameters}) can be set to a function, in order to
3204 appropriately deal with the frame when the window displaying the buffer
3205 shall be quit.
3207   When a child frame is used during minibuffer interaction, for example,
3208 to display completions in a separate window, the @code{minibuffer-exit}
3209 parameter (@pxref{Frame Interaction Parameters}) is useful in order to
3210 deal with the frame when the minibuffer is exited.
3212   The behavior of child frames deviates from that of top-level frames in
3213 a number of other ways as well.  Here we sketch a few of them:
3215 @itemize @bullet
3216 @item
3217 The semantics of maximizing and iconifying child frames is highly
3218 window-system dependent.  As a rule, applications should never invoke
3219 these operations on child frames.  By default, invoking
3220 @code{iconify-frame} on a child frame will try to iconify the top-level
3221 frame corresponding to that child frame instead.  To obtain a different
3222 behavior, users may customize the option @code{iconify-child-frame}
3223 described below.
3225 @item
3226 Raising, lowering and restacking child frames (@pxref{Raising and
3227 Lowering}) or changing the @code{z-group} (@pxref{Position Parameters})
3228 of a child frame changes only the stacking order of child frames with
3229 the same parent.
3231 @item
3232 Many window-systems are not able to change the opacity (@pxref{Font and
3233 Color Parameters}) of child frames.
3235 @item
3236 Transferring focus from a child frame to an ancestor that is not its
3237 parent by clicking with the mouse in a visible part of that ancestor's
3238 window may fail with some window-systems.  You may have to click into
3239 the direct parent's window-system window first.
3241 @item
3242 Window managers might not bother to extend their focus follows mouse
3243 policy to child frames.  Customizing @code{mouse-autoselect-window} can
3244 help in this regard (@pxref{Mouse Window Auto-selection}).
3246 @item
3247 Dropping (@pxref{Drag and Drop}) on child frames is not guaranteed to
3248 work on all window-systems.  Some will drop the object on the parent
3249 frame or on some ancestor instead.
3250 @end itemize
3252   The following two functions can be useful when working with child and
3253 parent frames:
3255 @defun frame-parent &optional frame
3256 This function returns the parent frame of @var{frame}.  The parent frame
3257 of @var{frame} is the Emacs frame whose window-system window is the
3258 parent window of @var{frame}'s window-system window.  If such a frame
3259 exists, @var{frame} is considered a child frame of that frame.
3261 This function returns @code{nil} if @var{frame} has no parent frame.
3262 @end defun
3264 @defun frame-ancestor-p ancestor descendant
3265 This functions returns non-@code{nil} if @var{ancestor} is an ancestor
3266 of @var{descendant}.  @var{ancestor} is an ancestor of @var{descendant}
3267 when it is either @var{descendant}'s parent frame or it is an ancestor
3268 of @var{descendant}'s parent frame.  Both, @var{ancestor} and
3269 @var{descendant} must specify live frames.
3270 @end defun
3272 Note also the function @code{window-largest-empty-rectangle}
3273 (@pxref{Coordinates and Windows}) which can be used to inscribe a child
3274 frame in the largest empty area of an existing window.  This can be
3275 useful to avoid that a child frame obscures any text shown in that
3276 window.
3278 Customizing the following option can be useful to tweak the behavior of
3279 @code{iconify-frame} for child frames.
3281 @defopt iconify-child-frame
3282 This option tells Emacs how to proceed when it is asked to iconify a
3283 child frame.  If it is @code{nil}, @code{iconify-frame} will do nothing
3284 when invoked on a child frame.  If it is @code{iconify-top-level}, Emacs
3285 will try to iconify the top-level frame that is the ancestor of this
3286 child frame instead.  If it is @code{make-invisible}, Emacs will try to
3287 make this child frame invisible instead of iconifying it.
3289 Any other value means to try iconifying the child frame.  Since such an
3290 attempt may not be honored by all window managers and can even lead to
3291 making the child frame unresponsive to user actions, the default is to
3292 iconify the top level frame instead.
3293 @end defopt
3296 @node Mouse Tracking
3297 @section Mouse Tracking
3298 @cindex mouse tracking
3299 @c @cindex tracking the mouse   Duplicates track-mouse
3301   Sometimes it is useful to @dfn{track} the mouse, which means to display
3302 something to indicate where the mouse is and move the indicator as the
3303 mouse moves.  For efficient mouse tracking, you need a way to wait until
3304 the mouse actually moves.
3306   The convenient way to track the mouse is to ask for events to represent
3307 mouse motion.  Then you can wait for motion by waiting for an event.  In
3308 addition, you can easily handle any other sorts of events that may
3309 occur.  That is useful, because normally you don't want to track the
3310 mouse forever---only until some other event, such as the release of a
3311 button.
3313 @defspec track-mouse body@dots{}
3314 This special form executes @var{body}, with generation of mouse motion
3315 events enabled.  Typically, @var{body} would use @code{read-event} to
3316 read the motion events and modify the display accordingly.  @xref{Motion
3317 Events}, for the format of mouse motion events.
3319 The value of @code{track-mouse} is that of the last form in @var{body}.
3320 You should design @var{body} to return when it sees the up-event that
3321 indicates the release of the button, or whatever kind of event means
3322 it is time to stop tracking.
3324 The @code{track-mouse} form causes Emacs to generate mouse motion
3325 events by binding the variable @code{track-mouse} to a
3326 non-@code{nil} value.  If that variable has the special value
3327 @code{dragging}, it additionally instructs the display engine to
3328 refrain from changing the shape of the mouse pointer.  This is
3329 desirable in Lisp programs that require mouse dragging across large
3330 portions of Emacs display, which might otherwise cause the mouse
3331 pointer to change its shape according to the display portion it hovers
3332 on (@pxref{Pointer Shape}).  Therefore, Lisp programs that need the
3333 mouse pointer to retain its original shape during dragging should bind
3334 @code{track-mouse} to the value @code{dragging} at the beginning of
3335 their @var{body}.
3336 @end defspec
3338 The usual purpose of tracking mouse motion is to indicate on the screen
3339 the consequences of pushing or releasing a button at the current
3340 position.
3342 In many cases, you can avoid the need to track the mouse by using
3343 the @code{mouse-face} text property (@pxref{Special Properties}).
3344 That works at a much lower level and runs more smoothly than
3345 Lisp-level mouse tracking.
3347 @ignore
3348 @c These are not implemented yet.
3350 These functions change the screen appearance instantaneously.  The
3351 effect is transient, only until the next ordinary Emacs redisplay.  That
3352 is OK for mouse tracking, since it doesn't make sense for mouse tracking
3353 to change the text, and the body of @code{track-mouse} normally reads
3354 the events itself and does not do redisplay.
3356 @defun x-contour-region window beg end
3357 This function draws lines to make a box around the text from @var{beg}
3358 to @var{end}, in window @var{window}.
3359 @end defun
3361 @defun x-uncontour-region window beg end
3362 This function erases the lines that would make a box around the text
3363 from @var{beg} to @var{end}, in window @var{window}.  Use it to remove
3364 a contour that you previously made by calling @code{x-contour-region}.
3365 @end defun
3367 @defun x-draw-rectangle frame left top right bottom
3368 This function draws a hollow rectangle on frame @var{frame} with the
3369 specified edge coordinates, all measured in pixels from the inside top
3370 left corner.  It uses the cursor color, the one used for indicating the
3371 location of point.
3372 @end defun
3374 @defun x-erase-rectangle frame left top right bottom
3375 This function erases a hollow rectangle on frame @var{frame} with the
3376 specified edge coordinates, all measured in pixels from the inside top
3377 left corner.  Erasure means redrawing the text and background that
3378 normally belong in the specified rectangle.
3379 @end defun
3380 @end ignore
3382 @node Mouse Position
3383 @section Mouse Position
3384 @cindex mouse position
3385 @cindex position of mouse
3387   The functions @code{mouse-position} and @code{set-mouse-position}
3388 give access to the current position of the mouse.
3390 @defun mouse-position
3391 This function returns a description of the position of the mouse.  The
3392 value looks like @code{(@var{frame} @var{x} . @var{y})}, where @var{x}
3393 and @var{y} are integers giving the (possibly rounded) position in
3394 multiples of the default character size of @var{frame} (@pxref{Frame
3395 Font}) relative to the native position of @var{frame} (@pxref{Frame
3396 Geometry}).
3397 @end defun
3399 @defvar mouse-position-function
3400 If non-@code{nil}, the value of this variable is a function for
3401 @code{mouse-position} to call.  @code{mouse-position} calls this
3402 function just before returning, with its normal return value as the
3403 sole argument, and it returns whatever this function returns to it.
3405 This abnormal hook exists for the benefit of packages like
3406 @file{xt-mouse.el} that need to do mouse handling at the Lisp level.
3407 @end defvar
3409 @defun set-mouse-position frame x y
3410 This function @dfn{warps the mouse} to position @var{x}, @var{y} in
3411 frame @var{frame}.  The arguments @var{x} and @var{y} are integers,
3412 giving the position in multiples of the default character size of
3413 @var{frame} (@pxref{Frame Font}) relative to the native position of
3414 @var{frame} (@pxref{Frame Geometry}).
3416 The resulting mouse position is constrained to the native frame of
3417 @var{frame}.  If @var{frame} is not visible, this function does nothing.
3418 The return value is not significant.
3419 @end defun
3421 @defun mouse-pixel-position
3422 This function is like @code{mouse-position} except that it returns
3423 coordinates in units of pixels rather than units of characters.
3424 @end defun
3426 @defun set-mouse-pixel-position frame x y
3427 This function warps the mouse like @code{set-mouse-position} except that
3428 @var{x} and @var{y} are in units of pixels rather than units of
3429 characters.
3431 The resulting mouse position is not constrained to the native frame of
3432 @var{frame}.  If @var{frame} is not visible, this function does nothing.
3433 The return value is not significant.
3434 @end defun
3436 On a graphical terminal the following two functions allow the absolute
3437 position of the mouse cursor to be retrieved and set.
3439 @defun mouse-absolute-pixel-position
3440 This function returns a cons cell (@var{x} . @var{y}) of the coordinates
3441 of the mouse cursor position in pixels, relative to a position (0, 0) of
3442 the selected frame's display.
3443 @end defun
3445 @defun set-mouse-absolute-pixel-position x y
3446 This function moves the mouse cursor to the position (@var{x}, @var{y}).
3447 The coordinates @var{x} and @var{y} are interpreted in pixels relative
3448 to a position (0, 0) of the selected frame's display.
3449 @end defun
3451 The following function can tell whether the mouse cursor is currently
3452 visible on a frame:
3454 @defun frame-pointer-visible-p &optional frame
3455 This predicate function returns non-@code{nil} if the mouse pointer
3456 displayed on @var{frame} is visible; otherwise it returns @code{nil}.
3457 @var{frame} omitted or @code{nil} means the selected frame.  This is
3458 useful when @code{make-pointer-invisible} is set to @code{t}: it
3459 allows you to know if the pointer has been hidden.
3460 @xref{Mouse Avoidance,,,emacs, The Emacs Manual}.
3461 @end defun
3463 @need 3000
3465 @node Pop-Up Menus
3466 @section Pop-Up Menus
3467 @cindex menus, popup
3469   A Lisp program can pop up a menu so that the user can choose an
3470 alternative with the mouse.  On a text terminal, if the mouse is not
3471 available, the user can choose an alternative using the keyboard
3472 motion keys---@kbd{C-n}, @kbd{C-p}, or up- and down-arrow keys.
3474 @defun x-popup-menu position menu
3475 This function displays a pop-up menu and returns an indication of
3476 what selection the user makes.
3478 The argument @var{position} specifies where on the screen to put the
3479 top left corner of the menu.  It can be either a mouse button event
3480 (which says to put the menu where the user actuated the button) or a
3481 list of this form:
3483 @example
3484 ((@var{xoffset} @var{yoffset}) @var{window})
3485 @end example
3487 @noindent
3488 where @var{xoffset} and @var{yoffset} are coordinates, measured in
3489 pixels, counting from the top left corner of @var{window}.  @var{window}
3490 may be a window or a frame.
3492 If @var{position} is @code{t}, it means to use the current mouse
3493 position (or the top-left corner of the frame if the mouse is not
3494 available on a text terminal).  If @var{position} is @code{nil}, it
3495 means to precompute the key binding equivalents for the keymaps
3496 specified in @var{menu}, without actually displaying or popping up the
3497 menu.
3499 The argument @var{menu} says what to display in the menu.  It can be a
3500 keymap or a list of keymaps (@pxref{Menu Keymaps}).  In this case, the
3501 return value is the list of events corresponding to the user's choice.
3502 This list has more than one element if the choice occurred in a
3503 submenu.  (Note that @code{x-popup-menu} does not actually execute the
3504 command bound to that sequence of events.)  On text terminals and
3505 toolkits that support menu titles, the title is taken from the prompt
3506 string of @var{menu} if @var{menu} is a keymap, or from the prompt
3507 string of the first keymap in @var{menu} if it is a list of keymaps
3508 (@pxref{Defining Menus}).
3510 Alternatively, @var{menu} can have the following form:
3512 @example
3513 (@var{title} @var{pane1} @var{pane2}...)
3514 @end example
3516 @noindent
3517 where each pane is a list of form
3519 @example
3520 (@var{title} @var{item1} @var{item2}...)
3521 @end example
3523 Each @var{item} should be a cons cell, @code{(@var{line} . @var{value})},
3524 where @var{line} is a string and @var{value} is the value to return if
3525 that @var{line} is chosen.  Unlike in a menu keymap, a @code{nil}
3526 @var{value} does not make the menu item non-selectable.
3527 Alternatively, each @var{item} can be a string rather than a cons
3528 cell; this makes a non-selectable menu item.
3530 If the user gets rid of the menu without making a valid choice, for
3531 instance by clicking the mouse away from a valid choice or by typing
3532 @kbd{C-g}, then this normally results in a quit and
3533 @code{x-popup-menu} does not return.  But if @var{position} is a mouse
3534 button event (indicating that the user invoked the menu with the
3535 mouse) then no quit occurs and @code{x-popup-menu} returns @code{nil}.
3536 @end defun
3538   @strong{Usage note:} Don't use @code{x-popup-menu} to display a menu
3539 if you could do the job with a prefix key defined with a menu keymap.
3540 If you use a menu keymap to implement a menu, @kbd{C-h c} and @kbd{C-h
3541 a} can see the individual items in that menu and provide help for them.
3542 If instead you implement the menu by defining a command that calls
3543 @code{x-popup-menu}, the help facilities cannot know what happens inside
3544 that command, so they cannot give any help for the menu's items.
3546   The menu bar mechanism, which lets you switch between submenus by
3547 moving the mouse, cannot look within the definition of a command to see
3548 that it calls @code{x-popup-menu}.  Therefore, if you try to implement a
3549 submenu using @code{x-popup-menu}, it cannot work with the menu bar in
3550 an integrated fashion.  This is why all menu bar submenus are
3551 implemented with menu keymaps within the parent menu, and never with
3552 @code{x-popup-menu}.  @xref{Menu Bar}.
3554   If you want a menu bar submenu to have contents that vary, you should
3555 still use a menu keymap to implement it.  To make the contents vary, add
3556 a hook function to @code{menu-bar-update-hook} to update the contents of
3557 the menu keymap as necessary.
3559 @node Dialog Boxes
3560 @section Dialog Boxes
3561 @cindex dialog boxes
3563   A dialog box is a variant of a pop-up menu---it looks a little
3564 different, it always appears in the center of a frame, and it has just
3565 one level and one or more buttons.  The main use of dialog boxes is
3566 for asking questions that the user can answer with ``yes'', ``no'',
3567 and a few other alternatives.  With a single button, they can also
3568 force the user to acknowledge important information.  The functions
3569 @code{y-or-n-p} and @code{yes-or-no-p} use dialog boxes instead of the
3570 keyboard, when called from commands invoked by mouse clicks.
3572 @defun x-popup-dialog position contents &optional header
3573 This function displays a pop-up dialog box and returns an indication of
3574 what selection the user makes.  The argument @var{contents} specifies
3575 the alternatives to offer; it has this format:
3577 @example
3578 (@var{title} (@var{string} . @var{value})@dots{})
3579 @end example
3581 @noindent
3582 which looks like the list that specifies a single pane for
3583 @code{x-popup-menu}.
3585 The return value is @var{value} from the chosen alternative.
3587 As for @code{x-popup-menu}, an element of the list may be just a
3588 string instead of a cons cell @code{(@var{string} . @var{value})}.
3589 That makes a box that cannot be selected.
3591 If @code{nil} appears in the list, it separates the left-hand items from
3592 the right-hand items; items that precede the @code{nil} appear on the
3593 left, and items that follow the @code{nil} appear on the right.  If you
3594 don't include a @code{nil} in the list, then approximately half the
3595 items appear on each side.
3597 Dialog boxes always appear in the center of a frame; the argument
3598 @var{position} specifies which frame.  The possible values are as in
3599 @code{x-popup-menu}, but the precise coordinates or the individual
3600 window don't matter; only the frame matters.
3602 If @var{header} is non-@code{nil}, the frame title for the box is
3603 @samp{Information}, otherwise it is @samp{Question}.  The former is used
3604 for @code{message-box} (@pxref{message-box}).  (On text terminals, the
3605 box title is not displayed.)
3607 In some configurations, Emacs cannot display a real dialog box; so
3608 instead it displays the same items in a pop-up menu in the center of the
3609 frame.
3611 If the user gets rid of the dialog box without making a valid choice,
3612 for instance using the window manager, then this produces a quit and
3613 @code{x-popup-dialog} does not return.
3614 @end defun
3616 @node Pointer Shape
3617 @section Pointer Shape
3618 @cindex pointer shape
3619 @cindex mouse pointer shape
3621   You can specify the mouse pointer style for particular text or
3622 images using the @code{pointer} text property, and for images with the
3623 @code{:pointer} and @code{:map} image properties.  The values you can
3624 use in these properties are @code{text} (or @code{nil}), @code{arrow},
3625 @code{hand}, @code{vdrag}, @code{hdrag}, @code{modeline}, and
3626 @code{hourglass}.  @code{text} stands for the usual mouse pointer
3627 style used over text.
3629   Over void parts of the window (parts that do not correspond to any
3630 of the buffer contents), the mouse pointer usually uses the
3631 @code{arrow} style, but you can specify a different style (one of
3632 those above) by setting @code{void-text-area-pointer}.
3634 @defopt void-text-area-pointer
3635 This variable specifies the mouse pointer style for void text areas.
3636 These include the areas after the end of a line or below the last line
3637 in the buffer.  The default is to use the @code{arrow} (non-text)
3638 pointer style.
3639 @end defopt
3641   When using X, you can specify what the @code{text} pointer style
3642 really looks like by setting the variable @code{x-pointer-shape}.
3644 @defvar x-pointer-shape
3645 This variable specifies the pointer shape to use ordinarily in the
3646 Emacs frame, for the @code{text} pointer style.
3647 @end defvar
3649 @defvar x-sensitive-text-pointer-shape
3650 This variable specifies the pointer shape to use when the mouse
3651 is over mouse-sensitive text.
3652 @end defvar
3654   These variables affect newly created frames.  They do not normally
3655 affect existing frames; however, if you set the mouse color of a
3656 frame, that also installs the current value of those two variables.
3657 @xref{Font and Color Parameters}.
3659   The values you can use, to specify either of these pointer shapes, are
3660 defined in the file @file{lisp/term/x-win.el}.  Use @kbd{M-x apropos
3661 @key{RET} x-pointer @key{RET}} to see a list of them.
3663 @node Window System Selections
3664 @section Window System Selections
3665 @cindex selection (for window systems)
3666 @cindex clipboard
3667 @cindex primary selection
3668 @cindex secondary selection
3670   In window systems, such as X, data can be transferred between
3671 different applications by means of @dfn{selections}.  X defines an
3672 arbitrary number of @dfn{selection types}, each of which can store its
3673 own data; however, only three are commonly used: the @dfn{clipboard},
3674 @dfn{primary selection}, and @dfn{secondary selection}.  Other window
3675 systems support only the clipboard.  @xref{Cut and Paste,, Cut and
3676 Paste, emacs, The GNU Emacs Manual}, for Emacs commands that make use
3677 of these selections.  This section documents the low-level functions
3678 for reading and setting window-system selections.
3680 @deffn Command gui-set-selection type data
3681 This function sets a window-system selection.  It takes two arguments:
3682 a selection type @var{type}, and the value to assign to it, @var{data}.
3684 @var{type} should be a symbol; it is usually one of @code{PRIMARY},
3685 @code{SECONDARY} or @code{CLIPBOARD}.  These are symbols with
3686 upper-case names, in accord with X Window System conventions.  If
3687 @var{type} is @code{nil}, that stands for @code{PRIMARY}.
3689 If @var{data} is @code{nil}, it means to clear out the selection.
3690 Otherwise, @var{data} may be a string, a symbol, an integer (or a cons
3691 of two integers or list of two integers), an overlay, or a cons of two
3692 markers pointing to the same buffer.  An overlay or a pair of markers
3693 stands for text in the overlay or between the markers.  The argument
3694 @var{data} may also be a vector of valid non-vector selection values.
3696 This function returns @var{data}.
3697 @end deffn
3699 @defun gui-get-selection &optional type data-type
3700 This function accesses selections set up by Emacs or by other
3701 programs.  It takes two optional arguments, @var{type} and
3702 @var{data-type}.  The default for @var{type}, the selection type, is
3703 @code{PRIMARY}.
3705 The @var{data-type} argument specifies the form of data conversion to
3706 use, to convert the raw data obtained from another program into Lisp
3707 data.  Meaningful values include @code{TEXT}, @code{STRING},
3708 @code{UTF8_STRING}, @code{TARGETS}, @code{LENGTH}, @code{DELETE},
3709 @code{FILE_NAME}, @code{CHARACTER_POSITION}, @code{NAME},
3710 @code{LINE_NUMBER}, @code{COLUMN_NUMBER}, @code{OWNER_OS},
3711 @code{HOST_NAME}, @code{USER}, @code{CLASS}, @code{ATOM}, and
3712 @code{INTEGER}.  (These are symbols with upper-case names in accord
3713 with X conventions.)  The default for @var{data-type} is
3714 @code{STRING}.  Window systems other than X usually support only a
3715 small subset of these types, in addition to @code{STRING}.
3716 @end defun
3718 @defopt selection-coding-system
3719 This variable specifies the coding system to use when reading and
3720 writing selections or the clipboard.  @xref{Coding
3721 Systems}.  The default is @code{compound-text-with-extensions}, which
3722 converts to the text representation that X11 normally uses.
3723 @end defopt
3725 @cindex clipboard support (for MS-Windows)
3726 When Emacs runs on MS-Windows, it does not implement X selections in
3727 general, but it does support the clipboard.  @code{gui-get-selection}
3728 and @code{gui-set-selection} on MS-Windows support the text data type
3729 only; if the clipboard holds other types of data, Emacs treats the
3730 clipboard as empty.  The supported data type is @code{STRING}.
3732 For backward compatibility, there are obsolete aliases
3733 @code{x-get-selection} and @code{x-set-selection}, which were the
3734 names of @code{gui-get-selection} and @code{gui-set-selection} before
3735 Emacs 25.1.
3737 @node Drag and Drop
3738 @section Drag and Drop
3739 @cindex drag and drop
3741 @vindex x-dnd-test-function
3742 @vindex x-dnd-known-types
3743   When a user drags something from another application over Emacs, that other
3744 application expects Emacs to tell it if Emacs can handle the data that is
3745 dragged.  The variable @code{x-dnd-test-function} is used by Emacs to determine
3746 what to reply.  The default value is @code{x-dnd-default-test-function}
3747 which accepts drops if the type of the data to be dropped is present in
3748 @code{x-dnd-known-types}.  You can customize @code{x-dnd-test-function} and/or
3749 @code{x-dnd-known-types} if you want Emacs to accept or reject drops based
3750 on some other criteria.
3752 @vindex x-dnd-types-alist
3753   If you want to change the way Emacs handles drop of different types
3754 or add a new type, customize @code{x-dnd-types-alist}.  This requires
3755 detailed knowledge of what types other applications use for drag and
3756 drop.
3758 @vindex dnd-protocol-alist
3759   When an URL is dropped on Emacs it may be a file, but it may also be
3760 another URL type (ftp, http, etc.).  Emacs first checks
3761 @code{dnd-protocol-alist} to determine what to do with the URL@.  If
3762 there is no match there and if @code{browse-url-browser-function} is
3763 an alist, Emacs looks for a match there.  If no match is found the
3764 text for the URL is inserted.  If you want to alter Emacs behavior,
3765 you can customize these variables.
3767 @node Color Names
3768 @section Color Names
3770 @cindex color names
3771 @cindex specify color
3772 @cindex numerical RGB color specification
3773   A color name is text (usually in a string) that specifies a color.
3774 Symbolic names such as @samp{black}, @samp{white}, @samp{red}, etc.,
3775 are allowed; use @kbd{M-x list-colors-display} to see a list of
3776 defined names.  You can also specify colors numerically in forms such
3777 as @samp{#@var{rgb}} and @samp{RGB:@var{r}/@var{g}/@var{b}}, where
3778 @var{r} specifies the red level, @var{g} specifies the green level,
3779 and @var{b} specifies the blue level.  You can use either one, two,
3780 three, or four hex digits for @var{r}; then you must use the same
3781 number of hex digits for all @var{g} and @var{b} as well, making
3782 either 3, 6, 9 or 12 hex digits in all.  (See the documentation of the
3783 X Window System for more details about numerical RGB specification of
3784 colors.)
3786   These functions provide a way to determine which color names are
3787 valid, and what they look like.  In some cases, the value depends on the
3788 @dfn{selected frame}, as described below; see @ref{Input Focus}, for the
3789 meaning of the term ``selected frame''.
3791   To read user input of color names with completion, use
3792 @code{read-color} (@pxref{High-Level Completion, read-color}).
3794 @defun color-defined-p color &optional frame
3795 This function reports whether a color name is meaningful.  It returns
3796 @code{t} if so; otherwise, @code{nil}.  The argument @var{frame} says
3797 which frame's display to ask about; if @var{frame} is omitted or
3798 @code{nil}, the selected frame is used.
3800 Note that this does not tell you whether the display you are using
3801 really supports that color.  When using X, you can ask for any defined
3802 color on any kind of display, and you will get some result---typically,
3803 the closest it can do.  To determine whether a frame can really display
3804 a certain color, use @code{color-supported-p} (see below).
3806 @findex x-color-defined-p
3807 This function used to be called @code{x-color-defined-p},
3808 and that name is still supported as an alias.
3809 @end defun
3811 @defun defined-colors &optional frame
3812 This function returns a list of the color names that are defined
3813 and supported on frame @var{frame} (default, the selected frame).
3814 If @var{frame} does not support colors, the value is @code{nil}.
3816 @findex x-defined-colors
3817 This function used to be called @code{x-defined-colors},
3818 and that name is still supported as an alias.
3819 @end defun
3821 @defun color-supported-p color &optional frame background-p
3822 This returns @code{t} if @var{frame} can really display the color
3823 @var{color} (or at least something close to it).  If @var{frame} is
3824 omitted or @code{nil}, the question applies to the selected frame.
3826 Some terminals support a different set of colors for foreground and
3827 background.  If @var{background-p} is non-@code{nil}, that means you are
3828 asking whether @var{color} can be used as a background; otherwise you
3829 are asking whether it can be used as a foreground.
3831 The argument @var{color} must be a valid color name.
3832 @end defun
3834 @defun color-gray-p color &optional frame
3835 This returns @code{t} if @var{color} is a shade of gray, as defined on
3836 @var{frame}'s display.  If @var{frame} is omitted or @code{nil}, the
3837 question applies to the selected frame.  If @var{color} is not a valid
3838 color name, this function returns @code{nil}.
3839 @end defun
3841 @defun color-values color &optional frame
3842 @cindex rgb value
3843 This function returns a value that describes what @var{color} should
3844 ideally look like on @var{frame}.  If @var{color} is defined, the
3845 value is a list of three integers, which give the amount of red, the
3846 amount of green, and the amount of blue.  Each integer ranges in
3847 principle from 0 to 65535, but some displays may not use the full
3848 range.  This three-element list is called the @dfn{rgb values} of the
3849 color.
3851 If @var{color} is not defined, the value is @code{nil}.
3853 @example
3854 (color-values "black")
3855      @result{} (0 0 0)
3856 (color-values "white")
3857      @result{} (65280 65280 65280)
3858 (color-values "red")
3859      @result{} (65280 0 0)
3860 (color-values "pink")
3861      @result{} (65280 49152 51968)
3862 (color-values "hungry")
3863      @result{} nil
3864 @end example
3866 The color values are returned for @var{frame}'s display.  If
3867 @var{frame} is omitted or @code{nil}, the information is returned for
3868 the selected frame's display.  If the frame cannot display colors, the
3869 value is @code{nil}.
3871 @findex x-color-values
3872 This function used to be called @code{x-color-values},
3873 and that name is still supported as an alias.
3874 @end defun
3876 @node Text Terminal Colors
3877 @section Text Terminal Colors
3878 @cindex colors on text terminals
3880   Text terminals usually support only a small number of colors, and
3881 the computer uses small integers to select colors on the terminal.
3882 This means that the computer cannot reliably tell what the selected
3883 color looks like; instead, you have to inform your application which
3884 small integers correspond to which colors.  However, Emacs does know
3885 the standard set of colors and will try to use them automatically.
3887   The functions described in this section control how terminal colors
3888 are used by Emacs.
3890   Several of these functions use or return @dfn{rgb values}, described
3891 in @ref{Color Names}.
3893   These functions accept a display (either a frame or the name of a
3894 terminal) as an optional argument.  We hope in the future to make
3895 Emacs support different colors on different text terminals; then this
3896 argument will specify which terminal to operate on (the default being
3897 the selected frame's terminal; @pxref{Input Focus}).  At present,
3898 though, the @var{frame} argument has no effect.
3900 @defun tty-color-define name number &optional rgb frame
3901 This function associates the color name @var{name} with
3902 color number @var{number} on the terminal.
3904 The optional argument @var{rgb}, if specified, is an rgb value, a list
3905 of three numbers that specify what the color actually looks like.
3906 If you do not specify @var{rgb}, then this color cannot be used by
3907 @code{tty-color-approximate} to approximate other colors, because
3908 Emacs will not know what it looks like.
3909 @end defun
3911 @defun tty-color-clear &optional frame
3912 This function clears the table of defined colors for a text terminal.
3913 @end defun
3915 @defun tty-color-alist &optional frame
3916 This function returns an alist recording the known colors supported by
3917 a text terminal.
3919 Each element has the form @code{(@var{name} @var{number} . @var{rgb})}
3920 or @code{(@var{name} @var{number})}.  Here, @var{name} is the color
3921 name, @var{number} is the number used to specify it to the terminal.
3922 If present, @var{rgb} is a list of three color values (for red, green,
3923 and blue) that says what the color actually looks like.
3924 @end defun
3926 @defun tty-color-approximate rgb &optional frame
3927 This function finds the closest color, among the known colors
3928 supported for @var{display}, to that described by the rgb value
3929 @var{rgb} (a list of color values).  The return value is an element of
3930 @code{tty-color-alist}.
3931 @end defun
3933 @defun tty-color-translate color &optional frame
3934 This function finds the closest color to @var{color} among the known
3935 colors supported for @var{display} and returns its index (an integer).
3936 If the name @var{color} is not defined, the value is @code{nil}.
3937 @end defun
3939 @node Resources
3940 @section X Resources
3942 This section describes some of the functions and variables for
3943 querying and using X resources, or their equivalent on your operating
3944 system.  @xref{X Resources,, X Resources, emacs, The GNU Emacs
3945 Manual}, for more information about X resources.
3947 @defun x-get-resource attribute class &optional component subclass
3948 The function @code{x-get-resource} retrieves a resource value from the X
3949 Window defaults database.
3951 Resources are indexed by a combination of a @dfn{key} and a @dfn{class}.
3952 This function searches using a key of the form
3953 @samp{@var{instance}.@var{attribute}} (where @var{instance} is the name
3954 under which Emacs was invoked), and using @samp{Emacs.@var{class}} as
3955 the class.
3957 The optional arguments @var{component} and @var{subclass} add to the key
3958 and the class, respectively.  You must specify both of them or neither.
3959 If you specify them, the key is
3960 @samp{@var{instance}.@var{component}.@var{attribute}}, and the class is
3961 @samp{Emacs.@var{class}.@var{subclass}}.
3962 @end defun
3964 @defvar x-resource-class
3965 This variable specifies the application name that @code{x-get-resource}
3966 should look up.  The default value is @code{"Emacs"}.  You can examine X
3967 resources for other application names by binding this
3968 variable to some other string, around a call to @code{x-get-resource}.
3969 @end defvar
3971 @defvar x-resource-name
3972 This variable specifies the instance name that @code{x-get-resource}
3973 should look up.  The default value is the name Emacs was invoked with,
3974 or the value specified with the @samp{-name} or @samp{-rn} switches.
3975 @end defvar
3977 To illustrate some of the above, suppose that you have the line:
3979 @example
3980 xterm.vt100.background: yellow
3981 @end example
3983 @noindent
3984 in your X resources file (whose name is usually @file{~/.Xdefaults}
3985 or @file{~/.Xresources}).  Then:
3987 @example
3988 @group
3989 (let ((x-resource-class "XTerm") (x-resource-name "xterm"))
3990   (x-get-resource "vt100.background" "VT100.Background"))
3991      @result{} "yellow"
3992 @end group
3993 @group
3994 (let ((x-resource-class "XTerm") (x-resource-name "xterm"))
3995   (x-get-resource "background" "VT100" "vt100" "Background"))
3996      @result{} "yellow"
3997 @end group
3998 @end example
4000 @defvar inhibit-x-resources
4001 If this variable is non-@code{nil}, Emacs does not look up X
4002 resources, and X resources do not have any effect when creating new
4003 frames.
4004 @end defvar
4006 @node Display Feature Testing
4007 @section Display Feature Testing
4008 @cindex display feature testing
4010   The functions in this section describe the basic capabilities of a
4011 particular display.  Lisp programs can use them to adapt their behavior
4012 to what the display can do.  For example, a program that ordinarily uses
4013 a popup menu could use the minibuffer if popup menus are not supported.
4015   The optional argument @var{display} in these functions specifies which
4016 display to ask the question about.  It can be a display name, a frame
4017 (which designates the display that frame is on), or @code{nil} (which
4018 refers to the selected frame's display, @pxref{Input Focus}).
4020   @xref{Color Names}, @ref{Text Terminal Colors}, for other functions to
4021 obtain information about displays.
4023 @defun display-popup-menus-p &optional display
4024 This function returns @code{t} if popup menus are supported on
4025 @var{display}, @code{nil} if not.  Support for popup menus requires
4026 that the mouse be available, since the menu is popped up by clicking
4027 the mouse on some portion of the Emacs display.
4028 @end defun
4030 @defun display-graphic-p &optional display
4031 This function returns @code{t} if @var{display} is a graphic display
4032 capable of displaying several frames and several different fonts at
4033 once.  This is true for displays that use a window system such as X,
4034 and false for text terminals.
4035 @end defun
4037 @defun display-mouse-p &optional display
4038 @cindex mouse, availability
4039 This function returns @code{t} if @var{display} has a mouse available,
4040 @code{nil} if not.
4041 @end defun
4043 @defun display-color-p &optional display
4044 @findex x-display-color-p
4045 This function returns @code{t} if the screen is a color screen.
4046 It used to be called @code{x-display-color-p}, and that name
4047 is still supported as an alias.
4048 @end defun
4050 @defun display-grayscale-p &optional display
4051 This function returns @code{t} if the screen can display shades of gray.
4052 (All color displays can do this.)
4053 @end defun
4055 @defun display-supports-face-attributes-p attributes &optional display
4056 @anchor{Display Face Attribute Testing}
4057 This function returns non-@code{nil} if all the face attributes in
4058 @var{attributes} are supported (@pxref{Face Attributes}).
4060 The definition of ``supported'' is somewhat heuristic, but basically
4061 means that a face containing all the attributes in @var{attributes},
4062 when merged with the default face for display, can be represented in a
4063 way that's
4065 @enumerate
4066 @item
4067 different in appearance than the default face, and
4069 @item
4070 close in spirit to what the attributes specify, if not exact.
4071 @end enumerate
4073 Point (2) implies that a @code{:weight black} attribute will be
4074 satisfied by any display that can display bold, as will
4075 @code{:foreground "yellow"} as long as some yellowish color can be
4076 displayed, but @code{:slant italic} will @emph{not} be satisfied by
4077 the tty display code's automatic substitution of a dim face for
4078 italic.
4079 @end defun
4081 @defun display-selections-p &optional display
4082 This function returns @code{t} if @var{display} supports selections.
4083 Windowed displays normally support selections, but they may also be
4084 supported in some other cases.
4085 @end defun
4087 @defun display-images-p &optional display
4088 This function returns @code{t} if @var{display} can display images.
4089 Windowed displays ought in principle to handle images, but some
4090 systems lack the support for that.  On a display that does not support
4091 images, Emacs cannot display a tool bar.
4092 @end defun
4094 @defun display-screens &optional display
4095 This function returns the number of screens associated with the display.
4096 @end defun
4098 @defun display-pixel-height &optional display
4099 This function returns the height of the screen in pixels.
4100 On a character terminal, it gives the height in characters.
4102 For graphical terminals, note that on multi-monitor setups this
4103 refers to the pixel height for all physical monitors associated with
4104 @var{display}.  @xref{Multiple Terminals}.
4105 @end defun
4107 @defun display-pixel-width &optional display
4108 This function returns the width of the screen in pixels.
4109 On a character terminal, it gives the width in characters.
4111 For graphical terminals, note that on multi-monitor setups this
4112 refers to the pixel width for all physical monitors associated with
4113 @var{display}.  @xref{Multiple Terminals}.
4114 @end defun
4116 @defun display-mm-height &optional display
4117 This function returns the height of the screen in millimeters,
4118 or @code{nil} if Emacs cannot get that information.
4120 For graphical terminals, note that on multi-monitor setups this
4121 refers to the height for all physical monitors associated with
4122 @var{display}.  @xref{Multiple Terminals}.
4123 @end defun
4125 @defun display-mm-width &optional display
4126 This function returns the width of the screen in millimeters,
4127 or @code{nil} if Emacs cannot get that information.
4129 For graphical terminals, note that on multi-monitor setups this
4130 refers to the width for all physical monitors associated with
4131 @var{display}.  @xref{Multiple Terminals}.
4132 @end defun
4134 @defopt display-mm-dimensions-alist
4135 This variable allows the user to specify the dimensions of graphical
4136 displays returned by @code{display-mm-height} and
4137 @code{display-mm-width} in case the system provides incorrect values.
4138 @end defopt
4140 @cindex backing store
4141 @defun display-backing-store &optional display
4142 This function returns the backing store capability of the display.
4143 Backing store means recording the pixels of windows (and parts of
4144 windows) that are not exposed, so that when exposed they can be
4145 displayed very quickly.
4147 Values can be the symbols @code{always}, @code{when-mapped}, or
4148 @code{not-useful}.  The function can also return @code{nil}
4149 when the question is inapplicable to a certain kind of display.
4150 @end defun
4152 @cindex SaveUnder feature
4153 @defun display-save-under &optional display
4154 This function returns non-@code{nil} if the display supports the
4155 SaveUnder feature.  That feature is used by pop-up windows
4156 to save the pixels they obscure, so that they can pop down
4157 quickly.
4158 @end defun
4160 @defun display-planes &optional display
4161 This function returns the number of planes the display supports.
4162 This is typically the number of bits per pixel.
4163 For a tty display, it is log to base two of the number of colors supported.
4164 @end defun
4166 @defun display-visual-class &optional display
4167 This function returns the visual class for the screen.  The value is
4168 one of the symbols @code{static-gray} (a limited, unchangeable number
4169 of grays), @code{gray-scale} (a full range of grays),
4170 @code{static-color} (a limited, unchangeable number of colors),
4171 @code{pseudo-color} (a limited number of colors), @code{true-color} (a
4172 full range of colors), and @code{direct-color} (a full range of
4173 colors).
4174 @end defun
4176 @defun display-color-cells &optional display
4177 This function returns the number of color cells the screen supports.
4178 @end defun
4180   These functions obtain additional information about the window
4181 system in use where Emacs shows the specified @var{display}.  (Their
4182 names begin with @code{x-} for historical reasons.)
4184 @defun x-server-version &optional display
4185 This function returns the list of version numbers of the GUI window
4186 system running on @var{display}, such as the X server on GNU and Unix
4187 systems.  The value is a list of three integers: the major and minor
4188 version numbers of the protocol, and the distributor-specific release
4189 number of the window system software itself.  On GNU and Unix systems,
4190 these are normally the version of the X protocol and the
4191 distributor-specific release number of the X server software.  On
4192 MS-Windows, this is the version of the Windows OS.
4193 @end defun
4195 @defun x-server-vendor &optional display
4196 This function returns the vendor that provided the window system
4197 software (as a string).  On GNU and Unix systems this really means
4198 whoever distributes the X server.  On MS-Windows this is the vendor ID
4199 string of the Windows OS (Microsoft).
4201 When the developers of X labeled software distributors as
4202 ``vendors'', they showed their false assumption that no system could
4203 ever be developed and distributed noncommercially.
4204 @end defun
4206 @ignore
4207 @defvar x-no-window-manager
4208 This variable's value is @code{t} if no X window manager is in use.
4209 @end defvar
4210 @end ignore