summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-12-28 22:59:47 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-12-28 22:59:47 (GMT)
commit0a5d0843c169cfee7963b1feb685c3df23fed7c5 (patch)
tree7cd3c101d33a8fda6d4de37149c484975c458fd3
parent474bd9cda9c65a64819dd2992b1eb7cf3de2ca24 (diff)
downloadtk-0a5d0843c169cfee7963b1feb685c3df23fed7c5.zip
tk-0a5d0843c169cfee7963b1feb685c3df23fed7c5.tar.gz
tk-0a5d0843c169cfee7963b1feb685c3df23fed7c5.tar.bz2
TIP#171 implementation - sanity for <MouseWheel> event handling!
-rw-r--r--ChangeLog7
-rw-r--r--generic/tkEvent.c12
-rw-r--r--win/tkWinX.c25
3 files changed, 28 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 7295f6b..67c6f3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-12-28 Donal K. Fellows <dkf@users.sf.net>
+ TIP #171 IMPLEMENTATION
+
+ * win/tkWinX.c (GenerateXEvent): Redirect <MouseWheel> to the window
+ that contains the mouse.
+ * generic/tkEvent.c (InvokeFocusHandlers): Do not direct <MouseWheel>
+ through the focus mechanism.
+
* generic/tkImgPNG.c (ReadIDAT): Corrected code to transfer blocks of
compressed data into the Tcl_ZlibStream. Allows the reading of all
images from PngSuite set. Thanks to Michael Kirkham for fix/testing.
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index e3f925d..13e1304 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkEvent.c,v 1.37 2008/11/08 18:44:39 dkf Exp $
+ * RCS: @(#) $Id: tkEvent.c,v 1.38 2008/12/28 22:59:47 dkf Exp $
*/
#include "tkInt.h"
@@ -247,16 +247,10 @@ InvokeFocusHandlers(
}
/*
- * MouseWheel events are not focus specific on Mac OS X.
+ * Only key-related events are directed according to the focus.
*/
-#ifdef MAC_OSX_TK
-#define FOCUS_DIRECTED_EVENT_MASK (KeyPressMask|KeyReleaseMask)
-#else
-#define FOCUS_DIRECTED_EVENT_MASK (KeyPressMask|KeyReleaseMask|MouseWheelMask)
-#endif
-
- if (mask & FOCUS_DIRECTED_EVENT_MASK) {
+ if (mask & (KeyPressMask|KeyReleaseMask)) {
(*winPtrPtr)->dispPtr->lastEventTime = eventPtr->xkey.time;
*winPtrPtr = TkFocusKeyEvent(*winPtrPtr, eventPtr);
if (*winPtrPtr == NULL) {
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 160e141..4609a94 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.59 2008/12/10 05:02:52 das Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.60 2008/12/28 22:59:47 dkf Exp $
*/
/*
@@ -1006,10 +1006,26 @@ GenerateXEvent(
LPARAM lParam)
{
XEvent event;
- TkWindow *winPtr = (TkWindow *)Tk_HWNDToWindow(hwnd);
+ TkWindow *winPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ if (message == WM_MOUSEWHEEL) {
+ POINTS rootPoint = MAKEPOINTS(lParam);
+ POINT pos;
+
+ /*
+ * Redirect mousewheel events to the window containing the cursor.
+ * That feels much less strange to users, and is how all the other
+ * platforms work.
+ */
+
+ pos.x = rootPoint.x;
+ pos.y = rootPoint.y;
+ hwnd = WindowFromPoint(pos);
+ }
+
+ winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd);
if (!winPtr || winPtr->window == None) {
return;
}
@@ -1107,11 +1123,6 @@ GenerateXEvent(
break;
case WM_MOUSEWHEEL:
- /*
- * The mouse wheel event is closer to a key event than a mouse event
- * in that the message is sent to the window that has focus.
- */
-
case WM_CHAR:
case WM_UNICHAR:
case WM_SYSKEYDOWN: