Subject: Re: bug#76051: 29.4; Incorrect workarea entry in display-monitor-attributes-list on macOS

From: Ship Mints <[email-masked]>
Date: Mon, 26 May 2025 15:38:46 -0400

On Mon, May 26, 2025 at 3:35 PM Alan Third <[email-masked]> wrote:

> On Tue, Feb 04, 2025 at 02:42:07PM +0100, Anders Lindgren wrote:
> > Hi!
>
> Hi Anders,
>
> > I think the `display-monitor-attributes-list' function returns an
> incorrect
> > `workarea' entry on macOS.
> >
> > Concretely, I have a laptop with an external monitor connected. The
> > external monitor is placed above to the left.
> >
> > The `display-monitor-attributes-list' function returns the following
> > (abbreviated):
> >
> >     (((geometry 0 0 1728 1117) (workarea 0 38 1728 1079) ...
> >      ((geometry -2560 -723 2560 1440) (workarea -2560 -638 2560 1330)
> ...))
> >
> > The first member in the list describes the laptop monitor (the primary
> > monitor), the second the external monitor.
> >
> > The first two numbers, `X' and `Y', in each entry describe the position
> of
> > the top left corner of the area, relative to the top left corner of the
> > primary monitor.
> >
> > The number that I think is incorrect is the `Y' of the workarea of the
> > external monitor, which is "-638". It indicates that there is a (723-638
> =
> > 85 pixel area on top of the screen which is outside the work area.)
> >
> > However, in reality, there is a 25 pixel menu bar which should be outside
> > the work area. The 85 probably comes from the macOS dock, which is placed
> > in the lower part of the screen.
> >
> > The height field correctly includes both the menu bar and the dock.
> >
> > I've tested this on Emacs 29.4 and 30.0.93 on macOS 15.1.
>
> I'm pretty sure the arithmetic was wrong, and it was treating external
> monitors differently from the primary screen for some reason I
> couldn't work out.
>
> Can you check if the attached looks right to you? I can't check as I
> don't have an external monitor here.
>

Also see the following bug which has a working patch:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76691