From e1f4e434397a66223cf6265b4b0a134128c6c65f Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 28 Dec 2008 22:59:47 +0000 Subject: TIP#171 implementation - sanity for event handling! FossilOrigin-Name: da1b92466b00755b637abcefff167817f0240a69 --- ChangeLog | 7 +++++++ generic/tkEvent.c | 12 +++--------- win/tkWinX.c | 25 ++++++++++++++++++------- 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 + TIP #171 IMPLEMENTATION + + * win/tkWinX.c (GenerateXEvent): Redirect to the window + that contains the mouse. + * generic/tkEvent.c (InvokeFocusHandlers): Do not direct + 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: -- cgit v0.12