]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
fix: output position if xrandr offsetted them
authorMathis Raguin <mathis@cri.epita.fr>
Tue, 28 May 2019 19:53:39 +0000 (21:53 +0200)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Tue, 31 Dec 2019 10:02:31 +0000 (11:02 +0100)
Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
autorandr.py

index aa1be0b28d04f340504687898e2511139b06d33b..433cdc6dfdb683ef773abff9ddae2f628cab2799 100755 (executable)
@@ -717,6 +717,7 @@ def get_fb_dimensions(configuration):
 
 def apply_configuration(new_configuration, current_configuration, dry_run=False):
     "Apply a configuration"
+    require_xrandr_fix = True
     outputs = sorted(new_configuration.keys(), key=lambda x: new_configuration[x].sort_key)
     if dry_run:
         base_argv = ["echo", "xrandr"]
@@ -777,7 +778,11 @@ def apply_configuration(new_configuration, current_configuration, dry_run=False)
                         except ValueError:
                             pass
 
-            enable_outputs.append(option_vector)
+            if new_configuration[output].options.get("pos", "0x0") == "0x0":
+                enable_outputs.insert(0, option_vector)
+                require_xrandr_fix = False
+            else:
+                enable_outputs.append(option_vector)
 
     # Perform pe-change auxiliary changes
     if auxiliary_changes_pre:
@@ -811,6 +816,13 @@ def apply_configuration(new_configuration, current_configuration, dry_run=False)
         if call_and_retry(argv, dry_run=dry_run) != 0:
             raise AutorandrException("Command failed: %s" % " ".join(argv))
 
+    # Fix all outputs if no 0x0 output has been found as xrandr will shift them
+    if require_xrandr_fix:
+        for index in range(0, len(enable_outputs), 2):
+            argv = base_argv + list(chain.from_iterable(enable_outputs[index:index + 2]))
+            if call_and_retry(argv, dry_run=dry_run) != 0:
+                raise AutorandrException("Command failed: %s" % " ".join(argv))
+
 
 def is_equal_configuration(source_configuration, target_configuration):
     """