GNU bug report logs - #36165
27.0.50; `select-frame-set-input-focus' moves mouse pointer outside of frame

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> gmail.com>

Date: Tue, 11 Jun 2019 07:24:02 UTC

Severity: normal

Found in version 27.0.50

Done: Pip Cet <pipcet <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36165 in the body.
You can then email your comments to 36165 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#36165; Package emacs. (Tue, 11 Jun 2019 07:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Pip Cet <pipcet <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 11 Jun 2019 07:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; `select-frame-set-input-focus' moves mouse pointer outside
 of frame
Date: Tue, 11 Jun 2019 07:22:41 +0000
[Message part 1 (text/plain, inline)]
In emacs -Q, disable scroll-bar-mode and evaluate:

(let ((mouse-autoselect-window t))
  (select-frame-set-input-focus (window-frame)))

The mouse pointer will now be to the right of the window frame; with
normal window managers, this doesn't matter much, except that a "resize
this window" cursor might be shown rather than the usual one, but with
tiling window managers, the cursor position may correspond to another
window, which is then raised and wrongly receives keyboard focus. This
actually happened to me.

The attached patch fixes things, by moving the mouse pointer to the last
valid x position.

diff --git a/lisp/frame.el b/lisp/frame.el
index a8c230cb7b..7b61003c9a 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -979,10 +979,11 @@ select-frame-set-input-focus
   ;; Move mouse cursor if necessary.
   (cond
    (mouse-autoselect-window
-    (let ((edges (window-inside-edges (frame-selected-window frame))))
+    (let ((edges (window-edges (frame-selected-window frame)
+                               t nil t)))
       ;; Move mouse cursor into FRAME's selected window to avoid that
       ;; Emacs mouse-autoselects another window.
-      (set-mouse-position frame (nth 2 edges) (nth 1 edges))))
+      (set-mouse-pixel-position frame (1- (nth 2 edges)) (nth 1 edges))))
    (focus-follows-mouse
     ;; Move mouse cursor into FRAME to avoid that another frame gets
     ;; selected by the window manager.
[emacs-patch-2.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36165; Package emacs. (Tue, 11 Jun 2019 08:18:02 GMT) Full text and rfc822 format available.

Message #8 received at 36165 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Pip Cet <pipcet <at> gmail.com>, 36165 <at> debbugs.gnu.org
Subject: Re: bug#36165: 27.0.50; `select-frame-set-input-focus' moves mouse
 pointer outside of frame
Date: Tue, 11 Jun 2019 10:17:50 +0200
> In emacs -Q, disable scroll-bar-mode and evaluate:
>
> (let ((mouse-autoselect-window t))
>    (select-frame-set-input-focus (window-frame)))
>
> The mouse pointer will now be to the right of the window frame; with
> normal window managers, this doesn't matter much, except that a "resize
> this window" cursor might be shown rather than the usual one, but with
> tiling window managers, the cursor position may correspond to another
> window, which is then raised and wrongly receives keyboard focus. This
> actually happened to me.
>
> The attached patch fixes things, by moving the mouse pointer to the last
> valid x position.

Pushed to master.  Please have a look and close the bug in case I did
things right.

Thank your very much, martin




Reply sent to Pip Cet <pipcet <at> gmail.com>:
You have taken responsibility. (Wed, 12 Jun 2019 14:41:04 GMT) Full text and rfc822 format available.

Notification sent to Pip Cet <pipcet <at> gmail.com>:
bug acknowledged by developer. (Wed, 12 Jun 2019 14:41:04 GMT) Full text and rfc822 format available.

Message #13 received at 36165-done <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 36165-done <at> debbugs.gnu.org
Subject: Re: bug#36165: 27.0.50; `select-frame-set-input-focus' moves mouse
 pointer outside of frame
Date: Wed, 12 Jun 2019 14:39:23 +0000
Thanks, it appears to work here.

On Tue, Jun 11, 2019 at 8:17 AM martin rudalics <rudalics <at> gmx.at> wrote:
>
>  > In emacs -Q, disable scroll-bar-mode and evaluate:
>  >
>  > (let ((mouse-autoselect-window t))
>  >    (select-frame-set-input-focus (window-frame)))
>  >
>  > The mouse pointer will now be to the right of the window frame; with
>  > normal window managers, this doesn't matter much, except that a "resize
>  > this window" cursor might be shown rather than the usual one, but with
>  > tiling window managers, the cursor position may correspond to another
>  > window, which is then raised and wrongly receives keyboard focus. This
>  > actually happened to me.
>  >
>  > The attached patch fixes things, by moving the mouse pointer to the last
>  > valid x position.
>
> Pushed to master.  Please have a look and close the bug in case I did
> things right.
>
> Thank your very much, martin




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 11 Jul 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 348 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.