+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_mode = re.search("[0-9]{3,}x[0-9]{3,}", output.options["mode"]).group(0)
+ o_width, o_height = map(int, o_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 "rotate" in output.options:
+ if output.options["rotate"] in ("left", "right"):
+ o_width, o_height = o_height, o_width
+ if "pos" in output.options:
+ o_left, o_top = map(int, output.options["pos"].split("x"))
+ o_width += o_left
+ o_height += o_top
+ if "panning" in output.options:
+ match = re.match("(?P<w>[0-9]+)x(?P<h>[0-9]+)(?:\+(?P<x>[0-9]+))?(?:\+(?P<y>[0-9]+))?.*", output.options["panning"])
+ if match:
+ detail = match.groupdict(default="0")
+ o_width = int(detail.get("w")) + int(detail.get("x"))
+ o_height = int(detail.get("h")) + int(detail.get("y"))
+ width = max(width, o_width)
+ height = max(height, o_height)
+ return int(width), int(height)
+
+