Exemplo n.º 1
0
    def maybe_handle_event(self, event):
        if event.type != Gdk.EventType.KEY_PRESS:
            return False

        filtered_state = Gdk.ModifierType(
            event.state
            & ~(Gdk.ModifierType.MOD2_MASK | Gdk.ModifierType.LOCK_MASK))

        if filtered_state == 0 and event.keyval == Gdk.KEY_Escape:
            if status.Awake:
                self.manager.cancel_unlock_widget()
                return True

        if status.Awake:
            if (event.keyval in (Gdk.KEY_Tab, Gdk.KEY_ISO_Left_Tab)):
                if event.keyval == Gdk.KEY_ISO_Left_Tab:
                    self.manager.propagate_tab_event(True)
                else:
                    self.manager.propagate_tab_event(False)
                return True
            elif filtered_state == 0 and (event.keyval in (Gdk.KEY_Return,
                                                           Gdk.KEY_KP_Enter)):
                self.manager.propagate_activation()
                return True
            elif event.keyval == Gdk.KEY_space and isinstance(
                    self.manager.get_focused_widget(), Gtk.Button):
                self.manager.propagate_activation()
                return True

        if settings.get_allow_shortcuts():
            for entry in self.shortcut_actions:
                res = entry.activate(event.keyval, event.hardware_keycode,
                                     filtered_state)

                if res == -1:
                    continue
                else:
                    self.client.handle_keybinding(res)
                    return True

        return False
Exemplo n.º 2
0
    def maybe_handle_event(self, event):
        if event.type != Gdk.EventType.KEY_PRESS:
            return False

        filtered_state = Gdk.ModifierType(event.state & ~(Gdk.ModifierType.MOD2_MASK | Gdk.ModifierType.LOCK_MASK))

        if filtered_state == 0 and event.keyval == Gdk.KEY_Escape:
            if status.Awake:
                self.manager.cancel_unlock_widget()
                return True

        if event.keyval == Gdk.KEY_Menu:
            return True

        if status.Awake:
            if (event.keyval in (Gdk.KEY_Tab, Gdk.KEY_ISO_Left_Tab)):
                if event.keyval == Gdk.KEY_ISO_Left_Tab:
                    self.manager.propagate_tab_event(True)
                else:
                    self.manager.propagate_tab_event(False)
                return True
            elif event.keyval == Gdk.KEY_space and isinstance(self.manager.get_focused_widget(), Gtk.Button):
                self.manager.propagate_activation()
                return True

        if settings.get_allow_shortcuts():
            for entry in self.shortcut_actions:
                res = entry.activate(event.keyval, event.hardware_keycode, filtered_state)

                if res == -1:
                    continue
                else:
                    self.client.handle_keybinding(res)
                    return True

        return False