diff options
Diffstat (limited to 'tk/win/tkWinScrlbr.c')
-rw-r--r-- | tk/win/tkWinScrlbr.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/tk/win/tkWinScrlbr.c b/tk/win/tkWinScrlbr.c index 12f4ea212eb..fa622ca365d 100644 --- a/tk/win/tkWinScrlbr.c +++ b/tk/win/tkWinScrlbr.c @@ -57,12 +57,14 @@ static int initialized = 0; static int hArrowWidth, hThumb; /* Horizontal control metrics. */ static int vArrowWidth, vArrowHeight, vThumb; /* Vertical control metrics. */ +TCL_DECLARE_MUTEX(winScrlbrMutex) + /* * This variable holds the default width for a scrollbar in string * form for use in a Tk_ConfigSpec. */ -static char defWidth[8]; +static char defWidth[TCL_INTEGER_SPACE]; /* * Declarations for functions defined in this file. @@ -116,8 +118,10 @@ TkpCreateScrollbar(tkwin) TkWindow *winPtr = (TkWindow *)tkwin; if (!initialized) { + Tcl_MutexLock(&winScrlbrMutex); UpdateScrollbarMetrics(); initialized = 1; + Tcl_MutexUnlock(&winScrlbrMutex); } scrollPtr = (WinScrollbar *) ckalloc(sizeof(WinScrollbar)); @@ -173,11 +177,7 @@ UpdateScrollbar(scrollPtr) scrollInfo.nMin = 0; scrollInfo.nMax = MAX_SCROLL; thumbSize = (scrollPtr->info.lastFraction - scrollPtr->info.firstFraction); - if (tkpIsWin32s) { - scrollInfo.nPage = 0; - } else { - scrollInfo.nPage = ((UINT) (thumbSize * (double) MAX_SCROLL)) + 1; - } + scrollInfo.nPage = ((UINT) (thumbSize * (double) MAX_SCROLL)) + 1; if (thumbSize < 1.0) { scrollInfo.nPos = (int) ((scrollPtr->info.firstFraction / (1.0-thumbSize)) @@ -668,16 +668,18 @@ ModalLoopProc(tkwin, eventPtr) WinScrollbar *scrollPtr = (WinScrollbar *) winPtr->instanceData; int oldMode; - Tcl_Preserve((ClientData)scrollPtr); - scrollPtr->winFlags |= IN_MODAL_LOOP; - oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); - TkWinResendEvent(scrollPtr->oldProc, scrollPtr->hwnd, eventPtr); - (void) Tcl_SetServiceMode(oldMode); - scrollPtr->winFlags &= ~IN_MODAL_LOOP; - if (scrollPtr->hwnd && scrollPtr->winFlags & ALREADY_DEAD) { - DestroyWindow(scrollPtr->hwnd); + if (scrollPtr->hwnd) { + Tcl_Preserve((ClientData)scrollPtr); + scrollPtr->winFlags |= IN_MODAL_LOOP; + oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); + TkWinResendEvent(scrollPtr->oldProc, scrollPtr->hwnd, eventPtr); + (void) Tcl_SetServiceMode(oldMode); + scrollPtr->winFlags &= ~IN_MODAL_LOOP; + if (scrollPtr->hwnd && scrollPtr->winFlags & ALREADY_DEAD) { + DestroyWindow(scrollPtr->hwnd); + } + Tcl_Release((ClientData)scrollPtr); } - Tcl_Release((ClientData)scrollPtr); } /* @@ -743,3 +745,5 @@ TkpScrollbarPosition(scrollPtr, x, y) } return BOTTOM_GAP; } + + |