Tk Source Code

Artifact [f6b39155]
Login

Artifact f6b39155ede945c9770b92dccd0fbb52890604bb:

Attachment "badclick-win32.patch" to ticket [1391053f] added by a_kovalenko 2005-12-27 12:32:27.
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 04:59:38 -0000
@@ -7761,6 +7761,26 @@
 	result = 0;
 	goto done;
 
+    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:
+	/* When a mouse event occurs in a non-client area, we want Tk to
+	 * notice the mouse state change in this very moment.
+	 *
+	 * When Tk_PointerEvent was not called here, it used to generate
+	 * spurious mouse events later, misdirected to some Tk window 
+	 * on certain conditions (i.e. maximizing/closing double click)
+	 *  */
+	Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam));
+	result = (*tkWinProcs->defWindowProc)(hwnd, message, wParam, lParam);
+	return result;
+
     case WM_NCHITTEST: {
 	winPtr = GetTopLevel(hwnd);
 	if (winPtr && (TkGrabState(winPtr) == TK_GRAB_EXCLUDED)) {