Subject: Re: bug#34516: Multi-monitor frame sets

From: Alan Third <[email-masked]>
Date: Sat, 2 Mar 2019 20:54:24 +0000

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
> >
> > 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 :-)

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.

> Something like this (assuming nobody every connects more than 9
> monitors to the same system).
> 
> 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.
-- 
Alan Third