Curses and the mouse

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

 



I've finally got round to fiddling with curses, and I've got a test
program that works some of the time.

The immediate concern is the mouse. It works in an xterm window, and as
I read the docs it's supposed to work on a Linux VC with gpm active.

Well, it doesn't, at least for me.

I'm running RHL 7.3.

Here are the curses bits from my programs:
#include <curses.h>
#include <signal.h>
#ifdef NCURSES_MOUSE_VERSION
	 int ny = 0, nx = 0;

	mmask_t MouseMask,newMouseMask = BUTTON1_RELEASED |
BUTTON1_PRESSED 
			  		| BUTTON1_CLICKED |
BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED;
#endif /* NCURSES_MOUSE_VERSION */
  	(void) initscr();      /* initialize the curses library */
#ifdef NCURSES_MOUSE_VERSION
	MouseMask = mousemask(newMouseMask, (mmask_t *) NULL);
	move(Line++,40);
	printw("nn=%d, requested mm=%d\n", MouseMask, newMouseMask);
#endif /* NCURSES_MOUSE_VERSION */


  	keypad(stdscr, TRUE);  /* enable keyboard mapping */
  	(void) nonl();         /* tell curses not to do NL->CR/NL on
output */ 
	(void) cbreak();       /* take input chars one at a time, no
wait for \n */     
	(void) echo();         /* echo input - in color */ 



  for (;;)
  {
/* refresh, accept single keystroke of input */
	int ch = getch();    
	if (ch == 4) break;
/* process the command keystroke */
	switch (ch)
	{
		default:
			break;
<snip>
#ifdef NCURSES_MOUSE_VERSION
	case KEY_MOUSE:
	{ 
		MEVENT myevent; 
		addstr("\nClick!");
		getmouse(&myevent);
		nx = myevent.x;
		ny = myevent.y; 
		printw("\nx=%d, y=%d",nx,ny);
		ungetch('\n'); 
		break; 
	}
#endif /* NCURSES_MOUSE_VERSION */
}

In an xterm window, I get reports like this:
                                        nn=31, requested mm=31
     has "Next Page" key
     has "Prev Page" key
Click!
x=42, y=1
Click!
x=2, y=5
Click!
x=0, y=1

On a vc, no response to mouse-clicks.

I've checked this: http://en.tldp.org/HOWTO/NCURSES-Programming-HOWTO/
and see nothing to change.

Any hints?


-- 
Please, reply only to the list.




_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@redhat.com
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux