all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#36165: 27.0.50; `select-frame-set-input-focus' moves mouse pointer outside of frame
@ 2019-06-11  7:22 Pip Cet
  2019-06-11  8:17 ` martin rudalics
  0 siblings, 1 reply; 3+ messages in thread
From: Pip Cet @ 2019-06-11  7:22 UTC (permalink / raw)
  To: 36165

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

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.

[-- Attachment #2: emacs-patch-2.diff --]
[-- Type: text/x-patch, Size: 818 bytes --]

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.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#36165: 27.0.50; `select-frame-set-input-focus' moves mouse pointer outside of frame
  2019-06-11  7:22 bug#36165: 27.0.50; `select-frame-set-input-focus' moves mouse pointer outside of frame Pip Cet
@ 2019-06-11  8:17 ` martin rudalics
  2019-06-12 14:39   ` Pip Cet
  0 siblings, 1 reply; 3+ messages in thread
From: martin rudalics @ 2019-06-11  8:17 UTC (permalink / raw)
  To: Pip Cet, 36165

 > 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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#36165: 27.0.50; `select-frame-set-input-focus' moves mouse pointer outside of frame
  2019-06-11  8:17 ` martin rudalics
@ 2019-06-12 14:39   ` Pip Cet
  0 siblings, 0 replies; 3+ messages in thread
From: Pip Cet @ 2019-06-12 14:39 UTC (permalink / raw)
  To: martin rudalics; +Cc: 36165-done

Thanks, it appears to work here.

On Tue, Jun 11, 2019 at 8:17 AM martin rudalics <rudalics@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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-12 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-11  7:22 bug#36165: 27.0.50; `select-frame-set-input-focus' moves mouse pointer outside of frame Pip Cet
2019-06-11  8:17 ` martin rudalics
2019-06-12 14:39   ` Pip Cet

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.