Пример #1
0
 def makeRootWindowModels(self):
     log("makeRootWindowModels() root=%s", self.root)
     self.capture = self.setup_capture()
     if not MULTI_WINDOW:
         return (RootWindowModel(self.root, self.capture), )
     models = []
     screen = self.root.get_screen()
     n = screen.get_n_monitors()
     for i in range(n):
         geom = screen.get_monitor_geometry(i)
         x, y, width, height = geom.x, geom.y, geom.width, geom.height
         try:
             scale_factor = screen.get_monitor_scale_factor(i)
         except Exception as e:
             screenlog("no scale factor: %s", e)
         else:
             screenlog("scale factor for monitor %i: %i", i, scale_factor)
         model = RootWindowModel(self.root, self.capture)
         if hasattr(screen, "get_monitor_plug_name"):
             plug_name = screen.get_monitor_plug_name(i)
             if plug_name or n > 1:
                 model.title = plug_name or str(i)
         model.geometry = (x, y, width, height)
         screenlog("monitor %i: %10s geometry=%s", i,
                   model.get_property("title"),
                   model.get_property("geometry"))
         models.append(model)
     log("makeRootWindowModels()=%s", models)
     return models
Пример #2
0
    def test_root_window_model(self):
        from xpra.server.shadow.root_window_model import RootWindowModel
        W = 640
        H = 480

        class FakeDisplay:
            def get_name(self):
                return "fake-display"

        class FakeScreen:
            def get_display(self):
                return FakeDisplay()

        class FakeRootWindow:
            def get_screen(self):
                return FakeScreen()

            def get_geometry(self):
                return (0, 0, W, H)

        class FakeCapture:
            def take_screenshot(self):
                return self.get_image(0, 0, W, H)

            def get_image(self, x, y, w, h):
                pixels = "0" * w * 4 * h
                return ImageWrapper(x, y, w, h, pixels, "BGRA", 32, w * 4, 4,
                                    ImageWrapper.PACKED, True, None)

            def get_info(self):
                return {"type": "fake"}

        window = FakeRootWindow()
        rwm = RootWindowModel(window, FakeCapture())
        assert repr(rwm)
        assert rwm.get_info()
        rwm.get_default_window_icon(32)
        for prop in ("title", "class-instance", "size-hints", "icons"):
            rwm.get_property(prop)
        for prop, value in {
                "client-machine": socket.gethostname(),
                "window-type": ["NORMAL"],
                "fullscreen": False,
                "shadow": True,
                "depth": 24,
                "scaling": None,
                "opacity": None,
                "content-type": "desktop",
        }.items():
            assert rwm.get_property(prop) == value
        rwm.suspend()
        rwm.unmanage(True)
        assert rwm.take_screenshot()
        assert rwm.get_image(10, 10, 20, 20)
        rwm.geometry = (10, 10, W, H)
        img = rwm.get_image(10, 10, 20, 20)
        assert img.get_target_x() == 10
        assert img.get_target_y() == 10
Пример #3
0
 def makeRootWindowModels(self):
     log("makeRootWindowModels() root=%s", self.root)
     self.capture = self.setup_capture()
     if not MULTI_WINDOW:
         return (RootWindowModel(self.root, self.capture),)
     models = []
     monitors = get_monitors()
     for i, monitor in enumerate(monitors):
         geom = monitor["Monitor"]
         x1, y1, x2, y2 = geom
         assert x1<x2 and y1<y2
         model = RootWindowModel(self.root, self.capture)
         model.title = monitor["Device"].lstrip("\\\\.\\")
         model.geometry = x1, y1, x2-x1, y2-y1
         screenlog("monitor %i: %10s geometry=%s (from %s)", i, model.title, model.geometry, geom)
         models.append(model)
         screenlog("makeRootWindowModels: model(%s)=%s", monitor, model)
     log("makeRootWindowModels()=%s", models)
     return models