bug-ncurses
[Top][All Lists]
Advanced

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

Re: mouse handling doesn't looks correct


From: Pavel Stehule
Subject: Re: mouse handling doesn't looks correct
Date: Wed, 27 Jan 2021 13:19:05 +0100



st 27. 1. 2021 v 13:06 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:


st 27. 1. 2021 v 0:23 odesílatel Thomas Dickey <dickey@his.com> napsal:
On Mon, Jan 25, 2021 at 06:42:36PM +0100, Pavel Stehule wrote:
> Hi
>
> I try to implement drag support for my ncurses application. I found an
> example
>
> https://gist.github.com/sylt/93d3f7b77e7f3a881603#file-ncurses_mouse_movement-c
>
> It worked almost well, with two exceptions.

Just reading the source code, I see an error: the printf's are not fflush'd.
As a result, the control sequence may be corrupted and ignored.

I have an equivalent test in ncurses (test/ncurses.c, menu A or a).
That works fairly reliable (with xterm of course).

I am testing this example, and it doesn't work like I expect. ncurses does only two events - click press and click release.

There are no "mouse - move" events. I need to get events when the user presses left click and try to move with the mouse.

I have another example

int main() {
  int ch, count=0;
  MEVENT event;

  initscr();
  raw();
  keypad(stdscr, TRUE);
  noecho();

  clear();
  cbreak();

  mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);

  while ((ch = getch()) != 'q')
  {
    count++;
    mvprintw(1, 1, "Has mouse: %d", has_mouse());
    mvprintw(2, 1, "Key code: %x; mouse code:%x", ch, KEY_MOUSE);
    if (ch == KEY_MOUSE)
    {
      assert(getmouse(&event) == OK);
      mvprintw(3, 3, "Mouse Event: x=%d, y=%d z=%d",
               event.x, event.y, event.z);
      mvprintw(4, 3, "Mouse device id: %x", event.id);
      mvprintw(5, 3, "Mouse button mask: %x", event.bstate);
    }
    mvprintw(6, 1, "Event number: %4d",count);
    refresh();
  }
  endwin();
}

I don't see any difference if I use the REPORT_MOUSE_POSITION option.

Regards

Pavel
 

Regards

Pavel



Wheel mice are a special problem, if you attempt to push button 2
(the wheel itself), that's likely to produce other buttons (6 or 7).
But I recall improving that a while back (and in my quick check,
it seems okay: just reporting position).

> When I use the mouse wheel, the mouse is in some strange state, and when I
> try to move with the mouse, then it generates events like the left button
> is pressed, but no button is pressed. After left click the behaviour is
> returned to normal.
>
> Second issue, that I can see, are a few false events. Although I did only
> mouse move, it generates the same mouse event like mouse click.
>
> Name         : ncurses
> Version      : 6.2
> Release      : 3.20200222.fc33
> Architecture : x86_64
> Size         : 608 k
> Source       : ncurses-6.2-3.20200222.fc33.src.rpm
> Repository   : @System
> >From repo    : anaconda
> Summary      : Ncurses support utilities
> URL          : https://invisible-island.net/ncurses/ncurses.html
> License      : MIT
>
> Is there some way to implement drag correctly?
>
> Regards
>
> Pavel Stehule

--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

reply via email to

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