Chromium Code Reviews| Index: remoting/tools/me2me_virtual_host.py |
| diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py |
| index 19987b2576b477f97a97436d7695815e191fd49b..445233564bdbf5725f6a330aa14583968655d009 100755 |
| --- a/remoting/tools/me2me_virtual_host.py |
| +++ b/remoting/tools/me2me_virtual_host.py |
| @@ -13,6 +13,7 @@ import atexit |
| import getpass |
| import json |
| import logging |
| +import optparse |
| import os |
| import random |
| import signal |
| @@ -197,8 +198,10 @@ def signal_handler(signum, stackframe): |
| class Desktop: |
| """Manage a single virtual desktop""" |
| - def __init__(self): |
| + def __init__(self, width, height): |
| self.x_proc = None |
| + self.width = width |
| + self.height = height |
| g_desktops.append(self) |
| @staticmethod |
| @@ -218,10 +221,11 @@ class Desktop: |
| raise Exception("xauth failed with code %d" % ret_code) |
| logging.info("Starting Xvfb on display :%d" % display); |
| + screen_option = "%dx%dx24" % (self.width, self.height) |
| self.x_proc = subprocess.Popen(["Xvfb", ":%d" % display, |
| "-auth", X_AUTH_FILE, |
| "-nolisten", "tcp", |
| - "-screen", "0", "1024x768x24", |
| + "-screen", "0", screen_option |
| ]) |
| if not self.x_proc.pid: |
| raise Exception("Could not start Xvfb.") |
| @@ -269,6 +273,24 @@ class Desktop: |
| def main(): |
| + parser = optparse.OptionParser() |
| + parser.add_option("-s", "--size", dest="size", default="1280x1024", |
| + help="size of virtual desktop (default: %default)") |
|
Wez
2011/12/09 23:51:16
nit: Would "geometry" be the more X11-ish name?
Wez
2011/12/09 23:51:16
nit: "size of virtual desktop" -> "dimensions of v
Lambros
2011/12/13 01:32:22
Nah. xrandr uses '-s' and '--size', and calls it
|
| + (options, args) = parser.parse_args() |
| + |
| + size_components = options.size.split("x") |
| + if len(size_components) != 2: |
| + parser.error("Incorrect size format, should be WIDTHxHEIGHT"); |
| + |
| + try: |
| + width = int(size_components[0]) |
| + height = int(size_components[1]) |
| + except ValueError: |
| + parser.error("Width/Height must be numeric") |
| + |
| + if width <= 0 or height <= 0: |
| + parser.error("Width/Height must be positive numbers") |
|
Wez
2011/12/09 23:51:16
nit: You could move this test inside the try and h
Wez
2011/12/09 23:51:16
nit: It may make sense to prohibit too-small deskt
Lambros
2011/12/13 01:32:22
Done.
Lambros
2011/12/13 01:32:22
Done.
|
| + |
| atexit.register(cleanup) |
| for s in [signal.SIGHUP, signal.SIGINT, signal.SIGTERM]: |
| @@ -295,7 +317,7 @@ def main(): |
| logging.info("Using host_id: " + host.host_id) |
| - desktop = Desktop() |
| + desktop = Desktop(width, height) |
| desktop.launch_x_server() |
| desktop.launch_x_session() |
| desktop.launch_host() |