theotherjimmy / autorandr-rs

like autorandr, but kdl and a daemon
38 stars 4 forks source link

Replace break-then-make with double-resize; Add logging #5

Closed theotherjimmy closed 3 years ago

theotherjimmy commented 3 years ago

Summary

Naively reconfiguring monitors can lead to erros, as documented by the RandR extension:

'x' and 'y' contain the desired location within the screen for this
monitor's content. 'x' and 'y' must be within the screen size, else
a Value error results.

Note that I have found that you can also get a Value erro when the edge of a configured monitor (well a crtc) would fall outside of the configured screen size (which is the size of a virtual surface that all connected monitors display a part of).

In short, reconfiguring a monitor will fail if the monitor contains pixels outside the screen.

Previously, autorandrd(1) avoided this issue by disabling a monitor (which I called "break") before re-enabling a monitor (which I called "make"). This would result in both a screen flicker and a problem for some hardware that can't easily keep up with these fast screen changes.

Instead, this commit re-configures the screen to allow for space for both the current monitor config and the final monitor config first, avoiding the need for a break, as the reconfigure will not error. This may result in less flickering and may result in fewer calls to the X server in some situations.

Example log

INFO - Setting Screen Size 5120x2880
INFO - Configuring CRTC 729 to mode 733 at 0,1440
INFO - Configuring CRTC 730 to mode 752 at 0,0
INFO - Setting Screen Size 2560x2880
Monitor configuration: Work-Desktop
theotherjimmy commented 3 years ago

This works well for me, and I think it's a step forward compared to the prior implementation.