示例#1
0
def test_flash_window(flasher, window, pre_opacity):
    if pre_opacity:
        xutil.set_opacity(window, pre_opacity)
    expected_opacity = ([pre_opacity] +
                        flasher.compute_flash_series(pre_opacity) +
                        [pre_opacity])
    # WindowWatcher collapses runs of the same value
    if all(x == expected_opacity[0] for x in expected_opacity):
        expected_opacity = [expected_opacity[0]]
    watcher = WindowWatcher(window)
    watcher.start()
    flasher.flash_window(window)
    assert watcher.report() == approx(expected_opacity, 0.01)
示例#2
0
    def _handle_property_change(self, event):
        """Handle a property change on a watched window."""
        atom_name = get_atom_name(event.atom)
        if atom_name == "_NET_ACTIVE_WINDOW":
            focused_window = get_active_window().reply()
            logging.info("Focus shifted to %s", focused_window)

            try:
                set_opacity(focused_window,
                            flashfocus.ui.CONFIG['flash_opacity'])
            except:
                pass

            self.queue_window(focused_window, "focus_shift")
        elif atom_name == "WM_NAME" and event.window == self.message_window:
            # Received kill signal from server -> terminate the thread
            self.keep_going = False
示例#3
0
    def flash_window(self, window):
        """Briefly change the opacity of a Xorg window."""
        log('Flashing window %s', str(window))
        try:
            pre_flash_opacity = xutil.request_opacity(window).unpack()

            log('Current opacity = %s', str(pre_flash_opacity))
            log('Beginning flash animation...')
            flash_series = self.compute_flash_series(pre_flash_opacity)
            for opacity in flash_series:
                xutil.set_opacity(window, opacity)
                sleep(self.timechunk)
            log('Resetting opacity to default')
            if pre_flash_opacity:
                xutil.set_opacity(window, pre_flash_opacity)
            else:
                xutil.delete_opacity(window)
        except WindowError:
            log('Attempted to flash a nonexistant window %s, ignoring...',
                str(window))
        log('Unlocking window %s', window)
        self.locked_windows.discard(window)
示例#4
0
    def _flash(self, window):
        """Flash a window.

        This function just iterates across `self.flash_series` and modifies the
        window opacity accordingly. It waits `self.timechunk` between
        modifications.
        """
        try:
            self.progress[window] = 0
            while self.progress[window] < self.ntimepoints:
                target_opacity = self.flash_series[self.progress[window]]
                set_opacity(window, target_opacity)
                sleep(self.timechunk)
                self.progress[window] += 1

            logging.info("Resetting window %s opacity to default", window)
            set_opacity(window, self.default_opacity)

        except WindowError:
            logging.info(
                "Attempted to draw to nonexistant window %s, ignoring...",
                str(window))
        finally:
            del self.progress[window]
示例#5
0
def test_get_set_opacity(window):
    assert not xutil.request_opacity(window).unpack()
    xutil.set_opacity(window, 0.5)
    assert xutil.request_opacity(window).unpack() == approx(0.5, 0.00001)
示例#6
0
def test_delete_opacity(window):
    xutil.set_opacity(window, 0.5)
    assert xutil.request_opacity(window).unpack()
    xutil.delete_opacity(window)
    assert not xutil.request_opacity(window).unpack()