예제 #1
0
def get_window_attributes(window: Wnck.Window):
    window_dir = dir(window)
    attributes = []
    if "get_application" in window_dir and "get_name" in dir(
            window.get_application()):
        attributes.append(("application", window.get_application().get_name()))
    if "get_name" in window_dir:
        attributes.append(("name", window.get_name()))
    if "get_class_group_name" in window_dir:
        attributes.append(("class_group", window.get_class_group_name()))
    if "get_class_instance_name" in window_dir:
        attributes.append(("class_instance", window.get_class_instance_name()))
    if "get_icon_name" in window_dir:
        attributes.append(("icon", window.get_icon_name()))
    return dict(attributes)
예제 #2
0
    def get_window_meta(window: Wnck.Window, state: Dict[str, Any],
                        winman: WindowManager) -> bool:
        """Gather information about ``window`` to pass to the command

        :param window: The window to inspect.
        :param state: The metadata dict to :meth:`dict.update` with gathered
            values.
        :returns: A boolean indicating success or failure.

        .. todo:: Is the MPlayer safety hack in :meth:`get_window_meta` still
            necessary with the refactored window-handling code?
        .. todo:: Can the :func:`logging.debug` call in :meth:`get_window_meta`
            be reworked to call :meth:`Wnck.Window.get_name` lazily?
        """
        # Bail out early on None or things like the desktop window
        if not winman.is_relevant(window):
            return False

        win_rect = Rectangle(*window.get_geometry())
        logging.debug(
            "Operating on window %r with title \"%s\" "
            "and geometry %r", window, window.get_name(), win_rect)

        monitor_id, monitor_geom = winman.get_monitor(window)

        # MPlayer safety hack
        if not winman.usable_region:
            logging.debug(
                "Received a worthless value for largest "
                "rectangular subset of desktop (%r). Doing "
                "nothing.", winman.usable_region)
            return False

        state.update({
            "monitor_id": monitor_id,
            "monitor_geom": monitor_geom,
        })
        return True
예제 #3
0
파일: view.py 프로젝트: J-Arun-Mani/Scream
    def add_window(self, window: Wnck.Window):

        combobox = self.get("windows-combobox")
        name = window.get_name()
        combobox.append_text(name)
        self.windows[name] = window