Tk Source Code

Artifact [739c29d3]
Login

Artifact 739c29d3636785a86303a4ab10b98ce3a8cef8b4:

Attachment "badclick-win32-v2.patch" to ticket [1391053f] added by a_kovalenko 2005-12-27 13:57:19.
Index: generic/tkInt.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkInt.h,v
retrieving revision 1.69
diff -u -r1.69 tkInt.h
--- generic/tkInt.h	27 Nov 2005 02:36:14 -0000	1.69
+++ generic/tkInt.h	27 Dec 2005 06:51:24 -0000
@@ -906,6 +906,11 @@
 #define ALT_MASK	(AnyModifier<<2)
 #define EXTENDED_MASK	(AnyModifier<<3)
 
+/* The following special modifier is passed to Tk_UpdatePointer to specify
+ * that the cursor should not be changed.
+ * */
+#define NOCURSOR_MASK	(AnyModifier<<4)
+
 /*
  * Object types not declared in tkObj.c need to be mentioned here so they can
  * be properly registered with Tcl:
Index: generic/tkPointer.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkPointer.c,v
retrieving revision 1.10
diff -u -r1.10 tkPointer.c
--- generic/tkPointer.c	15 Nov 2005 15:18:22 -0000	1.10
+++ generic/tkPointer.c	27 Dec 2005 06:51:25 -0000
@@ -239,9 +239,12 @@
     TkWindow *targetWinPtr;
     XPoint pos;
     XEvent event;
-    int changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS;
+    int no_cursor = (state & NOCURSOR_MASK);
+    int changes; 
     int type, b, mask;
 
+    state &= ~NOCURSOR_MASK;
+    changes = ( state ^ tsdPtr->lastState) & ALL_BUTTONS;
     pos.x = x;
     pos.y = y;
 
@@ -386,7 +389,8 @@
     } else {
 	targetWinPtr = winPtr;
     }
-    UpdateCursor(targetWinPtr);
+    if (!no_cursor)
+	UpdateCursor(targetWinPtr);
 
     /*
      * If no other events caused the position to be updated, generate a motion
Index: win/tkWinWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinWm.c,v
retrieving revision 1.107
diff -u -r1.107 tkWinWm.c
--- win/tkWinWm.c	10 Dec 2005 01:42:01 -0000	1.107
+++ win/tkWinWm.c	27 Dec 2005 06:51:35 -0000
@@ -7664,6 +7664,8 @@
 				 * one level deep. */
     LRESULT result;
     TkWindow *winPtr = NULL;
+    POINT point;
+    int state;
 
     switch (message) {
     case WM_KILLFOCUS:
@@ -7778,6 +7780,24 @@
 	break;
     }
 
+    case WM_NCLBUTTONDOWN:
+    case WM_NCLBUTTONDBLCLK:
+    case WM_NCMBUTTONDOWN:
+    case WM_NCMBUTTONDBLCLK:
+    case WM_NCRBUTTONDOWN:
+    case WM_NCRBUTTONDBLCLK:
+    case WM_NCLBUTTONUP:
+    case WM_NCMBUTTONUP:
+    case WM_NCRBUTTONUP: 
+	point.x = (short) LOWORD(lParam);
+	point.y = (short) HIWORD(lParam);
+	state = TkWinGetModifierState();
+	state |= NOCURSOR_MASK;
+	ClientToScreen(hwnd,&point);
+	Tk_UpdatePointer(NULL, point.x, point.y, state);
+	result = (*tkWinProcs->defWindowProc)(hwnd, message, wParam, lParam);
+	return result;
+
     case WM_MOUSEACTIVATE: {
 	ActivateEvent *eventPtr;
 	winPtr = GetTopLevel((HWND) wParam);