PDCursesMod icon indicating copy to clipboard operation
PDCursesMod copied to clipboard

mousemask, mouse wheel - different behave than ncurses

Open okbob opened this issue 2 years ago • 12 comments

I am author of pspg https://github.com/okbob/pspg. It was designed against ncurses, and now I try to port it for pdcurses. I use pdcurses for VT on Linux. Today I found one small issue:

I use mousemask, and I had to little bit different setting for pdcurses (it requires MOUSE_WHEEL_SCROLL flag)

#if NCURSES_MOUSE_VERSION > 1

<--><-->mousemask(BUTTON1_PRESSED | BUTTON1_RELEASED |
<--><--><--><-->  BUTTON4_PRESSED | BUTTON5_PRESSED |
<--><--><--><-->  BUTTON_ALT | BUTTON_CTRL |

#ifdef PDCURSES

<--><--><--><-->  MOUSE_WHEEL_SCROLL | REPORT_MOUSE_POSITION |

#endif

<--><--><--><-->  (opts.xterm_mouse_mode ? REPORT_MOUSE_POSITION : 0),
<--><--><--><-->  NULL);

is it expected behave?

okbob avatar Dec 16 '22 13:12 okbob

A that part was missing in your question: you did define PDC_NCMOUSE, didn't you?

GitMensch avatar Dec 16 '22 14:12 GitMensch

pá 16. 12. 2022 v 15:55 odesílatel Simon Sobisch @.***> napsal:

A that part was missing in your question: you did define PDC_NCMOUSE, didn't you?

I did it

https://github.com/okbob/pspg/commit/5aa8d2ada77ba65bd50373bcf9baa15adfba4f3f

— Reply to this email directly, view it on GitHub https://github.com/Bill-Gray/PDCursesMod/issues/255#issuecomment-1355002694, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFO46MQTSSF3PAIVM4BW3WNR7HZANCNFSM6AAAAAATA6SMYA . You are receiving this because you authored the thread.Message ID: @.***>

okbob avatar Dec 16 '22 15:12 okbob

There are some weirdnesses in handling the mouse wheel in ncurses, caused in part by mmask_t being a mere 32 bits. Some comments on the problems here. I had to do some odd things in the code to allow for the possibility that ncurses couldn't return a wheel-up event. We switched PDCursesMod to default to 64-bit mmask_ts a while back.

Bill-Gray avatar Dec 29 '22 02:12 Bill-Gray

I don't understand to implementation part. Just if pdcurses provides an compatibility with PDC_NCMOUSE, then it is surprising so this doesn't work by default. Maybe you can in compatibility mode implicitly set MOUSE_WHEEL_SCROLL when BUTTON4_PRESSED are BUTTON5_PRESSED set. Note - MOUSE_WHEEL_SCROLL is not in ncurses.

okbob avatar Dec 29 '22 03:12 okbob

Um. I see your point; if you've #defined PDC_NCMOUSE, you would reasonably expect full compatibility with ncurses, including the shortcomings of ncurses.

That does open up some problems. "Fixing" this would mean we'd have the same problems as ncurses (poor wheel handling, no tilt-wheel handling) and would break the current binary compatibility. The need for compatibility with what PDCursesMod does now argues in favor of three options:

(1) the default scenario where PDC_NCMOUSE isn't #defined; (2) The current scheme where PDC_NCMOUSE being #defined means you get something pretty close to matching ncurses behavior, except that you can read the mouse wheel and mouse movement events; (3) A new option in which we just try to match ncurses, right down to places where it's limited by trying to fit all events into 32 bits.

Bill-Gray avatar Dec 29 '22 19:12 Bill-Gray

I love that plan and suggest for 3: PDC_NCMOUSE_LIMITTED or something like that.

GitMensch avatar Dec 29 '22 20:12 GitMensch

čt 29. 12. 2022 v 20:30 odesílatel Bill Gray @.***> napsal:

Um. I see your point; if you've #defined PDC_NCMOUSE, you would reasonably expect full compatibility with ncurses, including the shortcomings of ncurses.

That does open up some problems. "Fixing" this would mean we'd have the same problems as ncurses (poor wheel handling, no tilt-wheel handling) and would break the current binary compatibility. The need for compatibility with what PDCursesMod does now argues in favor of three options:

I am not sure if I understand the core issue well, maybe not - and I know nothing about pdcurses, so my opinion can be wrong.

I think that the behavior that I wound on pdcurses is not correct and the flag PDC_NCMOUSE is not too important.

If I understand correctly the design of the mousemask function, then I can get any event that is enabled by some bits. Mouse wheel is abstracted by BUTTON4, BUTTON5. And If I enable these buttons by mousemask, then any other flag should not be necessary.

Unfortunately, I know nothing about standard or usual behaviour, but I think the implementation of mousemask in pdcurses is not fully correct, because for functionality of BUTTON4 and BUTTON5 I need a separate flag.

(1) the default scenario where PDC_NCMOUSE isn't #defined; (2) The current scheme where PDC_NCMOUSE being #defined means you get something pretty close to matching ncurses behavior, except that you can read the mouse wheel and mouse movement events; (3) A new option in which we just try to match ncurses, right down to places where it's limited by trying to fit all events into 32 bits.

— Reply to this email directly, view it on GitHub https://github.com/Bill-Gray/PDCursesMod/issues/255#issuecomment-1367539053, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFO4363UU3O5FSEPDFEVTWPXRDRANCNFSM6AAAAAATA6SMYA . You are receiving this because you authored the thread.Message ID: @.***>

okbob avatar Dec 30 '22 03:12 okbob