From 051fd65aba444e3118c60a1be4951260b293dfa4 Mon Sep 17 00:00:00 2001 From: Rui Guo Date: Fri, 19 Jun 2009 23:17:41 +0800 Subject: [PATCH] Add some window events. 1. Define onfocus onleave onshow onhide events. 2. Implement onfocus & onleave event. --- src/process.c | 6 ++++++ src/script.c | 15 +++++++++++++-- src/script.h | 2 +- src/window.h | 6 +++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/process.c b/src/process.c index b7a46a2..6bd76fc 100644 --- a/src/process.c +++ b/src/process.c @@ -5156,6 +5156,9 @@ struct win *wi; } D_other = fore; D_fore = 0; +#ifdef SCRIPT + trigger_sevent(&fore->w_sev.onleave, display, fore); +#endif } if (l->l_cvlist == 0 && (p == 0 || l != p->w_savelayer)) KillLayerChain(l); @@ -5225,6 +5228,9 @@ struct win *wi; windows = p; WListLinkChanged(); } +#ifdef SCRIPT + trigger_sevent(&fore->w_sev.onfocus, display, fore); +#endif } } } diff --git a/src/script.c b/src/script.c index 1cc415b..42f5ff2 100644 --- a/src/script.c +++ b/src/script.c @@ -187,17 +187,28 @@ struct sev_description { char *params; int offset; } event_table[] = { + /* NOTE: Manually sorted in Alphabet order! */ + /* Global events */ {"global_cmdexecuted", "sS", offsetof(struct gevents, cmdexecuted)}, {"global_detached", "di", offsetof(struct gevents, detached)}, /* The command "detach" triggers both 'cmdexecuted' and 'detached' events. However, we need the 'detached' event to trigger callbacks from remote detaches. */ + /* fore window changed to window w on display d. */ {"global_forechanged", "dw", offsetof(struct gevents, forechanged)}, /* Window events */ - {"window_resize", "", offsetof(struct win, w_sev.resize)}, - {"window_can_resize", "", offsetof(struct win, w_sev.canresize)} + {"window_can_resize", "", offsetof(struct win, w_sev.canresize)}, + {"window_onfocus", "dw", offsetof(struct win, w_sev.onfocus)}, + /* last view of window w disappeared on display d. */ + {"window_onhide", "dw", offsetof(struct win, w_sev.onhide)}, + /* window w lost its focus on display d. */ + {"window_onleave", "dw", offsetof(struct win, w_sev.onleave)}, + {"window_onresize", "", offsetof(struct win, w_sev.onresize)}, + /* window w first showed up on display d. When there are regions, it can + * still be shown while losing focus. */ + {"window_onshow", "dw", offsetof(struct win, w_sev.onshow)}, }; /* Get the event queue with the given name in the obj. If the obj is NULL, diff --git a/src/script.h b/src/script.h index efb3952..6f70ce9 100644 --- a/src/script.h +++ b/src/script.h @@ -49,7 +49,7 @@ struct binding }; void LoadBindings(void); -void FinializeBindings(void); +void FinalizeBindings(void); void ScriptCmd __P((int argc, const char **argv)); /***Script events***/ diff --git a/src/window.h b/src/window.h index f9bb72b..b79adfa 100644 --- a/src/window.h +++ b/src/window.h @@ -283,8 +283,12 @@ struct win #ifdef SCRIPT struct { - struct script_event resize; struct script_event canresize; + struct script_event onresize; + struct script_event onfocus; + struct script_event onleave; + struct script_event onhide; + struct script_event onshow; } w_sev; /*For Script events. */ #endif }; -- 2.11.4.GIT