jakehilborn / displayplacer

macOS command line utility to configure multi-display resolutions and arrangements. Essentially XRandR for macOS.
MIT License
3.74k stars 134 forks source link

Once mirrored, can't unmirror displays using displayplacer #98

Open MarqueIV opened 2 years ago

MarqueIV commented 2 years ago

TL;DR

I can't seem to get your command to stop mirroring my displays, once mirrored.

The Details

I have an interesting issue regarding mirroring. There's definitely a bug. I just don't know if it's in your software or the OS.

First, here's my arrangement. image

Using the shortened IDs AAAA, BBBB, CCCC and DDDD for readability, AAAA is my MacBook Pro's built-in display (lower left), BBBB is my 40" 4K display (center), and CCCC and DDDD are two 2.5K displays that flank the sides.

To configure this arrangement, I use the following command (again with the IDs shortened for readability here):

displayplacer \
    "id:AAAA res:1512x982 hz:120 color_depth:8 scaling:on origin:(-1512,1721) degree:0" \
    "id:BBBB res:3840x2160 hz:60 color_depth:8 scaling:off origin:(0,0) degree:0" \
    "id:CCCC res:2560x1440 hz:60 color_depth:8 scaling:off origin:(-2560,281) degree:0" \
    "id:DDDD res:2560x1440 hz:60 color_depth:8 scaling:off origin:(3840,222) degree:0"

This works as expected.

Now for certain times, I want all my displays to mirror my MacBook Pro's display, so the above changes to this...

displayplacer \
    "id:AAAA+BBBB+CCCC+DDDD res:1512x982 hz:120 color_depth:8 scaling:on origin:(0,0) degree:0"

And this (seems to) works as expected.

BUT... if I then go back and initiate the first command to re-set everything back up as separate displays, something odd happens. A few things actually.

  1. The visuals do not update. All screens still appear to be mirroring the MBPs screen as before.
  2. The mouse is now wildly out of sync with the visuals on all but the MBPs display, responding to the physical pixel dimensions, not the scaled, displayed image of the mirror.
  3. On larger screens (which in my case is all of them) the mouse is also physically 'constrained' to the physical dimensions of the smaller screen, but on the larger screen.

For example, on the 4K screen, the mouse is now restricted to an area in the upper left corner with dimensions 1512x982 (matching the dimensions of the MBP's display), meaning I can't move my cursor to the right side or bottom edge of my screen.

Now, even though it's constrained to that area, it responds as if that area the mouse is confined to is 'mapped to' the full screen, meaning when I move the mouse to the right edge of that area (where it stops/is constrained) the UI responds as if the mouse was all the way on the right side of the screen. In other words, the mouse area is 'scaled down' from the visuals, which are incorrectly scaled up to match the mirroring, which again, it shouldn't be doing in the first place!

The result is on all but the MBP's display (which of course has a 1:1 scale with itself) the mouse is scaled out of proportion to the UI by the ratio of the physical screen to the mirrored screen.

Make sense?

Re-Mirroring 'Resets' Things

If I however re-execute the 'mirroring' version above, then all displays go back to properly mirroring the MBP's display, all with the correct scaling. In other words, it's only when you try using DisplayPlacer to unmirror that things go wonky.

Stop Mirroring Entirely - Can't use DisplayPlacer

In order to get it to actually stop mirroring, I have to manually go into System Preferences -> Displays and disable mirroring there which leaves my monitors' arrangement in a garbled state, so I then go back and re-apply my first command above, which brings things back to normal.

One More Thing

Also, I've mentioned this before... you really should consider updating your displayplacer list with two changes... one, give us a flag to just show that last line so we can easily save it off into a file/script for quick reapplications without having to grep for it, and two, for readability, I highly encourage you to use the line continuation character / like I have, indenting the following lines. It's still technically a single command, it's just much more readable. But that's neither here nor there regarding this issue. This issue is a stopper for me. Hoping you can help figure it out.

steady137 commented 2 years ago

Wonderful utility. I see a similar behavior on MBP 16" M1 running Monterey 12.5.1 with 2x 4ks mirrored with the lid, and trying to unmirror just the lid. Happy to help test or with further diagnostics.

MarqueIV commented 2 years ago

Wonderful utility. I see a similar behavior on MBP 16" M1 running Monterey 12.5.1 with 2x 4ks mirrored with the lid, and trying to unmirror just the lid. Happy to help test or with further diagnostics.

Ok, pretty sure that rules out the macOS beta. That means now it's either DisplayPlacer or the APIs which DisplayPlacer uses.

Trying to dig through the C code now. Just been forever since I've done C so I'm a little rusty.

mgumz commented 1 year ago

@MarqueIV @steady137 /cc @jakehilborn: feel free to try #102

g6ai commented 1 year ago

@mgumz I have tested it and it works well! Many thanks!

mgumz commented 1 year ago

@g6ai well, then express your desire for the PR to be merged at the PR =)

jakehilborn commented 1 year ago

@MarqueIV @steady137 @g6ai Mirroring behavior has been improved in release v1.3.0. Could you try it out and let me know if it works for your setup?

g6ai commented 1 year ago

Can confirm release v1.3.0 resolves this issue for my setup. Thanks guys for the great work!