workaround invalid mouse related ncurses behavior - part 2

bah, it also happens with right mouse button.
This commit is contained in:
Andrzej Rybczak
2011-05-31 15:22:09 +02:00
parent 45e5b1ef91
commit d08b2e80fd

View File

@@ -523,13 +523,13 @@ int main(int argc, char *argv[])
{ {
getmouse(&mouse_event); getmouse(&mouse_event);
// workaround shitty ncurses behavior introduced in >=5.8, when we mysteriously get // 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 // a few times after ncmpcpp startup 2^27 code instead of BUTTON{1,3}_RELEASED. since that
// 2^27 thing shows constantly instead of BUTTON2_PRESSED, it was redefined to be recognized // 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 // 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, // after BUTTON{1,3} was pressed. so, here is the workaround: if last event was BUTTON{1,3}_PRESSED,
// we MUST get BUTTON1_RELEASED afterwards. if we get BUTTON2_PRESSED, erroneus behavior // we MUST get BUTTON{1,3}_RELEASED afterwards. if we get BUTTON2_PRESSED, erroneus behavior
// is about to occur and we need to prevent that. // is about to occur and we need to prevent that.
if (old_mouse_event.bstate & BUTTON1_PRESSED && mouse_event.bstate & BUTTON2_PRESSED) if (old_mouse_event.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED) && mouse_event.bstate & BUTTON2_PRESSED)
continue; continue;
if (mouse_event.bstate & BUTTON1_PRESSED if (mouse_event.bstate & BUTTON1_PRESSED
&& mouse_event.y == LINES-(Config.statusbar_visibility ? 2 : 1) && mouse_event.y == LINES-(Config.statusbar_visibility ? 2 : 1)