From: Phillip Berndt Date: Thu, 22 Jan 2015 10:41:48 +0000 (+0100) Subject: Python version: Correctly determine the mode of transformed outputs X-Git-Tag: 1.0~100 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cf2b326a2498bee2f6af3fc190d673cd6831b93c;hp=664d140f46ffdbf7f1d3a71d15a300d53e2a742c;p=deb_pkgs%2Fautorandr.git Python version: Correctly determine the mode of transformed outputs --- diff --git a/autorandr.py b/autorandr.py index 1225491..c7aa866 100755 --- a/autorandr.py +++ b/autorandr.py @@ -84,7 +84,7 @@ class XrandrOutput(object): unknown\ connection | (?Pconnected)\s+ # If connected: (?Pprimary\ )? # Might be primary screen - (?P[0-9]+)x(?P[0-9]+) # Resolution + (?P[0-9]+)x(?P[0-9]+) # Resolution (might be overridden below!) \+(?P[0-9]+)\+(?P[0-9]+)\s+ # Position (?:\(0x[0-9a-fA-F]+\)\s+)? # XID (?P(?:normal|left|right|inverted))\s+ # Rotation @@ -98,7 +98,8 @@ class XrandrOutput(object): ))+ \s* (?P(?: - [0-9]+x[0-9]+.+?\*current.+\s+h:.+\s+v:.+clock\s+(?P[0-9\.]+)Hz\s* | # Interesting (current) resolution: Extract rate + (?P[0-9]+)x(?P[0-9]+).+?\*current.+\s+ + h:.+\s+v:.+clock\s+(?P[0-9\.]+)Hz\s* | # Interesting (current) resolution: Extract rate [0-9]+x[0-9]+.+\s+h:.+\s+v:.+\s* # Other resolutions )*) """ @@ -191,10 +192,13 @@ class XrandrOutput(object): options["off"] = None edid = None else: - if match["rotate"] not in ("left", "right"): - options["mode"] = "%sx%s" % (match["width"], match["height"]) + if "mode_width" in match: + options["mode"] = "%sx%s" % (match["mode_width"], match["mode_height"]) else: - options["mode"] = "%sx%s" % (match["height"], match["width"]) + if match["rotate"] not in ("left", "right"): + options["mode"] = "%sx%s" % (match["width"], match["height"]) + else: + options["mode"] = "%sx%s" % (match["height"], match["width"]) if match["rotate"] != "normal": options["rotate"] = match["rotate"] if "reflect" in match: @@ -209,6 +213,10 @@ class XrandrOutput(object): transformation = ",".join(match["transform"].strip().split()) if transformation != "1.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,1.000000": options["transform"] = transformation + if "mode_width" not in match: + # TODO We'd need to apply the reverse transformation here. Let's see if someone complains, I doubt that this + # special case is actually required. + print("Warning: Output %s has a transformation applied. Could not determine correct mode!", file=sys.stderr) if match["gamma"]: gamma = match["gamma"].strip() if gamma != "1.0:1.0:1.0":