summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authormdejong <mdejong>2003-02-18 06:22:44 (GMT)
committermdejong <mdejong>2003-02-18 06:22:44 (GMT)
commit1821e19bc72152b13ef6a7789b22bf239d713846 (patch)
tree4c81cd56ef843501912d782732a5165b523d2f02 /generic
parenta90f19807e0282b4c15f10bd77b96d1c281b22d3 (diff)
downloadtk-1821e19bc72152b13ef6a7789b22bf239d713846.zip
tk-1821e19bc72152b13ef6a7789b22bf239d713846.tar.gz
tk-1821e19bc72152b13ef6a7789b22bf239d713846.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.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkEvent.c19
-rw-r--r--generic/tkInt.h4
2 files changed, 20 insertions, 3 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;
+ }
+ }
}
/*
diff --git a/generic/tkInt.h b/generic/tkInt.h
index cd40d80..2723d41 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -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: tkInt.h,v 1.55 2003/01/28 20:39:15 jenglish Exp $
+ * RCS: $Id: tkInt.h,v 1.56 2003/02/18 06:22:44 mdejong Exp $
*/
#ifndef _TKINT
@@ -493,6 +493,8 @@ typedef struct TkDisplay {
*/
int mouseButtonState; /* current mouse button state for this
* display */
+ Window mouseButtonWindow; /* Window the button state was set in,
+ * added in Tk 8.4. */
Window warpWindow;
int warpX;
int warpY;