[PATCH] intelligently choose the window size (#800609)

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

 



From: "Brian C. Lane" <bcl@xxxxxxxxxx>

Picking a maximum window size can be complicated by multiple monitor
setups as well as not knowing which display anaconda will end up on.
This patch solves the window size problem by examining the xrandr output
and picking the smallest width and height available and setting the size
to that. These are picked independently so that the size chosen can fit
on any display.

This means that on a single display it will use all of the available
space. On a multiple monitor setup it will pick a size that can be used
on any of the connected displays.
---
 pyanaconda/gui.py |   43 ++++++++++++++++++++++++++++---------------
 1 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/pyanaconda/gui.py b/pyanaconda/gui.py
index 6b7ecfb..d8360a9 100755
--- a/pyanaconda/gui.py
+++ b/pyanaconda/gui.py
@@ -41,6 +41,7 @@ import network
 from installinterfacebase import InstallInterfaceBase
 import imp
 import iw
+import re
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -1363,21 +1364,33 @@ class InstallControlWindow:
             if gtk.gdk.screen_height() < 600:
                 i.hide()
 
-            width = None
-            height = None
-            xrandr = iutil.execWithCapture("xrandr", ["-q"], stderr="/dev/tty5")
-            lines = xrandr.splitlines()
-            xrandr = filter(lambda x: "current" in x, lines)
-            if xrandr and len(xrandr) == 1:
-                fields = xrandr[0].split()
-                pos = fields.index('current')
-                if len(fields) > pos + 3:
-                    width = int(fields[pos + 1])
-                    height = int(fields[pos + 3].replace(',', ''))
-
-            if width and height:
-                self.window.set_size_request(min(width, 800), min(height, 600))
-
+            # Find a window size that will fit on whatever display gets picked
+            # Parse the connected lines from xrandr, which look like this:
+            # DVI-I-1 connected 1680x1050+1680+0 (normal left inverted right x axis y axis) 473mm x 296mm
+            try:
+                widths = []
+                heights= []
+                xrandr = iutil.execWithCapture("xrandr", ["-q"], stderr="/dev/tty5")
+                lines = [l.split() for l in xrandr.splitlines()]
+                displays = filter(lambda x: "connected" in x, lines)
+                for fields in displays:
+                    log.debug("display: %s", (fields,))
+                    m = re.match("(\d+)x(\d+).*", fields[2])
+                    if m and len(m.groups()) == 2:
+                        widths.append(int(m.group(1)))
+                        heights.append(int(m.group(2)))
+
+                # Pick the smallest size that will fit
+                width = min(widths)
+                height = min(heights)
+            except Exception as e:
+                log.info("screen size detection failed: %s", (str(e),))
+                width = 800
+                height= 600
+
+            # Set the window size, but no smaller than 800x600
+            log.info("Setting window size to %dx%d" % (width, height))
+            self.window.set_size_request(max(width, 800), max(height, 600))
         self.window.show()
 
         if flags.debug:
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux