Subject: bug#34516: Multi-monitor frame sets

From: Andy Moreton <[email-masked]>
Date: Sat, 02 Mar 2019 23:57:35 +0000

On Sat 02 Mar 2019, Alan Third wrote:

> On Sun, Feb 24, 2019 at 01:56:31PM +0100, Robert Pluim wrote:
>> Juri Linkov <[email-masked]> writes:
>> 
>> > Since on Windows 'display-monitor-attributes-list' returns such
>> > fake monitor names:
>> >
>> >   \\.\DISPLAY1
>> >   \\.\DISPLAY2

These names are *not* fake: they are the name of the underlying device
that represents the monitor. 

>> > on macOS it could return something like that or generate fake names
>> > from geometry like "1920x1080+0+0", "2560x1440+1920+16".

It would be more usefulr to use the underlying device name, like on other
platforms.

> I’m a bit late to this conversation, sorry.
>
> I’d hope that the geometry would contain the origin of the monitor in
> the overall screen ‘space’, so the primary monitor would have 0, 0,
> and one to the left would have -1920, 0, or something. So it might not
> be too confusing.

Yes, that is exactly how it works: the geometry shows where the monitor
is positioned in the overall coordinate system, and the workspace shows
the area on that monitor that is available to display frames (i.e. not
occupied by system tray toolbar, dock etc).

>> Something like this (assuming nobody every connects more than 9
>> monitors to the same system).

Not a sound assumption: why add an arbitrary limitation when there is no
need to ? Allow an arbitrary number of monitors, since there is no
reason to restrict it.

>> 
>> diff --git a/src/nsfns.m b/src/nsfns.m
>> index edcdb988f7..91ab17032c 100644
>> --- a/src/nsfns.m
>> +++ b/src/nsfns.m
>> @@ -2698,6 +2698,12 @@ and GNUstep implementations ("distributor-specific release
>>  
>>  #ifdef NS_IMPL_COCOA
>>        m->name = ns_screen_name (did);
>> +      if (m->name == NULL)      /* Fallback value.  */
>> +        {
>> +          char name[9];
>> +          snprintf (name, sizeof(name), "DISPLAY%1d", i+1);
>> +          m->name = xstrdup (name);
>> +        }
>>  
>>        {
>>          CGSize mms = CGDisplayScreenSize (did);
>
> This appears to be the only place that ns_screen_name is called, so it
> would probably be better to put this code in it and make
> ns_screen_name return a name no matter what.
>
> Also, it might be worth considering using the ‘did’ value instead of
> ‘i’. As far as I can tell it’s just a uint32_t, and should stay the
> same as long as the system isn’t rebooted.

Is the did value reused if monitors are dynamically plugged and
unplugged ? This may happen when using a laptop with docking
stations and external monitors.

    AndyM