Subject: bug#34516: closed (Re: bug#34516: Multi-monitor frame sets)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 25 Feb 2019 21:14:02 +0000

Your bug report

#34516: Multi-monitor frame sets

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
34516: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=34516
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#34516: Multi-monitor frame sets
From: Juri Linkov <[email-masked]>
To: Andy Moreton <[email-masked]>
Cc: [email-masked]
Date: Mon, 25 Feb 2019 23:11:47 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

>>>> 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.

Subject: Multi-monitor frame sets
From: Juri Linkov <[email-masked]>
To: [email-masked]
Date: Sun, 17 Feb 2019 21:34:19 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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)