On Tue, 2012-03-06 at 15:04 -0800, Brian C. Lane wrote: > 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. Looks reasonable enough to me overall, although I know very little about X. That's a pretty wide net you're using to catch exceptions, but I suppose the idea is to take a stab at it and just move along if there's a problem. Since you're logging the exception we'll hopefully be able to fix non-xrandr problems pretty easily, which is good. Ack. > --- > 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: _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list