Subject: Re: bug#17378: 24.3.1: xterm-mouse-event: Wrong type argument: wholenump, -6

From: Stefan Monnier <[email-masked]>
Date: Wed, 07 May 2014 21:15:43 -0400

> Nice analysis!  I did scroll-down first, then scroll-up.  I'll do it again,
> this time typing '1', '2', etc. before each action, for clarity.

Good idea, thanks.

> C-x 3
> ESC [ M SPC \337 =
> ESC [ M # \337 =
> 1
> ESC [ M SPC \337 =
> ESC [ M # \337 =
> 2
> ESC [ M ! \337 =
> ESC [ M # \337 =
> 3
> ESC [ M " \337 =
> ESC [ M # \337 =

Looks all normal.

> 4
> ESC [ M a \337 =
> ESC [ M a \337 =
> ESC [ M a \337 =

So, while you think this should generate a mouse-4 event (aka
"wheel-up"), this will generate mouse-5 events (aka "wheel-down"),
instead.  Do you indeed see that it scrolls in the wrong direction?

> 5
> ESC [ M = ESC [
> ESC [ M = ESC [

Hmm... so these weird entries are for the mouse-5 events?
At least now we know what they look like: the ?? is the second part of
the position.  Which means that this can look like another mouse-N event.

> ESC [ M =
> m o v e

Hmmm.... what was that?  Where did the "ESC [" go?
Did you type "move" or just "ve"?

> 1
> ESC [ M SPC \362 2
> ESC [ M # \362 2
> 2
> ESC [ M ! \362 2
> ESC [ M # \362 2
> 3
> ESC [ M " \362 2
> ESC [ M # \362 2

Again, this looks normal.

> 4
> ESC [ M a \362 2
> ESC [ M # \362 2
> ESC [ M a \362 2
> ESC [ M a \362 2

But here we have a "spurious up-mouse" event in between.  So we should
try and ignore them.

> 5
> ESC [ M 2 ESC [
> ESC [ M 2 ESC [
> ESC [ M 2 ESC [
> ESC [ M 2 ESC [
> ESC [ M 2 ESC [
> ESC [ M 2 ESC [

And here, again the "ESC [ M ?? ESC [" form for the mouse-5.
I don't think there's much hope to support this mouse-5 click format.
Looks like a bug somewhere in the terminal (or something stacked in
between, like screen/pmux).

        Stefan