unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 17439@debbugs.gnu.org
Subject: bug#17439: 24.3.50; run-with-idle-timer runs on focus-out
Date: Thu, 08 May 2014 23:45:27 +0300	[thread overview]
Message-ID: <87ha50578c.fsf@mail.jurta.org> (raw)

Some change a few months ago introduced a significant inconvenience.
After switching to another application, the focus returns back to Emacs.
It happens when using `mouse-avoidance-mode' customized to `banish'.
This mode relies on `run-with-idle-timer' that moves the mouse cursor
on a new input.  This caused no problems in prior releases.

However, now input events include a new event type `focus-out',
so the mouse cursor is moved on switching from Emacs frame
(and the new mouse cursor position puts the focus back
due to specific configuration).

This code illustrates the problem:

(defun test () (message "%S" last-input-event))
(setq timer (run-with-idle-timer 0.1 t 'test))

On switching out it prints to *Messages*:

(focus-in #<frame emacs@localhost 0x1121908>)
(focus-out #<frame emacs@localhost 0x1121908>)

This specific problem can be fixed by this patch:

=== modified file 'lisp/avoid.el'
--- lisp/avoid.el	2014-01-31 06:42:29 +0000
+++ lisp/avoid.el	2014-05-08 20:39:59 +0000
@@ -343,7 +343,8 @@ (defun mouse-avoidance-ignore-p ()
 		 (let ((modifiers (event-modifiers (car last-input-event))))
 		   (or (memq (car last-input-event)
 			     '(mouse-movement scroll-bar-movement
-					      select-window switch-frame))
+					      select-window switch-frame
+					      focus-in focus-out))
 		       (memq 'click modifiers)
 		       (memq 'double modifiers)
 		       (memq 'triple modifiers)

PS: it seems there are other places that check only for `switch-frame',
and not for new event types `focus-in' and `focus-out'.  But maybe
this problem occurs only in `run-with-idle-timer' because switching out
doesn't emit the event on its own, i.e. `read-event' doesn't return it.





             reply	other threads:[~2014-05-08 20:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 20:45 Juri Linkov [this message]
2014-05-09  6:28 ` bug#17439: 24.3.50; run-with-idle-timer runs on focus-out Eli Zaretskii
2014-05-09 20:35   ` Juri Linkov
2014-05-10  6:16     ` Eli Zaretskii
2014-05-10 20:38       ` Juri Linkov
2014-05-11 20:19       ` Juri Linkov
2014-05-11 21:06         ` Stefan Monnier
2014-05-11 21:31           ` Juri Linkov
2014-05-11 22:29             ` Stefan Monnier
2014-05-12 20:39               ` Juri Linkov
2014-05-13 19:33                 ` Stefan Monnier
2014-05-20 21:14                   ` Juri Linkov
2014-05-20 22:12                     ` Juri Linkov

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=87ha50578c.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=17439@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).