Attachment "jumpingScrollbars_8.5.1.patch" to
ticket [1697054fff]
added by
arobert3434
2008-08-06 06:08:40.
--- tk8.5.1/macosx/tkMacOSXScrlbr.c~ 2008-05-14 22:13:36.000000000 -0400
+++ tk8.5.1/macosx/tkMacOSXScrlbr.c 2008-08-05 19:00:44.000000000 -0400
@@ -565,11 +565,11 @@
MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr;
Tcl_DString cmdString;
int origValue, variant;
- short trackBarSize;
+ short trackBarSize, pixDiff;
double oldFirstFraction, newFirstFraction;
char valueString[40];
Point currentPoint = { 0, 0 };
- Rect trackRect;
+ Rect ctrlRect;
Tcl_Interp *interp;
MouseTrackingResult trackingResult;
OSStatus err;
@@ -580,20 +580,18 @@
Tcl_DStringInit(&cmdString);
origValue = GetControl32BitValue(macScrollPtr->sbHandle);
- GetControlBounds(macScrollPtr->sbHandle, &trackRect);
+ GetControlBounds(macScrollPtr->sbHandle, &ctrlRect);
if (scrollPtr->vertical) {
- variant = (trackRect.right - trackRect.left) < metrics[0].width ? 1 : 0;
- trackBarSize = trackRect.bottom - trackRect.top -
+ variant = (ctrlRect.right - ctrlRect.left) < metrics[0].width ? 1 : 0;
+ trackBarSize = ctrlRect.bottom - ctrlRect.top -
metrics[variant].topArrowHeight -
metrics[variant].bottomArrowHeight;
- InsetRect(&trackRect, -25, -113);
} else {
- variant = (trackRect.bottom - trackRect.top) < metrics[0].width ? 1 : 0;
- trackBarSize = trackRect.right - trackRect.left -
+ variant = (ctrlRect.bottom - ctrlRect.top) < metrics[0].width ? 1 : 0;
+ trackBarSize = ctrlRect.right - ctrlRect.left -
metrics[variant].topArrowHeight -
metrics[variant].bottomArrowHeight;
- InsetRect(&trackRect, -113, -25);
}
/*
@@ -620,28 +618,19 @@
/*
* Calculate where the scrollbar should move to, based on
* where the mouse button was pressed and where the scrollbar
- * initially was at that time. Note that PtInRect() will
- * return false if currentPoint or trackRect are not in
- * is not in current graphics port, which may happen if any
- * of the waiting idle events change the port (e.g. with
- * SetPort()) but fail to restore it before returning and the
- * scrollbar will lock in place.
+ * initially was at that time.
*/
newFirstFraction = oldFirstFraction;
- if (PtInRect(currentPoint, &trackRect)) {
- short pixDiff;
-
- if (scrollPtr->vertical) {
- pixDiff = currentPoint.v - mouseDownPoint.v;
- } else {
- pixDiff = currentPoint.h - mouseDownPoint.h;
- }
- newFirstFraction += (double)pixDiff / trackBarSize;
- if (newFirstFraction > 1.0) {
- newFirstFraction = 1.0;
- } else if (newFirstFraction < 0.0) {
- newFirstFraction = 0.0;
- }
+ if (scrollPtr->vertical) {
+ pixDiff = currentPoint.v - mouseDownPoint.v;
+ } else {
+ pixDiff = currentPoint.h - mouseDownPoint.h;
+ }
+ newFirstFraction += (double)pixDiff / trackBarSize;
+ if (newFirstFraction > 1.0) {
+ newFirstFraction = 1.0;
+ } else if (newFirstFraction < 0.0) {
+ newFirstFraction = 0.0;
}
/*