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