diff -r db2eab0beb45 -r cfd3445107b4 tuikit/driver_curses.py --- a/tuikit/driver_curses.py Sun Jan 27 23:51:59 2013 +0100 +++ b/tuikit/driver_curses.py Wed Jan 30 00:38:48 2013 +0100 @@ -318,8 +318,11 @@ if bstate & curses.REPORT_MOUSE_POSITION: if self._mouse_last_pos != (x, y): + if self._mouse_last_pos[0] is not None: + relx = x - (self._mouse_last_pos[0] or 0) + rely = y - (self._mouse_last_pos[1] or 0) + out += [('mousemove', 0, x, y, relx, rely)] self._mouse_last_pos = (x, y) - out += [('mousemove', x, y)] # we are interested only in changes, not buttons already pressed before event if self._mouse_last_bstate is not None: @@ -331,17 +334,17 @@ self._mouse_last_bstate = bstate if bstate & curses.BUTTON1_PRESSED: - out += [('mousedown', x, y, 1)] + out += [('mousedown', 1, x, y)] if bstate & curses.BUTTON2_PRESSED: - out += [('mousedown', x, y, 2)] + out += [('mousedown', 2, x, y)] if bstate & curses.BUTTON3_PRESSED: - out += [('mousedown', x, y, 3)] + out += [('mousedown', 3, x, y)] if bstate & curses.BUTTON1_RELEASED: - out += [('mouseup', x, y, 1)] + out += [('mouseup', 1, x, y)] if bstate & curses.BUTTON2_RELEASED: - out += [('mouseup', x, y, 2)] + out += [('mouseup', 2, x, y)] if bstate & curses.BUTTON3_RELEASED: - out += [('mouseup', x, y, 3)] + out += [('mouseup', 3, x, y)] # reset last pos when pressed/released if len(out) > 0 and out[-1][0] in ('mousedown', 'mouseup'): @@ -432,26 +435,30 @@ out = [] - if t in (0x20, 0x21, 0x22): # button press + if t in (0x20, 0x21, 0x22): + # button press btn = t - 0x1f if not btn in self.mbtnstack: self.mbtnstack.append(btn) self._mouse_last_pos = (None, None) - out += [('mousedown', x, y, btn)] + out += [('mousedown', btn, x, y)] else: + # mouse move if self._mouse_last_pos != (x, y): + if self._mouse_last_pos[0] is not None: + relx = x - self._mouse_last_pos[0] + rely = y - self._mouse_last_pos[1] + out += [('mousemove', btn, x, y, relx, rely)] self._mouse_last_pos = (x, y) - out += [('mousemove', x, y, btn)] - - elif t == 0x23: # button release + elif t == 0x23: + # button release btn = self.mbtnstack.pop() self._mouse_last_pos = (None, None) - out += [('mouseup', x, y, btn)] - - elif t in (0x60, 0x61): # wheel up, down + out += [('mouseup', btn, x, y)] + elif t in (0x60, 0x61): + # wheel up, down btn = 4 + t - 0x60 - out += [('mousewheel', x, y, btn)] - + out += [('mousewheel', btn, x, y)] else: raise Exception('Unknown mouse event: %x' % t)