Skip to content

Instantly share code, notes, and snippets.

@bonkydog
Created November 17, 2013 17:54
Show Gist options
  • Select an option

  • Save bonkydog/7516063 to your computer and use it in GitHub Desktop.

Select an option

Save bonkydog/7516063 to your computer and use it in GitHub Desktop.
Elisp hooks for gain and loss of focus.
diff --git a/src/frame.c b/src/frame.c
index 4494edda..6c89b7e 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -109,6 +109,8 @@ Lisp_Object Qalpha;
Lisp_Object Qface_set_after_frame_default;
+static Lisp_Object Qfocus_in_hook;
+static Lisp_Object Qfocus_out_hook;
static Lisp_Object Qdelete_frame_functions;
static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource;
@@ -893,6 +895,7 @@ is not generated.
This function checks if blink-cursor timers should be turned on again. */)
(Lisp_Object event)
{
+ Frun_hooks (1, &Qfocus_in_hook);
return call0 (intern ("blink-cursor-check"));
}
@@ -903,6 +906,7 @@ Focus out events occur when no frame has focus.
This function checks if blink-cursor timers should be turned off. */)
(Lisp_Object event)
{
+ Frun_hooks (1, &Qfocus_out_hook);
return call0 (intern ("blink-cursor-suspend"));
}
@@ -4465,6 +4469,16 @@ when the mouse is over clickable text. */);
The pointer becomes visible again when the mouse is moved. */);
Vmake_pointer_invisible = Qt;
+ DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook,
+ doc: /* Normal hook run when a frame gains input focus.*/);
+ Vfocus_in_hook = Qnil;
+ DEFSYM (Qfocus_in_hook, "focus-in-hook");
+
+ DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook,
+ doc: /* Normal hook run when a frame loses input focus.*/);
+ Vfocus_out_hook = Qnil;
+ DEFSYM (Qfocus_out_hook, "focus-out-hook");
+
DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions,
doc: /* Functions run before deleting a frame.
The functions are run with one arg, the frame to be deleted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment