--- Begin Message ---
Subject: |
Multi-monitor frame sets |
Date: |
Sun, 17 Feb 2019 21:34:19 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
Shouldn't frame.el provide a command like make-frame-on-display,
but to make a frame on the specified monitor instead of display?
Isn't the following patch the right way to do this?
(It also adds completion for the existing command):
diff --git a/lisp/frame.el b/lisp/frame.el
index dc81302939..38f2653905 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -644,9 +644,33 @@ window-system-for-display
(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: ")
+ (interactive (list (completing-read
+ (format "Make frame on display: ")
+ (delete-dups
+ (mapcar (lambda (frame)
+ (frame-parameter frame 'display))
+ (frame-list))))))
(make-frame (cons (cons 'display display) parameters)))
+(defun make-frame-on-monitor (monitor &optional parameters)
+ "Make a frame on monitor MONITOR.
+The optional argument PARAMETERS specifies additional frame parameters."
+ (interactive (list (completing-read
+ (format "Make frame on monitor: ")
+ (mapcar (lambda (a)
+ (cdr (assq 'name a)))
+ (display-monitor-attributes-list)))))
+ (let ((geometry (car (delq nil (mapcar (lambda (a)
+ (when (equal (cdr (assq 'name a))
monitor)
+ (cdr (assq 'geometry a))))
+ (display-monitor-attributes-list))))))
+ (make-frame (append (x-parse-geometry (format "%dx%d+%d+%d"
+ (nth 2 geometry)
+ (nth 3 geometry)
+ (nth 0 geometry)
+ (nth 1 geometry)))
+ parameters))))
+
(declare-function x-close-connection "xfns.c" (terminal))
(defun close-display-connection (display)
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#34516: Multi-monitor frame sets |
Date: |
Mon, 25 Feb 2019 23:11:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
>>>> Since on Windows 'display-monitor-attributes-list' returns such
>>>> fake monitor names:
>>>>
>>>> \\.\DISPLAY1
>>>> \\.\DISPLAY2
>>>>
>>>> on macOS it could return something like that or generate fake names
>>>> from geometry like "1920x1080+0+0", "2560x1440+1920+16".
>>>
>>> I often have two identical monitors attached, so that would be
>>> confusing :-)
>>>
>>> Something like this (assuming nobody every connects more than 9
>>> monitors to the same system).
>>
>> I hope at least the primary monitor always comes first in the list.
>
> The `display-monitor-attributes-list' docstring states:
>
> "Return a list of physical monitor attributes on DISPLAY.
> DISPLAY can be a display name, a terminal name, or a frame.
> If DISPLAY is omitted or nil, it defaults to the selected frame’s display.
> Each element of the list represents the attributes of a physical
> monitor. The first element corresponds to the primary monitor."
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Why are you still guessing, instead of reading the documentation ?
Right, the documentation should be the ultimate source of truth.
So I committed the patch to master.
--- End Message ---