commit ea0ab86ed5f4b0c20a75a8005dd00f4d20b4d5c5
Author: Joe English <jenglish@flightlab.com>
Date:   Sun May 30 14:36:14 2010 -0700

    tkWinScrlbr.c: Replace ScrollbarBindProc with normal event handler.

diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c
index 05aca48..715913f 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -64,10 +64,7 @@ TCL_DECLARE_MUTEX(winScrlbrMutex)
 
 static Window		CreateProc(Tk_Window tkwin, Window parent,
 			    ClientData instanceData);
-static void		ModalLoopProc(Tk_Window tkwin, XEvent *eventPtr);
-static int		ScrollbarBindProc(ClientData clientData,
-			    Tcl_Interp *interp, XEvent *eventPtr,
-			    Tk_Window tkwin, KeySym keySym);
+static void		ModalLoop(WinScrollbar *, XEvent *eventPtr);
 static LRESULT CALLBACK	ScrollbarProc(HWND hwnd, UINT message, WPARAM wParam,
 			    LPARAM lParam);
 static void		UpdateScrollbar(WinScrollbar *scrollPtr);
@@ -81,9 +78,21 @@ const Tk_ClassProcs tkpScrollbarProcs = {
     sizeof(Tk_ClassProcs),	/* size */
     NULL,			/* worldChangedProc */
     CreateProc,			/* createProc */
-    ModalLoopProc		/* modalProc */
+    NULL 			/* modalProc */
 };
 
+static void
+WinScrollbarEventProc(ClientData clientData, XEvent *eventPtr)
+{
+    WinScrollbar *scrollPtr = clientData;
+
+    if (eventPtr->type == ButtonPress) {
+	ModalLoop(scrollPtr, eventPtr);
+    } else {
+	TkScrollbarEventProc(clientData, eventPtr);
+    }
+}
+
 
 /*
  *----------------------------------------------------------------------
@@ -106,7 +115,6 @@ TkpCreateScrollbar(
     Tk_Window tkwin)
 {
     WinScrollbar *scrollPtr;
-    TkWindow *winPtr = (TkWindow *)tkwin;
 
     if (!initialized) {
 	Tcl_MutexLock(&winScrlbrMutex);
@@ -120,17 +128,8 @@ TkpCreateScrollbar(
     scrollPtr->hwnd = NULL;
 
     Tk_CreateEventHandler(tkwin,
-	    ExposureMask|StructureNotifyMask|FocusChangeMask,
-	    TkScrollbarEventProc, (ClientData) scrollPtr);
-
-    if (!Tcl_GetAssocData(winPtr->mainPtr->interp, "TkScrollbar", NULL)) {
-	Tcl_SetAssocData(winPtr->mainPtr->interp, "TkScrollbar", NULL,
-		(ClientData)1);
-	TkCreateBindingProcedure(winPtr->mainPtr->interp,
-		winPtr->mainPtr->bindingTable,
-		(ClientData)Tk_GetUid("Scrollbar"), "<ButtonPress>",
-		ScrollbarBindProc, NULL, NULL);
-    }
+	    ExposureMask|StructureNotifyMask|FocusChangeMask|ButtonPressMask,
+	    WinScrollbarEventProc, scrollPtr);
 
     return (TkScrollbar *) scrollPtr;
 }
@@ -601,62 +600,22 @@ TkpConfigureScrollbar(
 }
 
 /*
- *--------------------------------------------------------------
- *
- * ScrollbarBindProc --
- *
- *	This procedure is invoked when the default <ButtonPress> binding on
- *	the Scrollbar bind tag fires.
- *
- * Results:
- *	None.
- *
- * Side effects:
- *	The event enters a modal loop.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ScrollbarBindProc(
-    ClientData clientData,
-    Tcl_Interp *interp,
-    XEvent *eventPtr,
-    Tk_Window tkwin,
-    KeySym keySym)
-{
-    TkWindow *winPtr = (TkWindow *) tkwin;
-
-    if (eventPtr->type == ButtonPress) {
-	winPtr->flags |= TK_DEFER_MODAL;
-    }
-    return TCL_OK;
-}
-
-/*
  *----------------------------------------------------------------------
  *
- * ModalLoopProc --
- *
- *	This function is invoked at the end of the event processing whenever
- *	the ScrollbarBindProc has been invoked for a ButtonPress event.
+ * ModalLoop --
  *
- * Results:
- *	None.
- *
- * Side effects:
- *	Enters a modal loop.
+ *	This function is invoked in response to a ButtonPress event.
+ *	It resends the event to the Scrollbar window procedure,
+ * 	which in turn enters a modal loop.
  *
  *----------------------------------------------------------------------
  */
 
 static void
-ModalLoopProc(
-    Tk_Window tkwin,
+ModalLoop(
+    WinScrollbar *scrollPtr,
     XEvent *eventPtr)
 {
-    TkWindow *winPtr = (TkWindow*)tkwin;
-    WinScrollbar *scrollPtr = (WinScrollbar *) winPtr->instanceData;
     int oldMode;
 
     if (scrollPtr->hwnd) {
