From 8e0157050138d5e0a3912d5837d36f156849c008 Mon Sep 17 00:00:00 2001 From: Brian Jenkins Date: Mon, 18 Nov 2013 21:23:50 -0500 Subject: [PATCH] Add hooks to run on gaining/losing focus (tiny change) * src/frame.c (Qfocus_in_hook, Qfocus_out_hook): New static lisp objects. (Fhandle_focus_in, Fhandle_focus_out): Run focus hooks. (syms_of_frame): Add focus-in-hook, focus-out-hook. Fixes: debbugs:15029 --- src/ChangeLog | 7 +++++++ src/frame.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 6d54fac6f56..43f966cdc3c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2013-11-19 Brian Jenkins (tiny change) + + Add hooks to run on gaining/losing focus. (Bug#15029) + * frame.c (Qfocus_in_hook, Qfocus_out_hook): New static lisp objects. + (Fhandle_focus_in, Fhandle_focus_out): Run focus hooks. + (syms_of_frame): Add focus-in-hook, focus-out-hook. + 2013-11-18 Paul Eggert * data.c (bool_vector_binop_driver): Rename locals for sanity's sake. diff --git a/src/frame.c b/src/frame.c index 4494edda5d7..fccb53e2436 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. -- 2.39.2