From b869a952391958afac2c908faa8940854474532b Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 20 Mar 2013 20:42:52 +0000 Subject: 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 --- 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: -- cgit v0.9.1