1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-21 13:28:05 +01:00

Mouse wheel code enhancement (need to check if its correctly implemented)

This commit is contained in:
dan
2000-05-08 22:15:05 +00:00
parent 27838589a5
commit 139b34c7af
2 changed files with 56 additions and 9 deletions

View File

@@ -386,7 +386,7 @@ createConnectionWithSocket(int sock, Bool closeOnRelease) /*FOLD00*/
return cPtr; return cPtr;
} }
/*FOLD00*/
#if 0 #if 0
WMConnection* WMConnection*
@@ -425,7 +425,7 @@ WMCreateConnectionWithSocket(int sock, Bool closeOnRelease) /*FOLD00*/
return cPtr; return cPtr;
} }
#endif #endif
/*FOLD00*/
/* /*
* host is the name on which we want to listen for incoming connections, * host is the name on which we want to listen for incoming connections,
@@ -720,7 +720,7 @@ WMGetConnectionService(WMConnection *cPtr) /*FOLD00*/
char* char*
WMGetConnectionProtocol(WMConnection *cPtr) WMGetConnectionProtocol(WMConnection *cPtr) /*FOLD00*/
{ {
return cPtr->protocol; return cPtr->protocol;
} }
@@ -741,7 +741,7 @@ WMGetConnectionState(WMConnection *cPtr) /*FOLD00*/
WMConnectionTimeoutState WMConnectionTimeoutState
WMGetConnectionTimeoutState(WMConnection *cPtr) WMGetConnectionTimeoutState(WMConnection *cPtr) /*FOLD00*/
{ {
return cPtr->timeoutState; return cPtr->timeoutState;
} }
@@ -840,7 +840,7 @@ WMSendConnectionData(WMConnection *cPtr, WMData *data) /*FOLD00*/
return totalTransfer; return totalTransfer;
} }
/*FOLD00*/
/* /*
* WMGetConnectionAvailableData(connection): * WMGetConnectionAvailableData(connection):
@@ -914,7 +914,7 @@ WMSetConnectionDelegate(WMConnection *cPtr, ConnectionDelegate *delegate) /*FOLD
cPtr->handler.exception = WMAddInputHandler(cPtr->sock, WIExceptMask, cPtr->handler.exception = WMAddInputHandler(cPtr->sock, WIExceptMask,
inputHandler, cPtr); inputHandler, cPtr);
} }
/*FOLD00*/
#if 0 #if 0
Bool Bool
@@ -984,7 +984,7 @@ WMSetConnectionFlags(WMConnection *cPtr, unsigned int flags) /*FOLD00*/
void void
WMSetConnectionDefaultTimeout(unsigned int timeout) WMSetConnectionDefaultTimeout(unsigned int timeout) /*FOLD00*/
{ {
if (timeout == 0) { if (timeout == 0) {
DefaultTimeout = DEF_TIMEOUT; DefaultTimeout = DEF_TIMEOUT;
@@ -995,7 +995,7 @@ WMSetConnectionDefaultTimeout(unsigned int timeout)
void void
WMSetConnectionOpenTimeout(unsigned int timeout) WMSetConnectionOpenTimeout(unsigned int timeout) /*FOLD00*/
{ {
if (timeout == 0) { if (timeout == 0) {
OpenTimeout = DefaultTimeout; OpenTimeout = DefaultTimeout;

View File

@@ -697,6 +697,14 @@ handleActionEvents(XEvent *event, void *data)
switch (event->type) { switch (event->type) {
case ButtonRelease: 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; lPtr->flags.buttonPressed = 0;
tmp = getItemIndexAt(lPtr, event->xbutton.y); tmp = getItemIndexAt(lPtr, event->xbutton.y);
@@ -718,6 +726,45 @@ handleActionEvents(XEvent *event, void *data)
case ButtonPress: case ButtonPress:
if (event->xbutton.x > WMWidgetWidth(lPtr->vScroller)) { if (event->xbutton.x > WMWidgetWidth(lPtr->vScroller)) {
#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 <diskena@linuxfreak.com> */
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); tmp = getItemIndexAt(lPtr, event->xbutton.y);
lPtr->flags.buttonPressed = 1; lPtr->flags.buttonPressed = 1;