Use ignore_event attribute on events

This commit is contained in:
jakanakae-envangel 2018-03-13 18:24:55 +01:00 committed by brightonanc
parent 33ffac658f
commit 7882371958
1 changed files with 6 additions and 5 deletions

View File

@ -142,7 +142,6 @@ class PassthroughKeyParser(CommandKeyParser):
Attributes:
_mode: The mode this keyparser is for.
_orig_sequence: Current sequence with no key_mappings applied.
_ignore_next_key: Whether to pass the next key through.
"""
do_log = False
@ -160,7 +159,6 @@ class PassthroughKeyParser(CommandKeyParser):
self._read_config(mode)
self._orig_sequence = keyutils.KeySequence()
self._mode = mode
self._ignore_next_key = False
def __repr__(self):
return utils.get_repr(self, mode=self._mode)
@ -176,8 +174,8 @@ class PassthroughKeyParser(CommandKeyParser):
Return:
A self.Match member.
"""
if keyutils.is_modifier_key(e.key()) or self._ignore_next_key:
self._ignore_next_key = self._ignore_next_key and dry_run
if (keyutils.is_modifier_key(e.key()) or
getattr(e, "ignore_event", False)):
return QKeySequence.NoMatch
orig_sequence = self._orig_sequence.append_event(e)
@ -193,9 +191,12 @@ class PassthroughKeyParser(CommandKeyParser):
if window is None:
return match
self._ignore_next_key = True
first = True
for keyinfo in orig_sequence:
press_event = keyinfo.to_event(QEvent.KeyPress)
if first:
press_event.ignore_event = True
first = False
release_event = keyinfo.to_event(QEvent.KeyRelease)
QApplication.postEvent(window, press_event)
QApplication.postEvent(window, release_event)