#73 mapping keys that unfocus the window

This commit is contained in:
sezanzeb 2021-03-27 08:10:14 +01:00
parent c22d56f9af
commit 50c9730c8b
3 changed files with 7 additions and 15 deletions

View File

@ -292,7 +292,6 @@ class Row(Gtk.ListBoxRow):
self.show_click_here()
self.keycode_input.set_active(False)
self._state = IDLE
reader.clear()
self.window.save_preset()
def set_keycode_input_label(self, label):
@ -305,6 +304,7 @@ class Row(Gtk.ListBoxRow):
label.set_line_wrap_mode(2)
label.set_max_width_chars(13)
label.set_justify(Gtk.Justification.CENTER)
self.keycode_input.set_opacity(1)
def put_together(self, character):
"""Create all child GTK widgets and connect their signals."""

View File

@ -554,24 +554,15 @@ class TestIntegration(unittest.TestCase):
def test_clears_unreleased_on_focus_change(self):
ev_1 = Key(EV_KEY, 41, 1)
rows = self.get_rows()
row = rows[-1]
# focused
self.window.window.set_focus(row.keycode_input)
# focus
self.window.window.set_focus(self.get_rows()[0].keycode_input)
send_event_to_reader(new_event(*ev_1.keys[0]))
reader.read()
self.assertEqual(reader.get_unreleased_keys(), ev_1)
# unfocused
self.window.window.set_focus(None)
self.assertEqual(reader.get_unreleased_keys(), None)
send_event_to_reader(new_event(*ev_1.keys[0]))
reader.read()
self.assertEqual(reader.get_unreleased_keys(), ev_1)
# focus back
self.window.window.set_focus(row.keycode_input)
# focus different row
self.window.add_empty()
self.window.window.set_focus(self.get_rows()[1].keycode_input)
self.assertEqual(reader.get_unreleased_keys(), None)
def test_rows(self):

View File

@ -490,6 +490,7 @@ class TestReader(unittest.TestCase):
reader.terminate()
reader.clear()
time.sleep(EVENT_READ_TIMEOUT)
# no new events arrive after terminating
push_events('device 1', [new_event(EV_KEY, CODE_3, 1)])