;;; frame.el --- multi-frame management independent of window systems
-;; Copyright (C) 1993-1994, 1996-1997, 2000-2013 Free Software
+;; Copyright (C) 1993-1994, 1996-1997, 2000-2014 Free Software
;; Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: internal
;; Package: emacs
(delete-frame frame t)
;; Gildea@x.org says it is ok to ask questions before terminating.
(save-buffers-kill-emacs))))
+
+(defun handle-focus-in (_event)
+ "Handle a focus-in event.
+Focus-in events are usually bound to this function.
+Focus-in events occur when a frame has focus, but a switch-frame event
+is not generated.
+This function runs the hook `focus-in-hook'."
+ (interactive "e")
+ (run-hooks 'focus-in-hook))
+
+(defun handle-focus-out (_event)
+ "Handle a focus-out event.
+Focus-out events are usually bound to this function.
+Focus-out events occur when no frame has focus.
+This function runs the hook `focus-out-hook'."
+ (interactive "e")
+ (run-hooks 'focus-out-hook))
\f
;;;; Arrangement of frames at startup
(declare-function tool-bar-mode "tool-bar" (&optional arg))
+(defalias 'tool-bar-lines-needed 'tool-bar-height)
+
;; startup.el calls this function after loading the user's init
;; file. Now default-frame-alist and initial-frame-alist contain
;; information to which we must react; do what needs to be done.
(defun window-system-for-display (display)
"Return the window system for DISPLAY.
Return nil if we don't know how to interpret DISPLAY."
- (cl-loop for descriptor in display-format-alist
- for pattern = (car descriptor)
- for system = (cdr descriptor)
- when (string-match-p pattern display) return system))
+ ;; MS-Windows doesn't know how to create a GUI frame in a -nw session.
+ (if (and (eq system-type 'windows-nt)
+ (null (window-system)))
+ nil
+ (cl-loop for descriptor in display-format-alist
+ for pattern = (car descriptor)
+ for system = (cdr descriptor)
+ when (string-match-p pattern display) return system)))
(defun make-frame-on-display (display &optional parameters)
"Make a frame on display DISPLAY.
(define-obsolete-function-alias 'new-frame 'make-frame "22.1")
(defvar frame-inherited-parameters '()
- ;; FIXME: Shouldn't we add `font' here as well?
"Parameters `make-frame' copies from the `selected-frame' to the new frame.")
(defvar x-display-name)
(cdr (assq 'window-system parameters)))
(display
(or (window-system-for-display display)
- (error "Don't know how to interpret display \"%S\""
+ (error "Don't know how to interpret display %S"
display)))
(t window-system)))
(frame-creation-function (cdr (assq w frame-creation-function-alist)))
If FRAMES is nil, apply the font to the selected frame only.
If FRAMES is non-nil, it should be a list of frames to act upon,
-or t meaning all graphical frames. Also, if FRAME is non-nil,
-alter the user's Customization settings as though the
-font-related attributes of the `default' face had been \"set in
-this session\", so that the font is applied to future frames."
+or t meaning all existing graphical frames.
+Also, if FRAMES is non-nil, alter the user's Customization settings
+as though the font-related attributes of the `default' face had been
+\"set in this session\", so that the font is applied to future frames."
(interactive
(let* ((completion-ignore-case t)
(font (completing-read "Font name: "
(with-no-warnings
(not (null dos-windows-version))))
((memq frame-type '(x w32 ns))
- t) ;; FIXME?
+ t)
(t
nil))))
(defun display-pixel-height (&optional display)
"Return the height of DISPLAY's screen in pixels.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display.
+
For character terminals, each character counts as a single pixel.
+
For graphical terminals, note that on \"multi-monitor\" setups this
refers to the pixel height for all physical monitors associated
with DISPLAY. To get information for each physical monitor, use
-`display-monitor-attributes-list'.
-If DISPLAY is omitted or nil, it defaults to the selected frame's display."
+`display-monitor-attributes-list'."
(let ((frame-type (framep-on-display display)))
(cond
((memq frame-type '(x w32 ns))
(defun display-pixel-width (&optional display)
"Return the width of DISPLAY's screen in pixels.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display.
+
For character terminals, each character counts as a single pixel.
+
For graphical terminals, note that on \"multi-monitor\" setups this
refers to the pixel width for all physical monitors associated
with DISPLAY. To get information for each physical monitor, use
-`display-monitor-attributes-list'.
-If DISPLAY is omitted or nil, it defaults to the selected frame's display."
+`display-monitor-attributes-list'."
(let ((frame-type (framep-on-display display)))
(cond
((memq frame-type '(x w32 ns))
(defcustom display-mm-dimensions-alist nil
"Alist for specifying screen dimensions in millimeters.
-The dimensions will be used for `display-mm-height' and
-`display-mm-width' if defined for the respective display.
+The functions `display-mm-height' and `display-mm-width' consult
+this list before asking the system.
-Each element of the alist has the form (display . (width . height)),
-e.g. (\":0.0\" . (287 . 215)).
+Each element has the form (DISPLAY . (WIDTH . HEIGHT)), e.g.
+\(\":0.0\" . (287 . 215)).
-If `display' equals t, it specifies dimensions for all graphical
-displays not explicitly specified."
+If `display' is t, it specifies dimensions for all graphical displays
+not explicitly specified."
:version "22.1"
:type '(alist :key-type (choice (string :tag "Display name")
(const :tag "Default" t))
(defun display-mm-height (&optional display)
"Return the height of DISPLAY's screen in millimeters.
-System values can be overridden by `display-mm-dimensions-alist'.
-If the information is unavailable, value is nil.
+If the information is unavailable, this function returns nil.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display.
+
+You can override what the system thinks the result should be by
+adding an entry to `display-mm-dimensions-alist'.
+
For graphical terminals, note that on \"multi-monitor\" setups this
refers to the height in millimeters for all physical monitors
associated with DISPLAY. To get information for each physical
-monitor, use `display-monitor-attributes-list'.
-If DISPLAY is omitted or nil, it defaults to the selected frame's display."
+monitor, use `display-monitor-attributes-list'."
(and (memq (framep-on-display display) '(x w32 ns))
(or (cddr (assoc (or display (frame-parameter nil 'display))
display-mm-dimensions-alist))
(defun display-mm-width (&optional display)
"Return the width of DISPLAY's screen in millimeters.
-System values can be overridden by `display-mm-dimensions-alist'.
-If the information is unavailable, value is nil.
+If the information is unavailable, this function returns nil.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display.
+
+You can override what the system thinks the result should be by
+adding an entry to `display-mm-dimensions-alist'.
+
For graphical terminals, note that on \"multi-monitor\" setups this
refers to the width in millimeters for all physical monitors
associated with DISPLAY. To get information for each physical
-monitor, use `display-monitor-attributes-list'.
-If DISPLAY is omitted or nil, it defaults to the selected frame's display."
+monitor, use `display-monitor-attributes-list'."
(and (memq (framep-on-display display) '(x w32 ns))
(or (cadr (assoc (or display (frame-parameter nil 'display))
display-mm-dimensions-alist))
:group 'cursor)
(defcustom blink-cursor-blinks 10
- "How many times to blink before using a solid cursor on NS and X.
+ "How many times to blink before using a solid cursor on NS, X, and MS-Windows.
Use 0 or negative value to blink forever."
:version "24.4"
:type 'integer
:group 'cursor)
(defvar blink-cursor-blinks-done 1
- "Number of blinks done since we started blinking on NS and X")
+ "Number of blinks done since we started blinking on NS, X, and MS-Windows.")
(defvar blink-cursor-idle-timer nil
"Timer started after `blink-cursor-delay' seconds of Emacs idle time.
"Timer function of timer `blink-cursor-timer'."
(internal-show-cursor nil (not (internal-show-cursor-p)))
;; Each blink is two calls to this function.
- (when (memq window-system '(x ns w32))
- (setq blink-cursor-blinks-done (1+ blink-cursor-blinks-done))
- (when (and (> blink-cursor-blinks 0)
- (<= (* 2 blink-cursor-blinks) blink-cursor-blinks-done))
- (blink-cursor-suspend)
- (add-hook 'post-command-hook 'blink-cursor-check))))
+ (setq blink-cursor-blinks-done (1+ blink-cursor-blinks-done))
+ (when (and (> blink-cursor-blinks 0)
+ (<= (* 2 blink-cursor-blinks) blink-cursor-blinks-done))
+ (blink-cursor-suspend)
+ (add-hook 'post-command-hook 'blink-cursor-check)))
(defun blink-cursor-end ()
(setq blink-cursor-timer nil)))
(defun blink-cursor-suspend ()
- "Suspend cursor blinking on NS, X and W32.
+ "Suspend cursor blinking.
This is called when no frame has focus and timers can be suspended.
Timers are restarted by `blink-cursor-check', which is called when a
frame receives focus."
- (when (memq window-system '(x ns w32))
- (blink-cursor-end)
- (when blink-cursor-idle-timer
- (cancel-timer blink-cursor-idle-timer)
- (setq blink-cursor-idle-timer nil))))
+ (blink-cursor-end)
+ (when blink-cursor-idle-timer
+ (cancel-timer blink-cursor-idle-timer)
+ (setq blink-cursor-idle-timer nil)))
(defun blink-cursor-check ()
"Check if cursor blinking shall be restarted.
positive, and disable it otherwise. If called from Lisp, enable
the mode if ARG is omitted or nil.
+If the value of `blink-cursor-blinks' is positive (10 by default),
+the cursor stops blinking after that number of blinks, if Emacs
+gets no input during that time.
+
+See also `blink-cursor-interval' and `blink-cursor-delay'.
+
This command is effective only on graphical frames. On text-only
terminals, cursor blinking is controlled by the terminal."
:init-value (not (or noninteractive
:initialize 'custom-initialize-delay
:group 'cursor
:global t
- (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer))
- (setq blink-cursor-idle-timer nil)
- (blink-cursor-end)
+ (blink-cursor-suspend)
+ (remove-hook 'focus-in-hook #'blink-cursor-check)
+ (remove-hook 'focus-out-hook #'blink-cursor-suspend)
(when blink-cursor-mode
- ;; Hide the cursor.
- ;;(internal-show-cursor nil nil)
+ (add-hook 'focus-in-hook #'blink-cursor-check)
+ (add-hook 'focus-out-hook #'blink-cursor-suspend)
(setq blink-cursor-idle-timer
(run-with-idle-timer blink-cursor-delay
blink-cursor-delay
- 'blink-cursor-start))))
+ #'blink-cursor-start))))
\f
;; Frame maximization/fullscreen