From e58c4121633f54dd00b872d11a8e40cc777c5ab5 Mon Sep 17 00:00:00 2001 From: wolfsuit Date: Wed, 19 Feb 2003 22:20:54 +0000 Subject: 2003-02-19 Jim Ingham * tkMacOSXMouseEvents.c (GeneratePollingEvents): In the case where there was a capture window, we were sending the events to the capture window. But the capture window (return value or TkMacOSXGetCapture) is always a toplevel. So this is wrong in the case that the Event's toplevel IS the capture window - in which case the event should go to the subwindow most closely containing the event. Fixes bug #688188 --- ChangeLog | 10 ++++++++ macosx/tkMacOSXMouseEvent.c | 56 ++++++++++++++++++--------------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 829de23..bb2bdce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-02-19 Jim Ingham + + * tkMacOSXMouseEvents.c (GeneratePollingEvents): In the case + where there was a capture window, we were sending the events to + the capture window. But the capture window (return value or + TkMacOSXGetCapture) is always a toplevel. So this is wrong in + the case that the Event's toplevel IS the capture window - in + which case the event should go to the subwindow most closely + containing the event. + 2003-02-19 Benjamin Riefenstahl & Jim Ingham diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index e771edb..2516ef8 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -470,28 +470,38 @@ HandleInCollapse(WindowRef win) static int GeneratePollingEvents(MouseEventData * medPtr) { - Tk_Window tkwin, rootwin, grabWin; + Tk_Window tkwin, rootwin, grabWin, topPtr; Window window; int local_x, local_y; TkDisplay *dispPtr; - /* - * I really do not understand this complicated logic. Surely the event - * should be to either: (1) medPtr->whichWin, the window under the mouse - * (from which we then obviously extract the correct Tk subwindow), or - * (2) the current grab window. I really don't see why anything else is - * relevant. - */ -#if 0 + + grabWin = TkMacOSXGetCapture(); + if ((!TkpIsWindowFloating(medPtr->whichWin) && (medPtr->activeNonFloating != medPtr->whichWin))) { - tkwin = NULL; + /* + * If the window for this event is not floating, and is not the + * active non-floating window, don't generate polling events. + * We don't send events to backgrounded windows. So either send + * it to the grabWin, or NULL if there is no grabWin. + */ + + tkwin = grabWin; } else { + /* + * First check whether the toplevel containing this mouse + * event is the grab window. If not, then send the event + * to the grab window. Otherwise, set tkWin to the subwindow + * which most closely contains the mouse event. + */ + window = TkMacOSXGetXWindow(medPtr->whichWin); dispPtr = TkGetDisplayList(); rootwin = Tk_IdToWindow(dispPtr->display, window); - if (rootwin == NULL) { - tkwin = NULL; + if ((rootwin == NULL) + || ((grabWin != NULL) && (rootwin != grabWin))) { + tkwin = grabWin; } else { tkwin = Tk_TopCoordsToWindow(rootwin, medPtr->local.h, medPtr->local.v, @@ -504,28 +514,6 @@ GeneratePollingEvents(MouseEventData * medPtr) * adjust any state that Tk must remember. */ - grabWin = TkMacOSXGetCapture(); - - if ((tkwin == NULL) && (grabWin != NULL)) { - tkwin = grabWin; - } -#else - grabWin = TkMacOSXGetCapture(); - if (grabWin != NULL) { - tkwin = grabWin; - } else { - window = TkMacOSXGetXWindow(medPtr->whichWin); - dispPtr = TkGetDisplayList(); - rootwin = Tk_IdToWindow(dispPtr->display, window); - if (rootwin == NULL) { - tkwin = NULL; - } else { - tkwin = Tk_TopCoordsToWindow(rootwin, - medPtr->local.h, medPtr->local.v, - &local_x, &local_y); - } - } -#endif Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state); -- cgit v0.12