class hw: def __init__(self): self.logger = logging.getLogger("Prefs-HW") self.logger.debug("Getting hardware specs") self.screens = None self.combined_screen = None self.webcam = Webcam() self.get_screens() self.get_webcams() def get_current_screen(self, window=None): try: if window: screen = self.default_screen.get_monitor_at_window(window.get_window()) else: disp = GdkX11.X11Display.get_default() dm = Gdk.Display.get_device_manager(disp) pntr_device = dm.get_client_pointer() (src, x, y) = pntr_device.get_position() screen = self.default_screen.get_monitor_at_point(x, y) except: screen = 0 return screen def get_screens(self): try: self.logger.debug("Getting Video sources.") self.screens = [] self.default_screen = Gdk.Screen.get_default() self.logger.debug("Found {0} monitor(s).".format(self.default_screen.get_n_monitors())) for i in range(self.default_screen.get_n_monitors()): rect = self.default_screen.get_monitor_geometry(i) self.logger.debug(" Monitor {0} - X: {1}, Y: {2}, W: {3}, H: {4}".format(i, rect.x, rect.y, rect.width, rect.height)) self.screens.append({"x": rect.x, "y": rect.y, "width": rect.width, "height": rect.height}) if self.default_screen.get_n_monitors() > 1: self.combined_screen = {"x": 0, "y": 0, "width": self.default_screen.get_width(), "height": self.default_screen.get_height()} self.logger.debug(" Combined - X: 0, Y: 0, W: {0}, H: {1}".format(self.default_screen.get_width(), self.default_screen.get_height())) else: self.combined_screen = None except: self.logger.warning("Unable to find any video sources.") def get_webcams(self): self.webcam.detect()
def __init__(self): self.logger = logging.getLogger("Prefs-HW") self.logger.debug("Getting hardware specs") self.screens = None self.combined_screen = None self.webcam = Webcam() self.get_screens() self.get_webcams()