unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Cecilio Pardo <cpardo@imayhem.com>
To: 6372@debbugs.gnu.org.
Subject: bug#6372: 24.0.50; C-mouse-1 activates region
Date: Fri, 16 Aug 2024 03:18:42 +0200	[thread overview]
Message-ID: <2267ebe5-2b20-491d-acea-67ab28ca1471@imayhem.com> (raw)
In-Reply-To: <B10C013621504F2293AC68C8CA31CA37@us.oracle.com>

[-- Attachment #1: Type: text/plain, Size: 258 bytes --]

This seems to happen because TrackPopupMenu returns as
soon as the WM_LBUTTONDOWN is received. That message is
correctly purged. The problem comes from the subsequent
WM_LBUTTONUP message.

This patch is not a clean solution, but keeps the problem local.




[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 1308 bytes --]

diff --git a/src/w32fns.c b/src/w32fns.c
index bd65aa48a14..ae33f959dd2 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -5669,9 +5669,36 @@ #define WM_TOUCH 576
 			    0, hwnd, NULL))
 	  {
 	    MSG amsg;
-	    /* Eat any mouse messages during popupmenu */
+	    bool have_lbuttondown = false;
+	    /* Eat any mouse messages during popupmenu. If there is a
+	       WM_LBUTTONDOWN, then we need to wait for the
+	       corresponding WM_LBUTTONUP to suppress it, or it will be
+	       handled elsewhere */
 	    while (PeekMessage (&amsg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST,
-				PM_REMOVE));
+				PM_REMOVE))
+	      {
+		if (amsg.message == WM_LBUTTONDOWN)
+		  {
+		    have_lbuttondown = true;
+		    SetCapture(hwnd);
+		  }
+	      }
+
+	    if (have_lbuttondown)
+	      {
+		/* WM_LBUTTONUP should arrive, but we can't risk hanging
+		   here if it does not, so we wait only for so long */
+		struct timespec start = current_timespec();
+		while (!PeekMessage (&amsg, hwnd, WM_LBUTTONUP, WM_LBUTTONUP,
+				     PM_REMOVE))
+		  {
+		    if (timespectod (timespec_sub (current_timespec (),
+						   start)) > 2.0 )
+		      break;
+		  }
+		ReleaseCapture();
+	      }
+
 	    /* Get the menu selection, if any */
 	    if (PeekMessage (&amsg, hwnd, WM_COMMAND, WM_COMMAND, PM_REMOVE))
 	      {

  parent reply	other threads:[~2024-08-16  1:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-07 17:19 bug#6372: 24.0.50; C-mouse-1 activates region Drew Adams
2012-07-08 13:41 ` Chong Yidong
2012-07-08 17:18   ` Drew Adams
2012-07-08 18:09     ` Eli Zaretskii
2012-07-09  4:37       ` Chong Yidong
2012-07-21 11:42         ` Eli Zaretskii
2012-08-08 18:39           ` Drew Adams
2012-09-16 23:34             ` Drew Adams
2012-10-19 15:02               ` Drew Adams
2012-07-08 15:00 ` Dmitry Gutov
2020-08-18 11:10 ` Stefan Kangas
2020-08-18 12:11   ` Eli Zaretskii
2024-08-16  1:18 ` Cecilio Pardo [this message]
2024-08-18 21:47   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-19  7:11     ` Cecilio Pardo
     [not found] <<B10C013621504F2293AC68C8CA31CA37@us.oracle.com>
     [not found] ` <<CADwFkmkK6JtAXf6aOf_ZNMiw0gKDuGJrV1p7qehk+0qe4V7U=Q@mail.gmail.com>
     [not found]   ` <<83k0xwf92g.fsf@gnu.org>
2020-08-18 16:37     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2267ebe5-2b20-491d-acea-67ab28ca1471@imayhem.com \
    --to=cpardo@imayhem.com \
    --cc=6372@debbugs.gnu.org. \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).