diff options
author | mdejong <mdejong@noemail.net> | 2003-02-18 06:22:44 (GMT) |
---|---|---|
committer | mdejong <mdejong@noemail.net> | 2003-02-18 06:22:44 (GMT) |
commit | 2250e6cd7913daf076ee1a5fb9ea45e2f2180f40 (patch) | |
tree | 4c81cd56ef843501912d782732a5165b523d2f02 /generic/tkEvent.c | |
parent | a474c3282d3fe3442c160821fd21e19fcde02dd3 (diff) | |
download | tk-2250e6cd7913daf076ee1a5fb9ea45e2f2180f40.zip tk-2250e6cd7913daf076ee1a5fb9ea45e2f2180f40.tar.gz tk-2250e6cd7913daf076ee1a5fb9ea45e2f2180f40.tar.bz2 |
* generic/tkEvent.c (Tk_HandleEvent): Fixup button
press state saving code, it was incorrectly converting
normal motion events into button press and motion
events in some cases.
* generic/tkInt.h: Add mouseButtonWindow member
to the TkDisplay structure.
* tests/event.test: Add test case for faulty
button motion logic.
FossilOrigin-Name: e79d36e4257422c5659d9a61879718160950fb62
Diffstat (limited to 'generic/tkEvent.c')
-rw-r--r-- | generic/tkEvent.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 009e2f5..954f24c 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -11,7 +11,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.16 2002/06/19 19:37:54 mdejong Exp $ + * RCS: @(#) $Id: tkEvent.c,v 1.17 2003/02/18 06:22:44 mdejong Exp $ */ #include "tkPort.h" @@ -645,6 +645,7 @@ Tk_HandleEvent(eventPtr) if (eventPtr->type==ButtonPress) { dispPtr = TkGetDisplay(eventPtr->xbutton.display); + dispPtr->mouseButtonWindow = eventPtr->xbutton.window; eventPtr->xbutton.state |= dispPtr->mouseButtonState; switch (eventPtr->xbutton.button) { case 1: dispPtr->mouseButtonState |= Button1Mask; break; @@ -653,6 +654,7 @@ Tk_HandleEvent(eventPtr) } } else if (eventPtr->type==ButtonRelease) { dispPtr = TkGetDisplay(eventPtr->xbutton.display); + dispPtr->mouseButtonWindow = 0; switch (eventPtr->xbutton.button) { case 1: dispPtr->mouseButtonState &= ~Button1Mask; break; case 2: dispPtr->mouseButtonState &= ~Button2Mask; break; @@ -661,7 +663,20 @@ Tk_HandleEvent(eventPtr) eventPtr->xbutton.state |= dispPtr->mouseButtonState; } else if (eventPtr->type==MotionNotify) { dispPtr = TkGetDisplay(eventPtr->xmotion.display); - eventPtr->xmotion.state |= dispPtr->mouseButtonState; + if (dispPtr->mouseButtonState & (Button1Mask|Button2Mask|Button3Mask)) { + if (eventPtr->xbutton.window != dispPtr->mouseButtonWindow) { + /* + * This motion event should not be interpreted as a button + * press + motion event since this is not the same window + * the button was pressed down in. + */ + dispPtr->mouseButtonState &= + ~(Button1Mask|Button2Mask|Button3Mask); + dispPtr->mouseButtonWindow = 0; + } else { + eventPtr->xmotion.state |= dispPtr->mouseButtonState; + } + } } /* |