nwg-piotr / nwg-displays

Output management utility for sway and Hyprland.
MIT License
336 stars 22 forks source link

Displays overlap #3

Open alanorth opened 2 years ago

alanorth commented 2 years ago

I have an internal display (eDP-1) and an external display (DP-5). Both displays are 1920x1080 with scale 1.33. When I snap them together in nwg-displays the positions are incorrect and there is a slight overlap that causes the mouse pointer to be mirrored on both displays temporarily before jumping to the next screen when it reaches the edge.

First display is DP-5, which starts at position 0,0:

2022-03-23T16:01:34,334635825+03:00-fs8

Second display is eDP-1, which starts at 1086,0 when I snap it to DP-5:

2022-03-23T16:10:34,403356356+03:00-fs8

If I manually drag eDP-5 to 1445,0 the transition between displays works as expected. 2022-03-23T16:02:30,386353292+03:00-fs8

I guess this is a problem with the fractional scaling math? I am using nwg-displays 0.1.2 on Arch Linux and Sway 1.7. Thank you!

nwg-piotr commented 2 years ago

I guess this is a problem with the fractional scaling math?

For sure, and it may be difficult to reproduce on my hardware. Did you try using a view scale other than 0.3?

alanorth commented 2 years ago

The largest view scale I can use is 0.5, and even then the situation is weird. Here the external display (DP-5) is 1445x813 at position 0,0:

2022-03-24T09:07:11,376967980+03:00-fs8

And here the internal display (eDP-1) is 1920x1080 (despite me setting the scale, hmm) at position 1434,0 but at the edge of the window so I can't even move it further.

2022-03-24T09:07:22,890332102+03:00-fs8

With fractional scaling of the display sizes the snapping of displays is totally unreliable. It seems you must set the positions manually.

nwg-piotr commented 2 years ago

Does it work well on wdisplays?

nwg-piotr commented 2 years ago

Also: I experimented quite a lot by changing scaling on a two-headed setup (1366x768 + 1920x1080) and I could not reproduce the issue. :(

alanorth commented 2 years ago

It works well on wdisplays. Here are the same two displays as I tested with above, both 1920x1080 at 1.33 scale. When I drag the right one to snap to the left one the resulting positions are correct.

First, the external display at position 0,0:

2022-03-25T09:21:29,562030773+03:00-fs8

Then the internal display at position 1445,0:

2022-03-25T09:21:46,895751545+03:00-fs8

So the x position of 1145 seems to be:

1080 / 1.33 == 1443.60, rounded up to nearest integer 1444 + 1 == 1445

I note that snapping in nwg-displays gives me an x position of 1446 though!

And I just realized that this snapping bug only happens if you don't set the resolution using the "Modes" dropdown! So even though nwg-displays knows the "Size" (resolution) of the current display, unless you select the mode from the dropdown it will calculate the snapping math incorrectly.