(completion-ignored-extensions): Add .p64fsl, .d64fsl, and .dx64fsl.
[bpt/emacs.git] / lisp / frame.el
index 95cddb5..d68f80f 100644 (file)
@@ -1,17 +1,17 @@
 ;;; frame.el --- multi-frame management independent of window systems
 
 ;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -292,8 +290,9 @@ there (in decreasing order of priority)."
   ;; the buffer of the selected window, which fails when the selected
   ;; window is the minibuffer.
   (let ((old-buffer (current-buffer))
-       (window-system-frame-alist (cdr (assq initial-window-system
-                                             window-system-default-frame-alist))))
+       (window-system-frame-alist
+         (cdr (assq initial-window-system
+                    window-system-default-frame-alist))))
 
     (when (and frame-notice-user-settings
               (null frame-initial-frame))
@@ -416,6 +415,9 @@ there (in decreasing order of priority)."
             ;; Get rid of `name' unless it was specified explicitly before.
            (or (assq 'name frame-initial-frame-alist)
                (setq parms (delq (assq 'name parms) parms)))
+           ;; An explicit parent-id is a request to XEmbed the frame.
+           (or (assq 'parent-id frame-initial-frame-alist)
+                (setq parms (delq (assq 'parent-id parms) parms)))
 
            (setq parms (append initial-frame-alist
                                window-system-frame-alist
@@ -599,6 +601,8 @@ is not considered (see `next-frame')."
                                  0))
   (select-frame-set-input-focus (selected-frame)))
 
+(declare-function x-initialize-window-system "term/x-win" ())
+
 (defun make-frame-on-display (display &optional parameters)
   "Make a frame on X display DISPLAY.
 The optional second argument PARAMETERS specifies additional frame parameters."
@@ -714,7 +718,8 @@ setup is for focus to follow the pointer."
              (let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
                (cond
                 ((eq type t) nil)
-                ((eq type nil) (error "Terminal %s does not exist" (cdr (assq 'terminal 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)))
@@ -725,7 +730,10 @@ setup is for focus to follow the pointer."
     (unless frame-creation-function
       (error "Don't know how to create a frame on window system %s" w))
     (run-hooks 'before-make-frame-hook)
-    (setq frame (funcall frame-creation-function (append parameters (cdr (assq w window-system-default-frame-alist)))))
+    (setq frame
+          (funcall frame-creation-function
+                   (append parameters
+                           (cdr (assq w window-system-default-frame-alist)))))
     (normal-erase-is-backspace-setup-frame frame)
     ;; Inherit the original frame's parameters.
     (dolist (param frame-inherited-parameters)
@@ -821,9 +829,9 @@ the user during startup."
     (raise-frame frame)
     ;; Ensure, if possible, that frame gets input focus.
     (when (memq (window-system frame) '(x mac w32))
-          (x-focus-frame frame))
-    (cond (focus-follows-mouse
-          (set-mouse-position (selected-frame) (1- (frame-width)) 0))))
+      (x-focus-frame frame))
+    (when focus-follows-mouse
+      (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
 
 (defun other-frame (arg)
   "Select the ARGth different visible frame on current display, and raise it.
@@ -950,8 +958,15 @@ is given and non-nil, the unwanted frames are iconified instead."
                ;; Since we can't set a frame's minibuffer status,
                ;; we might as well omit the parameter altogether.
                (let* ((parms (nth 1 parameters))
-                      (mini (assq 'minibuffer parms)))
-                 (if mini (setq parms (delq mini parms)))
+                     (mini (assq 'minibuffer parms))
+                     (name (assq 'name parms))
+                     (explicit-name (cdr (assq 'explicit-name parms))))
+                (when mini (setq parms (delq mini parms)))
+                ;; Leave name in iff it was set explicitly.
+                ;; This should fix the behavior reported in
+                ;; http://lists.gnu.org/archive/html/emacs-devel/2007-08/msg01632.html
+                (when (and name (not explicit-name))
+                  (setq parms (delq name parms)))
                  parms))
               (set-window-configuration (nth 2 parameters)))
           (setq frames-to-delete (cons frame frames-to-delete)))))
@@ -1119,6 +1134,8 @@ bars (top, bottom, or nil)."
   "Return the terminal that is now selected."
   (frame-terminal (selected-frame)))
 
+(declare-function msdos-mouse-p "dosfns.c")
+
 (defun display-mouse-p (&optional display)
   "Return non-nil if DISPLAY has a mouse available.
 DISPLAY can be a display name, a frame, or nil (meaning the selected
@@ -1238,7 +1255,7 @@ displays not explicitely specified."
 
 (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'.
+System values can be overridden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
   (and (memq (framep-on-display display) '(x w32 mac))
        (or (cddr (assoc (or display (frame-parameter nil 'display))
@@ -1248,7 +1265,7 @@ If the information is unavailable, value is nil."
 
 (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'.
+System values can be overridden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
   (and (memq (framep-on-display display) '(x w32 mac))
        (or (cadr (assoc (or display (frame-parameter nil 'display))
@@ -1313,9 +1330,71 @@ The value is one of the symbols `static-gray', `gray-scale',
       'static-gray))))
 
 \f
+;;;; Frame geometry values
+
+(defun frame-geom-value-cons (type value &optional frame)
+  "Return equivalent geometry value for FRAME as a cons with car `+'.
+A geometry value equivalent to VALUE for FRAME is returned,
+where the value is a cons with car `+', not numeric.
+TYPE is the car of the original geometry spec (TYPE . VALUE).
+   It is `top' or `left', depending on which edge VALUE is related to.
+VALUE is the cdr of a frame geometry spec: (left/top . VALUE).
+If VALUE is a number, then it is converted to a cons value, perhaps
+   relative to the opposite frame edge from that in the original spec.
+FRAME defaults to the selected frame.
+
+Examples (measures in pixels) -
+ Assuming display height/width=1024, frame height/width=600:
+ 300 inside display edge:                   300  => (+  300)
+                                        (+  300) => (+  300)
+ 300 inside opposite display edge:      (-  300) => (+  124)
+                                           -300  => (+  124)
+ 300 beyond display edge
+  (= 724 inside opposite display edge): (+ -300) => (+ -300)
+ 300 beyond display edge
+  (= 724 inside opposite display edge): (- -300) => (+  724)
+
+In the 3rd, 4th, and 6th examples, the returned value is relative to
+the opposite frame edge from the edge indicated in the input spec."
+  (cond ((and (consp value) (eq '+ (car value))) ; e.g. (+ 300), (+ -300)
+         value)
+        ((natnump value) (list '+ value)) ; e.g. 300 => (+ 300)
+        (t                              ; e.g. -300, (- 300), (- -300)
+         (list '+ (- (if (eq 'left type) ; => (+ 124), (+ 124), (+ 724)
+                         (x-display-pixel-width)
+                       (x-display-pixel-height))
+                     (if (integerp value) (- value) (cadr value))
+                     (if (eq 'left type)
+                         (frame-pixel-width frame)
+                       (frame-pixel-height frame)))))))
+
+(defun frame-geom-spec-cons (spec &optional frame)
+  "Return equivalent geometry spec for FRAME as a cons with car `+'.
+A geometry specification equivalent to SPEC for FRAME is returned,
+where the value is a cons with car `+', not numeric.
+SPEC is a frame geometry spec: (left . VALUE) or (top . VALUE).
+If VALUE is a number, then it is converted to a cons value, perhaps
+   relative to the opposite frame edge from that in the original spec.
+FRAME defaults to the selected frame.
+
+Examples (measures in pixels) -
+ Assuming display height=1024, frame height=600:
+ top 300 below display top:               (top .  300) => (top +  300)
+                                          (top +  300) => (top +  300)
+ bottom 300 above display bottom:         (top -  300) => (top +  124)
+                                          (top . -300) => (top +  124)
+ top 300 above display top
+  (= bottom 724 above display bottom):    (top + -300) => (top + -300)
+ bottom 300 below display bottom
+  (= top 724 below display top):          (top - -300) => (top +  724)
+
+In the 3rd, 4th, and 6th examples, the returned value is relative to
+the opposite frame edge from the edge indicated in the input spec."
+  (cons (car spec) (frame-geom-value-cons (car spec) (cdr spec))))
+\f
 ;;;; Aliases for backward compatibility with Emacs 18.
-(define-obsolete-function-alias 'screen-height 'frame-height) ;before 19.15
-(define-obsolete-function-alias 'screen-width 'frame-width) ;before 19.15
+(define-obsolete-function-alias 'screen-height 'frame-height "19.7")
+(define-obsolete-function-alias 'screen-width 'frame-width "19.7")
 
 (defun set-screen-width (cols &optional pretend)
   "Change the size of the screen to COLS columns.
@@ -1351,8 +1430,8 @@ left untouched.  FRAME nil or omitted means use the selected frame."
       (when (eq (frame-parameter frame 'minibuffer) 'only)
        (delete-frame frame)))))
 
-(make-obsolete 'set-screen-width 'set-frame-width) ;before 19.15
-(make-obsolete 'set-screen-height 'set-frame-height) ;before 19.15
+(make-obsolete 'set-screen-width 'set-frame-width "19.7")
+(make-obsolete 'set-screen-height 'set-frame-height "19.7")
 
 ;; miscellaneous obsolescence declarations
 (define-obsolete-variable-alias 'delete-frame-hook