From: Rui Guo Date: Wed, 17 Jun 2009 15:07:10 +0000 (+0800) Subject: Move the original forechanged event to the new hook/unhook scheme. X-Git-Url: https://repo.or.cz/w/screen-lua.git/commitdiff_plain/8c6ca4579bfe8ff50eb8068ec7e68c717b3b6233 Move the original forechanged event to the new hook/unhook scheme. --- diff --git a/src/lua.c b/src/lua.c index 621b1a1..f36d4da 100644 --- a/src/lua.c +++ b/src/lua.c @@ -1051,6 +1051,12 @@ LuaPushParams(lua_State *L, const char *params, va_list va) push_display(L, &d); break; } + case 'w': + { + struct win *w = va_arg(va, struct win *); + push_window(L, &w); + break; + } } params++; num++; @@ -1198,18 +1204,6 @@ LuaDispatch(void *handler, const char *params, va_list va) return retvalue; } -int LuaForeWindowChanged(void) -{ - struct fn_def params[] = { - {push_display, &display}, - {push_window, display ? &D_fore : &fore}, - {NULL, NULL} - }; - if (!L) - return 0; - return LuaCallProcess("fore_changed", params); -} - /*FIXME: what if a func is registered twice or more? */ void LuaRegAutoUnHook(lua_State *L, lua_handler lh, int ticket) @@ -1299,7 +1293,6 @@ LuaRegEvent(lua_State *L) struct ScriptFuncs LuaFuncs = { - LuaForeWindowChanged, LuaProcessCaption }; diff --git a/src/process.c b/src/process.c index 069a67e..b7a46a2 100644 --- a/src/process.c +++ b/src/process.c @@ -5252,7 +5252,7 @@ struct win *wi; WindowChanged(wi, 'u'); flayer = D_forecv->c_layer; #ifdef SCRIPT - ScriptForeWindowChanged(); + trigger_sevent(&globalevents.forechanged, display, display ? D_fore : fore); #endif /* Activate called afterwards, so no RefreshHStatus needed */ } diff --git a/src/script.c b/src/script.c index 9626228..1cc415b 100644 --- a/src/script.c +++ b/src/script.c @@ -193,6 +193,7 @@ struct sev_description { /* The command "detach" triggers both 'cmdexecuted' and 'detached' events. However, we need the 'detached' event to trigger callbacks from remote detaches. */ + {"global_forechanged", "dw", offsetof(struct gevents, forechanged)}, /* Window events */ {"window_resize", "", offsetof(struct win, w_sev.resize)}, @@ -307,12 +308,6 @@ trigger_sevent(struct script_event *ev, VA_DOTS) } \ } while (0) -void ScriptForeWindowChanged(void) -{ - int ret; - ALL_SCRIPTS(sf_ForeWindowChanged, (), 0); -} - int ScriptProcessCaption(const char *str, struct win *win, int len) { int ret = 0; diff --git a/src/script.h b/src/script.h index 422c02b..efb3952 100644 --- a/src/script.h +++ b/src/script.h @@ -25,7 +25,6 @@ struct win; /*Obsolete*/ struct ScriptFuncs { - int (*sf_ForeWindowChanged) __P((void)); int (*sf_ProcessCaption) __P((const char *, struct win *, int len)); }; @@ -86,6 +85,7 @@ void unregister_listener(struct listener *l); struct gevents { struct script_event cmdexecuted; struct script_event detached; + struct script_event forechanged; }; extern struct gevents globalevents; #endif