Attachment "0001-ak-Track-pointer-button-state.patch" to
ticket [2838812f]
added by
patthoyts
2010-01-02 23:43:51.
From a6d01663e68affdd278029109451e861f7d26e73 Mon Sep 17 00:00:00 2001
From: Pat Thoyts <[email protected]>
Date: Sat, 2 Jan 2010 14:20:34 +0000
Subject: [PATCH 1/3] ak: Track pointer button state.
This patch from Anton Kovalenko enhances the pointer management to avoid
generating additional button events under some circumstances.
Signed-off-by: Pat Thoyts <[email protected]>
---
generic/tkInt.h | 10 ++++++++++
generic/tkPointer.c | 23 ++++++++++++++++++++++-
win/tkWinDialog.c | 12 +++---------
3 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/generic/tkInt.h b/generic/tkInt.h
index e0c5a2b..e7676a8 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -933,6 +933,16 @@ MODULE_SCOPE TkDisplay *tkDisplayList;
#define ALT_MASK (AnyModifier<<2)
#define EXTENDED_MASK (AnyModifier<<3)
+/* The following special modifier is passed to Tk_UpdatePointer to specify
+ * that the cursor should not be changed.
+ * */
+#define NOCURSOR_MASK (AnyModifier<<4)
+
+/* The following special modifier is passed to Tk_UpdatePointer
+ * in order to update current position but not to generate button events
+ * */
+#define NOBUTTONEVENTS_MASK (AnyModifier<<5)
+
/*
* Object types not declared in tkObj.c need to be mentioned here so they can
* be properly registered with Tcl:
diff --git a/generic/tkPointer.c b/generic/tkPointer.c
index 42f3765..23b709c 100644
--- a/generic/tkPointer.c
+++ b/generic/tkPointer.c
@@ -239,9 +239,25 @@ Tk_UpdatePointer(
TkWindow *targetWinPtr;
XPoint pos;
XEvent event;
- int changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS;
+ int no_cursor = (state & NOCURSOR_MASK);
+ int no_button_events = (state & NOBUTTONEVENTS_MASK);
+ int changes;
int type, b, mask;
+ if (state & ALL_BUTTONS) {
+ tsdPtr->lastState &= ~NOCURSOR_MASK;
+ }
+ state &= ~NOCURSOR_MASK & ~NOBUTTONEVENTS_MASK;
+ if (no_cursor) {
+ tsdPtr->lastState = (tsdPtr->lastState & ~ALL_BUTTONS) |
+ (state & ALL_BUTTONS) | NOCURSOR_MASK;
+ return;
+ } else if (tsdPtr->lastState & NOCURSOR_MASK) {
+ tsdPtr->lastState = (tsdPtr->lastState & ~NOCURSOR_MASK & ~ALL_BUTTONS) |
+ (state & ALL_BUTTONS);
+ return;
+ }
+ changes = ( state ^ tsdPtr->lastState) & ALL_BUTTONS;
pos.x = x;
pos.y = y;
@@ -253,6 +269,11 @@ Tk_UpdatePointer(
tsdPtr->lastState = (state & ~ALL_BUTTONS) | (tsdPtr->lastState
& ALL_BUTTONS);
+ if (no_button_events) {
+ tsdPtr->lastState = state;
+ return;
+ }
+
/*
* Generate Enter/Leave events. If the pointer has crossed window
* boundaries, update the current mouse position so we don't generate
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 9d098e2..20410c9 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -231,15 +231,9 @@ static char * ConvertExternalFilename(Tcl_Encoding encoding,
static void
EatSpuriousMessageBugFix(void)
{
- MSG msg;
- DWORD nTime = GetTickCount() + 250;
-
- while (GetTickCount() < nTime) {
- if (PeekMessage(&msg, 0, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE)){
- break;
- }
- PeekMessage(&msg, 0, WM_LBUTTONUP, WM_LBUTTONUP, PM_REMOVE);
- }
+ int state = TkWinGetModifierState();
+ Tk_UpdatePointer(NULL,0,0, state | NOBUTTONEVENTS_MASK);
+ return;
}
/*
--
1.6.6