Don't break keybinding service when we get an unexpected event

(onscreen keyboard)
This commit is contained in:
Michael Webster 2013-05-20 21:37:21 -04:00
parent 9f8f76b0eb
commit bc514d1c8c

View File

@ -132,21 +132,24 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread):
wait_for_release = False wait_for_release = False
while self.running: while self.running:
event = self.display.next_event() event = self.display.next_event()
self.current_event_time = event.time try:
if event.detail == self.keycode and event.type == X.KeyPress and not wait_for_release: self.current_event_time = event.time
modifiers = event.state & self.known_modifiers_mask if event.detail == self.keycode and event.type == X.KeyPress and not wait_for_release:
if modifiers == self.modifiers: modifiers = event.state & self.known_modifiers_mask
wait_for_release = True if modifiers == self.modifiers:
wait_for_release = True
self.display.allow_events(X.AsyncKeyboard, event.time)
else:
self.display.allow_events(X.ReplayKeyboard, event.time)
elif event.detail == self.keycode and wait_for_release:
if event.type == X.KeyRelease:
wait_for_release = False
GLib.idle_add(self.idle)
self.display.allow_events(X.AsyncKeyboard, event.time) self.display.allow_events(X.AsyncKeyboard, event.time)
else: else:
self.display.allow_events(X.ReplayKeyboard, event.time) self.display.allow_events(X.ReplayKeyboard, event.time)
elif event.detail == self.keycode and wait_for_release: except AttributeError:
if event.type == X.KeyRelease: continue
wait_for_release = False
GLib.idle_add(self.idle)
self.display.allow_events(X.AsyncKeyboard, event.time)
else:
self.display.allow_events(X.ReplayKeyboard, event.time)
def stop(self): def stop(self):
self.running = False self.running = False