diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2013-03-20 20:42:52 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-03-20 21:11:55 (GMT) |
commit | b869a952391958afac2c908faa8940854474532b (patch) | |
tree | 92cfbe86b7aa5f4a780164605368116e9138dc50 | |
parent | 4d939f2de5737108fbda249c67f3cb6eedb85f15 (diff) |
Delay the processing of button release events
This is needed because at times, a mousemove event came after
the button release event, and the virtual keys states
are confused.
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rwxr-xr-x | draw_piano.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/draw_piano.py b/draw_piano.py index 5c1fbfb..93ae6b0 100755 --- a/draw_piano.py +++ b/draw_piano.py @@ -124,7 +124,10 @@ class PianoKeyboard(Gtk.DrawingArea): elif event.type in (Gdk.EventType.TOUCH_END, Gdk.EventType.BUTTON_RELEASE): del self._touches[seq] - updated_positions = True + # execute the update pressed keys with a delay, + # because motion events can came after the button release + # and all the state is confused + GObject.timeout_add(10, self._update_pressed_keys, old_touches) if updated_positions: self._update_pressed_keys(old_touches) @@ -165,7 +168,6 @@ class PianoKeyboard(Gtk.DrawingArea): min_x = self._width max_x = 0 for touch in uniq_touches: - logging.error('TOUCH %s %s', touch.__class__, touch) min_x_touch, max_x_touch = \ self.get_damaged_range(int(touch[0]), int(touch[1])) if min_x_touch < min_x: |