From 139b34c7afb88d3d37539ead384f7355a7099c9f Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 May 2000 22:15:05 +0000 Subject: [PATCH] Mouse wheel code enhancement (need to check if its correctly implemented) --- WINGs/connection.c | 16 +++++++-------- WINGs/wlist.c | 49 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/WINGs/connection.c b/WINGs/connection.c index d6670cc6..3ddda941 100644 --- a/WINGs/connection.c +++ b/WINGs/connection.c @@ -386,7 +386,7 @@ createConnectionWithSocket(int sock, Bool closeOnRelease) /*FOLD00*/ return cPtr; } - + /*FOLD00*/ #if 0 WMConnection* @@ -425,7 +425,7 @@ WMCreateConnectionWithSocket(int sock, Bool closeOnRelease) /*FOLD00*/ return cPtr; } #endif - + /*FOLD00*/ /* * host is the name on which we want to listen for incoming connections, @@ -720,7 +720,7 @@ WMGetConnectionService(WMConnection *cPtr) /*FOLD00*/ char* -WMGetConnectionProtocol(WMConnection *cPtr) +WMGetConnectionProtocol(WMConnection *cPtr) /*FOLD00*/ { return cPtr->protocol; } @@ -741,7 +741,7 @@ WMGetConnectionState(WMConnection *cPtr) /*FOLD00*/ WMConnectionTimeoutState -WMGetConnectionTimeoutState(WMConnection *cPtr) +WMGetConnectionTimeoutState(WMConnection *cPtr) /*FOLD00*/ { return cPtr->timeoutState; } @@ -840,7 +840,7 @@ WMSendConnectionData(WMConnection *cPtr, WMData *data) /*FOLD00*/ return totalTransfer; } - + /*FOLD00*/ /* * WMGetConnectionAvailableData(connection): @@ -914,7 +914,7 @@ WMSetConnectionDelegate(WMConnection *cPtr, ConnectionDelegate *delegate) /*FOLD cPtr->handler.exception = WMAddInputHandler(cPtr->sock, WIExceptMask, inputHandler, cPtr); } - + /*FOLD00*/ #if 0 Bool @@ -984,7 +984,7 @@ WMSetConnectionFlags(WMConnection *cPtr, unsigned int flags) /*FOLD00*/ void -WMSetConnectionDefaultTimeout(unsigned int timeout) +WMSetConnectionDefaultTimeout(unsigned int timeout) /*FOLD00*/ { if (timeout == 0) { DefaultTimeout = DEF_TIMEOUT; @@ -995,7 +995,7 @@ WMSetConnectionDefaultTimeout(unsigned int timeout) void -WMSetConnectionOpenTimeout(unsigned int timeout) +WMSetConnectionOpenTimeout(unsigned int timeout) /*FOLD00*/ { if (timeout == 0) { OpenTimeout = DefaultTimeout; diff --git a/WINGs/wlist.c b/WINGs/wlist.c index b59e740d..d92c5bc8 100644 --- a/WINGs/wlist.c +++ b/WINGs/wlist.c @@ -697,6 +697,14 @@ handleActionEvents(XEvent *event, void *data) switch (event->type) { case ButtonRelease: +#define CHECK_WHEEL_PATCH +#ifdef CHECK_WHEEL_PATCH + /* Ignore mouse wheel events, they're not "real" button events */ + if (event->xbutton.button == WINGsConfiguration.mouseWheelUp || + event->xbutton.button == WINGsConfiguration.mouseWheelDown) + break; +#endif + lPtr->flags.buttonPressed = 0; tmp = getItemIndexAt(lPtr, event->xbutton.y); @@ -718,7 +726,46 @@ handleActionEvents(XEvent *event, void *data) case ButtonPress: if (event->xbutton.x > WMWidgetWidth(lPtr->vScroller)) { - tmp = getItemIndexAt(lPtr, event->xbutton.y); +#ifdef CHECK_WHEEL_PATCH + /* Mouse wheel events need to be properly handled here. It would + * be best to somehow route them to lPtr->vScroller so that the + * correct chain of actions is triggered. However, I found no + * clean way to do so, so I mostly copied the code that deals with + * WSIncrementPage and WSDecrementPage from vScrollCallBack. + * + * - Martynas Kunigelis */ + + if (event->xbutton.button == WINGsConfiguration.mouseWheelDown) { + /* Wheel down */ + int itemCount = WMGetBagItemCount(lPtr->items); + if (lPtr->topItem + lPtr->fullFitLines < itemCount) { + int incr = lPtr->fullFitLines-(1-lPtr->flags.dontFitAll)-1; + lPtr->topItem += incr; + + if (lPtr->topItem + lPtr->fullFitLines > itemCount) + lPtr->topItem = itemCount - lPtr->fullFitLines; + + updateScroller(lPtr); + } + break; + } + + if (event->xbutton.button == WINGsConfiguration.mouseWheelUp) { + /* Wheel up */ + if (lPtr->topItem > 0) { + int decr = lPtr->fullFitLines-(1-lPtr->flags.dontFitAll)-1; + lPtr->topItem -= decr; + + if (lPtr->topItem < 0) + lPtr->topItem = 0; + + updateScroller(lPtr); + } + break; + } +#endif + + tmp = getItemIndexAt(lPtr, event->xbutton.y); lPtr->flags.buttonPressed = 1; if (tmp >= 0) {