def get_image(self, x, y, width, height, logger=None): try: start = time.time() with xsync: if USE_XSHM: log("X11 shadow get_image, xshm=%s", self.xshm) if self.xshm is None: self.xshm = XImage.get_XShmWrapper( get_xwindow(self.window)) self.xshm.setup() if self.xshm: image = self.xshm.get_image(get_xwindow(self.window), x, y, width, height) #discard to ensure we will call XShmGetImage next time around self.xshm.discard() return image #fallback to gtk capture: return GTKRootWindowModel.get_image(self, x, y, width, height, logger) except Exception as e: log.warn("Warning: failed to capture root window pixels:") log.warn(" %s", e) #cleanup and hope for the best! self.cleanup() finally: end = time.time() log("X11 shadow captured %s pixels at %i MPixels/s using %s", width * height, (width * height / (end - start)) // 1024 // 1024, ["GTK", "XSHM"][USE_XSHM])
def get_image(self, x, y, width, height, logger=None): try: start = time.time() with xsync: if USE_XSHM: log("X11 shadow get_image, xshm=%s", self.xshm) if self.xshm is None: self.xshm = XImage.get_XShmWrapper(get_xwindow(self.window)) self.xshm.setup() if self.xshm: image = self.xshm.get_image(get_xwindow(self.window), x, y, width, height) #discard to ensure we will call XShmGetImage next time around self.xshm.discard() return image #fallback to gtk capture: return GTKRootWindowModel.get_image(self, x, y, width, height, logger) except Exception as e: log.warn("Warning: failed to capture root window pixels:") log.warn(" %s", e) #cleanup and hope for the best! self.cleanup() finally: end = time.time() log("X11 shadow captured %s pixels at %i MPixels/s using %s", width*height, (width*height/(end-start))//1024//1024, ["GTK", "XSHM"][USE_XSHM])
def get_image(self, x, y, width, height): return GTKRootWindowModel.get_image(self.root_window_model, x, y, width, height)