bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue with mouse event reporting (ncurses 6.2 and 6.3)


From: Anton Vidovic
Subject: Issue with mouse event reporting (ncurses 6.2 and 6.3)
Date: Mon, 3 Jan 2022 22:13:06 +0100

Hello Thomas,

while testing Lisp bindings to ncurses mouse functions (with
NCURSES_MOUSE_VERSION 2), an user reported the following ncurses bug:

When the only event registered with mousemask is
BUTTON1_DOUBLE_CLICKED, the events BUTTON1_PRESSED and
BUTTON1_RELEASED, which are not registered, are reported, and the
registered event BUTTON1_DOUBLE_CLICKED is not reported.

The only way to make getch report BUTTON1_DOUBLE_CLICKED is to also
register BUTTON1_CLICKED. In that case, both of them are reported, but
BUTTON1_PRESSED and BUTTON1_RELEASED are still also reported, even
though they are not registered.

This seems to be an issue with ncurses, tested with the release version
of ncurses 6.3 and 6.2, and this would be a minimal example:

#include <curses.h>
int main() {
    MEVENT ev;
    initscr();
    clear();
    noecho();
    cbreak();
    keypad(stdscr, TRUE);
    mousemask(BUTTON1_DOUBLE_CLICKED, NULL);
    bool end = false;
    while(!end) {
        int c = getch();
        switch(c) {
        case 'q':
            end = true;
            break;
        case KEY_MOUSE:
            if(getmouse(&ev) == OK) {
                printw("x: %d, y: %d, ", ev.x, ev.y);
                if(ev.bstate & BUTTON1_PRESSED)
                    printw("BUTTON1_PRESSED\n");
                if(ev.bstate & BUTTON1_RELEASED)
                    printw("BUTTON1_RELEASED\n");
                if(ev.bstate & BUTTON1_CLICKED)
                    printw("BUTTON1_CLICKED\n");
                if(ev.bstate & BUTTON1_DOUBLE_CLICKED)
                    printw("BUTTON1_DOUBLE_CLICKED\n");
                if(ev.bstate & BUTTON1_TRIPLE_CLICKED)
                    printw("BUTTON1_TRIPLE_CLICKED\n");
            }
            break;
        }
    }
    clrtoeol();
    refresh();
    endwin();
}

I hope you can find an opportunity to look into this.

Kind regards,
Anton




reply via email to

[Prev in Thread] Current Thread [Next in Thread]