From 34f0f21e850b299fa7392dac5277c2000dbc0773 Mon Sep 17 00:00:00 2001 From: Phillip Berndt Date: Mon, 9 Apr 2018 14:01:44 +0200 Subject: [PATCH] Add --fb option to xrandr invocations As suggested by @Vladimir-csp in #88. --- autorandr.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/autorandr.py b/autorandr.py index 5a0a686..ca761b0 100755 --- a/autorandr.py +++ b/autorandr.py @@ -631,6 +631,29 @@ def call_and_retry(*args, **kwargs): return retval +def get_fb_dimensions(configuration): + width = 0 + height = 0 + for output in configuration.values(): + if "off" in output.options or not output.edid: + continue + # This won't work with all modes -- but it's a best effort. + o_width, o_height = map(int, output.options["mode"].split("x")) + if "transform" in output.options: + a, b, c, d, e, f, g, h, i = map(float, output.options["transform"].split(",")) + w = (g * o_width + h * o_height + i) + x = (a * o_width + b * o_height + c) / w + y = (d * o_width + e * o_height + f) / w + o_width, o_height = x, y + if "pos" in output.options: + o_left, o_top = map(int, output.options["pos"].split("x")) + o_width += o_left + o_height += o_top + width = max(width, o_width) + height = max(height, o_height) + return int(width), int(height) + + def apply_configuration(new_configuration, current_configuration, dry_run=False): "Apply a configuration" outputs = sorted(new_configuration.keys(), key=lambda x: new_configuration[x].sort_key) @@ -659,6 +682,13 @@ def apply_configuration(new_configuration, current_configuration, dry_run=False) # explicitly, so avoid it unless necessary. # (See https://github.com/phillipberndt/autorandr/issues/72) + fb_dimensions = get_fb_dimensions(new_configuration) + try: + base_argv += ["--fb", "%dx%d" % fb_dimensions] + except: + # Failed to obtain frame-buffer size. Doesn't matter, xrandr will choose for the user. + pass + auxiliary_changes_pre = [] disable_outputs = [] enable_outputs = [] -- 2.39.2