From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#48409: Text runs away before user can copy it Date: Fri, 21 May 2021 20:55:27 +0000 Message-ID: References: <83fsypztd4.fsf@gnu.org> <87cztt9qdj.fsf@mail.linkov.net> <83mtsxxfo8.fsf@gnu.org> <87h7j12j93.fsf@mail.linkov.net> <83bl98rxqo.fsf@gnu.org> <83k0nvrhgg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38545"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48409@debbugs.gnu.org, juri@linkov.net To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 21 22:56:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lkCBn-0009so-Ek for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 May 2021 22:56:11 +0200 Original-Received: from localhost ([::1]:54258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lkCBl-00029j-I0 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 May 2021 16:56:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lkCBe-00029L-55 for bug-gnu-emacs@gnu.org; Fri, 21 May 2021 16:56:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lkCBd-0007jk-T5 for bug-gnu-emacs@gnu.org; Fri, 21 May 2021 16:56:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lkCBd-0003JW-S7 for bug-gnu-emacs@gnu.org; Fri, 21 May 2021 16:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 May 2021 20:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48409 X-GNU-PR-Package: emacs Original-Received: via spool by 48409-submit@debbugs.gnu.org id=B48409.162163054012669 (code B ref 48409); Fri, 21 May 2021 20:56:01 +0000 Original-Received: (at 48409) by debbugs.gnu.org; 21 May 2021 20:55:40 +0000 Original-Received: from localhost ([127.0.0.1]:37867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lkCBH-0003IF-Ok for submit@debbugs.gnu.org; Fri, 21 May 2021 16:55:40 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:54203 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lkCBC-0003HO-AP for 48409@debbugs.gnu.org; Fri, 21 May 2021 16:55:38 -0400 Original-Received: (qmail 30226 invoked by uid 3782); 21 May 2021 20:55:27 -0000 Original-Received: from acm.muc.de (p4fe15bd1.dip0.t-ipconnect.de [79.225.91.209]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 21 May 2021 22:55:27 +0200 Original-Received: (qmail 20335 invoked by uid 1000); 21 May 2021 20:55:27 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207003 Archived-At: Hello, Martin. On Thu, May 20, 2021 at 18:54:45 +0200, martin rudalics wrote: > > For clicks into the bottom line the attached might help. Clicks above > > must be caught elsewhere. But you don't get a drag event and no error > > message for them. > The attached patch should allow clicking anywhere in the minibuffer > window. Its more than kludgy but this is a bug that has annoyed me > for years. I've been laboriously working out a patch, too, and have come up with the one below. It takes a surprisingly similar approach to your own patch [snipped], but doesn't test for a minibuffer, so perhaps is more general. I didn't actually study your patch till my own was nearly finished. To detect mouse movement, my patch changes from comparing window relative x, y to frame relative x, y. If the code detects no movement, but a different window, the position of the up event is changed to be inside the window of the down event. diff --git a/src/keyboard.c b/src/keyboard.c index 47b5e59024..08386e0685 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5022,6 +5022,10 @@ static short const internal_border_parts[] = { static Lisp_Object button_down_location; +/* A cons recording the original frame-relative x and y coordinates of + the down mouse event. */ +static Lisp_Object frame_relative_event_pos; + /* Information about the most recent up-going button event: Which button, what location, and what time. */ @@ -5673,6 +5677,7 @@ make_lispy_event (struct input_event *event) double_click_count = 1; button_down_time = event->timestamp; *start_pos_ptr = Fcopy_alist (position); + frame_relative_event_pos = Fcons (event->x, event->y); ignore_mouse_drag_p = false; } @@ -5695,20 +5700,12 @@ make_lispy_event (struct input_event *event) ignore_mouse_drag_p = false; else { - Lisp_Object new_down, down; intmax_t xdiff = double_click_fuzz, ydiff = double_click_fuzz; - /* The third element of every position - should be the (x,y) pair. */ - down = Fcar (Fcdr (Fcdr (start_pos))); - new_down = Fcar (Fcdr (Fcdr (position))); - - if (CONSP (down) - && FIXNUMP (XCAR (down)) && FIXNUMP (XCDR (down))) - { - xdiff = XFIXNUM (XCAR (new_down)) - XFIXNUM (XCAR (down)); - ydiff = XFIXNUM (XCDR (new_down)) - XFIXNUM (XCDR (down)); - } + xdiff = XFIXNUM (event->x) + - XFIXNUM (XCAR (frame_relative_event_pos)); + ydiff = XFIXNUM (event->y) + - XFIXNUM (XCDR (frame_relative_event_pos)); if (! (0 < double_click_fuzz && - double_click_fuzz < xdiff @@ -5725,12 +5722,51 @@ make_lispy_event (struct input_event *event) a click. But mouse-drag-region completely ignores this case and it hasn't caused any real problem, so it's probably OK to ignore it as well. */ - && EQ (Fcar (Fcdr (start_pos)), Fcar (Fcdr (position))))) + && (EQ (Fcar (Fcdr (start_pos)), + Fcar (Fcdr (position))) /* Same buffer pos */ + || !EQ (Fcar (start_pos), + Fcar (position))))) /* Different window */ { /* Mouse has moved enough. */ button_down_time = 0; click_or_drag_modifier = drag_modifier; } + else if (((!EQ (Fcar (start_pos), Fcar (position))) + || (!EQ (Fcar (Fcdr (start_pos)), + Fcar (Fcdr (position))))) + /* Was the down event in a window body? */ + && FIXNUMP (Fcar (Fcdr (start_pos))) + && WINDOW_LIVE_P (Fcar (start_pos)) + && Ffboundp (Qwindow_edges)) + /* If the window (etc.) at the mouse position has + changed between the down event and the up event, + we assume there's been a redisplay between the + two events, and we pretend the mouse is still in + the old window to prevent a spurious drag event + being generated. */ + { + Lisp_Object edges + = call4 (Qwindow_edges, Fcar (start_pos), Qt, Qnil, Qt); + int new_x = XFIXNUM (Fcar (frame_relative_event_pos)); + int new_y = XFIXNUM (Fcdr (frame_relative_event_pos)); + + /* If the up-event is outside the down-event's + window, use coordinates that are within it. */ + if (new_x < XFIXNUM (Fcar (edges))) + new_x = XFIXNUM (Fcar (edges)); + else if (new_x >= XFIXNUM (Fcar (Fcdr (Fcdr (edges))))) + new_x = XFIXNUM (Fcar (Fcdr (Fcdr (edges)))) - 1; + if (new_y < XFIXNUM (Fcar (Fcdr (edges)))) + new_y = XFIXNUM (Fcar (Fcdr (edges))); + else if (new_y + >= XFIXNUM (Fcar (Fcdr (Fcdr (Fcdr (edges)))))) + new_y = XFIXNUM (Fcar (Fcdr (Fcdr (Fcdr (edges))))) - 1; + + position = make_lispy_position + (XFRAME (event->frame_or_window), + make_fixnum (new_x), make_fixnum (new_y), + event->timestamp); + } } /* Don't check is_double; treat this as multiple if the @@ -11649,6 +11685,7 @@ syms_of_keyboard (void) DEFSYM (Qmake_frame_visible, "make-frame-visible"); DEFSYM (Qselect_window, "select-window"); DEFSYM (Qselection_request, "selection-request"); + DEFSYM (Qwindow_edges, "window-edges"); { int i; @@ -11665,6 +11702,7 @@ syms_of_keyboard (void) button_down_location = make_nil_vector (5); staticpro (&button_down_location); + staticpro (&frame_relative_event_pos); mouse_syms = make_nil_vector (5); staticpro (&mouse_syms); wheel_syms = make_nil_vector (ARRAYELTS (lispy_wheel_names)); > martin -- Alan Mackenzie (Nuremberg, Germany).