Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-03-20 20:42:52 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-03-20 21:11:55 (GMT)
commitb869a952391958afac2c908faa8940854474532b (patch)
tree92cfbe86b7aa5f4a780164605368116e9138dc50
parent4d939f2de5737108fbda249c67f3cb6eedb85f15 (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-xdraw_piano.py6
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: