;;; frame.el --- multi-frame management independent of window systems
;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2003,
-;; 2004, 2005 Free Software Foundation, Inc.
+;; 2004, 2005, 2006 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
(defvar window-system-default-frame-alist nil
"Alist of window-system dependent default frame parameters.
-These may be set in your init file, like this:
+You can set this in your `.emacs' file; for example,
;; Disable menubar and toolbar on the console, but enable them under X.
(setq window-system-default-frame-alist
'((x (menu-bar-lines . 1) (tool-bar-lines . 1))
(nil (menu-bar-lines . 0) (tool-bar-lines . 0))))
-Also see `default-frame-alist'.")
+Parameters specified here supersede the values given in `default-frame-alist'.")
;; The initial value given here used to ask for a minibuffer.
;; But that's not necessary, because the default is to have one.
;; because that would override explicit user resizing.
(setq initial-frame-alist
(frame-remove-geometry-params initial-frame-alist))))
+ ;; Copy the environment of the Emacs process into the new frame.
+ (set-frame-parameter frame-initial-frame 'environment
+ (frame-parameter terminal-frame 'environment))
;; At this point, we know that we have a frame open, so we
;; can delete the terminal frame.
(delete-frame terminal-frame)
;; parameter in default-frame-alist in a dumped Emacs, which is not
;; what we want.
(when (and (boundp 'tool-bar-mode)
- (not noninteractive))
+ (not noninteractive))
(let ((default (assq 'tool-bar-lines default-frame-alist)))
(if default
- (setq tool-bar-mode (not (eq (cdr default) 0)))
- (setq default-frame-alist
- (cons (cons 'tool-bar-lines (if tool-bar-mode 1 0))
- default-frame-alist)))))
+ (setq tool-bar-mode (not (eq (cdr default) 0)))
+ ;; If Emacs was started on a tty, changing default-frame-alist
+ ;; would disable the toolbar on X frames created later. We
+ ;; want to keep the default of showing a toolbar under X even
+ ;; in this case.
+ ;;
+ ;; If the user explicitly called `tool-bar-mode' in .emacs,
+ ;; then default-frame-alist is already changed anyway.
+ (when initial-window-system
+ (setq default-frame-alist
+ (cons (cons 'tool-bar-lines (if tool-bar-mode 1 0))
+ default-frame-alist))))))
;; Creating and deleting frames may shift the selected frame around,
;; and thus the current buffer. Protect against that. We don't
(defun modify-all-frames-parameters (alist)
"Modify all current and future frames' parameters according to ALIST.
This changes `default-frame-alist' and possibly `initial-frame-alist'.
+Furthermore, this function removes all parameters in ALIST from
+`window-system-default-frame-alist'.
See help of `modify-frame-parameters' for more information."
- (let (element) ;; temp
- (dolist (frame (frame-list))
- (modify-frame-parameters frame alist))
-
- (dolist (pair alist) ;; conses to add/replace
- ;; initial-frame-alist needs setting only when
- ;; frame-notice-user-settings is true
- (and frame-notice-user-settings
- (setq element (assoc (car pair) initial-frame-alist))
- (setq initial-frame-alist (delq element initial-frame-alist)))
- (and (setq element (assoc (car pair) default-frame-alist))
- (setq default-frame-alist (delq element default-frame-alist)))))
+ (dolist (frame (frame-list))
+ (modify-frame-parameters frame alist))
+
+ (dolist (pair alist) ;; conses to add/replace
+ ;; initial-frame-alist needs setting only when
+ ;; frame-notice-user-settings is true.
+ (and frame-notice-user-settings
+ (setq initial-frame-alist
+ (assq-delete-all (car pair) initial-frame-alist)))
+ (setq default-frame-alist
+ (assq-delete-all (car pair) default-frame-alist))
+ ;; Remove any similar settings from the window-system specific
+ ;; parameters---they would override default-frame-alist.
+ (dolist (w window-system-default-frame-alist)
+ (setcdr w (assq-delete-all (car pair) (cdr w)))))
+
(and frame-notice-user-settings
(setq initial-frame-alist (append initial-frame-alist alist)))
(setq default-frame-alist (append default-frame-alist alist)))
(window-system . nil) The frame should be displayed on a terminal device.
(window-system . x) The frame should be displayed in an X window.
- (device . ID) The frame should use the display device identified by ID.
+ (terminal . ID) The frame should use the terminal identified by ID.
Before the frame is created (via `frame-creation-function-alist'), functions on the
hook `before-make-frame-hook' are run. After the frame is created, functions
setup is for focus to follow the pointer."
(interactive)
(let* ((w (cond
- ((assq 'device parameters)
- (let ((type (display-live-p (cdr (assq 'device parameters)))))
+ ((assq 'terminal parameters)
+ (let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
(cond
((eq type t) nil)
- ((eq type nil) (error "Display %s does not exist" (cdr (assq 'device parameters))))
+ ((eq type nil) (error "Terminal %s does not exist" (cdr (assq 'terminal parameters))))
(t type))))
((assq 'window-system parameters)
(cdr (assq 'window-system parameters)))
(run-hooks 'before-make-frame-hook)
(setq frame (funcall frame-creation-function (append parameters (cdr (assq w window-system-default-frame-alist)))))
(normal-erase-is-backspace-setup-frame frame)
- ;; Set up the frame-local environment, if needed.
- (when (eq (frame-display frame) (frame-display oldframe))
- (let ((env (frame-parameter oldframe 'environment)))
+ ;; Inherit the 'environment and 'client parameters, if needed.
+ (when (eq (frame-terminal frame) (frame-terminal oldframe))
+ (let ((env (frame-parameter oldframe 'environment))
+ (client (frame-parameter oldframe 'client)))
(if (not (framep env))
(setq env oldframe))
- (if env
- (set-frame-parameter frame 'environment env))))
+ (if (and env (not (assq 'environment parameters)))
+ (set-frame-parameter frame 'environment env))
+ (if (and client (not (assq 'client parameters)))
+ (set-frame-parameter frame 'client client))))
(run-hook-with-args 'after-make-frame-functions frame)
frame))
frame's terminal device."
(let* ((terminal (terminal-id terminal))
(func #'(lambda (frame)
- (eq (frame-display frame) terminal))))
+ (eq (frame-terminal frame) terminal))))
(filtered-frame-list func)))
(defun framep-on-display (&optional terminal)
is a frame, its type is returned. If TERMINAL is omitted or nil,
it defaults to the selected frame's terminal device. All frames
on a given display are of the same type."
- (or (display-live-p terminal)
+ (or (terminal-live-p terminal)
(framep terminal)
(framep (car (frames-on-display-list terminal)))))
(select-frame frame)
(raise-frame frame)
;; Ensure, if possible, that frame gets input focus.
- (cond ((eq (window-system frame) 'x)
+ (cond ((memq (window-system frame) '(x max))
(x-focus-frame frame))
((eq (window-system frame) 'w32)
(w32-focus-frame frame)))
(cond
((eq type 'x) (iconify-or-deiconify-frame))
((eq type t)
- (if (display-controlling-tty-p)
+ (if (controlling-tty-p)
(suspend-emacs)
(suspend-tty)))
(t (suspend-emacs)))))
(cons vert hor)))
\f
;;;; Frame/display capabilities.
-(defun selected-display ()
- "Return the display that is now selected."
- (frame-display (selected-frame)))
+(defun selected-terminal ()
+ "Return the terminal that is now selected."
+ (frame-terminal (selected-frame)))
(defun display-mouse-p (&optional display)
"Return non-nil if DISPLAY has a mouse available.