unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Window focus event
@ 2021-12-14 20:31 lxsameer
  2021-12-16  8:08 ` Michael Heerdegen
  0 siblings, 1 reply; 7+ messages in thread
From: lxsameer @ 2021-12-14 20:31 UTC (permalink / raw)
  To: emacs-devel@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 249 bytes --]

Hey folks,
I was wondering if there is a hook or a way to detect when focus changes from a window to another?

I know about the obsolete `focous-in-hook'. But it seems that its replacement doesn't do the same and works only on frame level. 



[-- Attachment #1.2: publickey - lxsameer@lxsameer.com - 0x037C595D.asc --]
[-- Type: application/pgp-keys, Size: 671 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: Window focus event
  2021-12-14 20:31 Window focus event lxsameer
@ 2021-12-16  8:08 ` Michael Heerdegen
  2021-12-16 14:30   ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2021-12-16  8:08 UTC (permalink / raw)
  To: lxsameer; +Cc: emacs-devel@gnu.org

lxsameer <lxsameer@lxsameer.com> writes:

> Hey folks,

Hello.

> I was wondering if there is a hook or a way to detect when focus
> changes from a window to another?
>
> I know about the obsolete `focous-in-hook'. But it seems that its
> replacement doesn't do the same and works only on frame level.

This question would probably better fit and get more attention in
emacs-help.  People seem to be quite busy here ATM.

Regarding the question: I would say `window-configuration-change-hook'
or `window-state-change-hook' are the best fitting hooks for the task.
May depend on your use case.

Note that Emacs sometimes internally selects windows temporarily
(`with-selected-window'), so doing something for every window selection
is most of the time not what you want.

Michael.



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

* Re: Window focus event
  2021-12-16  8:08 ` Michael Heerdegen
@ 2021-12-16 14:30   ` Stefan Monnier
  2021-12-17 10:28     ` lxsameer
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2021-12-16 14:30 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: lxsameer, emacs-devel@gnu.org

> Regarding the question: I would say `window-configuration-change-hook'
> or `window-state-change-hook' are the best fitting hooks for the task.
> May depend on your use case.

Indeed.

> Note that Emacs sometimes internally selects windows temporarily
> (`with-selected-window'), so doing something for every window selection
> is most of the time not what you want.

Note that neither of the above two hooks are run during
`with-selected-window`, AFAIK.


        Stefan




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

* Re: Window focus event
  2021-12-16 14:30   ` Stefan Monnier
@ 2021-12-17 10:28     ` lxsameer
  2021-12-17 13:43       ` Michael Heerdegen
  2021-12-17 19:51       ` Stefan Kangas
  0 siblings, 2 replies; 7+ messages in thread
From: lxsameer @ 2021-12-17 10:28 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Michael Heerdegen, emacs-devel@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 908 bytes --]



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Thursday, December 16th, 2021 at 3:30 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> > Regarding the question: I would say `window-configuration-change-hook'
> 

> > or `window-state-change-hook' are the best fitting hooks for the task.
> > 

> > May depend on your use case.
> 

> Indeed.
> 

> > Note that Emacs sometimes internally selects windows temporarily
> > 

> > (`with-selected-window'), so doing something for every window selection
> > 

> > is most of the time not what you want.
> 

> Note that neither of the above two hooks are run during
> 

> `with-selected-window`, AFAIK.
> 

> Stefan

Thanks folks, In the deprecation message of the `focus-in-hook` family, it refers to `after-focus-change-function`. Isn't it better to change that message to include these two hooks as well?

[-- Attachment #1.2: publickey - lxsameer@lxsameer.com - 0x037C595D.asc --]
[-- Type: application/pgp-keys, Size: 671 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: Window focus event
  2021-12-17 10:28     ` lxsameer
@ 2021-12-17 13:43       ` Michael Heerdegen
  2021-12-17 14:28         ` lxsameer
  2021-12-17 19:51       ` Stefan Kangas
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2021-12-17 13:43 UTC (permalink / raw)
  To: lxsameer; +Cc: Stefan Monnier, emacs-devel@gnu.org

lxsameer <lxsameer@lxsameer.com> writes:

> Thanks folks, In the deprecation message of the `focus-in-hook`
> family, it refers to `after-focus-change-function`. Isn't it better to
> change that message to include these two hooks as well?

AFAIU, input focus is a per frame concept.  Window selection is
something different.  There are overlaps (the selected window is
typically in the frame that has input focus), but I don't see that
`window-configuration-change-hook' is a replacement for `focus-in-hook'
like `after-focus-change-function' is.

You can change the selected window without changing focus.  It can be
that no frame has input focus.  If a frame gets focus, that doesn't
necessarily change the window configuration, etc.  I hope my mental
model is correct.

Is there anything you could do using `focus-in-hook' that you can't do with
`after-focus-change-function'?

Michael.



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

* Re: Window focus event
  2021-12-17 13:43       ` Michael Heerdegen
@ 2021-12-17 14:28         ` lxsameer
  0 siblings, 0 replies; 7+ messages in thread
From: lxsameer @ 2021-12-17 14:28 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Stefan Monnier, emacs-devel@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 1219 bytes --]

Thanks Michael, I think my mental model was wrong. Thanks for the clarification.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Friday, December 17th, 2021 at 2:43 PM, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> lxsameer lxsameer@lxsameer.com writes:
> 

> > Thanks folks, In the deprecation message of the `focus-in-hook`
> > 

> > family, it refers to `after-focus-change-function`. Isn't it better to
> > 

> > change that message to include these two hooks as well?
> 

> AFAIU, input focus is a per frame concept. Window selection is
> 

> something different. There are overlaps (the selected window is
> 

> typically in the frame that has input focus), but I don't see that
> 

> `window-configuration-change-hook' is a replacement for` focus-in-hook'
> 

> like `after-focus-change-function' is. You can change the selected window without changing focus. It can be that no frame has input focus. If a frame gets focus, that doesn't necessarily change the window configuration, etc. I hope my mental model is correct. Is there anything you could do using` focus-in-hook' that you can't do with
> 

> `after-focus-change-function'?
> 

> Michael.

[-- Attachment #1.2: publickey - lxsameer@lxsameer.com - 0x037C595D.asc --]
[-- Type: application/pgp-keys, Size: 671 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: Window focus event
  2021-12-17 10:28     ` lxsameer
  2021-12-17 13:43       ` Michael Heerdegen
@ 2021-12-17 19:51       ` Stefan Kangas
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Kangas @ 2021-12-17 19:51 UTC (permalink / raw)
  To: lxsameer, Stefan Monnier; +Cc: Michael Heerdegen, emacs-devel@gnu.org

lxsameer <lxsameer@lxsameer.com> writes:

> Thanks folks, In the deprecation message of the `focus-in-hook`
> family, it refers to `after-focus-change-function`. Isn't it better to
> change that message to include these two hooks as well?

See also Bug#51862.



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

end of thread, other threads:[~2021-12-17 19:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 20:31 Window focus event lxsameer
2021-12-16  8:08 ` Michael Heerdegen
2021-12-16 14:30   ` Stefan Monnier
2021-12-17 10:28     ` lxsameer
2021-12-17 13:43       ` Michael Heerdegen
2021-12-17 14:28         ` lxsameer
2021-12-17 19:51       ` Stefan Kangas

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