Hello!
I am trying to debug subtle mouse-related bugs in one of my projects
(SciTECO). I wrote a small test program (see attachment). To my surprise
for every KEY_MOUSE you actually may have to call getmouse() repeatedly -
this was not obvious from curs_mouse(3X). In XTerm 400
(TERM=xterm-256color) and simpleterm (st) the middle mouse button click
generates a BUTTON2_RELEASED, followed by a BUTTON2_PRESSED event.
Sometimes it's the other way around. With vttest I can confirm that the
escape sequence for the PRESSED event is actually always sent *before* the
RELEASED event. My version of ncurses is 6.5 (from FreeBSD ports). I do
not get PRESSED and RELEASED events separated in time like for the left
and right buttons, i.e. both events are received only when releasing the
middle mouse button.
Can you reproduce these issues?
I have another problem that in my app horizontal scrolls generate
unexpected BUTTON3_PRESSED events in XTerm and GNOME Console, but I cannot
yet reproduce this with my test program.
Yours sincerely,
Robin Haberkorn
--
@ii._._.*.._+__.+_+.+...+.+.++..+*+.+._.+...*_*.*.__+__._._.++..+_*.++__+__
.+_..*...+.+_+__.+._.+...*_+_+__._ ...*_ +.+._.+.._+*+_+__._._ .+_..+.+***_
. *_+_+__.+.*.++..+_+.*.__+_ _.+...*_*_+__.++*.+...++..+* +.+.._+__._+_.+..
.++..+*_.*...+*+.+.*_ +*+i2^rj.u#__%uu#_.%uu#_+%uu#_*!+!0a"t1010^t^c^c'0a^#
1010"=d'0a-100000"=d'0auuqq*100+q[_^euu]uq-rq:^/100@oo,+,+,+oqq^t0uq@o*+*!!
#include <curses.h>
#include <strings.h>
#define BUTTON_NUM(X) \
(BUTTON##X##_PRESSED | BUTTON##X##_RELEASED | \
BUTTON##X##_CLICKED | BUTTON##X##_DOUBLE_CLICKED |
BUTTON##X##_TRIPLE_CLICKED)
#define BUTTON_EVENT(X) \
(BUTTON1_##X | BUTTON2_##X | BUTTON3_##X | BUTTON4_##X | BUTTON5_##X)
int main(void)
{
initscr();
raw();
noecho();
scrollok(stdscr, TRUE);
keypad(stdscr, TRUE);
mouseinterval(0);
mousemask(BUTTON_EVENT(PRESSED) | BUTTON_EVENT(RELEASED) /*|
REPORT_MOUSE_POSITION*/, NULL);
for (;;) {
MEVENT event;
int c = wgetch(stdscr);
if (c == '\e')
break;
if (c != KEY_MOUSE)
continue;
while (getmouse(&event) == OK) {
printw("EVENT: 0x%016X == %02d [%c%c%c%c%c]\n",
event.bstate, ffs(event.bstate)-1,
event.bstate & BUTTON_NUM(4) ? 'U' : ' ',
event.bstate & BUTTON_NUM(5) ? 'D' : ' ',
event.bstate & BUTTON_EVENT(PRESSED) ? 'P' : ' ',
event.bstate & BUTTON_EVENT(RELEASED) ? 'R' : '
',
event.bstate & REPORT_MOUSE_POSITION ? 'M' : '
');
}
}
endwin();
return 0;
}