]> code.delx.au - gnu-emacs/blobdiff - lisp/frame.el
(backup-buffer-copy): Fully revert change. Sigh.
[gnu-emacs] / lisp / frame.el
index 5e6451dccacf29bc6a6d270d5d287dcd934f4294..97133dee87c0f20fc3e6fbd55e0aa375f79ae7ae 100644 (file)
@@ -1,7 +1,7 @@
 ;;; frame.el --- multi-frame management independent of window systems
 
 ;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -10,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -681,11 +681,13 @@ the user during startup."
        (nreverse frame-initial-geometry-arguments))
   (cdr param-list))
 
-(defcustom focus-follows-mouse t
+(defcustom focus-follows-mouse (not (eq window-system 'mac))
   "*Non-nil if window system changes focus when you move the mouse.
 You should set this variable to tell Emacs how your window manager
 handles focus, since there is no way in general for Emacs to find out
-automatically."
+automatically.
+
+This variable does not have any effect on MS-Windows."
   :type 'boolean
   :group 'frames
   :version "20.3")
@@ -695,7 +697,7 @@ automatically."
     (select-frame frame)
     (raise-frame frame)
     ;; Ensure, if possible, that frame gets input focus.
-    (cond ((eq window-system 'x)
+    (cond ((memq window-system '(x mac))
           (x-focus-frame frame))
          ((eq window-system 'w32)
           (w32-focus-frame frame)))
@@ -703,7 +705,7 @@ automatically."
           (set-mouse-position (selected-frame) (1- (frame-width)) 0))))
 
 (defun other-frame (arg)
-  "Select the ARG'th different visible frame on current display, and raise it.
+  "Select the ARGth different visible frame on current display, and raise it.
 All frames are arranged in a cyclic order.
 This command selects the frame ARG steps away in that order.
 A negative ARG moves in the opposite order.
@@ -767,7 +769,7 @@ If there is no frame by that name, signal an error."
     (raise-frame frame)
     (select-frame frame)
     ;; Ensure, if possible, that frame gets input focus.
-    (cond ((eq window-system 'x)
+    (cond ((memq window-system '(x mac))
           (x-focus-frame frame))
          ((eq window-system 'w32)
           (w32-focus-frame frame)))
@@ -879,7 +881,7 @@ pixels) is kept by adjusting the numbers of the lines and columns."
 (defun set-frame-parameter (frame parameter value)
   "Set frame parameter PARAMETER to VALUE on FRAME.
 If FRAME is nil, it defaults to the selected frame.
-See `modify-frame-parameters.'"
+See `modify-frame-parameters'."
   (modify-frame-parameters frame (list (cons parameter value))))
 
 (defun set-background-color (color-name)
@@ -1081,17 +1083,43 @@ For character terminals, each character counts as a single pixel."
      (t
       (frame-width (if (framep display) display (selected-frame)))))))
 
+(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.
+
+Each element of the alist has the form (display . (width . height)),
+e.g. (\":0.0\" . (287 . 215)).
+
+If `display' equals t, it specifies dimensions for all graphical
+displays not explicitely specified."
+  :version "22.1"
+  :type '(alist :key-type (choice (string :tag "Display name")
+                                 (const :tag "Default" t))
+               :value-type (cons :tag "Dimensions"
+                                 (integer :tag "Width")
+                                 (integer :tag "Height")))
+  :group 'frames)
+
 (defun display-mm-height (&optional display)
   "Return the height of DISPLAY's screen in millimeters.
+System values can be overriden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
   (and (memq (framep-on-display display) '(x w32 mac))
-       (x-display-mm-height display)))
+       (or (cddr (assoc (or display (frame-parameter nil 'display))
+                       display-mm-dimensions-alist))
+          (cddr (assoc t display-mm-dimensions-alist))
+          (x-display-mm-height display))))
 
 (defun display-mm-width (&optional display)
   "Return the width of DISPLAY's screen in millimeters.
+System values can be overriden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
   (and (memq (framep-on-display display) '(x w32 mac))
-       (x-display-mm-width display)))
+       (or (cadr (assoc (or display (frame-parameter nil 'display))
+                       display-mm-dimensions-alist))
+          (cadr (assoc t display-mm-dimensions-alist))
+          (x-display-mm-width display))))
 
 (defun display-backing-store (&optional display)
   "Return the backing store capability of DISPLAY's screen.
@@ -1251,49 +1279,19 @@ The function `blink-cursor-start' is called when the timer fires.")
 This timer calls `blink-cursor-timer-function' every
 `blink-cursor-interval' seconds.")
 
-(define-minor-mode blink-cursor-mode
-  "Toggle blinking cursor mode.
-With a numeric argument, turn blinking cursor mode on iff ARG is positive.
-When blinking cursor mode is enabled, the cursor of the selected
-window blinks.
-
-Note that this command is effective only when Emacs
-displays through a window system, because then Emacs does its own
-cursor display.  On a text-only terminal, this is not implemented."
-  :init-value (not (or noninteractive
-                      no-blinking-cursor
-                      (eq system-type 'ms-dos)
-                      (not (memq window-system '(x w32 mac)))))
-  :initialize 'custom-initialize-safe-default
-  :group 'cursor
-  :global t
-  (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer))
-  (if blink-cursor-timer (cancel-timer blink-cursor-timer))
-  (setq blink-cursor-idle-timer nil
-       blink-cursor-timer nil)
-  (if blink-cursor-mode
-      (progn
-       ;; Hide the cursor.
-       ;;(internal-show-cursor nil nil)
-       (setq blink-cursor-idle-timer
-             (run-with-idle-timer blink-cursor-delay
-                                  blink-cursor-delay
-                                  'blink-cursor-start)))
-    (internal-show-cursor nil t)))
-
-(define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1")
-
 (defun blink-cursor-start ()
   "Timer function called from the timer `blink-cursor-idle-timer'.
 This starts the timer `blink-cursor-timer', which makes the cursor blink
 if appropriate.  It also arranges to cancel that timer when the next
 command starts, by installing a pre-command hook."
   (when (null blink-cursor-timer)
-    (add-hook 'pre-command-hook 'blink-cursor-end)
-    (internal-show-cursor nil nil)
+    ;; Set up the timer first, so that if this signals an error,
+    ;; blink-cursor-end is not added to pre-command-hook.
     (setq blink-cursor-timer
          (run-with-timer blink-cursor-interval blink-cursor-interval
-                         'blink-cursor-timer-function))))
+                         'blink-cursor-timer-function))
+    (add-hook 'pre-command-hook 'blink-cursor-end)
+    (internal-show-cursor nil nil)))
 
 (defun blink-cursor-timer-function ()
   "Timer function of timer `blink-cursor-timer'."
@@ -1306,10 +1304,38 @@ When run, it cancels the timer `blink-cursor-timer' and removes
 itself as a pre-command hook."
   (remove-hook 'pre-command-hook 'blink-cursor-end)
   (internal-show-cursor nil t)
-  (cancel-timer blink-cursor-timer)
-  (setq blink-cursor-timer nil))
+  (when blink-cursor-timer
+    (cancel-timer blink-cursor-timer)
+    (setq blink-cursor-timer nil)))
 
+(define-minor-mode blink-cursor-mode
+  "Toggle blinking cursor mode.
+With a numeric argument, turn blinking cursor mode on if ARG is positive,
+otherwise turn it off.  When blinking cursor mode is enabled, the
+cursor of the selected window blinks.
 
+Note that this command is effective only when Emacs
+displays through a window system, because then Emacs does its own
+cursor display.  On a text-only terminal, this is not implemented."
+  :init-value (not (or noninteractive
+                      no-blinking-cursor
+                      (eq system-type 'ms-dos)
+                      (not (memq window-system '(x w32 mac)))))
+  :initialize 'custom-initialize-safe-default
+  :group 'cursor
+  :global t
+  (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer))
+  (setq blink-cursor-idle-timer nil)
+  (blink-cursor-end)
+  (when blink-cursor-mode
+    ;; Hide the cursor.
+    ;;(internal-show-cursor nil nil)
+    (setq blink-cursor-idle-timer
+          (run-with-idle-timer blink-cursor-delay
+                               blink-cursor-delay
+                               'blink-cursor-start))))
+
+(define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1")
 \f
 ;; Hourglass pointer