int appGrabbed = 0;                        /* Non-zero means event is being
                                         * reported to an application that is
                                         * affected by the grab. */
-#define ALL_BUTTONS \
-       (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
     static unsigned int state[] = {
        Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
     };
 
 #define META_MASK      (AnyModifier<<1)
 #define ALT_MASK       (AnyModifier<<2)
 
+#define ALL_BUTTONS \
+       (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
+
 /*
  * One of the following structures is maintained for each display
  * containing a window managed by Tk:
 
                eventPtr->xmotion.x, eventPtr->xmotion.y));
     } else if ((eventPtr->type == ButtonPress)
 /*         && (eventPtr->xbutton.button == Button1) */
-           && (eventPtr->xbutton.state == 0)) {
+           && ((eventPtr->xbutton.state & ALL_BUTTONS) == 0)) {
        scalePtr->flags |= BUTTON_PRESSED;
        SetScaleValue(scalePtr, PixelToValue(scalePtr,
                eventPtr->xbutton.x, eventPtr->xbutton.y));
 
                    eventPtr->xmotion.y));
        }
     } else if ((eventPtr->type == ButtonPress)
-           && (eventPtr->xbutton.state == 0)) {
+           && ((eventPtr->xbutton.state & ALL_BUTTONS) == 0)) {
        scrollPtr->pressField = scrollPtr->mouseField;
        if (scrollPtr->pressField != SLIDER) {
            scrollPtr->autoRepeat = Tk_CreateTimerHandler(