unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* focus-in-hook ---fires incorrectly?
@ 2018-03-26 17:20 T.V Raman
  2018-03-26 17:44 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: T.V Raman @ 2018-03-26 17:20 UTC (permalink / raw)
  To: emacs-devel


this is on emacs built from Git @head running on Debian under StumpWM
as a window-manager.

Try:

(add-hook 'focus-in-hook #'(lambda () (message "hello %s" (selected-frame))))

What you'd expect:

1. See "hello <frame-id>" when Emacs frames receive focus.
2. Nothing when Emacs loses focus.

What Actually Happens:

Hook fires when emacs loses focus, and you see "Hello <frame-id>"
where frame-id is the id of selected frame in emacs
2. You get "hello" when Emacs receives focus  -- with no frame-id.

Note that the corresponding focus-out-hook appears to work correctly
i.e. only fires when Emacs loses focus.

-- 

-- 

-- 

-- 



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

* Re: focus-in-hook ---fires incorrectly?
  2018-03-26 17:20 focus-in-hook ---fires incorrectly? T.V Raman
@ 2018-03-26 17:44 ` Eli Zaretskii
  2018-03-26 18:00   ` T.V Raman
  2018-03-26 20:09   ` Michael Heerdegen
  0 siblings, 2 replies; 5+ messages in thread
From: Eli Zaretskii @ 2018-03-26 17:44 UTC (permalink / raw)
  To: T.V Raman; +Cc: emacs-devel

> From: raman@google.com (T.V Raman)
> Date: Mon, 26 Mar 2018 10:20:11 -0700
> 
> this is on emacs built from Git @head running on Debian under StumpWM
> as a window-manager.

Can you try a different window-manager?  It could also depend on the
focus policy, I think.

> (add-hook 'focus-in-hook #'(lambda () (message "hello %s" (selected-frame))))
> 
> What you'd expect:
> 
> 1. See "hello <frame-id>" when Emacs frames receive focus.
> 2. Nothing when Emacs loses focus.
> 
> What Actually Happens:
> 
> Hook fires when emacs loses focus, and you see "Hello <frame-id>"
> where frame-id is the id of selected frame in emacs
> 2. You get "hello" when Emacs receives focus  -- with no frame-id.

It works as expected here, but I'm not on X.



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

* Re: focus-in-hook ---fires incorrectly?
  2018-03-26 17:44 ` Eli Zaretskii
@ 2018-03-26 18:00   ` T.V Raman
  2018-03-26 20:09   ` Michael Heerdegen
  1 sibling, 0 replies; 5+ messages in thread
From: T.V Raman @ 2018-03-26 18:00 UTC (permalink / raw)
  To: eliz; +Cc: emacs-devel, raman

Am bound to stumpwm because it talks to me -- I hope someone else on
the list can try different WMs.

Eli Zaretskii writes:
 > > From: raman@google.com (T.V Raman)
 > > Date: Mon, 26 Mar 2018 10:20:11 -0700
 > > 
 > > this is on emacs built from Git @head running on Debian under StumpWM
 > > as a window-manager.
 > 
 > Can you try a different window-manager?  It could also depend on the
 > focus policy, I think.
 > 
 > > (add-hook 'focus-in-hook #'(lambda () (message "hello %s" (selected-frame))))
 > > 
 > > What you'd expect:
 > > 
 > > 1. See "hello <frame-id>" when Emacs frames receive focus.
 > > 2. Nothing when Emacs loses focus.
 > > 
 > > What Actually Happens:
 > > 
 > > Hook fires when emacs loses focus, and you see "Hello <frame-id>"
 > > where frame-id is the id of selected frame in emacs
 > > 2. You get "hello" when Emacs receives focus  -- with no frame-id.
 > 
 > It works as expected here, but I'm not on X.

-- 

-- 



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

* Re: focus-in-hook ---fires incorrectly?
  2018-03-26 17:44 ` Eli Zaretskii
  2018-03-26 18:00   ` T.V Raman
@ 2018-03-26 20:09   ` Michael Heerdegen
  2018-03-28 12:37     ` Noam Postavsky
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2018-03-26 20:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, T.V Raman

Eli Zaretskii <eliz@gnu.org> writes:

> Can you try a different window-manager?  It could also depend on the
> focus policy, I think.

emacs26 on Debian here, with openbox.

Using the posted recipe with emacs -Q I get a message like

| hello #<frame *Messages*      micha@drachen 0x1174c30>

two times (!) when Emacs loses focus, and three times when I Alt-Tab
switch back to Emacs.


Michael.



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

* Re: focus-in-hook ---fires incorrectly?
  2018-03-26 20:09   ` Michael Heerdegen
@ 2018-03-28 12:37     ` Noam Postavsky
  0 siblings, 0 replies; 5+ messages in thread
From: Noam Postavsky @ 2018-03-28 12:37 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Eli Zaretskii, T.V Raman, Emacs developers

On 26 March 2018 at 16:09, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>> Can you try a different window-manager?  It could also depend on the
>> focus policy, I think.
>
> emacs26 on Debian here, with openbox.
>
> Using the posted recipe with emacs -Q I get a message like
>
> | hello #<frame *Messages*      micha@drachen 0x1174c30>
>
> two times (!) when Emacs loses focus, and three times when I Alt-Tab
> switch back to Emacs.

I get the expected behaviour using i3 with emacs26 on Debian.
One "hello #<frame...>" message per time I bring Emacs into focus.

I do seem to get a spurious message if I unfocus Emacs, switch to
another workspace and then back again; Emacs is still unfocused, but
it prints a "hello #<frame...>" message. Possibly the workspace
switching is implemented behind the scenes by first raising every
window in the workspace?



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

end of thread, other threads:[~2018-03-28 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-26 17:20 focus-in-hook ---fires incorrectly? T.V Raman
2018-03-26 17:44 ` Eli Zaretskii
2018-03-26 18:00   ` T.V Raman
2018-03-26 20:09   ` Michael Heerdegen
2018-03-28 12:37     ` Noam Postavsky

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).