Merge lp:~broder/checkbox/multimon-aware-resolution-test-632987 into lp:checkbox

Proposed by Evan Broder
Status: Merged
Merged at revision: 1053
Proposed branch: lp:~broder/checkbox/multimon-aware-resolution-test-632987
Merge into: lp:checkbox
Diff against target: 115 lines (+20/-58)
2 files modified
debian/changelog (+5/-1)
scripts/resolution_test (+15/-57)
To merge this branch: bzr merge lp:~broder/checkbox/multimon-aware-resolution-test-632987
Reviewer Review Type Date Requested Status
Brendan Donegan (community) Approve
Review via email: mp+76245@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

This looks good, approve

review: Approve
1053. By Evan Broder

Replace resolution_test with an implementation which uses GdkScreen to
be multimonitor-aware (LP: #632987)

Revision history for this message
Evan Broder (broder) wrote :

Sorry, realized I wanted to tweak this slightly. I wanted to reduce the amount of text printed out by the script to minimize the i18n impact. I'm not sure how to deal with actually translating the "Monitor %d" string in the script output.

It would also be nice to update the test description, since it refers to a single display a couple of times, but I don't know if we're allowed to do that at this point in the oneiric cycle.

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

I think it's fine at the moment. We can't actually change the test description right now as it will break translations, but we'll fix it in due time.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-09-19 19:47:38 +0000
3+++ debian/changelog 2011-09-20 15:46:23 +0000
4@@ -5,7 +5,11 @@
5 screens (LP: #852204)
6 * Remove memory/test from the Ubuntu Friendly whitelist (LP: #853799)
7
8- -- Daniel Manrique <daniel.manrique@canonical.com> Mon, 19 Sep 2011 15:31:24 -0400
9+ [ Evan Broder ]
10+ * Replace resolution_test with an implementation which uses GdkScreen to
11+ be multimonitor-aware (LP: #632987)
12+
13+ -- Evan Broder <evan@ebroder.net> Tue, 20 Sep 2011 08:30:18 -0700
14
15 checkbox (0.12.7) oneiric; urgency=low
16
17
18=== modified file 'scripts/resolution_test'
19--- scripts/resolution_test 2010-06-07 09:06:56 +0000
20+++ scripts/resolution_test 2011-09-20 15:46:23 +0000
21@@ -1,65 +1,24 @@
22 #!/usr/bin/python
23
24-import os
25-import re
26 import sys
27
28 from optparse import OptionParser
29
30-def error(message):
31- sys.stderr.write("ERROR: %s\n" % message)
32- sys.exit(1)
33-
34-def check_ati():
35- command = "lsmod | grep fglrx"
36- fglrx_lines = os.popen(command).readlines()
37- if len(fglrx_lines) != 0:
38- print "unknown (impossible to determine resolution with fglrx)"
39- return True
40-
41- return False
42-
43-def get_resolution():
44- command = "xrandr -q"
45- xrandr_lines = os.popen(command).readlines()
46- star_lines = [l for l in xrandr_lines if "*" in l]
47- if len(star_lines) != 1:
48- error("%s should return a single line with '*'" % command)
49-
50- star_line = star_lines[0]
51- match = re.search(r"(\d+)\s?x\s?(\d+)", star_line)
52- if not match:
53- error("%s should return pixels like '1024 x 768'" % command)
54-
55- horizontal = int(match.group(1))
56- vertical = int(match.group(2))
57-
58- fields = re.split(r"\s+", star_line)
59- star_fields = [f for f in fields if "*" in f]
60- if len(star_fields) < 1:
61- error("%s should return a refresh rate with '*'" % command)
62-
63- return (horizontal, vertical)
64+from gi.repository import Gdk
65
66 def check_resolution():
67- if check_ati():
68- return True
69-
70- (horizontal, vertical) = get_resolution()
71-
72- print "%d x %d" % (horizontal, vertical)
73- return True
74+ screen = Gdk.Screen.get_default()
75+ n = screen.get_n_monitors()
76+ for i in xrange(n):
77+ geom = screen.get_monitor_geometry(i)
78+ print 'Monitor %d:' % (i + 1)
79+ print ' %d x %d' % (geom.width, geom.height)
80
81 def compare_resolution(min_h, min_v):
82- if check_ati():
83- return True
84-
85- (horizontal, vertical) = get_resolution()
86-
87- if (horizontal >= min_h) and (vertical >= min_v):
88- return True
89- else:
90- return False
91+ # Evaluate just the primary display
92+ screen = Gdk.Screen.get_default()
93+ geom = screen.get_monitor_geometry(screen.get_primary_monitor())
94+ return geom.width >= min_h and geom.height >= min_h
95
96 def main(args):
97 usage = "Usage: %prog [OPTIONS]"
98@@ -75,13 +34,12 @@
99 (options, args) = parser.parse_args(args)
100
101 if (options.horizontal > 0) and (options.vertical > 0):
102- if compare_resolution(options.horizontal, options.vertical):
103- return 0
104+ if not compare_resolution(options.horizontal, options.vertical):
105+ return 1
106 else:
107- if check_resolution():
108- return 0
109+ check_resolution()
110
111- return 1
112+ return 0
113
114
115 if __name__ == "__main__":

Subscribers

People subscribed via source and target branches