Improving g-s-d's automatic output layouts



Hi guys -
    I've been staring a lot recently at the xrandr plugin for g-s-d,
and I'd like to propose some changes that I think will improve the
state of multi-monitor support in Linux, and I'd appreciate feedback
before I pursue developing them any further.

Right now, I'd like to improve the intelligence in g-s-d's handling of
hotplug events. Currently, when you hotplug an output, the previous
output layout only partially effects the new output layout, assuming
you don't have a relevant stanza in ~/.config/monitors.xml (which I
will be assuming for most of this discussion)

I noticed two slightly screwy behaviors from this in particular.
First, g-s-d will arrange the outputs from left-to-right in
effectively an arbitrary order, causing outputs to be rearranged or
un-mirrored. Second, g-s-d will preserve the mode that an output was
previously using, which means that if I unplug 1 of 2 outputs that are
mirrored, the second output will continue to use the (likely
sub-optimal) mode it was using before.

I would suggest the following set of rules for handling output hotplug
events, which I think solves those two problems and sets up a layout
which is much less likely to require user intervention [2]:

 - Any group of outputs which mirror each other (or a single output if
it isn't mirrored to anything) should be set by default to the largest
mode supported by those outputs
 - No outputs should overlap
 - No outputs should be "floating" away from all other outputs (the
set of outputs should be "connected")
 - The new output layout should be as similar as possible to the old
output layout, modulo changes necessitated by the previous 3 rules

On top of that, I would like to add one more rule, which I believe
makes things even more usable:

 - If a projector [3] is connected, it is by default made a mirror of
the primary output; otherwise the non-projector is arranged to the far
right of all other outputs. [4]

This last rule matches the behavior of OS X, and seems to work so well
that my friends who own Macs didn't notice how useful this behavior
was until I pointed out that that's what was happening.

I've attached a pseudocode implementation of the
auto_configure_outputs function which I believe implements the rules
I've described. It's basically a complete implementation, because I
wanted to make sure that I knew how to handle all of the edge cases,
and although I've used some Python idioms to make the code easier to
follow, I don't think they would affect the viability of a translation
into C.

While it's not hard to imagine scenarios involving 3 or more outputs
where this code doesn't do the "right" thing, I don't know of any
scenarios where this code will result in a layout that is invalid, and
it does seem to do the "right" thing for many of the cases I've
imagined.

I'd like to implement this and submit it as a patch to g-s-d, but I
wanted to first submit my thoughts and sketches and get feedback,
which I would greatly appreciate.

Thanks,
 - Evan

[1] https://blueprints.launchpad.net/ubuntu/+spec/multimedia-desktop-n-xorg-multihead-defaults

[2] Obviously there are cases where any of these assumptions might not
hold true, but it seems to me that those are all reasonably obscure
cases, and users facing those circumstances are always free to
configure the outputs themselves (at which point
~/.config/monitors.xml kicks in)

[3] Specifically, a device whose EDID information claims a physical
dimension of 0mm x 0mm

[4] If it's desirable, it would be easy to make the default layout for
a new projector or new non-projector configurable through GSettings in
the future

Attachment: auto_configure_outputs.py
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]