aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref/frames.texi
diff options
context:
space:
mode:
authorMartin Rudalics2015-08-20 18:09:24 +0200
committerMartin Rudalics2015-08-20 18:09:24 +0200
commite68d43eb8734b4ec466c489b43b26fe732e02dfd (patch)
tree2be30940d343202c871f6a97b4858676a00ae5d4 /doc/lispref/frames.texi
parentd13dc271e52c7d977aee6f32c3d40b8b15b04c6c (diff)
downloademacs-e68d43eb8734b4ec466c489b43b26fe732e02dfd.tar.gz
emacs-e68d43eb8734b4ec466c489b43b26fe732e02dfd.zip
Describe frame geometry and related functions in Elisp manual
* doc/lispref/display.texi (Size of Displayed Text, Line Height) (Showing Images): Update references. * doc/lispref/elisp.texi (Top): Update node listing. * doc/lispref/frames.texi (Frame Geometry): New node. Move `Size and Position' section here. (Size Parameters): Update references. (Mouse Position): Update references and nomenclature. Describe new functions `x-mouse-absolute-pixel-position' and `x-set-mouse-absolute-pixel-position'. * doc/lispref/windows.texi (Window Sizes): Update references. (Resizing Windows): Update references. Move description of `fit-frame-to-buffer' here. (Coordinates and Windows): Update nomenclature and references. Describe new arguments of `window-edges'. Comment out descriptions of `window-left-column', `window-top-line', `window-pixel-left' and `window-pixel-top'. Describe `window-absolute-pixel-position'.
Diffstat (limited to 'doc/lispref/frames.texi')
-rw-r--r--doc/lispref/frames.texi889
1 files changed, 575 insertions, 314 deletions
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}.