From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.bugs Subject: bug#4892: [PATCH] Fix mouse-position on macOS (bug#4892) Date: Wed, 4 Dec 2019 07:48:45 -0500 Message-ID: <308f07c7-3aa1-457a-b2fb-edf1039ed7f4@Spark> References: <20191204124404.GA62687@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="5de7ab33_643c9869_1689" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="182954"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 4892@debbugs.gnu.org To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 04 13:50:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1icU6e-000lR4-23 for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Dec 2019 13:50:12 +0100 Original-Received: from localhost ([::1]:38346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icU6c-0002jD-Vg for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Dec 2019 07:50:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55467) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icU6W-0002hC-38 for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2019 07:50:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icU6U-0005ad-GC for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2019 07:50:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35566) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icU6U-0005aV-99 for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2019 07:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1icU6U-0008V5-6z for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2019 07:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: David Reitter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Dec 2019 12:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 4892 X-GNU-PR-Package: emacs Original-Received: via spool by 4892-submit@debbugs.gnu.org id=B4892.157546374232590 (code B ref 4892); Wed, 04 Dec 2019 12:50:02 +0000 Original-Received: (at 4892) by debbugs.gnu.org; 4 Dec 2019 12:49:02 +0000 Original-Received: from localhost ([127.0.0.1]:41539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icU5V-0008TM-Ow for submit@debbugs.gnu.org; Wed, 04 Dec 2019 07:49:02 -0500 Original-Received: from mail-qt1-f194.google.com ([209.85.160.194]:38750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icU5T-0008T2-M4 for 4892@debbugs.gnu.org; Wed, 04 Dec 2019 07:49:00 -0500 Original-Received: by mail-qt1-f194.google.com with SMTP id 14so7586381qtf.5 for <4892@debbugs.gnu.org>; Wed, 04 Dec 2019 04:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=94c+3+cVkg2lj5K4PNvPNDQvj1zB7xXDQHbI2dAR9ck=; b=DHlRQzkgmGZE6HjzF5zc20/8op0pSQXH0Lp3EX4TfelJ803hFBFJ5kRn/m6t0/I63v EBdBPiUVnbz0swp0N9/2c3knVXGVu42ipdI2suGuS9W/huH9Z9UV1zqF80oTH1Kpd3Er n64kDKTRlR9aLm3GZlUZFmFcG8J6kl+uwaBs1MRg6qMdZSD5sopDNWUEL9VXzcuP51A8 WJt1X8x4+26hTXXaFhqDmi/wLmM578JnH5b7XkOd9lfL56jef8et6zb9dqUhFP6h2VZZ O1EuBp+evbggizi+RHRDn7hTfU/ep3ZVRam8bfbAKF+qW7jewNdu/sNLWgEHlNFow/E7 oTWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=94c+3+cVkg2lj5K4PNvPNDQvj1zB7xXDQHbI2dAR9ck=; b=UE6MgdSnWD2xOytQ1o8knF0iYKHSmvs/nZeS6Ylf7c3mEQX4oruiNfwvwKhi3zdN5V tmmH/IRVrF/k55AhdP4xVajBRC/BjeMNSty024f6LIMq+FzsOCLciSkuBzknz5eorKDe eBvZq3cXnZImcrhaCjnT6MkbD3iZ0U9GQc4suHNNqz4Rfh7R/LnWDXxw9YCj1PriDRe4 lt+sL+JVB03ss/H1aQR0WSla14cC7RNFyxaLxZIYVvmnFMaiVcLA6/RJs1cd68ybfHfR 52g+H8nqpWVMclN16xSDSkn4iYuIa7IST2tN3KDk+KGx0VUzZZx3TikRHHOCHW8j1KR/ alow== X-Gm-Message-State: APjAAAUbhH/63IUl1ahlrvcfogf/EZ0lG+f2cil7dybO4vDnl9FC5F3Y w5hh+UwzL0hhYOYTI2SJyw9BSFk5icUSbxQ= X-Google-Smtp-Source: APXvYqzLEVzSCDchCF/WhhP6FgnGFmDlYnLwvAN3f691t8kAJ8EB6ZoInlvgcmVaFujszf5QFTJDVg== X-Received: by 2002:ac8:47cc:: with SMTP id d12mr2498176qtr.246.1575463733933; Wed, 04 Dec 2019 04:48:53 -0800 (PST) Original-Received: from [10.0.1.5] (pool-98-116-189-180.nycmny.fios.verizon.net. [98.116.189.180]) by smtp.gmail.com with ESMTPSA id y200sm3570976qkb.1.2019.12.04.04.48.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 04:48:53 -0800 (PST) In-Reply-To: <20191204124404.GA62687@breton.holly.idiocy.org> X-Readdle-Message-ID: 308f07c7-3aa1-457a-b2fb-edf1039ed7f4@Spark X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:172833 Archived-At: --5de7ab33_643c9869_1689 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Looks good to me (but haven=E2=80=99t tried). Thanks for working on this=21= DR On Dec 4, 2019, 07:44 -0500, Alan Third , wrote: > * src/nsterm.m (ns=5Fmouse=5Fposition): Implement a search for the fram= e > under the mouse pointer. > --- > src/nsterm.m =7C 52 ++++++++++++++++++++++++++++++++++++++-------------= - > 1 file changed, 38 insertions(+), 14 deletions(-) > > diff --git a/src/nsterm.m b/src/nsterm.m > index 52a9830be8..71234ac783 100644 > --- a/src/nsterm.m > +++ b/src/nsterm.m > =40=40 -2475,7 +2475,7 =40=40 so some key presses (TAB) are swallowed b= y the system. */ > -----------------------------------------------------------------------= --- */ > =7B > id view; > - NSPoint position; > + NSPoint view=5Fposition; > Lisp=5FObject frame, tail; > struct frame *f; > struct ns=5Fdisplay=5Finfo *dpyinfo; > =40=40 -2498,31 +2498,55 =40=40 so some key presses (TAB) are swallowed= by the system. */ > X=46RAME (frame)->mouse=5Fmoved =3D 0; > > dpyinfo->last=5Fmouse=5Fscroll=5Fbar =3D nil; > - f =3D dpyinfo->ns=5Ffocus=5Fframe =3F dpyinfo->ns=5Ffocus=5Fframe : S= ELECTED=5F=46RAME (); > - if (dpyinfo->last=5Fmouse=5Fframe > - /* While dropping, use the last mouse frame only if there is no > - currently focused frame. */ > - && (=21EQ (track=5Fmouse, Qdropping) =7C=7C =21f) > + > +=23ifdef NS=5FIMPL=5FCOCOA > + /* =46ind the uppermost Emacs frame under the mouse pointer. > + > + This doesn't work on GNUstep, although in recent versions there > + is compatibility code that makes it a noop. */ > + > + NSPoint screen=5Fposition =3D =5BNSEvent mouseLocation=5D; > + NSInteger window=5Fnumber =3D 0; > + do > + =7B > + NSWindow *w; > + > + window=5Fnumber =3D =5BNSWindow windowNumberAtPoint:screen=5Fposition= > + belowWindowWithWindowNumber:window=5Fnumber=5D; > + w =3D =5BNSApp windowWithWindowNumber:window=5Fnumber=5D; > + > + if (w && =5B=5Bw delegate=5D isKindOfClass:=5BEmacsView class=5D=5D) > + f =3D ((EmacsView *)=5Bw delegate=5D)->emacsframe; > + =7D > + while (window=5Fnumber > 0 && =21f); > +=23endif > + > + if (=21f) > + f =3D dpyinfo->ns=5Ffocus=5Fframe =3F dpyinfo->ns=5Ffocus=5Fframe : S= ELECTED=5F=46RAME (); > + > + /* While dropping, use the last mouse frame only if there is no > + currently focused frame. */ > + if (=21f > + && EQ (track=5Fmouse, Qdropping) > + && dpyinfo->last=5Fmouse=5Fframe > && =46RAME=5FLIVE=5FP (dpyinfo->last=5Fmouse=5Fframe)) > f =3D dpyinfo->last=5Fmouse=5Fframe; > - else > - f =3D dpyinfo->ns=5Ffocus=5Fframe =3F dpyinfo->ns=5Ffocus=5Fframe : S= ELECTED=5F=46RAME (); > > if (f && =46RAME=5FNS=5FP (f)) > =7B > view =3D =46RAME=5FNS=5FVIEW (f); > > - position =3D =5B=5Bview window=5D mouseLocationOutsideOfEventStream=5D= ; > - position =3D =5Bview convertPoint: position fromView: nil=5D; > - remember=5Fmouse=5Fglyph (f, position.x, position.y, > + view=5Fposition =3D =5B=5Bview window=5D mouseLocationOutsideOfEventS= tream=5D; > + view=5Fposition =3D =5Bview convertPoint: view=5Fposition fromView: n= il=5D; > + remember=5Fmouse=5Fglyph (f, view=5Fposition.x, view=5Fposition.y, > &dpyinfo->last=5Fmouse=5Fglyph); > - NSTRACE=5FPOINT (=22position=22, position); > + NSTRACE=5FPOINT (=22view=5Fposition=22, view=5Fposition); > > if (bar=5Fwindow) *bar=5Fwindow =3D Qnil; > if (part) *part =3D scroll=5Fbar=5Fabove=5Fhandle; > > - if (x) XSETINT (*x, lrint (position.x)); > - if (y) XSETINT (*y, lrint (position.y)); > + if (x) XSETINT (*x, lrint (view=5Fposition.x)); > + if (y) XSETINT (*y, lrint (view=5Fposition.y)); > if (time) > *time =3D dpyinfo->last=5Fmouse=5Fmovement=5Ftime; > *fp =3D f; > -- > 2.21.0 > > > -- > Alan Third --5de7ab33_643c9869_1689 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Looks good to me (but haven=E2=80=99t tried). Thank= s for working on this=21
DR
On Dec 4, 2019, 07:44 -0500, Alan T= hird <alan=40idiocy.org>, wrote:
* = src/nsterm.m (ns=5Fmouse=5Fposition): Implement a search for the frame under the mouse pointer.
---
src/nsterm.m =7C 52 ++++++++++++++++++++++++++++++++++++++--------------<= br /> 1 file changed, 38 insertions(+), 14 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 52a9830be8..71234ac783 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
=40=40 -2475,7 +2475,7 =40=40 so some key presses (TAB) are swallowed by = the system. */
-------------------------------------------------------------------------= - */
=7B
id view;
- NSPoint position;
+ NSPoint view=5Fposition;
Lisp=5FObject frame, tail;
struct frame *f;
struct ns=5Fdisplay=5Finfo *dpyinfo;
=40=40 -2498,31 +2498,55 =40=40 so some key presses (TAB) are swallowed b= y the system. */
X=46RAME (frame)->mouse=5Fmoved =3D 0;

dpyinfo->last=5Fmouse=5Fscroll=5Fbar =3D nil;
- f =3D dpyinfo->ns=5Ffocus=5Fframe =3F dpyinfo->ns=5Ffocus=5Fframe= : SELECTED=5F=46RAME ();
- if (dpyinfo->last=5Fmouse=5Fframe
- /* While dropping, use the last mouse frame only if there is no
- currently focused frame. */
- && (=21EQ (track=5Fmouse, Qdropping) =7C=7C =21f)
+
+=23ifdef NS=5FIMPL=5FCOCOA
+ /* =46ind the uppermost Emacs frame under the mouse pointer.
+
+ This doesn't work on GNUstep, although in recent versions there
+ is compatibility code that makes it a noop. */
+
+ NSPoint screen=5Fposition =3D =5BNSEvent mouseLocation=5D;
+ NSInteger window=5Fnumber =3D 0;
+ do
+ =7B
+ NSWindow *w;
+
+ window=5Fnumber =3D =5BNSWindow windowNumberAtPoint:screen=5Fposition + belowWindowWithWindowNumber:window=5Fnumber=5D;
+ w =3D =5BNSApp windowWithWindowNumber:window=5Fnumber=5D;
+
+ if (w && =5B=5Bw delegate=5D isKindOfClass:=5BEmacsView class=5D= =5D)
+ f =3D ((EmacsView *)=5Bw delegate=5D)->emacsframe;
+ =7D
+ while (window=5Fnumber > 0 && =21f);
+=23endif
+
+ if (=21f)
+ f =3D dpyinfo->ns=5Ffocus=5Fframe =3F dpyinfo->ns=5Ffocus=5Fframe= : SELECTED=5F=46RAME ();
+
+ /* While dropping, use the last mouse frame only if there is no
+ currently focused frame. */
+ if (=21f
+ && EQ (track=5Fmouse, Qdropping)
+ && dpyinfo->last=5Fmouse=5Fframe
&& =46RAME=5FLIVE=5FP (dpyinfo->last=5Fmouse=5Fframe))
f =3D dpyinfo->last=5Fmouse=5Fframe;
- else
- f =3D dpyinfo->ns=5Ffocus=5Fframe =3F dpyinfo->ns=5Ffocus=5Fframe= : SELECTED=5F=46RAME ();

if (f && =46RAME=5FNS=5FP (f))
=7B
view =3D =46RAME=5FNS=5FVIEW (f);

- position =3D =5B=5Bview window=5D mouseLocationOutsideOfEventStream=5D;=
- position =3D =5Bview convertPoint: position fromView: nil=5D;
- remember=5Fmouse=5Fglyph (f, position.x, position.y,
+ view=5Fposition =3D =5B=5Bview window=5D mouseLocationOutsideOfEventStr= eam=5D;
+ view=5Fposition =3D =5Bview convertPoint: view=5Fposition fromView: nil= =5D;
+ remember=5Fmouse=5Fglyph (f, view=5Fposition.x, view=5Fposition.y,
&dpyinfo->last=5Fmouse=5Fglyph);
- NSTRACE=5FPOINT (=22position=22, position);
+ NSTRACE=5FPOINT (=22view=5Fposition=22, view=5Fposition);

if (bar=5Fwindow) *bar=5Fwindow =3D Qnil;
if (part) *part =3D scroll=5Fbar=5Fabove=5Fhandle;

- if (x) XSETINT (*x, lrint (position.x));
- if (y) XSETINT (*y, lrint (position.y));
+ if (x) XSETINT (*x, lrint (view=5Fposition.x));
+ if (y) XSETINT (*y, lrint (view=5Fposition.y));
if (time)
*time =3D dpyinfo->last=5Fmouse=5Fmovement=5Ftime;
*fp =3D f;
--
2.21.0


--
Alan Third
--5de7ab33_643c9869_1689--