summaryrefslogtreecommitdiff
path: root/lisp/frame.el
diff options
context:
space:
mode:
authorDaniel Colascione <dancol@dancol.org>2012-09-17 03:55:05 -0800
committerDaniel Colascione <dancol@dancol.org>2012-09-17 03:55:05 -0800
commitefc3dd3ccceae28db0a3fde54ed00478ff77c2e2 (patch)
tree19d4077c435c3fcc678c30fccbd2aa18b2f60ce1 /lisp/frame.el
parentce9f00e4e53c3a55cb78fa3dd1043d8f59ed47e3 (diff)
downloademacs-efc3dd3ccceae28db0a3fde54ed00478ff77c2e2.tar.gz
emacs-efc3dd3ccceae28db0a3fde54ed00478ff77c2e2.tar.bz2
emacs-efc3dd3ccceae28db0a3fde54ed00478ff77c2e2.zip
Detect window-system from display name
Diffstat (limited to 'lisp/frame.el')
-rw-r--r--lisp/frame.el53
1 files changed, 32 insertions, 21 deletions
diff --git a/lisp/frame.el b/lisp/frame.el
index 9be64a6b7ff..1e8883eb98e 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -25,6 +25,8 @@
;;; Commentary:
;;; Code:
+(eval-when-compile (require 'cl-lib))
+
(defvar frame-creation-function-alist
(list (cons nil
(if (fboundp 'tty-create-frame-with-faces)
@@ -45,6 +47,12 @@ Then, for frames on WINDOW-SYSTEM, any parameters specified in
ALIST supersede the corresponding parameters specified in
`default-frame-alist'.")
+(defvar display-format-alist nil
+ "Alist of patterns to decode display names.
+The car of each entry is a regular expression matching a display
+name string. The cdr is a symbol giving the window-system that
+handles the corresponding kind of display.")
+
;; The initial value given here used to ask for a minibuffer.
;; But that's not necessary, because the default is to have one.
;; By not specifying it here, we let an X resource specify it.
@@ -510,31 +518,19 @@ is not considered (see `next-frame')."
0))
(select-frame-set-input-focus (selected-frame)))
-(declare-function x-initialize-window-system "term/x-win" ())
-(declare-function ns-initialize-window-system "term/ns-win" ())
-(defvar x-display-name) ; term/x-win
+(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))
(defun make-frame-on-display (display &optional parameters)
"Make a frame on display DISPLAY.
The optional argument PARAMETERS specifies additional frame parameters."
(interactive "sMake frame on display: ")
- (cond ((featurep 'ns)
- (when (and (boundp 'ns-initialized) (not ns-initialized))
- (setq x-display-name display)
- (ns-initialize-window-system))
- (make-frame `((window-system . ns)
- (display . ,display) . ,parameters)))
- ((eq window-system 'w32)
- ;; On Windows, ignore DISPLAY.
- (make-frame parameters))
- (t
- (unless (string-match-p "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
- (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
- (when (and (boundp 'x-initialized) (not x-initialized))
- (setq x-display-name display)
- (x-initialize-window-system))
- (make-frame `((window-system . x)
- (display . ,display) . ,parameters)))))
+ (make-frame (cons (cons 'display display) parameters)))
(declare-function x-close-connection "xfns.c" (terminal))
@@ -616,6 +612,8 @@ neither or both.
(window-system . nil) The frame should be displayed on a terminal device.
(window-system . x) The frame should be displayed in an X window.
+ (display . \":0\") The frame should appear on display :0.
+
(terminal . TERMINAL) The frame should use the terminal object TERMINAL.
In addition, any parameter specified in `default-frame-alist',
@@ -626,11 +624,15 @@ this function runs the hook `before-make-frame-hook'. After
creating the frame, it runs the hook `after-make-frame-functions'
with one arg, the newly created frame.
+If a display parameter is supplied and a window-system is not,
+guess the window-system from the display.
+
On graphical displays, this function does not itself make the new
frame the selected frame. However, the window system may select
the new frame according to its own rules."
(interactive)
- (let* ((w (cond
+ (let* ((display (cdr (assq 'display parameters)))
+ (w (cond
((assq 'terminal parameters)
(let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
(cond
@@ -640,6 +642,10 @@ the new frame according to its own rules."
(t type))))
((assq 'window-system parameters)
(cdr (assq 'window-system parameters)))
+ (display
+ (or (window-system-for-display display)
+ (error "Don't know how to interpret display \"%S\""
+ display)))
(t window-system)))
(frame-creation-function (cdr (assq w frame-creation-function-alist)))
(oldframe (selected-frame))
@@ -647,6 +653,11 @@ the new frame according to its own rules."
frame)
(unless frame-creation-function
(error "Don't know how to create a frame on window system %s" w))
+
+ (unless (get w 'window-system-initialized)
+ (funcall (cdr (assq w window-system-initialization-alist)))
+ (put w 'window-system-initialized t))
+
;; Add parameters from `window-system-default-frame-alist'.
(dolist (p (cdr (assq w window-system-default-frame-alist)))
(unless (assq (car p) params)