From b003636958377ecad3ee5df4ca2de8717c4530b9 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 19 Aug 2015 18:55:24 -0300 Subject: Support for NCurses 6.0 and mouse wheel --- ScreenManager.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'ScreenManager.c') diff --git a/ScreenManager.c b/ScreenManager.c index c9253c3f..657065c6 100644 --- a/ScreenManager.c +++ b/ScreenManager.c @@ -9,6 +9,7 @@ in the source distribution for its full text. #include "ProcessList.h" #include "Object.h" +#include "CRT.h" #include #include @@ -196,26 +197,34 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { MEVENT mevent; int ok = getmouse(&mevent); if (ok == OK) { - if (mevent.y == LINES - 1) { - ch = FunctionBar_synthesizeEvent(panelFocus->currentBar, mevent.x); - } else { - for (int i = 0; i < this->panelCount; i++) { - Panel* panel = (Panel*) Vector_get(this->panels, i); - if (mevent.x >= panel->x && mevent.x <= panel->x+panel->w) { - if (mevent.y == panel->y) { - ch = EVENT_HEADER_CLICK(mevent.x - panel->x); - break; - } else if (mevent.y > panel->y && mevent.y <= panel->y+panel->h) { - if (panel == panelFocus || this->allowFocusChange) { - focus = i; - panelFocus = setCurrentPanel(panel); - Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1); + if (mevent.bstate & BUTTON1_RELEASED) { + if (mevent.y == LINES - 1) { + ch = FunctionBar_synthesizeEvent(panelFocus->currentBar, mevent.x); + } else { + for (int i = 0; i < this->panelCount; i++) { + Panel* panel = (Panel*) Vector_get(this->panels, i); + if (mevent.x >= panel->x && mevent.x <= panel->x+panel->w) { + if (mevent.y == panel->y) { + ch = EVENT_HEADER_CLICK(mevent.x - panel->x); + break; + } else if (mevent.y > panel->y && mevent.y <= panel->y+panel->h) { + if (panel == panelFocus || this->allowFocusChange) { + focus = i; + panelFocus = setCurrentPanel(panel); + Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1); + } + ch = KEY_MOUSE; + break; } - ch = KEY_MOUSE; - break; } } } + #if NCURSES_MOUSE_VERSION > 1 + } else if (mevent.bstate & BUTTON4_PRESSED) { + ch = KEY_WHEELUP; + } else if (mevent.bstate & BUTTON5_PRESSED) { + ch = KEY_WHEELDOWN; + #endif } } } -- cgit v1.2.3