Subject: bug#34516: Multi-monitor frame sets

From: Andy Moreton <[email-masked]>
Date: Tue, 19 Feb 2019 23:29:47 +0000

On Tue 19 Feb 2019, Juri Linkov wrote:

>> Why guess ? Read the documentation for `display-monitor-attributes-list'
>> which describes the meaning of the list elements in great detail.
>>
>> Note that you will need to take note of the `workarea' element of the
>> list which describes the usuable space on a given monitor (which
>> excludes space for toolbars etc that are not available to display a
>> frame).
>
> Thanks for the information.  Do you think it's possible to use
> the list elements from `display-monitor-attributes-list'
> to unambiguously select a monitor where to make a new frame?

Yes. The list describes all monitors available for displaying frames, so
any new frame you wish to create must be shown (at least partially) on
one of those monitors.

The monitors may have different sizes, and be physically arranged in
fairly arbitrary ways. For example, on Windows (from bug#21173):

  +----------+
  |          |
  | DISPLAY2 |
  |          |+----------+
  +----------+|          |
              | DISPLAY1 |
              | (primary)|
              +----------+

  (display-monitor-attributes-list)
  ;; ==>
  '(((geometry 0 0 1920 1080)
     (workarea 0 0 1920 1050)
     (mm-size 677 381)
     (name . "\\\\.\\DISPLAY1")
     (frames ...))
    ((geometry -1680 -1050 1680 1050)
     (workarea -1680 -1050 1680 1050)
     (mm-size 593 370)
     (name . "\\\\.\\DISPLAY2")
     (frames ...)))

  ;; For a frame on DISPLAY2:
  (frame-parameter (window-frame) 'left) ;; ==>  (+ -1668)
  (frame-parameter (window-frame) 'top)  ;; ==>  (+ -1046)