From: H.G. Muller Date: Tue, 12 Apr 2011 15:06:28 +0000 (+0200) Subject: Couple mouse wheel to v-scrolls in file browser X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=e9a0808a5551217eb4fd29d949f3c7672545c168;p=xboard.git Couple mouse wheel to v-scrolls in file browser A newly added mouse-wheel event handler was made to call the v-scroll callback routines with parameters to step one entry. The button-press handler for the lists themselves was also made to intercept the wheel events (buttons 4 and 5), to prevent they would select an entry, and make them scroll in stead as well. --- diff --git a/filebrowser/draw.c b/filebrowser/draw.c index 46ed663..abab957 100644 --- a/filebrowser/draw.c +++ b/filebrowser/draw.c @@ -655,7 +655,10 @@ SFvSliderMovedCallback(w, n, new) dir = &(SFdirs[SFdirPtr + n]); + old = dir->vOrigin; + if(new == -1) new = old + 1; else if(new == -2) new = old - 1; // [HGM] indicates scroll direction on mousewheel event + if(new < 0 || new > dir->nEntries - SFlistSize) return; dir->vOrigin = new; if (old == new) { diff --git a/filebrowser/path.c b/filebrowser/path.c index 5aac90c..edb43c8 100644 --- a/filebrowser/path.c +++ b/filebrowser/path.c @@ -77,6 +77,8 @@ static SFLogin *SFlogins; static int SFtwiddle = 0; +void SFsetText(char *path); + int SFchdir(path) char *path; @@ -713,6 +715,10 @@ SFbuttonPressList(w, n, event) int n; XButtonPressedEvent *event; { + int dir = 0; + if(event->button == Button4) dir = -2; // kludge to indicate relative motion + if(event->button == Button5) dir = -1; + if(dir) SFvSliderMovedCallback(w, n, dir); else SFbuttonPressed = 1; } @@ -725,6 +731,7 @@ SFbuttonReleaseList(w, n, event) { SFDir *dir; + if(event->button == Button4 || event->button == Button5) return; // [HGM] mouse wheel does not select SFbuttonPressed = 0; if (SFcurrentInvert[n] != -1) { diff --git a/filebrowser/selfile.c b/filebrowser/selfile.c index 477b022..d3f02f3 100644 --- a/filebrowser/selfile.c +++ b/filebrowser/selfile.c @@ -267,6 +267,14 @@ void SFsetFocus(Widget w, XtPointer data, XEvent *event, Boolean *b) XtSetKeyboardFocus((Widget) data, w); } +void SFwheelProc(Widget w, XtPointer data, XEvent *event, Boolean *b) +{ // [HGM] mouse-wheel callback scrolls lists + int dir, n = (intptr_t) data; + if(event->xbutton.button == Button4) dir = -2; // kludge to indicate relative motion + if(event->xbutton.button == Button5) dir = -1; + SFvSliderMovedCallback(w, n, dir); +} + static void SFcreateWidgets(toplevel, prompt, ok, cancel) Widget toplevel; @@ -522,6 +530,9 @@ SFcreateWidgets(toplevel, prompt, ok, cancel) SFhSliderMovedCallback, (XtPointer)(intptr_t) n); XtAddCallback(selFileHScrolls[n], XtNscrollProc, SFhAreaSelectedCallback, (XtPointer)(intptr_t) n); + + XtAddEventHandler(selFileVScrolls[n], ButtonPressMask, False, + SFwheelProc, (XtPointer)(intptr_t) n); // [HGM] couplemouse wheel to v-scroll } i = 0;