Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Virtual Me2Me implementation. This script runs and manages the processes | 6 # Virtual Me2Me implementation. This script runs and manages the processes |
| 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop | 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop |
| 8 # session, and Host process. | 8 # session, and Host process. |
| 9 # This script is intended to run continuously as a background daemon | 9 # This script is intended to run continuously as a background daemon |
| 10 # process, running under an ordinary (non-root) user account. | 10 # process, running under an ordinary (non-root) user account. |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 "-config", config_file.name | 511 "-config", config_file.name |
| 512 ] + extra_x_args, env=self.child_env) | 512 ] + extra_x_args, env=self.child_env) |
| 513 if not self.x_proc.pid: | 513 if not self.x_proc.pid: |
| 514 raise Exception("Could not start Xorg.") | 514 raise Exception("Could not start Xorg.") |
| 515 | 515 |
| 516 def _launch_x_server(self, extra_x_args): | 516 def _launch_x_server(self, extra_x_args): |
| 517 x_auth_file = os.path.expanduser("~/.Xauthority") | 517 x_auth_file = os.path.expanduser("~/.Xauthority") |
| 518 self.child_env["XAUTHORITY"] = x_auth_file | 518 self.child_env["XAUTHORITY"] = x_auth_file |
| 519 devnull = open(os.devnull, "r+") | 519 devnull = open(os.devnull, "r+") |
| 520 display = self.get_unused_display_number() | 520 display = self.get_unused_display_number() |
| 521 use_xorg = USE_XORG_ENV_VAR in os.environ | |
| 521 | 522 |
| 522 # Run "xauth add" with |child_env| so that it modifies the same XAUTHORITY | 523 # Run "xauth add" with |child_env| so that it modifies the same XAUTHORITY |
| 523 # file which will be used for the X session. | 524 # file which will be used for the X session. |
| 524 ret_code = subprocess.call("xauth add :%d . `mcookie`" % display, | 525 ret_code = subprocess.call("xauth add :%d . `mcookie`" % display, |
| 525 env=self.child_env, shell=True) | 526 env=self.child_env, shell=True) |
| 526 if ret_code != 0: | 527 if ret_code != 0: |
| 527 raise Exception("xauth failed with code %d" % ret_code) | 528 raise Exception("xauth failed with code %d" % ret_code) |
| 528 | 529 |
| 529 # Disable the Composite extension iff the X session is the default | 530 # Disable the Composite extension iff the X session is the default |
| 530 # Unity-2D, since it uses Metacity which fails to generate DAMAGE | 531 # Unity-2D, since it uses Metacity which fails to generate DAMAGE |
| 531 # notifications correctly. See crbug.com/166468. | 532 # notifications correctly. See crbug.com/166468. |
| 532 x_session = choose_x_session() | 533 x_session = choose_x_session() |
| 533 if (len(x_session) == 2 and | 534 if (len(x_session) == 2 and |
| 534 x_session[1] == "/usr/bin/gnome-session --session=ubuntu-2d"): | 535 x_session[1] == "/usr/bin/gnome-session --session=ubuntu-2d"): |
| 535 extra_x_args.extend(["-extension", "Composite"]) | 536 extra_x_args.extend(["-extension", "Composite"]) |
| 536 | 537 |
| 537 if USE_XORG_ENV_VAR in os.environ: | 538 if use_xorg: |
| 538 self._launch_xorg(display, x_auth_file, extra_x_args) | 539 self._launch_xorg(display, x_auth_file, extra_x_args) |
| 539 else: | 540 else: |
| 540 self._launch_xvfb(display, x_auth_file, extra_x_args) | 541 self._launch_xvfb(display, x_auth_file, extra_x_args) |
| 541 | 542 |
| 542 self.child_env["DISPLAY"] = ":%d" % display | 543 self.child_env["DISPLAY"] = ":%d" % display |
| 543 self.child_env["CHROME_REMOTE_DESKTOP_SESSION"] = "1" | 544 self.child_env["CHROME_REMOTE_DESKTOP_SESSION"] = "1" |
| 544 | 545 |
| 545 # Use a separate profile for any instances of Chrome that are started in | 546 # Use a separate profile for any instances of Chrome that are started in |
| 546 # the virtual session. Chrome doesn't support sharing a profile between | 547 # the virtual session. Chrome doesn't support sharing a profile between |
| 547 # multiple DISPLAYs, but Chrome Sync allows for a reasonable compromise. | 548 # multiple DISPLAYs, but Chrome Sync allows for a reasonable compromise. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 567 # starts configured to use the "base" ruleset, resulting in XKB configuring | 568 # starts configured to use the "base" ruleset, resulting in XKB configuring |
| 568 # for "xfree86" keycodes, and screwing up some keys. See crbug.com/119013. | 569 # for "xfree86" keycodes, and screwing up some keys. See crbug.com/119013. |
| 569 # Reconfigure the X server to use "evdev" keymap rules. The X server must | 570 # Reconfigure the X server to use "evdev" keymap rules. The X server must |
| 570 # be started with -noreset otherwise it'll reset as soon as the command | 571 # be started with -noreset otherwise it'll reset as soon as the command |
| 571 # completes, since there are no other X clients running yet. | 572 # completes, since there are no other X clients running yet. |
| 572 retcode = subprocess.call("setxkbmap -rules evdev", env=self.child_env, | 573 retcode = subprocess.call("setxkbmap -rules evdev", env=self.child_env, |
| 573 shell=True) | 574 shell=True) |
| 574 if retcode != 0: | 575 if retcode != 0: |
| 575 logging.error("Failed to set XKB to 'evdev'") | 576 logging.error("Failed to set XKB to 'evdev'") |
| 576 | 577 |
| 578 # Xorg+dummy will default to a resolution that is the maximum of all | |
| 579 # specified widths by the maximum of all the specified heights (which might | |
| 580 # even be a mode that wasn't specified by the user). Instead, we want to | |
| 581 # mimic the behavior we have with Xvfb, where the first size in the list is | |
| 582 # used as the initial size. Note: The session's settings daemon might change | |
| 583 # to a different resolution when it starts. | |
| 584 if use_xorg: | |
| 585 subprocess.call(["xrandr", "--size", "%dx%d" % self.sizes[0]], | |
| 586 env=self.child_env) | |
|
Lambros
2016/05/17 00:08:14
Should redirect stdout/stderr (as in the code belo
rkjnsn
2016/05/17 21:58:45
Is there a reason we wouldn't want an error messag
Lambros
2016/05/18 00:13:49
I suppressed the errors originally because Xvfb-ra
| |
| 587 | |
| 577 if not self.server_supports_exact_resize: | 588 if not self.server_supports_exact_resize: |
|
Lambros
2016/05/17 00:08:14
You currently set this to False for Xorg+dummy, wh
rkjnsn
2016/05/17 21:58:45
I agree that ‘server_supports_exact_resize’ probab
Lambros
2016/05/18 00:13:49
Sounds good.
| |
| 578 return | 589 return |
| 579 | 590 |
| 580 # Register the screen sizes if the X server's RANDR extension supports it. | 591 # Register the screen sizes if the X server's RANDR extension supports it. |
| 581 # Errors here are non-fatal; the X server will continue to run with the | 592 # Errors here are non-fatal; the X server will continue to run with the |
| 582 # dimensions from the "-screen" option. | 593 # dimensions from the "-screen" option. |
| 583 for width, height in self.sizes: | 594 for width, height in self.sizes: |
| 584 label = "%dx%d" % (width, height) | 595 label = "%dx%d" % (width, height) |
| 585 args = ["xrandr", "--newmode", label, "0", str(width), "0", "0", "0", | 596 args = ["xrandr", "--newmode", label, "0", str(width), "0", "0", "0", |
| 586 str(height), "0", "0", "0"] | 597 str(height), "0", "0", "0"] |
| 587 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) | 598 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1518 else: | 1529 else: |
| 1519 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) | 1530 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) |
| 1520 elif os.WIFSIGNALED(status): | 1531 elif os.WIFSIGNALED(status): |
| 1521 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) | 1532 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) |
| 1522 | 1533 |
| 1523 | 1534 |
| 1524 if __name__ == "__main__": | 1535 if __name__ == "__main__": |
| 1525 logging.basicConfig(level=logging.DEBUG, | 1536 logging.basicConfig(level=logging.DEBUG, |
| 1526 format="%(asctime)s:%(levelname)s:%(message)s") | 1537 format="%(asctime)s:%(levelname)s:%(message)s") |
| 1527 sys.exit(main()) | 1538 sys.exit(main()) |
| OLD | NEW |