From b2a1f313cf3c96df11c7d7c85c1aead7687bee7c Mon Sep 17 00:00:00 2001 From: marc_culler Date: Mon, 6 Dec 2021 12:59:55 +0000 Subject: Add a guard against remaining in the ignoreUpDown state forever; edit comments. --- macosx/tkMacOSXMouseEvent.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 1d3546e..6841aae 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -96,6 +96,7 @@ enum { static Bool isDragging = NO; static Bool ignoreDrags = NO; static Bool ignoreUpDown = NO; + static NSTimeInterval timestamp = 0; #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); @@ -186,13 +187,20 @@ enum { * and [39cbacb9e8]). Ignore button press events when ignoreUpDown is * set. These are extraneous events which appear when double-clicking * in a window without focus, causing duplicate Double-1 events (see - * ticket [7bda9882cb]. + * ticket [7bda9882cb]. To deal with this, when a LeftMouseDown event + * with clickCount 2 is received we ignore subsequent LeftMouseUp and + * LeftMouseDown events until the matching LeftMouseUp with click count + * 2 is received. */ + if ([theEvent timestamp] - timestamp > 1) { + ignoreUpDown = NO; + } if ([theEvent clickCount] == 2) { if (ignoreUpDown == YES) { return theEvent; } else { + timestamp = [theEvent timestamp]; ignoreUpDown = YES; } } -- cgit v0.12