aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/display.texi29
-rw-r--r--doc/lispref/elisp.texi9
-rw-r--r--doc/lispref/frames.texi889
-rw-r--r--doc/lispref/windows.texi266
4 files changed, 787 insertions, 406 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 9e9f8e3ca45..ae59bbbdefa 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1897,9 +1897,9 @@ to or less than the display width of @var{ellipsis}. If
1897 1897
1898The following function returns the size in pixels of text as if it were 1898The following function returns the size in pixels of text as if it were
1899displayed in a given window. This function is used by 1899displayed in a given window. This function is used by
1900@code{fit-window-to-buffer} (@pxref{Resizing Windows}) and 1900@code{fit-window-to-buffer} and @code{fit-frame-to-buffer}
1901@code{fit-frame-to-buffer} (@pxref{Size and Position}) to make a window 1901(@pxref{Resizing Windows}) to make a window exactly as large as the text
1902exactly as large as the text it contains. 1902it contains.
1903 1903
1904@defun window-text-pixel-size &optional window from to x-limit y-limit mode-and-header-line 1904@defun window-text-pixel-size &optional window from to x-limit y-limit mode-and-header-line
1905This function returns the size of the text of @var{window}'s buffer in 1905This function returns the size of the text of @var{window}'s buffer in
@@ -1952,12 +1952,12 @@ height of both, if present, in the return value.
1952contents of the line, plus optional additional vertical line spacing 1952contents of the line, plus optional additional vertical line spacing
1953above or below the display line. 1953above or below the display line.
1954 1954
1955 The height of the line contents is the maximum height of any 1955 The height of the line contents is the maximum height of any character
1956character or image on that display line, including the final newline 1956or image on that display line, including the final newline if there is
1957if there is one. (A display line that is continued doesn't include a 1957one. (A display line that is continued doesn't include a final
1958final newline.) That is the default line height, if you do nothing to 1958newline.) That is the default line height, if you do nothing to specify
1959specify a greater height. (In the most common case, this equals the 1959a greater height. (In the most common case, this equals the height of
1960height of the default frame font.) 1960the corresponding frame's default font, see @ref{Frame Font}.)
1961 1961
1962 There are several ways to explicitly specify a larger line height, 1962 There are several ways to explicitly specify a larger line height,
1963either by specifying an absolute height for the display line, or by 1963either by specifying an absolute height for the display line, or by
@@ -5406,12 +5406,11 @@ This removes only images that were put into @var{buffer} the way
5406@cindex size of image 5406@cindex size of image
5407This function returns the size of an image as a pair 5407This function returns the size of an image as a pair
5408@w{@code{(@var{width} . @var{height})}}. @var{spec} is an image 5408@w{@code{(@var{width} . @var{height})}}. @var{spec} is an image
5409specification. @var{pixels} non-@code{nil} means return sizes 5409specification. @var{pixels} non-@code{nil} means return sizes measured
5410measured in pixels, otherwise return sizes measured in canonical 5410in pixels, otherwise return sizes measured in the default character size
5411character units (fractions of the width/height of the frame's default 5411of @var{frame} (@pxref{Frame Font}). @var{frame} is the frame on which
5412font). @var{frame} is the frame on which the image will be displayed. 5412the image will be displayed. @var{frame} null or omitted means use the
5413@var{frame} null or omitted means use the selected frame (@pxref{Input 5413selected frame (@pxref{Input Focus}).
5414Focus}).
5415@end defun 5414@end defun
5416 5415
5417@defvar max-image-size 5416@defvar max-image-size
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index a32c69c1c2f..9044fbaec56 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -1041,6 +1041,7 @@ Frames
1041 1041
1042* Creating Frames:: Creating additional frames. 1042* Creating Frames:: Creating additional frames.
1043* Multiple Terminals:: Displaying on several different devices. 1043* Multiple Terminals:: Displaying on several different devices.
1044* Frame Geometry:: Geometric properties of frames.
1044* Frame Parameters:: Controlling frame size, position, font, etc. 1045* Frame Parameters:: Controlling frame size, position, font, etc.
1045* Terminal Parameters:: Parameters common for all frames on terminal. 1046* Terminal Parameters:: Parameters common for all frames on terminal.
1046* Frame Titles:: Automatic updating of frame titles. 1047* Frame Titles:: Automatic updating of frame titles.
@@ -1064,12 +1065,18 @@ Frames
1064* Resources:: Getting resource values from the server. 1065* Resources:: Getting resource values from the server.
1065* Display Feature Testing:: Determining the features of a terminal. 1066* Display Feature Testing:: Determining the features of a terminal.
1066 1067
1068Frame Geometry
1069
1070* Frame Layout:: Basic layout of frames.
1071* Frame Font:: The default font of a frame and how to set it.
1072* Size and Position:: Changing the size and position of a frame.
1073* Implied Frame Resizing:: Implied resizing of frames and how to prevent it.
1074
1067Frame Parameters 1075Frame Parameters
1068 1076
1069* Parameter Access:: How to change a frame's parameters. 1077* Parameter Access:: How to change a frame's parameters.
1070* Initial Parameters:: Specifying frame parameters when you make a frame. 1078* Initial Parameters:: Specifying frame parameters when you make a frame.
1071* Window Frame Parameters:: List of frame parameters for window systems. 1079* Window Frame Parameters:: List of frame parameters for window systems.
1072* Size and Position:: Changing the size and position of a frame.
1073* Geometry:: Parsing geometry specifications. 1080* Geometry:: Parsing geometry specifications.
1074 1081
1075Window Frame Parameters 1082Window Frame Parameters
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 79b5172ae0b..28e6fbdfef4 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -80,6 +80,7 @@ for @code{framep} above.
80@menu 80@menu
81* Creating Frames:: Creating additional frames. 81* Creating Frames:: Creating additional frames.
82* Multiple Terminals:: Displaying on several different devices. 82* Multiple Terminals:: Displaying on several different devices.
83* Frame Geometry:: Geometric properties of frames.
83* Frame Parameters:: Controlling frame size, position, font, etc. 84* Frame Parameters:: Controlling frame size, position, font, etc.
84* Terminal Parameters:: Parameters common for all frames on terminal. 85* Terminal Parameters:: Parameters common for all frames on terminal.
85* Frame Titles:: Automatic updating of frame titles. 86* Frame Titles:: Automatic updating of frame titles.
@@ -416,6 +417,545 @@ This function returns the attributes of the physical monitor
416dominating (see above) @var{frame}, which defaults to the selected frame. 417dominating (see above) @var{frame}, which defaults to the selected frame.
417@end defun 418@end defun
418 419
420
421@node Frame Geometry
422@section Frame Geometry
423@cindex frame geometry
424@cindex frame position
425@cindex position of frame
426@cindex frame size
427@cindex size of frame
428
429The geometry of a frame depends on the toolkit that was used to build
430this instance of Emacs and the terminal that displays the frame. This
431chapter describes these dependencies and some of the functions to deal
432with them. Note that the @var{frame} argument of all of these functions
433has to specify a live frame (@pxref{Deleting Frames}). If omitted or
434@code{nil}, it specifies the selected frame (@pxref{Input Focus}).
435
436@menu
437* Frame Layout:: Basic layout of frames.
438* Frame Font:: The default font of a frame and how to set it.
439* Size and Position:: Changing the size and position of a frame.
440* Implied Frame Resizing:: Implied resizing of frames and how to prevent it.
441@end menu
442
443
444@node Frame Layout
445@subsection Frame Layout
446@cindex frame layout
447@cindex layout of frame
448
449The drawing below sketches the layout of a frame on a graphical
450terminal:
451@smallexample
452@group
453
454 <------------ Outer Frame Width ----------->
455 ___________________________________________
456 ^(0) ___________ External Border __________ |
457 | | |_____________ Title Bar ______________| |
458 | | (1)_____________ Menu Bar ______________| | ^
459 | | (2)_____________ Tool Bar ______________| | ^
460 | | (3) _________ Internal Border ________ | | ^
461 | | | | ^ | | | |
462 | | | | | | | | |
463Outer | | | Inner | | | Native
464Frame | | | Frame | | | Frame
465Height | | | Height | | | Height
466 | | | | | | | | |
467 | | | |<--+--- Inner Frame Width ------->| | | |
468 | | | | | | | | |
469 | | | |___v______________________________| | | |
470 | | |___________ Internal Border __________| | v
471 v |______________ External Border _____________|
472 <-------- Native Frame Width -------->
473
474@end group
475@end smallexample
476
477In practice not all of the areas shown in the drawing will or may be
478present. The meaning of these areas is:
479
480@table @samp
481@item Outer Frame
482@cindex outer frame
483@cindex outer edges
484@cindex outer width
485@cindex outer height
486The @dfn{outer frame} is a rectangle comprising all areas shown in the
487drawing. The edges of that rectangle are called the @dfn{outer edges}
488of the frame. The @dfn{outer width} and @dfn{outer height} of the frame
489specify the size of that rectangle.
490
491@cindex outer position
492The upper left corner of the outer frame (indicated by ``(0)'' in the
493drawing above) is the @dfn{outer position} or the frame. It is
494specified by and settable via the @code{left} and @code{top} frame
495parameters (@pxref{Position Parameters}) as well as the functions
496@code{frame-position} and @code{set-frame-position} (@pxref{Size and
497Position}).
498
499@item External Border
500@cindex external border
501The @dfn{external border} is part of the decorations supplied by the
502window manager. It's typically used for resizing the frame with the
503mouse. The external border is normally not shown on ``fullboth'' and
504maximized frames (@pxref{Size Parameters}) and doesn't exist for text
505terminal frames.
506
507 The external border should not be confused with the @dfn{outer
508border} specified by the @code{border-width} frame parameter
509(@pxref{Layout Parameters}). Since the outer border is usually ignored
510on most platforms it is not covered here.
511
512@item Title Bar
513@cindex title bar
514The @dfn{title bar} is also part of the window manager's decorations and
515typically displays the title of the frame (@pxref{Frame Titles}) as well
516as buttons for minimizing, maximizing and deleting the frame. The title
517bar is usually not displayed on ``fullboth'' (@pxref{Size Parameters})
518or tooltip frames. Title bars don't exist for text terminal frames.
519
520@item Menu Bar
521@cindex internal menu bar
522@cindex external menu bar
523The menu bar (@pxref{Menu Bar}) can be either internal (drawn by Emacs
524itself) or external (drawn by a toolkit). Most builds (GTK+, Lucid,
525Motif and Windows) rely on an external menu bar. NS also uses an
526external menu bar which, however, is not part of the outer frame.
527Non-toolkit builds can provide an internal menu bar. On text terminal
528frames, the menu bar is part of the frame's root window (@pxref{Windows
529and Frames}).
530
531@item Tool Bar
532@cindex internal tool bar
533@cindex external tool bar
534Like the menu bar, the tool bar (@pxref{Tool Bar}) can be either
535internal (drawn by Emacs itself) or external (drawn by a toolkit). The
536GTK+ and NS builds have the tool bar drawn by the toolkit. The
537remaining builds use internal tool bars. With GTK+ the tool bar can be
538located on either side of the frame, immediately outside the internal
539border, see below.
540
541@item Native Frame
542@cindex native frame
543@cindex native edges
544@cindex native width
545@cindex native height
546@cindex display area
547The @dfn{native frame} is a rectangle located entirely within the outer
548frame. It excludes the areas occupied by the external border, the title
549bar and any external menu or external tool bar. The area enclosed by
550the native frame is sometimes also referred to as the @dfn{display area}
551of the frame. The edges of the native frame are called the @dfn{native
552edges} of the frame. The @dfn{native width} and @dfn{native height} of
553the frame specify the size of the rectangle.
554
555@cindex native position
556The top left corner of the native frame specifies the @dfn{native
557position} of the frame. (1)--(3) in the drawing above indicate that
558position for the various builds:
559
560@itemize @w
561@item (1) non-toolkit and terminal frames
562
563@item (2) Lucid, Motif and Windows frames
564
565@item (3) GTK+ and NS frames
566@end itemize
567
568Accordingly, the native height of a frame includes the height of the
569tool bar but not that of the menu bar (Lucid, Motif, Windows) or those
570of the menu bar and the tool bar (non-toolkit and text terminal frames).
571
572The native position of a frame is the reference position of functions
573that set or return the current position of the mouse (@pxref{Mouse
574Position}) and for functions dealing with the position of windows like
575@code{window-edges}, @code{window-at} or @code{coordinates-in-window-p}
576(@pxref{Coordinates and Windows}).
577
578@item Internal Border
579The internal border (@pxref{Layout Parameters}) is a border drawn by
580Emacs around the inner frame (see below).
581
582@item Inner Frame
583@cindex inner frame
584@cindex inner edges
585@cindex inner width
586@cindex inner height
587The @dfn{inner frame} is the rectangle reserved for the frame's windows.
588It's enclosed by the internal border which, however, is not part of the
589inner frame. Its edges are called the @dfn{inner edges} of the frame.
590The @dfn{inner width} and @dfn{inner height} specify the size of the
591rectangle.
592
593@cindex non-minibuffer frame
594@cindex minibuffer-only frame
595As a rule, the inner frame is subdivided into the frame's root window
596(@pxref{Windows and Frames}) and the frame's minibuffer window
597(@pxref{Minibuffer Windows}). There are two notable exceptions to this
598rule: A @dfn{non-minibuffer frame} contains a root window only and does
599not contain a minibuffer window. A @dfn{minibuffer-only frame} contains
600only a minibuffer window which also serves as that frame's root window.
601See @ref{Initial Parameters} for how to create such frame
602configurations.
603
604@item Text Area
605@cindex text area
606The @dfn{text area} of a frame is a somewhat fictitious area located
607entirely within the native frame. It can be obtained by removing from
608the native frame any internal borders, one vertical and one horizontal
609scroll bar, and one left and one right fringe as specified for this
610frame, see @ref{Layout Parameters}.
611@end table
612
613@cindex absolute position
614The @dfn{absolute position} of a frame or its edges is usually given in
615terms of pixels counted from an origin at position (0, 0) of the frame's
616display. Note that with multiple monitors the origin does not
617necessarily coincide with the top left corner of the entire usable
618display area. Hence the absolute outer position of a frame or the
619absolute positions of the edges of the outer, native or inner frame can
620be negative in such an environment even when that frame is completely
621visible.
622
623 For a frame on a graphical terminal the following function returns the
624sizes of the areas described above:
625
626@defun x-frame-geometry &optional frame
627This function returns geometric attributes of @var{frame}. The return
628value is an association list of the attributes listed below. All
629coordinate, height and width values are integers counting pixels.
630
631@table @code
632@item outer-position
633A cons of the absolute X- and Y-coordinates of the outer position of
634@var{frame}, relative to the origin at position (0, 0) of @var{frame}'s
635display.
636
637@item outer-size
638A cons of the outer width and height of @var{frame}.
639
640@item external-border-size
641A cons of the horizontal and vertical width of @var{frame}'s external
642borders as supplied by the window manager. If the window manager
643doesn't supply these values, Emacs will try to guess them from the
644coordinates of the outer and inner frame.
645
646@item title-bar-size
647A cons of the width and height of the title bar of @var{frame} as
648supplied by the window manager or operating system. If both of them are
649zero, the frame has no title bar. If only the width is zero, Emacs was
650not able to retrieve the width information.
651
652@item menu-bar-external
653If non-@code{nil}, this means the menu bar is external (not part of the
654native frame of @var{frame}).
655
656@item menu-bar-size
657A cons of the width and height of the menu bar of @var{frame}.
658
659@item tool-bar-external
660If non-@code{nil}, this means the tool bar is external (not part of the
661native frame of @var{frame}).
662
663@item tool-bar-position
664This tells on which side the tool bar on @var{frame} is and can be one
665of @code{left}, @code{top}, @code{right} or @code{bottom}. The only
666toolkit that currently supports a value other than @code{top} is GTK+.
667
668@item tool-bar-size
669A cons of the width and height of the tool bar of @var{frame}.
670
671@item internal-border-width
672The width of the internal border of @var{frame}.
673@end table
674@end defun
675
676The following function can be used to retrieve the edges of the outer,
677native and inner frame.
678
679@defun frame-edges &optional frame type
680This function returns the edges of the outer, native or inner frame of
681@var{frame}. @var{frame} must be a live frame and defaults to the
682selected one. The list returned has the form (@var{left} @var{top}
683@var{right} @var{bottom}) where all values are in pixels relative to the
684position (0, 0) of @var{frame}'s display. For terminal frames
685@var{left} and @var{top} are both zero.
686
687Optional argument @var{type} specifies the type of the edges to return:
688@var{type} @code{outer-edges} means to return the outer edges of
689@var{frame}, @code{native-edges} (or @code{nil}) means to return its
690native edges and @code{inner-edges} means to return its inner edges.
691
692Notice that the ``pixels at the positions'' @var{bottom} and @var{right}
693lie immediately outside the corresponding frame. This means that if you
694have, for example, two side-by-side frames positioned such that the
695right outer edge of the frame on the left equals the left outer edge of
696the frame on the right, the pixels ``representing'' that edge are part
697of the frame on the right.
698@end defun
699
700
701@node Frame Font
702@subsection Frame Font
703@cindex default font
704@cindex default character size
705@cindex default character width
706@cindex default width of character
707@cindex default character height
708@cindex default height of character
709Each frame has a @dfn{default font} which specifies the default
710character size for that frame. This size is meant when retrieving or
711changing the size of a frame in terms of ``columns'' or ``lines''
712(@pxref{Size Parameters}). It is also used when resizing (@pxref{Window
713Sizes}) or splitting (@pxref{Splitting Windows}) windows.
714
715@cindex line height
716@cindex column width
717The term @dfn{line height} is sometimes used instead of ``default
718character height''. Similarly, the term @dfn{column width} is used as
719shorthand for ``default character width''.
720
721@defun frame-char-height &optional frame
722@defunx frame-char-width &optional frame
723These functions return the default height and width of a character in
724@var{frame}, measured in pixels. Together, these values establish the
725size of the default font on @var{frame}. The values depend on the
726choice of font for @var{frame}, see @ref{Font and Color Parameters}.
727@end defun
728
729The default font can be also set directly with the following function:
730
731@deffn Command set-frame-font font &optional keep-size frames
732This sets the default font to @var{font}. When called interactively, it
733prompts for the name of a font, and uses that font on the selected
734frame. When called from Lisp, @var{font} should be a font name (a
735string), a font object, font entity, or a font spec.
736
737If the optional argument @var{keep-size} is @code{nil}, this keeps the
738number of frame lines and columns fixed. (If non-@code{nil}, the option
739@code{frame-inhibit-implied-resize} described in the next section will
740override this.) If @var{keep-size} is non-@code{nil} (or with a prefix
741argument), it tries to keep the size of the display area of the current
742frame fixed by adjusting the number of lines and columns.
743
744If the optional argument @var{frames} is @code{nil}, this applies the
745font to the selected frame only. If @var{frames} is non-@code{nil}, it
746should be a list of frames to act upon, or @code{t} meaning all existing
747graphical frames.
748@end deffn
749
750
751@node Size and Position
752@subsection Size and Position
753@cindex frame size
754@cindex frame position
755@cindex position of frame
756
757You can read or change the position of a frame using the frame
758parameters @code{left} and @code{top} (@pxref{Position Parameters}) and
759its size using the @code{height} and @code{width} parameters
760(@pxref{Size Parameters}). Here are some special features for working
761with sizes and positions. For all of these functions the argument
762@var{frame} must denote a live frame and defaults to the selected frame.
763
764@defun frame-position &optional Lisp_Object &optional frame
765This function returns the outer position (@pxref{Frame Layout}) of
766@var{frame} in pixels. The value is a cons giving the coordinates of
767the top left corner of the outer frame of @var{frame} relative to an
768origin at the position (0, 0) of the frame's display. On a text
769terminal frame both values are zero.
770@end defun
771
772@defun set-frame-position frame X Y
773This function sets the outer frame position of @var{frame} to @var{X}
774and @var{Y}. The latter arguments specify pixels and normally count
775from an origin at the position (0, 0) of @var{frame}'s display.
776
777A negative parameter value positions the right edge of the outer frame
778by @var{-x} pixels left from the right edge of the screen or the bottom
779edge by @var{-y} pixels up from the bottom edge of the screen.
780
781This function has no effect on text terminal frames.
782@end defun
783
784@defun frame-pixel-height &optional frame
785@defunx frame-pixel-width &optional frame
786 These functions return the inner height and width (the height and
787width of the display area, see @ref{Frame Layout}) of @var{frame} in
788pixels. For a text terminal, the results are in characters rather than
789pixels.
790@end defun
791
792@defun frame-text-height &optional frame
793@defunx frame-text-width &optional frame
794These functions return the height and width of the text area of
795@var{frame} (@pxref{Frame Layout}), measured in pixels. For a text
796terminal, the results are in characters rather than pixels.
797
798The value returned by @code{frame-text-height} differs from that
799returned by @code{frame-pixel-height} by not including the heights of
800any internal tool bar or menu bar, the height of one horizontal scroll
801bar and the widths of the internal border.
802
803The value returned by @code{frame-text-width} differs from that returned
804by @code{frame-pixel-width} by not including the width of one vertical
805scroll bar, the widths of one left and one right fringe and the widths
806of the internal border.
807@end defun
808
809@defun frame-height &optional frame
810@defunx frame-width &optional frame
811These functions return the height and width of the text area of
812@var{frame}, measured in units of the default font height and width of
813@var{frame} (@pxref{Frame Font}). These functions are plain shorthands
814for writing @code{(frame-parameter frame 'height)} and
815@code{(frame-parameter frame 'width)}.
816
817If the text area of @var{frame} measured in pixels is not a multiple of
818its default font size, the values returned by these functions are
819rounded down to the number of characters of the default font that fully
820fit into the text area.
821@end defun
822
823@defopt frame-resize-pixelwise
824If this option is @code{nil}, a frame's size is usually rounded to a
825multiple of the current values of that frame's @code{frame-char-height}
826and @code{frame-char-width} whenever the frame is resized. If this is
827non-@code{nil}, no rounding occurs, hence frame sizes can
828increase/decrease by one pixel.
829
830Setting this variable usually causes the next resize operation to pass
831the corresponding size hints to the window manager. This means that
832this variable should be set only in a user's initial file; applications
833should never bind it temporarily.
834
835The precise meaning of a value of @code{nil} for this option depends on
836the toolkit used. Dragging the external border with the mouse is done
837character-wise provided the window manager is willing to process the
838corresponding size hints. Calling @code{set-frame-size} (see below)
839with arguments that do not specify the frame size as an integer multiple
840of its character size, however, may: be ignored, cause a rounding
841(GTK+), or be accepted (Lucid, Motif, MS-Windows).
842
843With some window managers you may have to set this to non-@code{nil} in
844order to make a frame appear truly ``maximized'' or ``fullscreen''.
845@end defopt
846
847@defun set-frame-size frame width height pixelwise
848This function sets the size of the text area of @var{frame}, measured in
849terms of the canonical height and width of a character on @var{frame}
850(@pxref{Frame Font}).
851
852The optional argument @var{pixelwise} non-@code{nil} means to measure
853the new width and height in units of pixels instead. Note that if
854@code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
855fully honor the request if it does not increase/decrease the frame size
856to a multiple of its character size.
857@end defun
858
859@defun set-frame-height frame height &optional pretend pixelwise
860This function resizes the text area of @var{frame} to a height of
861@var{height} lines. The sizes of existing windows in @var{frame} are
862altered proportionally to fit.
863
864If @var{pretend} is non-@code{nil}, then Emacs displays @var{height}
865lines of output in @var{frame}, but does not change its value for the
866actual height of the frame. This is only useful on text terminals.
867Using a smaller height than the terminal actually implements may be
868useful to reproduce behavior observed on a smaller screen, or if the
869terminal malfunctions when using its whole screen. Setting the frame
870height ``for real'' does not always work, because knowing the correct
871actual size may be necessary for correct cursor positioning on
872text terminals.
873
874The optional fourth argument @var{pixelwise} non-@code{nil} means that
875@var{frame} should be @var{height} pixels high. Note that if
876@code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
877fully honor the request if it does not increase/decrease the frame
878height to a multiple of its character height.
879@end defun
880
881@defun set-frame-width frame width &optional pretend pixelwise
882This function sets the width of the text area of @var{frame}, measured
883in characters. The argument @var{pretend} has the same meaning as in
884@code{set-frame-height}.
885
886The optional fourth argument @var{pixelwise} non-@code{nil} means that
887@var{frame} should be @var{width} pixels wide. Note that if
888@code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
889fully honor the request if it does not increase/decrease the frame width
890to a multiple of its character width.
891@end defun
892
893None of these three functions will make a frame smaller than needed to
894display all of its windows together with their scroll bars, fringes,
895margins, dividers, mode and header lines. This contrasts with requests
896by the window manager triggered, for example, by dragging the external
897border of a frame with the mouse. Such requests are always honored by
898clipping, if necessary, portions that cannot be displayed at the right,
899bottom corner of the frame.
900
901
902@node Implied Frame Resizing
903@subsection Implied Frame Resizing
904@cindex implied frame resizing
905@cindex implied resizing of frame
906
907By default, Emacs tries to keep the number of lines and columns of a
908frame's text area unaltered when, for example, adding or removing the
909menu bar, changing the default font or setting the width of the frame's
910scroll bars. This means, however, that in such case Emacs must ask the
911window manager to resize the outer frame in order to accommodate the
912size change. Note that wrapping a menu or tool bar usually does not
913resize the frame's outer size, hence this will alter the number of
914displayed lines.
915
916 Occasionally, such @dfn{implied frame resizing} may be unwanted, for
917example, when the frame is maximized or made fullscreen (where it's
918turned off by default). In other cases you can disable implied resizing
919with the following option:
920
921@defopt frame-inhibit-implied-resize
922If this option is @code{nil}, changing font, menu bar, tool bar,
923internal borders, fringes or scroll bars of a specific frame may
924implicitly resize the frame's display area in order to preserve the
925number of columns or lines the frame displays. If this option is
926non-@code{nil}, no implied resizing is done.
927
928The value of this option can be also be a list of frame parameters. In
929that case, implied resizing is inhibited when changing a parameter that
930appears in this list. The frame parameters currently handled by this
931option are: @code{font}, @code{font-backend},
932@code{internal-border-width}, @code{menu-bar-lines} and
933@code{tool-bar-lines}.
934
935Changing any of the @code{scroll-bar-width}, @code{scroll-bar-height},
936@code{vertical-scroll-bars}, @code{horizontal-scroll-bars},
937@code{left-fringe} and @code{right-fringe} frame parameters is handled
938as if the frame contained just one live window. This means, for
939example, that removing vertical scroll bars on a frame containing
940several side by side windows will shrink the outer frame width by the
941width of one scroll bar provided this option is @code{nil} and keep it
942unchanged if this option is either @code{t} or a list containing
943@code{vertical-scroll-bars}.
944
945The default value is @code{'(tool-bar-lines)} for Lucid, Motif and
946Windows (which means that adding/removing a tool bar there does not
947change the outer frame height), @code{nil} on all other window systems
948including GTK+ (which means that changing any of the parameters listed
949above may change the size of the outer frame), and @code{t} otherwise
950(which means the outer frame size never changes implicitly when there's
951no window system support).
952
953Note that when a frame is not large enough to accommodate a change of
954any of the parameters listed above, Emacs may try to enlarge the frame
955even if this option is non-@code{nil}.
956@end defopt
957
958
419@node Frame Parameters 959@node Frame Parameters
420@section Frame Parameters 960@section Frame Parameters
421@cindex frame parameters 961@cindex frame parameters
@@ -438,7 +978,6 @@ frame transparency, the parameter @code{alpha} is also meaningful.
438* Parameter Access:: How to change a frame's parameters. 978* Parameter Access:: How to change a frame's parameters.
439* Initial Parameters:: Specifying frame parameters when you make a frame. 979* Initial Parameters:: Specifying frame parameters when you make a frame.
440* Window Frame Parameters:: List of frame parameters for window systems. 980* Window Frame Parameters:: List of frame parameters for window systems.
441* Size and Position:: Changing the size and position of a frame.
442* Geometry:: Parsing geometry specifications. 981* Geometry:: Parsing geometry specifications.
443@end menu 982@end menu
444 983
@@ -723,12 +1262,12 @@ pixel sizes of these character units (@pxref{Face Attributes}).
723@table @code 1262@table @code
724@vindex height, a frame parameter 1263@vindex height, a frame parameter
725@item height 1264@item height
726The height of the frame's text area (@pxref{Size and Position}), in 1265The height of the frame's text area (@pxref{Frame Geometry}), in
727characters. 1266characters.
728 1267
729@vindex width, a frame parameter 1268@vindex width, a frame parameter
730@item width 1269@item width
731The width of the frame's text area (@pxref{Size and Position}), in 1270The width of the frame's text area (@pxref{Frame Geometry}), in
732characters. 1271characters.
733 1272
734@vindex user-size, a frame parameter 1273@vindex user-size, a frame parameter
@@ -1183,309 +1722,6 @@ equivalent to the @code{:background} attribute of the
1183@end table 1722@end table
1184 1723
1185 1724
1186@node Size and Position
1187@subsection Frame Size and Position
1188@cindex size of frame
1189@cindex screen size
1190@cindex frame size
1191@cindex resize frame
1192
1193You can read or change the size and position of a frame using the frame
1194parameters @code{left}, @code{top}, @code{height}, and @code{width}.
1195Whatever geometry parameters you don't specify are chosen by the window
1196manager in its usual fashion.
1197
1198 Here are some special features for working with sizes and positions.
1199Most of the functions described below use a @var{frame} argument which
1200has to specify a live frame. If omitted or @code{nil}, it specifies the
1201selected frame, see @ref{Input Focus}.
1202
1203@defun set-frame-position frame left top
1204This function sets the position of the top left corner of @var{frame} to
1205@var{left} and @var{top}. These arguments are measured in pixels, and
1206normally count from the top left corner of the screen to the top left
1207corner of the rectangle allotted to the frame by the window manager.
1208
1209Negative parameter values position the bottom edge of that rectangle up
1210from the bottom edge of the screen, or the right rectangle edge to the
1211left of the right edge of the screen. It would probably be better if
1212the values were always counted from the left and top, so that negative
1213arguments would position the frame partly off the top or left edge of
1214the screen, but it seems inadvisable to change that now.
1215@end defun
1216
1217@cindex frame default font
1218@cindex default font of a frame
1219Each frame has a @dfn{default font} which specifies the canonical height
1220and width of a character on that frame. The default font is used when
1221retrieving or changing the size of a frame in terms of columns or lines.
1222It is also used when resizing (@pxref{Window Sizes}) or splitting
1223(@pxref{Splitting Windows}) windows.
1224
1225@defun frame-char-height &optional frame
1226@defunx frame-char-width &optional frame
1227These functions return the canonical height and width of a character in
1228@var{frame}, measured in pixels. Together, these values establish the
1229size of the default font on @var{frame}. The values depend on the
1230choice of font for @var{frame}, see @ref{Font and Color Parameters}.
1231@end defun
1232
1233The default font can be also set directly with the following function:
1234
1235@deffn Command set-frame-font font &optional keep-size frames
1236This sets the default font to @var{font}. When called interactively, it
1237prompts for the name of a font, and uses that font on the selected
1238frame. When called from Lisp, @var{font} should be a font name (a
1239string), a font object, font entity, or a font spec.
1240
1241If the optional argument @var{keep-size} is @code{nil}, this keeps the
1242number of frame lines and columns fixed. (If non-@code{nil}, the option
1243@code{frame-inhibit-implied-resize} described below will override this.)
1244If @var{keep-size} is non-@code{nil} (or with a prefix argument), it
1245tries to keep the size of the display area of the current frame fixed by
1246adjusting the number of lines and columns.
1247
1248If the optional argument @var{frames} is @code{nil}, this applies the
1249font to the selected frame only. If @var{frames} is non-@code{nil}, it
1250should be a list of frames to act upon, or @code{t} meaning all existing
1251graphical frames.
1252@end deffn
1253
1254@cindex frame display area
1255@cindex display area of a frame
1256The @dfn{display area} of a frame is a rectangular area within the area
1257allotted to the frame by the window manager. The display area neither
1258includes the title bar (@pxref{Frame Titles}) nor any other decorations
1259provided by the window manager (like an external border used for
1260resizing frames via mouse dragging).
1261
1262 The actual height of the display area depends on the window-system
1263and toolkit in use. With GTK+, the display area does not include any
1264tool bar or menu bar. With the Motif or Lucid toolkits and with
1265Windows, the display area includes the tool bar but not the menu bar.
1266In a graphical version with no toolkit, it includes both the tool bar
1267and menu bar. On a text terminal, the display area includes the menu
1268bar.
1269
1270@defun frame-pixel-height &optional frame
1271@defunx frame-pixel-width &optional frame
1272 These functions return the height and width of the display area of
1273@var{frame}, measured in pixels. For a text terminal, the results are
1274in characters rather than pixels.
1275@end defun
1276
1277@cindex frame text area
1278@cindex text area of a frame
1279 The @dfn{text area} of a frame is a concept implicitly used by all
1280functions that change a frame's height or width. It is a rectangle
1281located within the display area. Its size is obtained from that of the
1282display area by subtracting the sizes of any tool or menu bars that are
1283part of the display area, any internal borders, one vertical and one
1284horizontal scroll bar, and one left and one right fringe as specified
1285for this frame, see @ref{Layout Parameters}.
1286
1287@defun frame-text-height &optional frame
1288@defunx frame-text-width &optional frame
1289These functions return the height and width of the text area of
1290@var{frame}, measured in pixels. For a text terminal, the results are
1291in characters rather than pixels.
1292
1293The value returned by @code{frame-text-height} differs from that
1294returned by @code{frame-pixel-height} by not including the heights of
1295any tool bar or menu bar, the height of one horizontal scroll bar and
1296the widths of the internal border.
1297
1298The value returned by @code{frame-text-width} differs from that returned
1299by @code{frame-pixel-width} by not including the width of one vertical
1300scroll bar, the widths of one left and one right fringe and the widths
1301of the internal border.
1302@end defun
1303
1304@defun frame-height &optional frame
1305@defunx frame-width &optional frame
1306These functions return the height and width of the text area of
1307@var{frame}, measured in units of the default font height and width of
1308@var{frame}. These functions are plain shorthands for writing
1309@code{(frame-parameter frame 'height)} and @code{(frame-parameter frame
1310'width)}.
1311
1312If the text area of @var{frame} measured in pixles is not a multiple of
1313its default font size, the values returned by this functions are rounded
1314down to the number of characters of the default font that fully fit into
1315the text area.
1316@end defun
1317
1318@defopt frame-resize-pixelwise
1319If this option is @code{nil}, a frame's size is usually rounded to a
1320multiple of the current values of that frame's @code{frame-char-height}
1321and @code{frame-char-width}. If this is non-@code{nil}, no rounding
1322occurs, hence frame sizes can increase/decrease by one pixel.
1323
1324Setting this causes the next resize operation to pass the corresponding
1325size hints to the window manager. This means that this variable should
1326be set only in a user's initial file; applications should never bind it
1327temporarily.
1328
1329The precise meaning of a value of @code{nil} for this option depends
1330on the toolkit used. Dragging the frame border with the mouse is usually
1331done character-wise. Calling @code{set-frame-size} (see below)
1332with arguments that do not specify the frame size as an integer multiple
1333of its character size, however, may: be ignored, cause a
1334rounding (GTK+), or be accepted (Lucid, Motif, MS-Windows).
1335
1336With some window managers you may have to set this to non-@code{nil} in
1337order to make a frame appear truly ``maximized'' or ``fullscreen''.
1338@end defopt
1339
1340@defun set-frame-size frame width height pixelwise
1341This function sets the size of the text area of @var{frame}, measured in
1342characters; @var{width} and @var{height} specify the new width in
1343columns and the new height in lines.
1344
1345The optional argument @var{pixelwise} non-@code{nil} means to measure
1346the new width and height in units of pixels instead. Note that if
1347@code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
1348fully honor the request if it does not increase/decrease the frame size
1349to a multiple of its character size.
1350@end defun
1351
1352@defun set-frame-height frame height &optional pretend pixelwise
1353This function resizes the text area of @var{frame} to a height of
1354@var{height} lines. The sizes of existing windows in @var{frame} are
1355altered proportionally to fit.
1356
1357If @var{pretend} is non-@code{nil}, then Emacs displays @var{height}
1358lines of output in @var{frame}, but does not change its value for the
1359actual height of the frame. This is only useful on text terminals.
1360Using a smaller height than the terminal actually implements may be
1361useful to reproduce behavior observed on a smaller screen, or if the
1362terminal malfunctions when using its whole screen. Setting the frame
1363height ``for real'' does not always work, because knowing the correct
1364actual size may be necessary for correct cursor positioning on
1365text terminals.
1366
1367The optional fourth argument @var{pixelwise} non-@code{nil} means that
1368@var{frame} should be @var{height} pixels high. Note that if
1369@code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
1370fully honor the request if it does not increase/decrease the frame
1371height to a multiple of its character height.
1372@end defun
1373
1374@defun set-frame-width frame width &optional pretend pixelwise
1375This function sets the width of the text area of @var{frame}, measured
1376in characters. The argument @var{pretend} has the same meaning as in
1377@code{set-frame-height}.
1378
1379The optional fourth argument @var{pixelwise} non-@code{nil} means that
1380@var{frame} should be @var{width} pixels wide. Note that if
1381@code{frame-resize-pixelwise} is @code{nil}, some toolkits may refuse to
1382fully honor the request if it does not increase/decrease the frame width
1383to a multiple of its character width.
1384@end defun
1385
1386None of these three functions will make a frame smaller than needed to
1387display all of its windows together with their scroll bars, fringes,
1388margins, dividers, mode and header lines. This contrasts with requests
1389by the window manager triggered, for example, by dragging the external
1390border of a frame with the mouse. Such requests are always honored by
1391clipping, if necessary, portions that cannot be displayed at the right,
1392bottom corner of the frame.
1393
1394 By default, Emacs tries to keep the number of lines and columns of a
1395frame's text area unaltered when, for example, adding or removing a menu
1396bar, changing the default font or setting the width of the frame's
1397scroll bars. This means, however, that in such case Emacs must ask the
1398window manager to resize the display area of the frame in order to
1399accommodate the size change. Note that wrapping a menu or tool bar
1400usually does not resize the frame's display area, hence this will alter
1401the number of displayed lines.
1402
1403 Occasionally, such implied resizing of the display area may be
1404unwanted, for example, when the frame is maximized or made fullscreen
1405where it's turned off by default. In other cases you can disable
1406implied resizing with the following option:
1407
1408@defopt frame-inhibit-implied-resize
1409If this option is @code{nil}, changing font, menu bar, tool bar,
1410internal borders, fringes or scroll bars of a specific frame may
1411implicitly resize the frame's display area in order to preserve the
1412number of columns or lines the frame displays. If this option is
1413non-@code{nil}, no implied resizing is done.
1414
1415The value of this option can be also be a list of frame parameters. In
1416that case, implied resizing is inhibited when changing a parameter that
1417appears in this list. The frame parameters currently handled by this
1418option are: @code{font}, @code{font-backend},
1419@code{internal-border-width}, @code{menu-bar-lines} and
1420@code{tool-bar-lines}.
1421
1422Changing any of the @code{scroll-bar-width}, @code{scroll-bar-height},
1423@code{vertical-scroll-bars}, @code{horizontal-scroll-bars},
1424@code{left-fringe} and @code{right-fringe} frame parameters is handled
1425as if the frame contained just one live window. This means, for
1426example, that removing vertical scroll bars on a frame containing
1427several side by side windows will shrink the frame width by the width of
1428one scroll bar provided this option is @code{nil} and keep it unchanged
1429if this option is either @code{t} or a list containing
1430@code{vertical-scroll-bars}.
1431
1432The default value is @code{'(tool-bar-lines)} for Lucid, Motif and
1433Windows (which means that adding/removing a tool bar there does not
1434change the frame height), @code{nil} on all other window systems
1435including GTK+ (which means that changing any of the parameters listed
1436above may change the size of the frame), and @code{t} otherwise (which
1437means the frame size never changes implicitly when there's no window
1438system support).
1439
1440Note that when a frame is not large enough to accommodate a change of
1441any of the parameters listed above, Emacs may try to enlarge the frame
1442even if this option is non-@code{nil}.
1443@end defopt
1444
1445@c FIXME? Belongs more in Emacs manual than here?
1446@c But, e.g., fit-window-to-buffer is in this manual.
1447If you have a frame that displays only one window, you can fit that
1448frame to its buffer using the command @code{fit-frame-to-buffer}.
1449
1450@deffn Command fit-frame-to-buffer &optional frame max-height min-height max-width min-width only
1451This command adjusts the size of @var{frame} to display the contents of
1452its buffer exactly. @var{frame} can be any live frame and defaults to
1453the selected one. Fitting is done only if @var{frame}'s root window is
1454live. The arguments @var{max-height}, @var{min-height}, @var{max-width}
1455and @var{min-width} specify bounds on the new total size of
1456@var{frame}'s root window. @var{min-height} and @var{min-width} default
1457to the values of @code{window-min-height} and @code{window-min-width}
1458respectively.
1459
1460If the optional argument @var{only} is @code{vertically}, this function
1461may resize the frame vertically only. If @var{only} is
1462@code{horizontally}, it may resize the frame horizontally only.
1463@end deffn
1464
1465The behavior of @code{fit-frame-to-buffer} can be controlled with the
1466help of the two options listed next.
1467
1468@defopt fit-frame-to-buffer-margins
1469This option can be used to specify margins around frames to be fit by
1470@code{fit-frame-to-buffer}. Such margins can be useful to avoid, for
1471example, that such frames overlap the taskbar.
1472
1473It specifies the numbers of pixels to be left free on the left, above,
1474the right, and below a frame that shall be fit. The default specifies
1475@code{nil} for each which means to use no margins. The value specified
1476here can be overridden for a specific frame by that frame's
1477@code{fit-frame-to-buffer-margins} parameter, if present.
1478@end defopt
1479
1480@defopt fit-frame-to-buffer-sizes
1481This option specifies size boundaries for @code{fit-frame-to-buffer}.
1482It specifies the total maximum and minimum lines and maximum and minimum
1483columns of the root window of any frame that shall be fit to its buffer.
1484If any of these values is non-@code{nil}, it overrides the corresponding
1485argument of @code{fit-frame-to-buffer}.
1486@end defopt
1487
1488
1489@node Geometry 1725@node Geometry
1490@subsection Geometry 1726@subsection Geometry
1491 1727
@@ -2088,8 +2324,10 @@ give access to the current position of the mouse.
2088@defun mouse-position 2324@defun mouse-position
2089This function returns a description of the position of the mouse. The 2325This function returns a description of the position of the mouse. The
2090value looks like @code{(@var{frame} @var{x} . @var{y})}, where @var{x} 2326value looks like @code{(@var{frame} @var{x} . @var{y})}, where @var{x}
2091and @var{y} are integers giving the position in characters relative to 2327and @var{y} are integers giving the (possibly rounded) position in
2092the top left corner of the inside of @var{frame}. 2328multiples of the default character size of @var{frame} (@pxref{Frame
2329Font}) relative to the native position of @var{frame} (@pxref{Frame
2330Geometry}).
2093@end defun 2331@end defun
2094 2332
2095@defvar mouse-position-function 2333@defvar mouse-position-function
@@ -2105,9 +2343,13 @@ This abnormal hook exists for the benefit of packages like
2105@defun set-mouse-position frame x y 2343@defun set-mouse-position frame x y
2106This function @dfn{warps the mouse} to position @var{x}, @var{y} in 2344This function @dfn{warps the mouse} to position @var{x}, @var{y} in
2107frame @var{frame}. The arguments @var{x} and @var{y} are integers, 2345frame @var{frame}. The arguments @var{x} and @var{y} are integers,
2108giving the position in characters relative to the top left corner of the 2346giving the position in multiples of the default character size of
2109inside of @var{frame}. If @var{frame} is not visible, this function 2347@var{frame} (@pxref{Frame Font}) relative to the native position of
2110does nothing. The return value is not significant. 2348@var{frame} (@pxref{Frame Geometry}).
2349
2350The resulting mouse position is constrained to the native frame of
2351@var{frame}. If @var{frame} is not visible, this function does nothing.
2352The return value is not significant.
2111@end defun 2353@end defun
2112 2354
2113@defun mouse-pixel-position 2355@defun mouse-pixel-position
@@ -2118,12 +2360,31 @@ coordinates in units of pixels rather than units of characters.
2118@defun set-mouse-pixel-position frame x y 2360@defun set-mouse-pixel-position frame x y
2119This function warps the mouse like @code{set-mouse-position} except that 2361This function warps the mouse like @code{set-mouse-position} except that
2120@var{x} and @var{y} are in units of pixels rather than units of 2362@var{x} and @var{y} are in units of pixels rather than units of
2121characters. These coordinates are not required to be within the frame. 2363characters.
2122 2364
2123If @var{frame} is not visible, this function does nothing. The return 2365The resulting mouse position is not constrained to the native frame of
2124value is not significant. 2366@var{frame}. If @var{frame} is not visible, this function does nothing.
2367The return value is not significant.
2125@end defun 2368@end defun
2126 2369
2370On a graphical terminal the following two functions allow to retrieve
2371and set the absolute position of the mouse cursor.
2372
2373@defun x-mouse-absolute-pixel-position
2374This function returns a cons cell (@var{x} . @var{y}) of the coordinates
2375of the mouse cursor position in pixels, relative to a position (0, 0) of
2376the selected frame's display.
2377@end defun
2378
2379@defun x-set-mouse-absolute-pixel-position x y
2380This function moves the mouse cursor to the position (@var{x}, @var{y}).
2381The coordinates @var{x} and @var{y} are interpreted in pixels relative
2382to a position (0, 0) of the selected frame's display.
2383@end defun
2384
2385The following function can tell whether the mouse cursor is currently
2386visible on a frame:
2387
2127@defun frame-pointer-visible-p &optional frame 2388@defun frame-pointer-visible-p &optional frame
2128This predicate function returns non-@code{nil} if the mouse pointer 2389This predicate function returns non-@code{nil} if the mouse pointer
2129displayed on @var{frame} is visible; otherwise it returns @code{nil}. 2390displayed on @var{frame} is visible; otherwise it returns @code{nil}.
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index ccfe7ffb7bc..b55a139a334 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -432,8 +432,8 @@ specified either in units of pixels or in units of lines and columns.
432On a graphical display, the latter actually correspond to the height and 432On a graphical display, the latter actually correspond to the height and
433width of a ``default'' character specified by the frame's default font 433width of a ``default'' character specified by the frame's default font
434as returned by @code{frame-char-height} and @code{frame-char-width} 434as returned by @code{frame-char-height} and @code{frame-char-width}
435(@pxref{Size and Position}). Thus, if a window is displaying text with 435(@pxref{Frame Font}). Thus, if a window is displaying text with a
436a different font or size, the reported line height and column width for 436different font or size, the reported line height and column width for
437that window may differ from the actual number of text lines or columns 437that window may differ from the actual number of text lines or columns
438displayed within it. 438displayed within it.
439 439
@@ -791,8 +791,8 @@ If the value of this option is non-@code{nil}, Emacs resizes windows in
791units of pixels. This currently affects functions like 791units of pixels. This currently affects functions like
792@code{split-window} (@pxref{Splitting Windows}), @code{maximize-window}, 792@code{split-window} (@pxref{Splitting Windows}), @code{maximize-window},
793@code{minimize-window}, @code{fit-window-to-buffer}, 793@code{minimize-window}, @code{fit-window-to-buffer},
794@code{shrink-window-if-larger-than-buffer} (all listed below) and 794@code{fit-frame-to-buffer} and
795@code{fit-frame-to-buffer} (@pxref{Size and Position}). 795@code{shrink-window-if-larger-than-buffer} (all listed below).
796 796
797Note that when a frame's pixel size is not a multiple of its character 797Note that when a frame's pixel size is not a multiple of its character
798size, at least one window may get resized pixelwise even if this 798size, at least one window may get resized pixelwise even if this
@@ -836,8 +836,7 @@ resize operations (@pxref{Preserving Window Sizes}).
836 836
837If the option @code{fit-frame-to-buffer} (see below) is non-@code{nil}, 837If the option @code{fit-frame-to-buffer} (see below) is non-@code{nil},
838this function will try to resize the frame of @var{window} to fit its 838this function will try to resize the frame of @var{window} to fit its
839contents by calling @code{fit-frame-to-buffer} (@pxref{Size and 839contents by calling @code{fit-frame-to-buffer} (see below).
840Position}).
841@end deffn 840@end deffn
842 841
843@defopt fit-window-to-buffer-horizontally 842@defopt fit-window-to-buffer-horizontally
@@ -858,6 +857,47 @@ live window and this option is non-@code{nil}. If this is
858non-@code{nil} value means frames can be resized in both dimensions. 857non-@code{nil} value means frames can be resized in both dimensions.
859@end defopt 858@end defopt
860 859
860If you have a frame that displays only one window, you can fit that
861frame to its buffer using the command @code{fit-frame-to-buffer}.
862
863@deffn Command fit-frame-to-buffer &optional frame max-height min-height max-width min-width only
864This command adjusts the size of @var{frame} to display the contents of
865its buffer exactly. @var{frame} can be any live frame and defaults to
866the selected one. Fitting is done only if @var{frame}'s root window is
867live. The arguments @var{max-height}, @var{min-height}, @var{max-width}
868and @var{min-width} specify bounds on the new total size of
869@var{frame}'s root window. @var{min-height} and @var{min-width} default
870to the values of @code{window-min-height} and @code{window-min-width}
871respectively.
872
873If the optional argument @var{only} is @code{vertically}, this function
874may resize the frame vertically only. If @var{only} is
875@code{horizontally}, it may resize the frame horizontally only.
876@end deffn
877
878The behavior of @code{fit-frame-to-buffer} can be controlled with the
879help of the two options listed next.
880
881@defopt fit-frame-to-buffer-margins
882This option can be used to specify margins around frames to be fit by
883@code{fit-frame-to-buffer}. Such margins can be useful to avoid, for
884example, that such frames overlap the taskbar.
885
886It specifies the numbers of pixels to be left free on the left, above,
887the right, and below a frame that shall be fit. The default specifies
888@code{nil} for each which means to use no margins. The value specified
889here can be overridden for a specific frame by that frame's
890@code{fit-frame-to-buffer-margins} parameter, if present.
891@end defopt
892
893@defopt fit-frame-to-buffer-sizes
894This option specifies size boundaries for @code{fit-frame-to-buffer}.
895It specifies the total maximum and minimum lines and maximum and minimum
896columns of the root window of any frame that shall be fit to its buffer.
897If any of these values is non-@code{nil}, it overrides the corresponding
898argument of @code{fit-frame-to-buffer}.
899@end defopt
900
861@deffn Command shrink-window-if-larger-than-buffer &optional window 901@deffn Command shrink-window-if-larger-than-buffer &optional window
862This command attempts to reduce @var{window}'s height as much as 902This command attempts to reduce @var{window}'s height as much as
863possible while still showing its full buffer, but no less than 903possible while still showing its full buffer, but no less than
@@ -3622,33 +3662,28 @@ is off the screen due to horizontal scrolling:
3622@end group 3662@end group
3623@end example 3663@end example
3624 3664
3665
3625@node Coordinates and Windows 3666@node Coordinates and Windows
3626@section Coordinates and Windows 3667@section Coordinates and Windows
3627@cindex frame-relative coordinate 3668@cindex frame-relative coordinate
3628@cindex coordinate, relative to frame 3669@cindex coordinate, relative to frame
3629@cindex window position 3670@cindex window position
3630 3671
3631 This section describes functions that report the position of a 3672This section describes functions that report the position of a window.
3632window. Most of these functions report positions relative to the 3673Most of these functions report positions relative to an origin at the
3633window's frame. In this case, the coordinate origin @samp{(0,0)} lies 3674native position of the window's frame (@pxref{Frame Geometry}). Some
3634near the upper left corner of the frame. For technical reasons, on 3675functions report positions relative to the origin of the display of the
3635graphical displays the origin is not located at the exact corner of 3676window's frame. In any case, the origin has the coordinates (0, 0) and
3636the graphical window as it appears on the screen. If Emacs is built 3677X and Y coordinates increase ``rightward'' and ``downward''
3637with the GTK+ toolkit, the origin is at the upper left corner of the 3678respectively.
3638frame area used for displaying Emacs windows, below the title-bar, 3679
3639GTK+ menu bar, and tool bar (since these are drawn by the window 3680 For the following functions, X and Y coordinates are reported in
3640manager and/or GTK+, not by Emacs). But if Emacs is not built with 3681integer character units, i.e., numbers of lines and columns
3641GTK+, the origin is at the upper left corner of the tool bar (since in 3682respectively. On a graphical display, each ``line'' and ``column''
3642this case Emacs itself draws the tool bar). In both cases, the X and 3683corresponds to the height and width of a default character specified by
3643Y coordinates increase rightward and downward respectively. 3684the frame's default font (@pxref{Frame Font}).
3644 3685
3645 Except where noted, X and Y coordinates are reported in integer 3686@defun window-edges &optional window body absolute pixelwise
3646character units, i.e., numbers of lines and columns respectively. On a
3647graphical display, each ``line'' and ``column'' corresponds to the
3648height and width of a default character specified by the frame's
3649default font.
3650
3651@defun window-edges &optional window
3652This function returns a list of the edge coordinates of @var{window}. 3687This function returns a list of the edge coordinates of @var{window}.
3653If @var{window} is omitted or @code{nil}, it defaults to the selected 3688If @var{window} is omitted or @code{nil}, it defaults to the selected
3654window. 3689window.
@@ -3665,44 +3700,73 @@ header line, mode line, scroll bar, fringes, window divider and display
3665margins. On a text terminal, if the window has a neighbor on its right, 3700margins. On a text terminal, if the window has a neighbor on its right,
3666its right edge includes the separator line between the window and its 3701its right edge includes the separator line between the window and its
3667neighbor. 3702neighbor.
3668@end defun
3669 3703
3670@defun window-inside-edges &optional window 3704If the optional argument @var{body} is @code{nil}, this means to
3671This function is similar to @code{window-edges}, but the returned edge 3705return the edges corresponding to the total size of @var{window}.
3672values are for the text area of the window. They exclude any header 3706@var{body} non-@code{nil} means to return the edges of @var{window}'s
3673line, mode line, scroll bar, fringes, window divider, display margins, 3707body (aka text area). If @var{body} is non-@code{nil}, @var{window}
3674and vertical separator. 3708must specify a live window.
3709
3710If the optional argument @var{absolute} is @code{nil}, this means to
3711return edges relative to the native position of @var{window}'s frame.
3712@var{absolute} non-@code{nil} means to return coordinates relative to
3713the origin (0, 0) of @var{window}'s display. On non-graphical systems
3714this argument has no effect.
3715
3716If the optional argument @var{pixelwise} is @code{nil}, this means to
3717return the coordinates in terms of the default character width and
3718height of @var{window}'s frame (@pxref{Frame Font}), rounded if
3719necessary. @var{pixelwise} non-@code{nil} means to return the
3720coordinates in pixels. Note that the pixel specified by @var{right} and
3721@var{bottom} is immediately outside of these edges. If @var{absolute}
3722is non-@code{nil}, @var{pixelwise} is implicitly non-@code{nil} too.
3675@end defun 3723@end defun
3676 3724
3677@defun window-top-line &optional window 3725@defun window-body-edges &optional window
3678This function returns the Y coordinate of the topmost row of 3726This function returns the edges of @var{window}'s body (@pxref{Window
3679@var{window}, equivalent to the @var{top} entry in the list returned 3727Sizes}). Calling @code{(window-body-edges window)} is equivalent to
3680by @code{window-edges}. 3728calling @code{(window-edges window t)}, see above.
3681@end defun 3729@end defun
3682 3730
3731@comment The following two functions are confusing and hardly used.
3732@ignore
3683@defun window-left-column &optional window 3733@defun window-left-column &optional window
3684This function returns the X coordinate of the leftmost column of 3734This function returns the leftmost column of @var{window}. This value
3685@var{window}, equivalent to the @var{left} entry in the list returned 3735equals the @var{left} entry in the list returned by @code{(window-edges
3686by @code{window-edges}. 3736window)} minus the number of columns occupied by the internal border of
3737@var{window}'s frame.
3687@end defun 3738@end defun
3688 3739
3740@defun window-top-line &optional window
3741This function returns the topmost row of @var{window}. This value is
3742equal to the @var{top} entry in the list returned by @code{(window-edges
3743window)} minus the number of lines occupied by the internal border of
3744@var{window}'s frame.
3745@end defun
3746@end ignore
3747
3689 The following functions can be used to relate a set of 3748 The following functions can be used to relate a set of
3690frame-relative coordinates to a window: 3749frame-relative coordinates to a window:
3691 3750
3692@defun window-at x y &optional frame 3751@defun window-at x y &optional frame
3693This function returns the live window at the frame-relative 3752This function returns the live window at the coordinates @var{x} and
3694coordinates @var{x} and @var{y}, on frame @var{frame}. If there is no 3753@var{y} given in default character sizes (@pxref{Frame Font}) relative
3695window at that position, the return value is @code{nil}. If 3754to the native position of @var{frame} (@pxref{Frame Geometry}).
3696@var{frame} is omitted or @code{nil}, it defaults to the selected 3755
3756If there is no window at that position, the return value is @code{nil}.
3757If @var{frame} is omitted or @code{nil}, it defaults to the selected
3697frame. 3758frame.
3698@end defun 3759@end defun
3699 3760
3700@defun coordinates-in-window-p coordinates window 3761@defun coordinates-in-window-p coordinates window
3701This function checks whether a window @var{window} occupies the 3762This function checks whether a window @var{window} occupies the frame
3702frame-relative coordinates @var{coordinates}, and if so, which part of 3763relative coordinates @var{coordinates}, and if so, which part of the
3703the window that is. @var{window} should be a live window. 3764window that is. @var{window} should be a live window.
3765
3704@var{coordinates} should be a cons cell of the form @code{(@var{x} 3766@var{coordinates} should be a cons cell of the form @code{(@var{x}
3705. @var{y})}, where @var{x} and @var{y} are frame-relative coordinates. 3767. @var{y})}, where @var{x} and @var{y} are given in default character
3768sizes (@pxref{Frame Font}) relative to the native position of
3769@var{window}'s frame (@pxref{Frame Geometry}).
3706 3770
3707If there is no window at the specified position, the return value is 3771If there is no window at the specified position, the return value is
3708@code{nil} . Otherwise, the return value is one of the following: 3772@code{nil} . Otherwise, the return value is one of the following:
@@ -3757,46 +3821,96 @@ each text character is taken to be ``one pixel''.
3757 3821
3758@defun window-pixel-edges &optional window 3822@defun window-pixel-edges &optional window
3759This function returns a list of pixel coordinates for the edges of 3823This function returns a list of pixel coordinates for the edges of
3760@var{window}. If @var{window} is omitted or @code{nil}, it defaults 3824@var{window}. Calling @code{(window-pixel-edges window)} is equivalent
3761to the selected window. 3825to calling @code{(window-edges window nil nil t)}, see above.
3826@end defun
3762 3827
3763The return value has the form @code{(@var{left} @var{top} @var{right} 3828@comment The following two functions are confusing and hardly used.
3764@var{bottom})}. The list elements are, respectively, the X pixel 3829@ignore
3765coordinate of the left window edge, the Y pixel coordinate of the top 3830@defun window-pixel-left &optional window
3766edge, one more than the X pixel coordinate of the right edge, and one 3831This function returns the left pixel edge of window @var{window}. This
3767more than the Y pixel coordinate of the bottom edge. 3832value equals the @var{left} entry in the list returned by
3833@code{(window-pixel-edges window)} minus the number of pixels occupied
3834by the internal border of @var{window}'s frame. @var{window} must be a
3835valid window and defaults to the selected one.
3768@end defun 3836@end defun
3769 3837
3770@defun window-inside-pixel-edges &optional window 3838@defun window-pixel-top &optional window
3771This function is like @code{window-pixel-edges}, except that it 3839This function returns the top pixel edge of window @var{window}. This
3772returns the pixel coordinates for the edges of the window's text area, 3840value is equal to the @var{top} entry in the list returned by
3773rather than the pixel coordinates for the edges of the window itself. 3841@code{(window-pixel-edges window)} minus the number of pixels occupied
3774@var{window} must specify a live window. 3842by the internal border of @var{window}'s frame. @var{window} must be a
3843valid window and defaults to the selected one.
3844@end defun
3845@end ignore
3846
3847@defun window-body-pixel-edges &optional window
3848This function returns the pixel edges of @var{window}'s body. Calling
3849@code{(window-body-pixel-edges window)} is equivalent to calling
3850@code{(window-edges window t nil t)}, see above.
3775@end defun 3851@end defun
3776 3852
3777 The following functions return window positions in pixels, relative 3853 The following functions return window positions in pixels, relative to
3778to the display screen rather than the frame: 3854the origin of the display screen rather than that of the frame:
3779 3855
3780@defun window-absolute-pixel-edges &optional window 3856@defun window-absolute-pixel-edges &optional window
3781This function is like @code{window-pixel-edges}, except that it 3857This function returns the pixel coordinates of @var{WINDOW} relative to
3782returns the edge pixel coordinates relative to the top left corner of 3858an origin at (0, 0) of the display of @var{window}'s frame. Calling
3783the display screen. 3859@code{(window-absolute-pixel-edges)} is equivalent to calling
3860@code{(window-edges window nil t t)}, see above.
3784@end defun 3861@end defun
3785 3862
3786@defun window-inside-absolute-pixel-edges &optional window 3863@defun window-absolute-body-pixel-edges &optional window
3787This function is like @code{window-inside-pixel-edges}, except that it 3864This function returns the pixel coordinates of @var{WINDOW}'s body
3788returns the edge pixel coordinates relative to the top left corner of 3865relative to an origin at (0, 0) of the display of @var{window}'s frame.
3789the display screen. @var{window} must specify a live window. 3866Calling @code{(window-absolute-body-pixel-edges window)} is equivalent
3790@end defun 3867to calling @code{(window-edges window t t t)}, see above.
3791 3868
3792@defun window-pixel-left &optional window 3869Combined with @code{x-set-mouse-absolute-pixel-position}, this function
3793This function returns the left pixel edge of window @var{window}. 3870can be used to move the mouse pointer to an arbitrary buffer position
3794@var{window} must be a valid window and defaults to the selected one. 3871visible in some window:
3872
3873@example
3874@group
3875(let ((edges (window-absolute-body-pixel-edges))
3876 (position (pos-visible-in-window-p nil nil t)))
3877 (x-set-mouse-absolute-pixel-position
3878 (+ (nth 0 edges) (nth 0 position))
3879 (+ (nth 1 edges) (nth 1 position))))
3880@end group
3881@end example
3882
3883On a graphical terminal this form ``warps'' the mouse cursor to the
3884upper left corner of the glyph at the selected window's point. A
3885position calculated this way can be also used to show a tooltip window
3886there.
3795@end defun 3887@end defun
3796 3888
3797@defun window-pixel-top &optional window 3889The following function returns the screen coordinates of a buffer
3798This function returns the top pixel edge of window @var{window}. 3890position visible in a window:
3799@var{window} must be a valid window and defaults to the selected one. 3891
3892@defun window-absolute-pixel-position &optional position window
3893If the buffer position @var{position} is visible in window @var{window},
3894this function returns the display coordinates of the upper/left corner
3895of the glyph at @var{position}. The return value is a cons of the X-
3896and Y-coordinates of that corner, relative to an origin at (0, 0) of
3897@var{window}'s display. It returns @code{nil} if @var{position} is not
3898visible in @var{window}.
3899
3900@var{window} must be a live window and defaults to the selected
3901window. @var{position} defaults to the value of @code{window-point}
3902of @var{window}.
3903
3904This means that in order to move the mouse pointer to the position of
3905point in the selected window, it's sufficient to write:
3906
3907@example
3908@group
3909(let ((position (window-absolute-pixel-position)))
3910 (x-set-mouse-absolute-pixel-position
3911 (car position) (cdr position)))
3912@end group
3913@end example
3800@end defun 3914@end defun
3801 3915
3802 3916