From 45e5b1ef9153440cc2ea3003996e3d8729e95c8e Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Thu, 26 May 2011 18:04:34 +0200 Subject: [PATCH] workaround invalid mouse related ncurses behavior --- src/ncmpcpp.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 6e4b1279..917f258b 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -322,7 +322,7 @@ int main(int argc, char *argv[]) signal(SIGWINCH, sighandler); # endif // !WIN32 - MEVENT mouse_event; + MEVENT mouse_event, old_mouse_event; mouseinterval(0); if (Config.mouse_support) mousemask(ALL_MOUSE_EVENTS, 0); @@ -522,6 +522,15 @@ int main(int argc, char *argv[]) else if (Config.mouse_support && input == KEY_MOUSE) { getmouse(&mouse_event); + // workaround shitty ncurses behavior introduced in >=5.8, when we mysteriously get + // a few times after ncmpcpp startup 2^27 code instead of BUTTON1_RELEASED. since that + // 2^27 thing shows constantly instead of BUTTON2_PRESSED, it was redefined to be recognized + // as BUTTON2_PRESSED. but clearly we don't want to trigger behavior bound to BUTTON2 + // after BUTTON1 was pressed. so, here is the workaround: if last event was BUTTON1_PRESSED, + // we MUST get BUTTON1_RELEASED afterwards. if we get BUTTON2_PRESSED, erroneus behavior + // is about to occur and we need to prevent that. + if (old_mouse_event.bstate & BUTTON1_PRESSED && mouse_event.bstate & BUTTON2_PRESSED) + continue; if (mouse_event.bstate & BUTTON1_PRESSED && mouse_event.y == LINES-(Config.statusbar_visibility ? 2 : 1) ) // progressbar @@ -552,6 +561,7 @@ int main(int argc, char *argv[]) } else if (mouse_event.bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED)) myScreen->MouseButtonPressed(mouse_event); + old_mouse_event = mouse_event; } else if (Keypressed(input, Key.ToggleInterface)) {