Does mintty under Cygwin in any way support the events of losing and gaining focus?
I'm looking for the equivalent of WM_KILLFOCUS from Windows or autocmd FocusLost * call ... from gvim, but under Cygwin within the mintty terminal.
Does mintty under Cygwin in any way support the events of losing and gaining focus?
I'm looking for the equivalent of WM_KILLFOCUS from Windows or autocmd FocusLost * call ... from gvim, but under Cygwin within the mintty terminal.
Copyright © 2021 Jogjafile Inc.
Provided there was no actual answer after a few days, I'm providing my own, thanks to @Philippe's comment about
GetForegroundWindow.Disclaimer: no error checking in above code
This piece of code waits until the foreground window changes and prints out the title of the new foreground window to the
minttyconsole.I can now use this executable in a
bashscript to wait before executing another action that depends on focus being stolen.Since my environment is Cygwin, I'm providing the Makefile in case someone comes along and tries to compile the above on their own:
NB: Because of the
.exeextension, the extra rule is needed under Cygwin to leverage bothmakeimplicit rules and dependency checking. Using justall: wait-focus-lostworks for compilation, but breaks dependency checking.