[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mouse movement - no events?
From: |
Hohl, Gerrit |
Subject: |
Mouse movement - no events? |
Date: |
Fri, 13 Mar 2015 14:34:33 +0100 |
Hello everyone,
I don't know if it is a bug or just me having the wrong expectations.
I've written the following small program. I get keyboard key events as
well as resize events. I also get mouse key events (after I installed
the GPM package in my Ubuntu 14). But I don't get any events about mouse
movements.
I've seen that there is a REPORT_MOUSE_POSITION constant / macro. So I
guess there must be a way also to get these events.
What am I doing wrong? Or is my expectation the problem?
Regards
Gerrit
#include <curses.h>
#include <stdlib.h>
void quit(void) {
endwin();
}
int main(void) {
int x, y, ch;
MEVENT mev;
initscr();
atexit(quit);
noecho();
curs_set(0);
halfdelay(1);
keypad(stdscr, TRUE);
mousemask(ALL_MOUSE_EVENTS, NULL);
// timeout(1000);
getmaxyx(stdscr, y, x);
mvprintw(7, 5, "Size: [%3d, %3d]", x, y);
refresh();
do {
ch = getch();
switch (ch) {
case -1:
break;
case KEY_MOUSE:
if (getmouse(&mev) == OK) {
mvprintw(12, 5, "Mouse: x=%3d,
y=%3d, z=%3d, bstate=%010d",
mev.x, mev.y, mev.z,
mev.bstate);
} else {
mvprintw(12, 6, "Bad mouse event
---");
}
refresh();
break;
case KEY_RESIZE:
getmaxyx(stdscr, y, x);
mvprintw(7, 5, "Size: [%3d, %3d]", x,
y);
refresh();
break;
default:
mvprintw(10, 5, "Last key: %5d", ch);
refresh();
}
} while (ch != 27);
return(0);
}
- Mouse movement - no events?,
Hohl, Gerrit <=