Esempio n. 1
0
    def _config_allows_flash(self, window: Window, rule: Dict) -> bool:
        """Check whether a config parameter disallows a window from flashing.

        Returns
        -------
        If window should be flashed, this function returns True, else False.

        """
        if self.track_workspaces:
            self.prev_workspace = self.current_workspace
            self.current_workspace = get_focused_workspace()

        if not rule.get("flash_on_focus"):
            logging.debug(
                f"flash_on_focus is False for window {window.id}, ignoring...")
            return False

        if rule.get("flash_lone_windows") != "always":
            if len(list_mapped_windows(self.current_workspace)) < 2:
                if (rule.get("flash_lone_windows") == "never" or
                    (self.current_workspace != self.prev_workspace
                     and rule.get("flash_lone_windows") == "on_open_close") or
                    (self.current_workspace == self.prev_workspace
                     and rule.get("flash_lone_windows") == "on_switch")):
                    logging.debug(
                        "Current workspace has <2 windows, ignoring...")
                    return False

        if rule.get("flash_fullscreen") is not True:
            if window.is_fullscreen():
                logging.debug("Window is fullscreen, ignoring...")
                return False

        return True
Esempio n. 2
0
 def shutdown(self, disconnect_from_wm: bool = True) -> None:
     """Cleanup after recieving a SIGINT."""
     self.keep_going = False
     self._kill_producers()
     logging.info("Resetting windows to full opacity...")
     for window in list_mapped_windows():
         window.set_opacity(1)
     if disconnect_from_wm:
         logging.info("Disconnecting from display server...")
         disconnect_display_conn()
Esempio n. 3
0
 def __init__(self, num_windows: int = 2) -> None:
     wm_names = ["window" + str(i) for i in range(1, num_windows + 1)]
     wm_classes = zip(wm_names, [name.capitalize() for name in wm_names])
     clear_desktops()
     self.windows = [
         create_blank_window(wm_name, wm_class)
         for wm_name, wm_class in zip(wm_names, wm_classes)
     ]
     # Wait for all of the windows to be mapped
     for window in self.windows:
         while window not in list_mapped_windows():
             pass
     change_focus(self.windows[0])
     # Wait for the focus to actually change
     while get_focused_window() != self.windows[0]:
         pass
Esempio n. 4
0
def test_list_mapped_windows(windows):
    assert list_mapped_windows(0) == windows
    assert list_mapped_windows(2) == list()
Esempio n. 5
0
def clear_workspace(workspace: int) -> None:
    for window in list_mapped_windows(workspace):
        try:
            window.destroy()
        except WMError:
            pass
Esempio n. 6
0
 def _set_all_window_opacity_to_default(self) -> None:
     logging.info("Setting all windows to their default opacity...")
     for window in list_mapped_windows():
         self.router.route_request(
             WMEvent(window=window, event_type=WMEventType.WINDOW_INIT))