1
1
;;; frame.el --- multi-frame management independent of window systems
3
3
;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2003,
4
;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
7
7
;; Keywords: internal
39
39
(defvar window-system-default-frame-alist nil
40
40
"Alist of window-system dependent default frame parameters.
41
You can set this in your `.emacs' file; for example,
43
;; Disable menubar and toolbar on the console, but enable them under X.
44
(setq window-system-default-frame-alist
45
'((x (menu-bar-lines . 1) (tool-bar-lines . 1))
46
(nil (menu-bar-lines . 0) (tool-bar-lines . 0))))
48
Parameters specified here supersede the values given in `default-frame-alist'.")
41
You can set this in your init file; for example,
43
;; Disable menubar and toolbar on the console, but enable them under X.
44
(setq window-system-default-frame-alist
45
'((x (menu-bar-lines . 1) (tool-bar-lines . 1))
46
(nil (menu-bar-lines . 0) (tool-bar-lines . 0))))
48
Parameters specified here supersede the values given in
49
`default-frame-alist'.")
50
51
;; The initial value given here used to ask for a minibuffer.
51
52
;; But that's not necessary, because the default is to have one.
52
53
;; By not specifying it here, we let an X resource specify it.
53
54
(defcustom initial-frame-alist nil
54
"*Alist of frame parameters for creating the initial X window frame.
55
You can set this in your `.emacs' file; for example,
56
(setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
57
Parameters specified here supersede the values given in `default-frame-alist'.
59
If the value calls for a frame without a minibuffer, and you have not created
60
a minibuffer frame on your own, one is created according to
61
`minibuffer-frame-alist'.
63
You can specify geometry-related options for just the initial frame
64
by setting this variable in your `.emacs' file; however, they won't
65
take effect until Emacs reads `.emacs', which happens after first creating
66
the frame. If you want the frame to have the proper geometry as soon
67
as it appears, you need to use this three-step process:
55
"Alist of parameters for the initial X window frame.
56
You can set this in your init file; for example,
58
(setq initial-frame-alist
59
'((top . 1) (left . 1) (width . 80) (height . 55)))
61
Parameters specified here supersede the values given in
62
`default-frame-alist'.
64
If the value calls for a frame without a minibuffer, and you have
65
not created a minibuffer frame on your own, a minibuffer frame is
66
created according to `minibuffer-frame-alist'.
68
You can specify geometry-related options for just the initial
69
frame by setting this variable in your init file; however, they
70
won't take effect until Emacs reads your init file, which happens
71
after creating the initial frame. If you want the initial frame
72
to have the proper geometry as soon as it appears, you need to
73
use this three-step process:
68
74
* Specify X resources to give the geometry you want.
69
75
* Set `default-frame-alist' to override these options so that they
70
76
don't affect subsequent frames.
78
84
(defcustom minibuffer-frame-alist '((width . 80) (height . 2))
79
"*Alist of frame parameters for initially creating a minibuffer frame.
80
You can set this in your `.emacs' file; for example,
85
"Alist of parameters for initial minibuffer frame.
86
You can set this in your init file; for example,
81
88
(setq minibuffer-frame-alist
82
'((top . 1) (left . 1) (width . 80) (height . 2)))
89
'((top . 1) (left . 1) (width . 80) (height . 2)))
83
91
Parameters specified here supersede the values given in
84
92
`default-frame-alist', for a minibuffer frame."
85
93
:type '(repeat (cons :format "%v"
90
98
(defcustom pop-up-frame-alist nil
91
"*Alist of frame parameters used when creating pop-up frames.
92
Pop-up frames are used for completions, help, and the like.
93
This variable can be set in your init file, like this:
99
"Alist of parameters for automatically generated new frames.
100
You can set this in your init file; for example,
94
102
(setq pop-up-frame-alist '((width . 80) (height . 20)))
95
These supersede the values given in `default-frame-alist',
104
If non-nil, the value you specify here is used by the default
105
`pop-up-frame-function' for the creation of new frames.
107
Since `pop-up-frame-function' is used by `display-buffer' for
108
making new frames, any value specified here by default affects
109
the automatic generation of new frames via `display-buffer' and
110
all functions based on it. The behavior of `make-frame' is not
111
affected by this variable."
97
112
:type '(repeat (cons :format "%v"
98
113
(symbol :tag "Parameter")
99
114
(sexp :tag "Value")))
102
117
(defcustom pop-up-frame-function
103
118
(lambda () (make-frame pop-up-frame-alist))
104
"Function to call to handle automatic new frame creation.
105
It is called with no arguments and should return a newly created frame."
119
"Function used by `display-buffer' for creating a new frame.
120
This function is called with no arguments and should return a new
121
frame. The default value calls `make-frame' with the argument
122
`pop-up-frame-alist'."
106
123
:type '(choice (const nil) (function :tag "function"))
109
126
(defcustom special-display-frame-alist
110
127
'((height . 14) (width . 80) (unsplittable . t))
111
"*Alist of frame parameters used when creating special frames.
112
Special frames are used for buffers whose names are in
128
"Alist of parameters for special frames.
129
Special frames are used for buffers whose names are listed in
113
130
`special-display-buffer-names' and for buffers whose names match
114
131
one of the regular expressions in `special-display-regexps'.
115
133
This variable can be set in your init file, like this:
116
135
(setq special-display-frame-alist '((width . 80) (height . 20)))
117
137
These supersede the values given in `default-frame-alist'."
118
138
:type '(repeat (cons :format "%v"
119
139
(symbol :tag "Parameter")
123
143
(defun special-display-popup-frame (buffer &optional args)
124
"Display BUFFER in its own frame, reusing an existing window if any.
125
Return the window chosen.
126
Currently we do not insist on selecting the window within its frame.
127
If ARGS is an alist, use it as a list of frame parameter specs.
128
If ARGS is a list whose car is a symbol,
129
use (car ARGS) as a function to do the work.
130
Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
144
"Display BUFFER and return the window chosen.
145
If BUFFER is already displayed in a visible or iconified frame,
146
raise that frame. Otherwise, display BUFFER in a new frame.
148
Optional argument ARGS is a list specifying additional
151
If ARGS is an alist, use it as a list of frame parameters. If
152
these parameters contain \(same-window . t), display BUFFER in
153
the selected window. If they contain \(same-frame . t), display
154
BUFFER in a window of the selected frame.
156
If ARGS is a list whose car is a symbol, use (car ARGS) as a
157
function to do the work. Pass it BUFFER as first argument,
158
and (cdr ARGS) as second."
131
159
(if (and args (symbolp (car args)))
132
160
(apply (car args) buffer (cdr args))
133
161
(let ((window (get-buffer-window buffer 0)))
146
174
;; Stay on the same frame if requested.
147
175
(when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args)))
148
(let* ((pop-up-frames nil) (pop-up-windows t)
149
special-display-regexps special-display-buffer-names
150
(window (display-buffer buffer)))
151
;; Only do it if this is a new window:
152
;; (set-window-dedicated-p window t)
176
(let* ((pop-up-windows t)
178
special-display-buffer-names special-display-regexps)
179
(display-buffer buffer)))
154
180
;; If no window yet, make one in a new frame.
156
182
(with-current-buffer buffer
607
633
(defvar x-display-name) ; term/x-win
609
635
(defun make-frame-on-display (display &optional parameters)
610
"Make a frame on X display DISPLAY.
611
The optional second argument PARAMETERS specifies additional frame parameters."
636
"Make a frame on display DISPLAY.
637
The optional argument PARAMETERS specifies additional frame parameters."
612
638
(interactive "sMake frame on display: ")
615
(when (and (boundp 'ns-initialized) (not ns-initialized))
616
(setq x-display-name display)
617
(ns-initialize-window-system))
618
(make-frame `((window-system . ns) (display . ,display) . ,parameters)))
620
(unless (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
621
(error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
622
(when (and (boundp 'x-initialized) (not x-initialized))
623
(setq x-display-name display)
624
(x-initialize-window-system))
625
(make-frame `((window-system . x) (display . ,display) . ,parameters)))))
627
(defun make-frame-on-tty (tty type &optional parameters)
628
"Make a frame on terminal device TTY.
629
TTY should be the file name of the tty device to use. TYPE
630
should be the terminal type string of TTY, for example \"xterm\"
631
or \"vt100\". The optional third argument PARAMETERS specifies
632
additional frame parameters."
633
;; Use "F" rather than "f", in case the device does not exist, as
634
;; far as the filesystem is concerned.
635
(interactive "FOpen frame on tty device: \nsTerminal type of %s: ")
637
(error "Invalid terminal device"))
639
(error "Invalid terminal type"))
640
(if (eq window-system 'pc)
641
(make-frame `((window-system . pc) (tty . ,tty) (tty-type . ,type) . ,parameters))
642
(make-frame `((window-system . nil) (tty . ,tty) (tty-type . ,type) . ,parameters))))
639
(cond ((featurep 'ns)
640
(when (and (boundp 'ns-initialized) (not ns-initialized))
641
(setq x-display-name display)
642
(ns-initialize-window-system))
643
(make-frame `((window-system . ns)
644
(display . ,display) . ,parameters)))
645
((eq system-type 'windows-nt)
646
;; On Windows, ignore DISPLAY.
647
(make-frame parameters))
649
(unless (string-match-p "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
650
(error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
651
(when (and (boundp 'x-initialized) (not x-initialized))
652
(setq x-display-name display)
653
(x-initialize-window-system))
654
(make-frame `((window-system . x)
655
(display . ,display) . ,parameters)))))
644
657
(declare-function x-close-connection "xfns.c" (terminal))
674
687
(x-close-connection display))))
676
689
(defun make-frame-command ()
677
"Make a new frame, and select it if the terminal displays only one frame."
690
"Make a new frame, on the same terminal as the selected frame.
691
If the terminal is a text-only terminal, this also selects the
679
(if (and window-system (not (eq window-system 'pc)))
694
(if (display-graphic-p)
681
696
(select-frame (make-frame))))
1106
1121
(defun auto-raise-mode (arg)
1107
1122
"Toggle whether or not the selected frame should auto-raise.
1108
With arg, turn auto-raise mode on if and only if arg is positive.
1123
With ARG, turn auto-raise mode on if and only if ARG is positive.
1109
1124
Note that this controls Emacs's own auto-raise feature.
1110
1125
Some window managers allow you to enable auto-raise for certain windows.
1111
1126
You can use that for Emacs windows if you wish, but if you do,
1123
1138
(defun auto-lower-mode (arg)
1124
1139
"Toggle whether or not the selected frame should auto-lower.
1125
With arg, turn auto-lower mode on if and only if arg is positive.
1140
With ARG, turn auto-lower mode on if and only if ARG is positive.
1126
1141
Note that this controls Emacs's own auto-lower feature.
1127
1142
Some window managers allow you to enable auto-lower for certain windows.
1128
1143
You can use that for Emacs windows if you wish, but if you do,
1362
1377
(declare-function x-display-visual-class "xfns.c" (&optional terminal))
1364
1379
(defun display-visual-class (&optional display)
1365
"Returns the visual class of DISPLAY.
1380
"Return the visual class of DISPLAY.
1366
1381
The value is one of the symbols `static-gray', `gray-scale',
1367
1382
`static-color', `pseudo-color', `true-color', or `direct-color'."
1368
1383
(let ((frame-type (framep-on-display display)))
1600
1615
;; Hourglass pointer
1602
1617
(defcustom display-hourglass t
1603
"*Non-nil means show an hourglass pointer, when Emacs is busy.
1618
"Non-nil means show an hourglass pointer, when Emacs is busy.
1604
1619
This feature only works when on a window system that can change
1605
1620
cursor shapes."
1607
1622
:group 'cursor)
1609
1624
(defcustom hourglass-delay 1
1610
"*Seconds to wait before displaying an hourglass pointer when Emacs is busy."
1625
"Seconds to wait before displaying an hourglass pointer when Emacs is busy."
1612
1627
:group 'cursor)
1615
1630
(defcustom cursor-in-non-selected-windows t
1616
"*Non-nil means show a hollow box cursor in non-selected windows.
1631
"Non-nil means show a hollow box cursor in non-selected windows.
1617
1632
If nil, don't show a cursor except in the selected window.
1618
1633
If t, display a cursor related to the usual cursor type
1619
1634
\(a solid box becomes hollow, a bar becomes a narrower bar).