(compilation-directory-properties):
[bpt/emacs.git] / lisp / frame.el
index 8e1be2b..8f7fdf1 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 Free Software Foundation, Inc.
+;;   2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -685,7 +685,9 @@ the user during startup."
   "*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)))
@@ -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)))
@@ -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,15 +1304,45 @@ 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 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))
+  (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
 
 (defcustom display-hourglass t
-  "*Non-nil to show an hourglass pointer when Emacs is busy on a window system."
+  "*Non-nil means show an hourglass pointer, when Emacs is busy.
+This feature only works when on a window system that can change
+cursor shapes."
   :type 'boolean
   :group 'cursor)