Moved emacs version checking code to very beginning.
[emacs.git] / lispref / frames.texi
blob82c4936c753a74f6cbf1c597f16e506a5f0da4dc
1 @c -*-texinfo-*-
2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. 
4 @c See the file elisp.texi for copying conditions.
5 @setfilename ../info/frames
6 @node Frames, Positions, Windows, Top
7 @chapter Frames
8 @cindex frame
10   A @var{frame} is a rectangle on the screen that contains one or more
11 Emacs windows.  A frame initially contains a single main window (plus
12 perhaps a minibuffer window) which you can subdivide vertically or
13 horizontally into smaller windows.
15 @cindex terminal frame
16 @cindex X window frame
17   When Emacs runs on a text-only terminal, it has just one frame, a
18 @dfn{terminal frame}.  There is no way to create another terminal frame
19 after startup.  If Emacs has an X display, it does not have a terminal
20 frame; instead, it starts with a single @dfn{X window frame}.  You can
21 create more; see @ref{Creating Frames}.
23 @defun framep object
24 This predicate returns @code{t} if @var{object} is a frame, and
25 @code{nil} otherwise.
26 @end defun
28 @menu
29 * Creating Frames::             Creating additional X Window frames.
30 * Frame Parameters::            Controlling frame size, position, font, etc.
31 * Deleting Frames::             Frames last until explicitly deleted.
32 * Finding All Frames::          How to examine all existing frames.
33 * Frames and Windows::          A frame contains windows;
34                                   display of text always works through windows.
35 * Minibuffers and Frames::      How a frame finds the minibuffer to use.
36 * Input Focus::                 Specifying the selected frame.
37 * Visibility of Frames::        Frames may be visible or invisible, or icons.
38 * Raising and Lowering::        Raising a frame makes it hide other X windows;
39                                   lowering it makes the others hide them.
40 * Frame Configurations::        Saving the state of all frames.
41 * Mouse Tracking::              Getting events that say when the mouse moves.
42 * Mouse Position::              Asking where the mouse is, or moving it.
43 * Pop-Up Menus::                Displaying a menu for the user to select from.
44 * Dialog Boxes::                Displaying a box to ask yes or no.
45 * X Selections::                Transferring text to and from other X clients.
46 * X Connections::               Opening and closing the X server connection.
47 * Resources::                   Getting resource values from the server.
48 * Server Data::                 Getting info about the X server.
49 @end menu
51   @xref{Display}, for related information.
53 @node Creating Frames
54 @section Creating Frames
56 To create a new frame, call the function @code{make-frame}.
58 @defun make-frame alist
59 This function creates a new frame, if the display mechanism permits
60 creation of frames.  (An X server does; an ordinary terminal does not.)
62 The argument is an alist specifying frame parameters.  Any parameters
63 not mentioned in @var{alist} default according to the value of the
64 variable @code{default-frame-alist}; parameters not specified there
65 either default from the standard X defaults file and X resources.
67 The set of possible parameters depends in principle on what kind of
68 window system Emacs uses to display its the frames.  @xref{X Frame
69 Parameters}, for documentation of individual parameters you can specify
70 when creating an X window frame.
71 @end defun
73 @defvar default-frame-alist
74 This is an alist specifying default values of frame parameters.
75 Each element has the form:
77 @example
78 (@var{parameter} . @var{value})
79 @end example
81 If you use options that specify window appearance when you invoke Emacs,
82 they take effect by adding elements to @code{default-frame-alist}.
83 @xref{Command Arguments,,, emacs, The GNU Emacs Manual}.
84 @end defvar
86 @defvar before-make-frame-hook
87 A normal hook run by @code{make-frame} before it actually creates the
88 frame.
89 @end defvar
91 @defvar after-make-frame-hook
92 A normal hook run by @code{make-frame} after it creates the frame.
93 @end defvar
95 @node Frame Parameters
96 @section Frame Parameters
98 A frame has many parameters that control its appearance and behavior.
99 Just what parameters a frame has depends on what display mechanism it
100 uses.
102 Frame parameters exist for the sake of window systems.  A terminal frame
103 has a few parameters, for compatibility's sake only.  You can't change
104 these parameters directly; the only ones that ever change are the height
105 and width.
107 @menu
108 * Parameter Access::       How to change a frame's parameters.
109 * Initial Parameters::     Specifying frame parameters when you make a frame.
110 * X Frame Parameters::     Individual parameters documented.
111 * Size and Position::      Changing the size and position of a frame.
112 @end menu
114 @node Parameter Access
115 @subsection Access to Frame Parameters
117 These functions let you read and change the parameter values of a
118 frame.
120 @defun frame-parameters frame
121 The function @code{frame-parameters} returns an alist listing all the
122 parameters of @var{frame} and their values.
123 @end defun
125 @defun modify-frame-parameters frame alist
126 This function alters the parameters of frame @var{frame} based on the
127 elements of @var{alist}.  Each element of @var{alist} has the form
128 @code{(@var{parm} . @var{value})}, where @var{parm} is a symbol naming a
129 parameter.  If you don't mention a parameter in @var{alist}, its value
130 doesn't change.
131 @end defun
133 @node Initial Parameters
134 @subsection Initial Frame Parameters
136 You can specify the parameters for the initial startup frame
137 by setting @code{initial-frame-alist} in your @file{.emacs} file.
139 @defvar initial-frame-alist
140 This variable's value is an alist of parameter values used when creating
141 the initial X window frame.
142 @end defvar
144 If these parameters specify a separate minibuffer-only frame,
145 and you have not created one, Emacs creates one for you.
147 @defvar minibuffer-frame-alist
148 This variable's value is an alist of parameter values used when creating
149 an initial minibuffer-only frame---if such a frame is needed, according
150 to the parameters for the main initial frame.
151 @end defvar
153 @node X Frame Parameters
154 @subsection X Window Frame Parameters
156 Just what parameters a frame has depends on what display mechanism it
157 uses.  Here is a table of the parameters of an X window frame:
159 @table @code
160 @item name
161 The name of the frame.  Most window managers display the frame's name in
162 the frame's border, at the top of the frame.  If you don't specify a
163 name, and you have more than one frame, Emacs sets the frame name based
164 on the buffer displayed in the frame's selected window.
166 If you specify the frame name explicitly when you create the frame, the
167 name is also used (instead of the name of the Emacs executable) when
168 looking up X resources for the frame.
170 @item left
171 The screen position of the left edge, in pixels.
173 @item top
174 The screen position of the top edge, in pixels.
176 @item height
177 The height of the frame contents, in characters.  (To get the height in
178 pixels, call @code{frame-pixel-height}; see @ref{Size and Position}.)
180 @item width
181 The width of the frame contents, in characters.  (To get the height in
182 pixels, call @code{frame-pixel-width}; see @ref{Size and Position}.)
184 @item window-id
185 The number of the X window for the frame.
187 @item minibuffer
188 Whether this frame has its own minibuffer.  The value @code{t} means
189 yes, @code{nil} means no, @code{only} means this frame is just a
190 minibuffer, a minibuffer window (in some other frame) means the new
191 frame uses that minibuffer.
193 @item font
194 The name of the font for displaying text in the frame.  This is a
195 string.
197 @item auto-raise
198 Whether selecting the frame raises it (non-@code{nil} means yes).
200 @item auto-lower
201 Whether deselecting the frame lowers it (non-@code{nil} means yes).
203 @item vertical-scroll-bars
204 Whether the frame has scroll bars for vertical scrolling
205 (non-@code{nil} means yes).
207 @item horizontal-scroll-bars
208 Whether the frame has scroll bars for horizontal scrolling
209 (non-@code{nil} means yes).  (Horizontal scroll bars are not currently
210 implemented.)
212 @item icon-type
213 The type of icon to use for this frame when it is iconified.
214 Non-@code{nil} specifies a bitmap icon, @code{nil} a text icon.
216 @item foreground-color
217 The color to use for the inside of a character.  This is a string; the X
218 server defines the meaningful color names.
220 @item background-color
221 The color to use for the background of text.
223 @item mouse-color
224 The color for the mouse cursor.
226 @item cursor-color
227 The color for the cursor that shows point.
229 @item border-color
230 The color for the border of the frame.
232 @item cursor-type
233 The way to display the cursor.  There are two legitimate values:
234 @code{bar} and @code{box}.  The symbol @code{bar} specifies a vertical
235 bar between characters as the cursor.  The symbol @code{box} specifies
236 an ordinary black box overlaying the character after point; that is the
237 default.
239 @item border-width
240 The width in pixels of the window border.
242 @item internal-border-width
243 The distance in pixels between text and border.
245 @item unsplittable
246 If non-@code{nil}, this frame's window is never split automatically.
248 @item visibility
249 The state of visibility of the frame.  There are three possibilities:
250 @code{nil} for invisible, @code{t} for visible, and @code{icon} for
251 iconified.  @xref{Visibility of Frames}.
253 @item menu-bar-lines
254 The number of lines to allocate at the top of the frame for a menu bar.
255 The default is 1.  @xref{Menu Bar}.
257 @item parent-id
258 @c ??? Not yet working.
259 The X window number of the window that should be the parent of this one.
260 Specifying this lets you create an Emacs window inside some other
261 application's window.  (It is not certain this will be implemented; try
262 it and see if it works.)
263 @end table
265 @node Size and Position
266 @subsection Frame Size And Position
268   You can read or change the size and position of a frame using the
269 frame parameters @code{left}, @code{top}, @code{height} and
270 @code{width}.  When you create a frame, you must specify either both
271 size parameters or neither.  Likewise, you must specify either both
272 position parameters or neither.  Whatever geometry parameters you don't
273 specify are chosen by the window manager in its usual fashion.
275   Here are some special features for working with sizes and positions:
277 @defun set-frame-position frame left top
278 This function sets the position of the top left corner of
279 @var{frame}---to @var{left} and @var{top}.  These arguments are measured
280 in pixels, counting from the top left corner of the screen.
281 @end defun
283 @defun frame-height &optional frame
284 @defunx frame-width &optional frame
285 These functions return the height and width of @var{frame}, measured in
286 characters.  If you don't supply @var{frame}, they use the selected
287 frame.
288 @end defun
290 @defun frame-pixel-height &optional frame
291 @defunx frame-pixel-width &optional frame
292 These functions return the height and width of @var{frame}, measured in
293 pixels.  If you don't supply @var{frame}, they use the selected frame.
294 @end defun
296 @defun frame-char-height &optional frame
297 @defunx frame-char-width &optional frame
298 These functions return the height and width, respectively, of a
299 character in @var{frame}, measured in pixels.  The values depend on the
300 choice of font.  If you don't supply @var{frame}, these functions use
301 the selected frame.
302 @end defun
304 @defun set-frame-size frame cols rows
305 This function sets the size of @var{frame}, measured in characters;
306 @var{cols} and @var{rows} specify the new width and height.
308 To set the size based on values measured in pixels, use
309 @code{frame-char-height} and @code{frame-char-width} to convert
310 them to units of characters.
311 @end defun
313   The old-fashioned functions @code{set-screen-height} and
314 @code{set-screen-width}, which were used to specify the height and width
315 of the screen in Emacs versions that did not support multiple frames,
316 are still usable.  They apply to the selected frame.  @xref{Screen
317 Size}.
319 @defun x-parse-geometry geom
320 @cindex geometry specification
321 The function @code{x-parse-geometry} converts a standard X windows
322 geometry string to an alist which you can use as part of the argument to
323 @code{make-frame}.
325 The alist describes which parameters were specified in @var{geom}, and
326 gives the values specified for them.  Each element looks like
327 @code{(@var{parameter} . @var{value})}.  The possible @var{parameter}
328 values are @code{left}, @code{top}, @code{width}, and @code{height}.
330 @smallexample
331 (x-parse-geometry "35x70+0-0")
332      @result{} ((width . 35) (height . 70) (left . 0) (top . -1))
333 @end smallexample
334 @end defun
336 @ignore
337 New functions @code{set-frame-height} and @code{set-frame-width} set the
338 size of a specified frame.  The frame is the first argument; the size is
339 the second.
340 @end ignore
342 @node Deleting Frames
343 @section Deleting Frames
344 @cindex deletion of frames
346 Frames remain potentially visible until you explicitly @dfn{delete}
347 them.  A deleted frame cannot appear on the screen, but continues to
348 exist as a Lisp object until there are no references to it.  There is no
349 way to cancel the deletion of a frame aside from restoring a saved frame
350 configuration (@pxref{Frame Configurations}); this is similar to the
351 way windows behave.
353 @deffn Command delete-frame &optional frame
354 This function deletes the frame @var{frame}.  By default, @var{frame} is
355 the selected frame.
356 @end deffn
358 @defun frame-live-p frame
359 The function @code{frame-live-p} returns non-@code{nil} if the frame
360 @var{frame} has not been deleted.
361 @end defun
363 @node Finding All Frames
364 @section Finding All Frames
366 @defun frame-list
367 The function @code{frame-list} returns a list of all the frames that
368 have not been deleted.  It is analogous to @code{buffer-list} for
369 buffers.  The list that you get is newly created, so modifying the list
370 doesn't have any effect on the internals of Emacs.
371 @end defun
373 @defun visible-frame-list
374 This function returns a list of just the currently visible frames.
375 @xref{Visibility of Frames}.
376 @end defun
378 @defun next-frame &optional frame minibuf
379 The function @code{next-frame} lets you cycle conveniently through all
380 the frames from an arbitrary starting point.  It returns the ``next''
381 frame after @var{frame} in the cycle.  If @var{frame} is omitted or
382 @code{nil}, it defaults to the selected frame.
384 The second argument, @var{minibuf}, says which frames to consider:
386 @table @asis
387 @item @code{nil}
388 Exclude minibuffer-only frames.
389 @item @code{visible}
390 Consider all visible frames.
391 @item a window
392 Consider only the frames using that particular window as their
393 minibuffer.
394 @item anything else
395 Consider all frames.
396 @end table
397 @end defun
399 @defun previous-frame &optional frame minibuf
400 Like @code{next-frame}, but cycles through all frames in the opposite
401 direction.
402 @end defun
404 @node Frames and Windows
405 @section Frames and Windows
407   Each window is part of one and only one frame; you can get the frame
408 with @code{window-frame}.
410 @defun window-frame window
411 This function returns the frame that @var{window} is on.
412 @end defun
414   All the non-minibuffer windows in a frame are arranged in a cyclic
415 order.  The order runs from the frame's top window, which is at the
416 upper left corner, down and to the right, until it reaches the window at
417 the lower right corner (always the minibuffer window, if the frame has
418 one), and then it moves back to the top.
420 @defun frame-top-window frame
421 This returns the topmost, leftmost window of frame @var{frame}.
422 This is a window
423 @end defun
425 At any time, exactly one window on any frame is @dfn{selected within the
426 frame}.  The significance of this designation is that selecting the
427 frame also selects this window.  You can get the frame's current
428 selected window with @code{frame-selected-window}.
430 @defun frame-selected-window frame
431 This function returns the window on @var{frame} which is selected within
432 @var{frame}.
433 @end defun
435 Conversely, selecting a window for Emacs with @code{select-window} also
436 makes that window selected within its frame.  @xref{Selecting Windows}.
438 @node Minibuffers and Frames
439 @section Minibuffers and Frames
441 Normally, each frame has its own minibuffer window at the bottom, which
442 is used whenever that frame is selected.  If the frame has a minibuffer,
443 you can get it with @code{minibuffer-window} (@pxref{Minibuffer Misc}).
445 However, you can also create a frame with no minibuffer.  Such a frame
446 must use the minibuffer window of some other frame.  When you create the
447 frame, you can specify explicitly the frame on which to find the
448 minibuffer to use.  If you don't, then the minibuffer is found in the
449 frame which is the value of the variable
450 @code{default-minibuffer-frame}.  Its value should be a frame which does
451 have a minibuffer.
453 If you use a minibuffer-only frame, you might want that frame to raise
454 when you enter the minibuffer.  If so, set the variable
455 @code{minibuffer-auto-raise} to @code{t}.  @xref{Raising and Lowering}.
457 @node Input Focus
458 @section Input Focus
459 @cindex input focus
460 @cindex selected frame
462 At any time, one frame in Emacs is the @dfn{selected frame}.  The selected
463 window always resides on the selected frame.
465 @defun selected-frame
466 This function returns the selected frame.
467 @end defun
469 The X server normally directs keyboard input to the X window that the
470 mouse is in.  Some window managers use mouse clicks or keyboard events
471 to @dfn{shift the focus} to various X windows, overriding the normal
472 behavior of the server.
474 Lisp programs can switch frames ``temporarily'' by calling
475 the function @code{select-frame}.  This does not override the window
476 manager; rather, it escapes from the window manager's control until
477 that control is somehow reasserted.
479 @c ??? This is not yet implemented properly.
480 @defun select-frame frame
481 This function selects frame @var{frame}, temporarily disregarding the
482 focus of the X server.  The selection of @var{frame} lasts until the
483 next time the user does something to select a different frame, or until
484 the next time this function is called.
485 @end defun
487 Emacs cooperates with the X server and the window managers by arranging
488 to select frames according to what the server and window manager ask
489 for.  It does so by generating a special kind of input event, called a
490 @dfn{focus} event.  The command loop handles a focus event by calling
491 @code{handle-select-frame}.  @xref{Focus Events}.
493 @deffn Command handle-switch-frame frame
494 This function handles a focus event by selecting frame @var{frame}.
496 Focus events normally do their job by invoking this command.
497 Don't call it for any other reason.
498 @end deffn
500 @defun redirect-frame-focus frame focus-frame
501 This function redirects focus from @var{frame} to @var{focus-frame}.
502 This means that @var{focus-frame} will receive subsequent keystrokes and
503 intended for @var{frame}.  After such an event, the value of
504 @code{last-event-frame} will be @var{focus-frame}.  Also, switch-frame
505 events specifying @var{frame} will instead select @var{focus-frame}.
507 If @var{focus-frame} is @code{nil}, that cancels any existing
508 redirection for @var{frame}, which therefore once again receives its own
509 events.
511 One use of focus redirection is for frames that don't have minibuffers.
512 These frames use minibuffers on other frames.  Activating a minibuffer
513 on another frame redirects focus to that frame.  This puts the focus on
514 the minibuffer's frame, where it belongs, even though the mouse remains
515 in the frame which activated the minibuffer.
517 Selecting a frame can also change focus redirections.  Selecting frame
518 @code{bar}, when @code{foo} had been selected, changes any redirections
519 pointing to @code{foo} so that they point to @code{bar} instead.  This
520 allows focus redirection to work properly when the user switches from
521 one frame to another using @code{select-window}.
523 This means that a frame whose focus is redirected to itself is treated
524 differently from a frame whose focus is not redirected.
525 @code{select-frame} affects the former but not the latter.
527 The redirection lasts until @code{redirect-frame-focus} is called to
528 change it.
529 @end defun
531 @node Visibility of Frames
532 @section Visibility of Frames
533 @cindex visible frame
534 @cindex invisible frame
535 @cindex iconified frame
536 @cindex frame visibility
538 A frame may be @dfn{visible}, @dfn{invisible}, or @dfn{iconified}.  If
539 it is visible, you can see its contents.  If it is iconified, the
540 frame's contents do not appear on the screen, but an icon does.  If the
541 frame is invisible, it doesn't show in the screen, not even as an icon.
543 @deffn Command make-frame-visible &optional frame
544 This function makes frame @var{frame} visible.  If you omit @var{frame},
545 it makes the selected frame visible.
546 @end deffn
548 @deffn Command make-frame-invisible &optional frame
549 This function makes frame @var{frame} invisible.  If you omit
550 @var{frame}, it makes the selected frame invisible.
551 @end deffn
553 @deffn Command iconify-frame &optional frame
554 This function iconifies frame @var{frame}.  If you omit @var{frame}, it
555 iconifies the selected frame.
556 @end deffn
558 @defun frame-visible-p frame
559 This returns the visibility status of frame @var{frame}.  The value is
560 @code{t} if @var{frame} is visible, @code{nil} if it is invisible, and
561 @code{icon} if it is iconified.
562 @end defun
564   The visibility status of a frame is also available as a frame
565 parameter.  You can read or change it as such.  @xref{X Frame
566 Parameters}.
568 @node Raising and Lowering
569 @section Raising and Lowering Frames
571 The X Window System uses a desktop metaphor.  Part of this metaphor is
572 the idea that windows are stacked in a notional third dimension
573 perpendicular to the screen surface, and thus ordered from ``highest''
574 to ``lowest''.  Where two windows overlap, the one higher up covers the
575 one underneath.  Even a window at the bottom of the stack can be seen if
576 no other window overlaps it.
578 @cindex raising a frame
579 @cindex lowering a frame
580 A window's place in this ordering is not fixed; in fact, users tend to
581 change the order frequently.  @dfn{Raising} a window means moving it
582 ``up'', to the top of the stack.  @dfn{Lowering} a window means moving
583 it to the bottom of the stack.  This motion is in the notional third
584 dimension only, and does not change the position of the window on the
585 screen.
587 You can raise and lower Emacs's X windows with these functions:
589 @defun raise-frame frame
590 This function raises frame @var{frame}.
591 @end defun
593 @defun lower-frame frame
594 This function lowers frame @var{frame}.
595 @end defun
597 @defopt minibuffer-auto-raise
598 If this is non-@code{nil}, activation of the minibuffer raises the frame
599 that the minibuffer window is in.
600 @end defopt
602 You can also enable auto-raise (raising automatically when a frame is
603 selected) or auto-lower (lowering automatically when it is deselected)
604 for any frame using frame parameters.  @xref{X Frame Parameters}.
606 @node Frame Configurations
607 @section Frame Configurations
608 @cindex frame configuration
610   A @dfn{frame configuration} records the current arrangement of frames,
611 all their properties, and the window configuration of each one.
613 @defun current-frame-configuration
614 This function returns a frame configuration list which describes
615 the current arrangement of frames and their contents.
616 @end defun
618 @defun set-frame-configuration configuration
619 This function restores the state of frames described in
620 @var{configuration}.
621 @end defun
623 @node Mouse Tracking
624 @section Mouse Tracking
625 @cindex mouse tracking
626 @cindex tracking the mouse
628 Sometimes it is useful to @dfn{track} the mouse, which means, to display
629 something to indicate where the mouse is and move the indicator as the
630 mouse moves.  For efficient mouse tracking, you need a way to wait until
631 the mouse actually moves.
633 The convenient way to track the mouse is to ask for events to represent
634 mouse motion.  Then you can wait for motion by waiting for an event.  In
635 addition, you can easily handle any other sorts of events that may
636 occur.  That is useful, because normally you don't want to track the
637 mouse forever---only until some other event, such as the release of a
638 button.
640 @defspec track-mouse body@dots{}
641 Execute @var{body}, meanwhile generating input events for mouse motion.
642 The code in @var{body} can read these events with @code{read-event} or
643 @code{read-key-sequence}.  @xref{Motion Events}, for the format of mouse
644 motion events.
646 The value of @code{track-mouse} is that of the last form in @var{body}.
647 @end defspec
649 The usual purpose of tracking mouse motion is to indicate on the screen
650 the consequences of pushing or releasing a button at the current
651 position.
653 @ignore
654 @c These are not implemented yet.
656 These functions change the screen appearance instantaneously.  The
657 effect is transient, only until the next ordinary Emacs redisplay.  That
658 is ok for mouse tracking, since it doesn't make sense for mouse tracking
659 to change the text, and the body of @code{track-mouse} normally reads
660 the events itself and does not do redisplay.
662 @defun x-contour-region window beg end
663 This function draws lines to make a box around the text from @var{beg}
664 to @var{end}, in window @var{window}.
665 @end defun
667 @defun x-uncontour-region window beg end
668 This function erases the lines that would make a box around the text
669 from @var{beg} to @var{end}, in window @var{window}.  Use it to remove
670 a contour that you previously made by calling @code{x-contour-region}.
671 @end defun
673 @defun x-draw-rectangle frame left top right bottom
674 This function draws a hollow rectangle on frame @var{frame} with the
675 specified edge coordinates, all measured in pixels from the inside top
676 left corner.  It uses the cursor color, the one used for indicating the
677 location of point.
678 @end defun
680 @defun x-erase-rectangle frame left top right bottom
681 This function erases a hollow rectangle on frame @var{frame} with the
682 specified edge coordinates, all measured in pixels from the inside top
683 left corner.  Erasure means redrawing the text and background that
684 normally belong in the specified rectangle.
685 @end defun
686 @end ignore
688 @node Mouse Position
689 @section Mouse Position
690 @cindex mouse position
691 @cindex position of mouse
693   The functions @code{mouse-position} and @code{set-mouse-position}
694 give access to the current position of the mouse.
696 @defun mouse-position
697 This function returns a description of the position of the mouse.  The
698 value looks like @code{(@var{frame} @var{x} . @var{y})}, where @var{x}
699 and @var{y} are integers giving the position in characters relative to
700 the top left corner of the inside of @var{frame}.
701 @end defun
703 @defun set-mouse-position frame x y
704 This function @dfn{warps the mouse} to position @var{x}, @var{y} in
705 frame @var{frame}.  The arguments @var{x} and @var{y} are integers,
706 giving the position in characters relative to the top left corner of the
707 inside of @var{frame}.
708 @end defun
710 @defun mouse-pixel-position
711 This function is like @code{mouse-position} except that it returns
712 coordinates in units of pixels rather than units of characters.
713 @end defun
715 @defun set-mouse-pixel-position frame x y
716 This function warps the mouse like @code{set-mouse-position} except that
717 @var{x} and @var{y} are in units of pixels rather than units of
718 characters.  These coordinates are not required to be within the frame.
719 @end defun
721 @need 3000
723 @node Pop-Up Menus
724 @section Pop-Up Menus
726 @defun x-popup-menu position menu
727 This function displays a pop-up menu and returns an indication of
728 what selection the user makes.
730 The argument @var{position} specifies where on the screen to put the
731 menu.  It can be either a mouse button event (which says to put the menu
732 where the user actuated the button) or a list of this form:
734 @example
735 ((@var{xoffset} @var{yoffset}) @var{window})
736 @end example
738 @noindent
739 where @var{xoffset} and @var{yoffset} are coordinates, measured in
740 pixels, counting from the top left corner of @var{window}'s frame.
742 If @var{position} is @code{t}, it means to use the current mouse
743 position.  If @var{position} is @code{nil}, it means to precompute the
744 key binding equivalents for the keymaps specified in @var{menu},
745 without actually displaying or popping up the menu.
747 The argument @var{menu} says what to display in the menu.  It can be a
748 keymap or a list of keymaps (@pxref{Menu Keymaps}).  Alternatively, it
749 can have the following form:
751 @example
752 (@var{title} @var{pane1} @var{pane2}...)
753 @end example
755 @noindent
756 where each pane is a list of form
758 @example
759 (@var{title} (@var{line} @var{item})...)
760 @end example
762 Each @var{line} should be a string, and each @var{item} should be the
763 value to return if that @var{line} is chosen.
764 @end defun
766 @strong{Usage note:} Don't use @code{x-popup-menu} to display a menu if
767 a prefix key with a menu keymap would do the job.  If you use a menu
768 keymap to implement a menu, @kbd{C-h c} and @kbd{C-h a} can see the
769 individual items in that menu and provide help for them.  If instead you
770 implement the menu by defining a command that calls @code{x-popup-menu},
771 the help facilities cannot know what happens inside that command, so
772 they cannot give any help for the menu's items.  This is the reason why
773 all the menu bar items except @samp{Buffers} are implemented with menu
774 keymaps (@pxref{Menu Keymaps}).
776 @node Dialog Boxes
777 @section Dialog Boxes
778 @cindex dialog boxes
780   A dialog box is a variant of a pop-up menu.  It looks a little
781 different (if Emacs uses an X toolkit), it always appears in the center
782 of a frame, and it has just one level and one pane.  The main use of
783 dialog boxes is for asking questions that the user can answer with
784 ``yes'', ``no'', and a few other alternatives.  The functions
785 @code{y-or-n-p} and @code{yes-or-no-p} use dialog boxes instead of the
786 keyboard, when called from commands invoked by mouse clicks.
788 @defun x-popup-dialog position contents
789 This function displays a pop-up dialog box and returns an indication of
790 what selection the user makes.  The argument @var{contents} specifies
791 the alternatives to offer; it has this format:
793 @example
794 (@var{title} (@var{string} . @var{value})@dots{})
795 @end example
797 @noindent
798 which looks like the list that specifies a single pane for
799 @code{x-popup-menu}.
801 The return value is @var{value} from the chosen alternative.
803 An element of the list may be just a string instead of a cons cell
804 @code{(@var{string} . @var{value})}.  That makes a box that cannot
805 be selected.
807 If @code{nil} appears in the list, it separates the left-hand items from
808 the right-hand items; items that precede the @code{nil} appear on the
809 left, and items that follow the @code{nil} appear on the right.  If you
810 don't include a @code{nil} in the list, then approximately half the
811 items appear on each side.
813 Dialog boxes always appear in the center of a frame; the argument
814 @var{position} specifies which frame.  The possible values are as in
815 @code{x-popup-menu}, but the precise coordinates don't matter; only the
816 frame matters.
818 If your Emacs executable does not use an X toolkit, then it cannot
819 display a real dialog box; so instead it displays the same items in a
820 pop-up menu in the center of the frame.
821 @end defun
823 @node X Selections
824 @section X Selections
825 @cindex selection (for X windows)
827 The X server records a set of @dfn{selections} which permit transfer of
828 data between application programs.  The various selections are
829 distinguished by @dfn{selection types}, represented in Emacs by
830 symbols.  X clients including Emacs can read or set the selection for
831 any given type.
833 @defun x-set-selection type data
834 This function sets a ``selection'' in the X server.  It takes two
835 arguments: a selection type @var{type}, and the value to assign to it,
836 @var{data}.  If @var{data} is @code{nil}, it means to clear out the
837 selection.  Otherwise, @var{data} may be a string, a symbol, an integer
838 (or a cons of two integers or list of two integers), an overlay, or a
839 cons of two markers pointing to the same buffer.  An overlay or a pair
840 of markers stands for text in the overlay or between the markers.
842 The data may also be a vector of valid non-vector selection values.
844 Each possible @var{type} has its own selection value, which changes
845 independently.  The usual values of @var{type} are @code{PRIMARY} and
846 @code{SECONDARY}; these are symbols with upper-case names, in accord
847 with X Window System conventions.  The default is @code{PRIMARY}.
848 @end defun
850 @defun x-get-selection type data-type
851 This function accesses selections set up by Emacs or by other X
852 clients.  It takes two optional arguments, @var{type} and
853 @var{data-type}.  The default for @var{type}, the selection type, is
854 @code{PRIMARY}.
856 The @var{data-type} argument specifies the form of data conversion to
857 use, to convert the raw data obtained from another X client into Lisp
858 data.  Meaningful values include @code{TEXT}, @code{STRING},
859 @code{TARGETS}, @code{LENGTH}, @code{DELETE}, @code{FILE_NAME},
860 @code{CHARACTER_POSITION}, @code{LINE_NUMBER}, @code{COLUMN_NUMBER},
861 @code{OWNER_OS}, @code{HOST_NAME}, @code{USER}, @code{CLASS},
862 @code{NAME}, @code{ATOM}, and @code{INTEGER}.  (These are symbols with
863 upper-case names in accord with X conventions.)  The default for
864 @var{data-type} is @code{STRING}.
865 @end defun
867 @cindex cut buffer
868 The X server also has a set of numbered @dfn{cut buffers} which can
869 store text or other data being moved between applications.  Cut buffers
870 are considered obsolete, but Emacs supports them for the sake of X
871 clients that still use them.
873 @defun x-get-cut-buffer n
874 This function returns the contents of cut buffer number @var{n}.
875 @end defun
877 @defun x-set-cut-buffer string
878 This function stores @var{string} into the first cut buffer (cut buffer
879 0), moving the other values down through the series of cut buffers, much
880 like the way successive kills in Emacs move down the kill ring.
881 @end defun
883 @node X Connections
884 @section X Connections
886 You can close the connection with the X server with the function
887 @code{x-close-current-connection}, and open a new one with
888 @code{x-open-connection} (perhaps with a different server and display).
890 @defun x-close-current-connection
891 This function closes the connection to the X server.  It deletes all
892 frames, making Emacs effectively inaccessible to the user; therefore, a
893 Lisp program that closes the connection should open another one.
894 @end defun
896 @defun x-open-connection display &optional resource-string
897 This function opens a connection to an X server, for use of display
898 @var{display}.
900 The optional argument @var{resource-string} is a string of resource
901 names and values, in the same format used in the @file{.Xresources}
902 file.  The values you specify override the resource values recorded in
903 the X server itself.  Here's an example of what this string might look
904 like:
906 @example
907 "*BorderWidth: 3\n*InternalBorder: 2\n"
908 @end example
910 @xref{Resources}.
911 @end defun
913 @defun x-display-color-p
914 This returns @code{t} if the connected X display has color, and
915 @code{nil} otherwise.
916 @end defun
918 @defun x-color-defined-p color
919 This function reports whether a color name is meaningful and supported
920 on the X display Emacs is using.  It returns @code{t} if the display
921 supports that color; otherwise, @code{nil}.
923 Black-and-white displays support just two colors, @code{"black"} or
924 @code{"white"}.  Color displays support many other colors.
925 @end defun
927 @defun x-synchronize flag
928 The function @code{x-synchronize} enables or disables synchronous
929 communication with the X server.  It enables synchronous communication
930 if @var{flag} is non-@code{nil}, and disables it if @var{flag} is
931 @code{nil}.
933 In synchronous mode, Emacs waits for a response to each X protocol
934 command before doing anything else.  This is useful for debugging Emacs,
935 because protocol errors are reported right away, which helps you find
936 the erroneous command.  Synchronous mode is not the default because it
937 is much slower.
938 @end defun
940 @node Resources
941 @section X Resources
943 @defun x-get-resource attribute &optional name class
944 The function @code{x-get-resource} retrieves a resource value from the X
945 Windows defaults database.
947 Resources are indexed by a combination of a @dfn{key} and a @dfn{class}.
948 This function searches using a key of the form
949 @samp{@var{instance}.@var{attribute}}, using the name under which Emacs
950 was invoked as @var{instance}, and using @samp{Emacs} as the class.
952 The optional arguments @var{component} and @var{subclass} add to the key
953 and the class, respectively.  You must specify both of them or neither.
954 If you specify them, the key is
955 @samp{@var{instance}.@var{component}.@var{attribute}}, and the class is
956 @samp{Emacs.@var{subclass}}.
957 @end defun
959   @xref{Resources X, X Resources,, emacs, The GNU Emacs Manual}.
961 @node Server Data
962 @section Data about the X Server
964   This section describes functions and a variable that you can use to
965 get information about the capabilities and origin of the X server that
966 Emacs is displaying its frames on.
968 @defun x-display-screens
969 This function returns the number of screens associated with the current
970 display.
971 @end defun
973 @defun x-server-version
974 This function returns the list of version numbers of the X server in
975 use.
976 @end defun
978 @defun x-server-vendor
979 This function returns the vendor supporting the X server in use.
980 @end defun
982 @defun x-display-pixel-height
983 This function returns the height of this X screen in pixels.
984 @end defun
986 @defun x-display-mm-height
987 This function returns the height of this X screen in millimeters.
988 @end defun
990 @defun x-display-pixel-width
991 This function returns the width of this X screen in pixels.
992 @end defun
994 @defun x-display-mm-width
995 This function returns the width of this X screen in millimeters.
996 @end defun
998 @defun x-display-backing-store
999 This function returns the backing store capability of this screen.
1000 Values can be the symbols @code{always}, @code{when-mapped}, or
1001 @code{not-useful}.
1002 @end defun
1004 @defun x-display-save-under
1005 This function returns non-@code{nil} if this X screen supports the
1006 SaveUnder feature.
1007 @end defun
1009 @defun x-display-planes
1010 This function returns the number of planes this display supports.
1011 @end defun
1013 @defun x-display-visual-class
1014 This function returns the visual class for this X screen.  The value is
1015 one of the symbols @code{static-gray}, @code{gray-scale},
1016 @code{static-color}, @code{pseudo-color}, @code{true-color}, and
1017 @code{direct-color}.
1018 @end defun
1020 @defun x-display-color-p
1021 This function returns @code{t} if the X screen in use is a color
1022 screen.
1023 @end defun
1025 @defun x-display-color-cells
1026 This function returns the number of color cells this X screen supports.
1027 @end defun
1029 @ignore
1030 @defvar x-no-window-manager
1031 This variable's value is is @code{t} if no X window manager is in use.
1032 @end defvar
1033 @end ignore
1035 @ignore
1036 @item
1037 The functions @code{x-pixel-width} and @code{x-pixel-height} return the
1038 width and height of an X Window frame, measured in pixels.
1040 @item
1041 x-pointer-shape, x-nontext-pointer-shape, x-mode-pointer-shape.
1042 x-cross-pointer-shape.
1043 @end ignore