GNU bug report logs - #34516
Multi-monitor frame sets

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 17 Feb 2019 21:10:02 UTC

Severity: normal

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Juri Linkov <juri <at> linkov.net>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#34516: closed (Multi-monitor frame sets)
Date: Mon, 25 Feb 2019 21:14:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 25 Feb 2019 23:11:47 +0200
with message-id <875zt7efos.fsf <at> mail.linkov.net>
and subject line Re: bug#34516: Multi-monitor frame sets
has caused the debbugs.gnu.org bug report #34516,
regarding Multi-monitor frame sets
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
34516: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=34516
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Multi-monitor frame sets
Date: Sun, 17 Feb 2019 21:34:19 +0200
[Message part 3 (text/plain, inline)]
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):

[make-frame-on-monitor.patch (text/x-diff, inline)]
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)
[Message part 5 (message/rfc822, inline)]
From: Juri Linkov <juri <at> linkov.net>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 34516-done <at> debbugs.gnu.org
Subject: Re: bug#34516: Multi-monitor frame sets
Date: Mon, 25 Feb 2019 23:11:47 +0200
>>>> 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.


This bug report was last modified 6 years and 51 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.