comparison lisp/frame.el @ 109058:2f0720afc474

Change default-frame-alist and menu/tool-bar-mode interaction (Bug#2249). Don't add entries for `menu-bar-lines' and `tool-bar-lines' to `default-frame-alist' and `initial-frame-alist' at startup. Instead, use X resources to update the `menu-bar-mode' and `tool-bar-mode' variables at startup, and use them as defaults during frame creation. * lisp/frame.el (frame-notice-user-settings): Don't change default-frame-alist based on menu-bar-mode and tool-bar-mode, or vice versa. * lisp/menu-bar.el (menu-bar-mode): * lisp/tool-bar.el (tool-bar-mode): Don't change default-frame-alist. Set init-value to t. * lisp/startup.el (command-line): Use X resources to set the value of menu-bar-mode and tool-bar-mode, before calling frame-initialize. * src/frame.c (Vmenu_bar_mode, Vtool_bar_mode): New vars. * src/w32fns.c (Fx_create_frame): * src/nsfns.m (Fx_create_frame): Likewise. * src/xfns.c (Fx_create_frame): Don't consult X resouces when setting menu-bar-lines and tool-bar-lines. Use menu-bar-mode and tool-bar-mode, which are now set using these X resources at startup, to determine the defaults.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 26 Jun 2010 20:30:52 -0400
parents 16aebfb142a6
children bd58a72bb9bb
comparison
equal deleted inserted replaced
109057:384a6f7da770 109058:2f0720afc474
37 function to this list, which should take an alist of parameters 37 function to this list, which should take an alist of parameters
38 as its argument.") 38 as its argument.")
39 39
40 (defvar window-system-default-frame-alist nil 40 (defvar window-system-default-frame-alist nil
41 "Alist of window-system dependent default frame parameters. 41 "Alist of window-system dependent default frame parameters.
42 You can set this in your init file; for example,
43
44 ;; Disable menubar and toolbar on the console, but enable them under X.
45 (setq window-system-default-frame-alist
46 '((x (menu-bar-lines . 1) (tool-bar-lines . 1))
47 (nil (menu-bar-lines . 0) (tool-bar-lines . 0))))
48
49 Parameters specified here supersede the values given in 42 Parameters specified here supersede the values given in
50 `default-frame-alist'.") 43 `default-frame-alist'.")
51 44
52 ;; The initial value given here used to ask for a minibuffer. 45 ;; The initial value given here used to ask for a minibuffer.
53 ;; But that's not necessary, because the default is to have one. 46 ;; But that's not necessary, because the default is to have one.
285 (defun frame-notice-user-settings () 278 (defun frame-notice-user-settings ()
286 "Act on user's init file settings of frame parameters. 279 "Act on user's init file settings of frame parameters.
287 React to settings of `initial-frame-alist', 280 React to settings of `initial-frame-alist',
288 `window-system-default-frame-alist' and `default-frame-alist' 281 `window-system-default-frame-alist' and `default-frame-alist'
289 there (in decreasing order of priority)." 282 there (in decreasing order of priority)."
290 ;; Make menu-bar-mode and default-frame-alist consistent.
291 (when (boundp 'menu-bar-mode)
292 (let ((default (assq 'menu-bar-lines default-frame-alist)))
293 (if default
294 (setq menu-bar-mode (not (eq (cdr default) 0)))
295 (setq default-frame-alist
296 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
297 default-frame-alist)))))
298
299 ;; Make tool-bar-mode and default-frame-alist consistent. Don't do
300 ;; it in batch mode since that would leave a tool-bar-lines
301 ;; parameter in default-frame-alist in a dumped Emacs, which is not
302 ;; what we want.
303 (when (and (boundp 'tool-bar-mode)
304 (not noninteractive))
305 (let ((default (assq 'tool-bar-lines default-frame-alist)))
306 (if default
307 (setq tool-bar-mode (not (eq (cdr default) 0)))
308 ;; If Emacs was started on a tty, changing default-frame-alist
309 ;; would disable the toolbar on X frames created later. We
310 ;; want to keep the default of showing a toolbar under X even
311 ;; in this case.
312 ;;
313 ;; If the user explicitly called `tool-bar-mode' in .emacs,
314 ;; then default-frame-alist is already changed anyway.
315 (when initial-window-system
316 (setq default-frame-alist
317 (cons (cons 'tool-bar-lines (if tool-bar-mode 1 0))
318 default-frame-alist))))))
319
320 ;; Creating and deleting frames may shift the selected frame around, 283 ;; Creating and deleting frames may shift the selected frame around,
321 ;; and thus the current buffer. Protect against that. We don't 284 ;; and thus the current buffer. Protect against that. We don't
322 ;; want to use save-excursion here, because that may also try to set 285 ;; want to use save-excursion here, because that may also try to set
323 ;; the buffer of the selected window, which fails when the selected 286 ;; the buffer of the selected window, which fails when the selected
324 ;; window is the minibuffer. 287 ;; window is the minibuffer.