(suspend-frame): Call `iconify-or-deiconify-frame' also on w32 frames.
[bpt/emacs.git] / lisp / frame.el
index 6b8dba8..27dc4be 100644 (file)
@@ -31,9 +31,8 @@
   (list (cons nil
              (if (fboundp 'tty-create-frame-with-faces)
                  'tty-create-frame-with-faces
-               (function
-                (lambda (parameters)
-                  (error "Can't create multiple frames without a window system"))))))
+                (lambda (parameters)
+                  (error "Can't create multiple frames without a window system")))))
   "Alist of window-system dependent functions to call to create a new frame.
 The window system startup file should add its frame creation
 function to this list, which should take an alist of parameters
@@ -241,10 +240,6 @@ Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
        ;; Copy the environment of the Emacs process into the new frame.
        (set-frame-parameter frame-initial-frame 'environment
                             (frame-parameter terminal-frame 'environment))
-       (set-frame-parameter frame-initial-frame 'term-environment-variable
-                            (getenv "TERM"))
-       (set-frame-parameter frame-initial-frame 'display-environment-variable
-                            (getenv "DISPLAY"))
        ;; At this point, we know that we have a frame open, so we
        ;; can delete the terminal frame.
        (delete-frame terminal-frame)
@@ -730,17 +725,11 @@ setup is for focus to follow the pointer."
     (normal-erase-is-backspace-setup-frame frame)
     ;; Inherit the 'environment and 'client parameters.
     (let ((env (frame-parameter oldframe 'environment))
-         (client (frame-parameter oldframe 'client))
-          (termenv (frame-parameter oldframe 'term-environment-variable))
-          (displayenv (frame-parameter oldframe 'display-environment-variable)))
+         (client (frame-parameter oldframe 'client)))
       (if (not (framep env))
          (setq env oldframe))
       (if (and env (not (assq 'environment parameters)))
          (set-frame-parameter frame 'environment env))
-      (if (and termenv (not (assq 'term-environment-variable parameters)))
-         (set-frame-parameter frame 'term-environment-variable termenv))
-      (if (and displayenv (not (assq 'display-environment-variable parameters)))
-         (set-frame-parameter frame 'display-environment-variable displayenv))
       (if (and client (not (assq 'client parameters)))
          (set-frame-parameter frame 'client client)))
     (run-hook-with-args 'after-make-frame-functions frame)
@@ -762,16 +751,35 @@ setup is for focus to follow the pointer."
    (lambda (frame)
      (eq frame (window-frame (minibuffer-window frame))))))
 
-(defun frames-on-display-list (&optional terminal)
-  "Return a list of all frames on TERMINAL.
-
-TERMINAL should be a terminal identifier (an integer), a frame,
-or a name of an X display (a string of the form
+;; Used to be called `terminal-id' in termdev.el.
+(defun get-device-terminal (device)
+  "Return the terminal corresponding to DEVICE.
+DEVICE can be a terminal, a frame, nil (meaning the selected frame's terminal),
+the name of an X display device (HOST.SERVER.SCREEN) or a tty device file."
+  (cond
+   ((or (null device) (framep device))
+    (frame-terminal device))
+   ((stringp device)
+    (let ((f (car (filtered-frame-list
+                   (lambda (frame)
+                     (or (equal (frame-parameter frame 'display) device)
+                         (equal (frame-parameter frame 'tty) device)))))))
+      (or f (error "Display %s does not exist" device))
+      (frame-terminal f)))
+   ((terminal-live-p device) device)
+   (t
+    (error "Invalid argument %s in `get-device-terminal'" device))))
+
+(defun frames-on-display-list (&optional device)
+  "Return a list of all frames on DEVICE.
+
+DEVICE should be a terminal, a frame,
+or a name of an X display or tty (a string of the form
 HOST:SERVER.SCREEN).
 
-If TERMINAL is omitted or nil, it defaults to the selected
+If DEVICE is omitted or nil, it defaults to the selected
 frame's terminal device."
-  (let* ((terminal (terminal-id terminal))
+  (let* ((terminal (get-device-terminal device))
         (func #'(lambda (frame)
                   (eq (frame-terminal frame) terminal))))
     (filtered-frame-list func)))
@@ -823,10 +831,8 @@ This variable does not have any effect on MS-Windows."
     (select-frame frame)
     (raise-frame frame)
     ;; Ensure, if possible, that frame gets input focus.
-    (cond ((memq (window-system frame) '(x max))
-          (x-focus-frame frame))
-         ((eq (window-system frame) 'w32)
-          (w32-focus-frame frame)))
+    (cond ((memq (window-system frame) '(x max w32))
+          (x-focus-frame frame)))
     (cond (focus-follows-mouse
           (set-mouse-position (selected-frame) (1- (frame-width)) 0))))
 
@@ -870,7 +876,7 @@ Calls `suspend-emacs' if invoked from the controlling tty device,
   (interactive)
   (let ((type (framep (selected-frame))))
     (cond
-     ((eq type 'x) (iconify-or-deiconify-frame))
+     ((memq type '(x w32)) (iconify-or-deiconify-frame))
      ((eq type t)
       (if (controlling-tty-p)
          (suspend-emacs)
@@ -910,10 +916,8 @@ 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 frame) 'x)
-          (x-focus-frame frame))
-         ((eq (window-system frame) 'w32)
-          (w32-focus-frame frame)))
+    (cond ((memq (window-system frame) '(x w32))
+          (x-focus-frame frame)))
     (when focus-follows-mouse
       (set-mouse-position frame (1- (frame-width frame)) 0))))
 \f