hooks: remove

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-09-14 15:12:51 +02:00
parent 5b27fb014e
commit 4c178d5441
15 changed files with 0 additions and 592 deletions

View File

@ -50,7 +50,6 @@ set(AWE_SRCS
${SOURCE_DIR}/banning.c ${SOURCE_DIR}/banning.c
${SOURCE_DIR}/luaa.c ${SOURCE_DIR}/luaa.c
${SOURCE_DIR}/spawn.c ${SOURCE_DIR}/spawn.c
${SOURCE_DIR}/hooks.c
${SOURCE_DIR}/mouse.c ${SOURCE_DIR}/mouse.c
${SOURCE_DIR}/button.c ${SOURCE_DIR}/button.c
${SOURCE_DIR}/screen.c ${SOURCE_DIR}/screen.c

View File

@ -62,9 +62,6 @@ awesome_atexit(void)
{ {
int screen_nbr, nscreens; int screen_nbr, nscreens;
if(globalconf.hooks.exit != LUA_REFNIL)
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.exit, 0, 0);
signal_object_emit(globalconf.L, &global_signals, "exit", 0); signal_object_emit(globalconf.L, &global_signals, "exit", 0);
a_dbus_cleanup(); a_dbus_cleanup();
@ -422,7 +419,6 @@ main(int argc, char **argv)
} }
globalconf.loop = ev_default_loop(0); globalconf.loop = ev_default_loop(0);
ev_timer_init(&globalconf.timer, &luaA_on_timer, 0., 0.);
/* register function for signals */ /* register function for signals */
ev_signal_init(&sigint, exit_on_signal, SIGINT); ev_signal_init(&sigint, exit_on_signal, SIGINT);

View File

@ -110,7 +110,6 @@ client_set_urgent(lua_State *L, int cidx, bool urgent)
xcb_set_wm_hints(globalconf.connection, c->window, &wmh); xcb_set_wm_hints(globalconf.connection, c->window, &wmh);
hook_property(c, "urgent");
luaA_object_emit_signal(L, cidx, "property::urgent", 0); luaA_object_emit_signal(L, cidx, "property::urgent", 0);
} }
} }
@ -158,7 +157,6 @@ client_set_icon_name(lua_State *L, int cidx, char *icon_name)
p_delete(&c->icon_name); p_delete(&c->icon_name);
c->icon_name = icon_name; c->icon_name = icon_name;
luaA_object_emit_signal(L, cidx, "property::icon_name", 0); luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
hook_property(c, "icon_name");
} }
void void
@ -168,7 +166,6 @@ client_set_alt_icon_name(lua_State *L, int cidx, char *icon_name)
p_delete(&c->alt_icon_name); p_delete(&c->alt_icon_name);
c->alt_icon_name = icon_name; c->alt_icon_name = icon_name;
luaA_object_emit_signal(L, cidx, "property::icon_name", 0); luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
hook_property(c, "icon_name");
} }
void void
@ -219,7 +216,6 @@ client_set_name(lua_State *L, int cidx, char *name)
client_t *c = luaA_client_checkudata(L, cidx); client_t *c = luaA_client_checkudata(L, cidx);
p_delete(&c->name); p_delete(&c->name);
c->name = name; c->name = name;
hook_property(c, "name");
luaA_object_emit_signal(L, cidx, "property::name", 0); luaA_object_emit_signal(L, cidx, "property::name", 0);
} }
@ -229,7 +225,6 @@ client_set_alt_name(lua_State *L, int cidx, char *name)
client_t *c = luaA_client_checkudata(L, cidx); client_t *c = luaA_client_checkudata(L, cidx);
p_delete(&c->alt_name); p_delete(&c->alt_name);
c->alt_name = name; c->alt_name = name;
hook_property(c, "name");
luaA_object_emit_signal(L, cidx, "property::name", 0); luaA_object_emit_signal(L, cidx, "property::name", 0);
} }
@ -277,13 +272,6 @@ client_unfocus_update(client_t *c)
globalconf.screens.tab[c->phys_screen].client_focus = NULL; globalconf.screens.tab[c->phys_screen].client_focus = NULL;
ewmh_update_net_active_window(c->phys_screen); ewmh_update_net_active_window(c->phys_screen);
/* Call hook */
if(globalconf.hooks.unfocus != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unfocus, 1, 0);
}
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1); luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1);
} }
@ -424,13 +412,6 @@ client_focus_update(client_t *c)
ewmh_update_net_active_window(c->phys_screen); ewmh_update_net_active_window(c->phys_screen);
/* execute hook */
if(globalconf.hooks.focus != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.focus, 1, 0);
}
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1); luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1);
} }
@ -726,20 +707,8 @@ HANDLE_GEOM(height)
p_delete(&startup_id); p_delete(&startup_id);
} }
/* Call hook to notify list change */
if(globalconf.hooks.clients != LUA_REFNIL)
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
luaA_class_emit_signal(globalconf.L, &client_class, "list", 0); luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
/* call hook */
if(globalconf.hooks.manage != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
lua_pushboolean(globalconf.L, startup);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.manage, 2, 0);
}
/* client is still on top of the stack; push startup value, /* client is still on top of the stack; push startup value,
* and emit signals with 2 args */ * and emit signals with 2 args */
lua_pushboolean(globalconf.L, startup); lua_pushboolean(globalconf.L, startup);
@ -911,9 +880,6 @@ client_resize(client_t *c, area_t geometry, bool hints)
screen_client_moveto(c, new_screen, false); screen_client_moveto(c, new_screen, false);
/* execute hook */
hook_property(c, "geometry");
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0); luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0);
/** \todo This need to be VERIFIED before it is emitted! */ /** \todo This need to be VERIFIED before it is emitted! */
@ -950,8 +916,6 @@ client_set_minimized(lua_State *L, int cidx, bool s)
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
if(strut_has_value(&c->strut)) if(strut_has_value(&c->strut))
screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0); screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
/* execute hook */
hook_property(c, "minimized");
luaA_object_emit_signal(L, cidx, "property::minimized", 0); luaA_object_emit_signal(L, cidx, "property::minimized", 0);
} }
} }
@ -971,7 +935,6 @@ client_set_sticky(lua_State *L, int cidx, bool s)
c->sticky = s; c->sticky = s;
banning_need_update((c)->screen); banning_need_update((c)->screen);
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
hook_property(c, "sticky");
luaA_object_emit_signal(L, cidx, "property::sticky", 0); luaA_object_emit_signal(L, cidx, "property::sticky", 0);
} }
} }
@ -1018,7 +981,6 @@ client_set_fullscreen(lua_State *L, int cidx, bool s)
client_resize(c, geometry, false); client_resize(c, geometry, false);
client_stack(); client_stack();
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
hook_property(c, "fullscreen");
luaA_object_emit_signal(L, cidx, "property::fullscreen", 0); luaA_object_emit_signal(L, cidx, "property::fullscreen", 0);
} }
} }
@ -1058,7 +1020,6 @@ client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
client_resize(c, geometry, c->size_hints_honor); client_resize(c, geometry, c->size_hints_honor);
client_stack(); client_stack();
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
hook_property(c, "maximized_horizontal");
luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0); luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0);
} }
} }
@ -1098,7 +1059,6 @@ client_set_maximized_vertical(lua_State *L, int cidx, bool s)
client_resize(c, geometry, c->size_hints_honor); client_resize(c, geometry, c->size_hints_honor);
client_stack(); client_stack();
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
hook_property(c, "maximized_vertical");
luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0); luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0);
} }
} }
@ -1125,8 +1085,6 @@ client_set_above(lua_State *L, int cidx, bool s)
c->above = s; c->above = s;
client_stack(); client_stack();
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
/* execute hook */
hook_property(c, "above");
luaA_object_emit_signal(L, cidx, "property::above", 0); luaA_object_emit_signal(L, cidx, "property::above", 0);
} }
} }
@ -1153,8 +1111,6 @@ client_set_below(lua_State *L, int cidx, bool s)
c->below = s; c->below = s;
client_stack(); client_stack();
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
/* execute hook */
hook_property(c, "below");
luaA_object_emit_signal(L, cidx, "property::below", 0); luaA_object_emit_signal(L, cidx, "property::below", 0);
} }
} }
@ -1174,8 +1130,6 @@ client_set_modal(lua_State *L, int cidx, bool s)
c->modal = s; c->modal = s;
client_stack(); client_stack();
ewmh_client_update_hints(c); ewmh_client_update_hints(c);
/* execute hook */
hook_property(c, "modal");
luaA_object_emit_signal(L, cidx, "property::modal", 0); luaA_object_emit_signal(L, cidx, "property::modal", 0);
} }
} }
@ -1201,8 +1155,6 @@ client_set_ontop(lua_State *L, int cidx, bool s)
} }
c->ontop = s; c->ontop = s;
client_stack(); client_stack();
/* execute hook */
hook_property(c, "ontop");
luaA_object_emit_signal(L, cidx, "property::ontop", 0); luaA_object_emit_signal(L, cidx, "property::ontop", 0);
} }
} }
@ -1272,20 +1224,9 @@ client_unmanage(client_t *c)
for(int i = 0; i < tags->len; i++) for(int i = 0; i < tags->len; i++)
untag_client(c, tags->tab[i]); untag_client(c, tags->tab[i]);
/* call hook */
if(globalconf.hooks.unmanage != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unmanage, 1, 0);
}
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1); luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1);
/* Call hook to notify list change */
if(globalconf.hooks.clients != LUA_REFNIL)
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
luaA_class_emit_signal(globalconf.L, &client_class, "list", 0); luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
if(strut_has_value(&c->strut)) if(strut_has_value(&c->strut))
@ -1420,7 +1361,6 @@ client_set_border_width(lua_State *L, int cidx, int width)
/* Changing border size also affects the size of the titlebar. */ /* Changing border size also affects the size of the titlebar. */
titlebar_update_geometry(c); titlebar_update_geometry(c);
hook_property(c, "border_width");
luaA_object_emit_signal(L, cidx, "property::border_width", 0); luaA_object_emit_signal(L, cidx, "property::border_width", 0);
} }
@ -1440,8 +1380,6 @@ client_set_icon(lua_State *L, int cidx, int iidx)
luaA_object_unref_item(L, cidx, c->icon); luaA_object_unref_item(L, cidx, c->icon);
c->icon = luaA_object_ref_item(L, cidx, iidx); c->icon = luaA_object_ref_item(L, cidx, iidx);
luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0); luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0);
/* execute hook */
hook_property(c, "icon");
} }
/** Kill a client. /** Kill a client.
@ -1486,10 +1424,6 @@ luaA_client_swap(lua_State *L)
*ref_c = swap; *ref_c = swap;
*ref_swap = c; *ref_swap = c;
/* Call hook to notify list change */
if(globalconf.hooks.clients != LUA_REFNIL)
luaA_dofunction_from_registry(L, globalconf.hooks.clients, 0, 0);
luaA_class_emit_signal(globalconf.L, &client_class, "list", 0); luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
} }
@ -1657,7 +1591,6 @@ luaA_client_struts(lua_State *L)
{ {
luaA_tostrut(L, 2, &c->strut); luaA_tostrut(L, 2, &c->strut);
ewmh_update_strut(c->window, &c->strut); ewmh_update_strut(c->window, &c->strut);
hook_property(c, "struts");
luaA_object_emit_signal(L, 1, "property::struts", 0); luaA_object_emit_signal(L, 1, "property::struts", 0);
screen_emit_signal(L, c->screen, "property::workarea", 0); screen_emit_signal(L, c->screen, "property::workarea", 0);
} }
@ -1685,7 +1618,6 @@ luaA_client_set_hidden(lua_State *L, client_t *c)
{ {
c->hidden = b; c->hidden = b;
banning_need_update((c)->screen); banning_need_update((c)->screen);
hook_property(c, "hidden");
if(strut_has_value(&c->strut)) if(strut_has_value(&c->strut))
screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0); screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
luaA_object_emit_signal(L, -3, "property::hidden", 0); luaA_object_emit_signal(L, -3, "property::hidden", 0);
@ -1756,7 +1688,6 @@ static int
luaA_client_set_size_hints_honor(lua_State *L, client_t *c) luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
{ {
c->size_hints_honor = luaA_checkboolean(L, -1); c->size_hints_honor = luaA_checkboolean(L, -1);
hook_property(c, "size_hints_honor");
luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0); luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0);
return 0; return 0;
} }

10
event.c
View File

@ -417,11 +417,6 @@ event_handle_leavenotify(void *data __attribute__ ((unused)),
if((c = client_getbytitlebarwin(ev->event)) || (c = client_getbywin(ev->event))) if((c = client_getbytitlebarwin(ev->event)) || (c = client_getbywin(ev->event)))
{ {
if(globalconf.hooks.mouse_leave != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.mouse_leave, 1, 0);
}
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "mouse::leave", 0); luaA_object_emit_signal(globalconf.L, -1, "mouse::leave", 0);
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);
@ -479,11 +474,6 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
if((c = client_getbytitlebarwin(ev->event)) if((c = client_getbytitlebarwin(ev->event))
|| (c = client_getbywin(ev->event))) || (c = client_getbywin(ev->event)))
{ {
if(globalconf.hooks.mouse_enter != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.mouse_enter, 1, 0);
}
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0); luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0);
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);

1
ewmh.c
View File

@ -620,7 +620,6 @@ ewmh_process_client_strut(client_t *c, xcb_get_property_reply_t *strut_r)
c->strut.bottom_start_x = strut[10]; c->strut.bottom_start_x = strut[10];
c->strut.bottom_end_x = strut[11]; c->strut.bottom_end_x = strut[11];
hook_property(c, "struts");
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "property::struts", 0); luaA_object_emit_signal(globalconf.L, -1, "property::struts", 0);
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);

View File

@ -92,37 +92,8 @@ typedef struct
} colors; } colors;
/** Default font */ /** Default font */
font_t *font; font_t *font;
struct
{
/** Command to execute when spawning a new client */
int manage;
/** Command to execute when unmanaging client */
int unmanage;
/** Command to execute when giving focus to a client */
int focus;
/** Command to execute when removing focus to a client */
int unfocus;
/** Command to run when mouse enter a client */
int mouse_enter;
/** Command to run when mouse leave a client */
int mouse_leave;
/** Command to run when client list changes */
int clients;
/** Command to run on numbers of tag changes */
int tags;
/** Command to run when client gets (un)tagged */
int tagged;
/** Command to run on property change */
int property;
/** Command to run on time */
int timer;
/** Command to run on awesome exit */
int exit;
} hooks;
/** The event loop */ /** The event loop */
struct ev_loop *loop; struct ev_loop *loop;
/** The timeout after which we need to stop select() */
struct ev_timer timer;
/** The key grabber function */ /** The key grabber function */
int keygrabber; int keygrabber;
/** The mouse pointer grabber function */ /** The mouse pointer grabber function */

221
hooks.c
View File

@ -1,221 +0,0 @@
/*
* hooks.c - Lua hooks management
*
* Copyright © 2008 Julien Danjou <julien@danjou.info>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include "globalconf.h"
#include "luaa.h"
#define HANDLE_HOOK(L, h) \
do { \
if(lua_gettop(L) == 1) \
luaA_registerfct(L, 1, &h); \
lua_rawgeti(L, LUA_REGISTRYINDEX, h); \
return 1; \
} while(0)
/** Set the function called each time a client gets focus. This function is
* called with the client object as argument.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call each time a client gets focus.
*/
static int
luaA_hooks_focus(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.focus);
}
/** Set the function called each time a client loses focus. This function is
* called with the client object as argument.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call each time a client loses focus.
*/
static int
luaA_hooks_unfocus(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.unfocus);
}
/** Set the function called each time a new client appears. This function is
* called with the client object as argument, plus a boolean argument which is
* true if the client is managed at startup.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call on each new client.
*/
static int
luaA_hooks_manage(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.manage);
}
/** Set the function called each time a client goes away. This function is
* called with the client object as argument.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call when a client goes away.
*/
static int
luaA_hooks_unmanage(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.unmanage);
}
/** Set the function called each time the mouse enter a window. This
* function is called with the client object as argument.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call each time a client gets mouse over it.
*/
static int
luaA_hooks_mouse_enter(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.mouse_enter);
}
/** Set the function called each time the mouse leave a window. This
* function is called with the client object as argument.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call each time a client gets mouse over it.
*/
static int
luaA_hooks_mouse_leave(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.mouse_leave);
}
/** Set the function called on each client list change.
* This function is called without any argument.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call on each client list change.
*/
static int
luaA_hooks_clients(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.clients);
}
/** Set the function called on each screen tag list change.
* This function is called with a screen number as first argument,
* the tag object as second and the action (add, remove, select or unselect)
* as third.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call on each tag list change.
*/
static int
luaA_hooks_tags(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.tags);
}
/** Set the function called on each client's tags change.
* This function is called with the client and the tag as argument.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call on each client's tags change.
*/
static int
luaA_hooks_tagged(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.tagged);
}
/** Set the function called on each client's property change.
* This function is called with the client object as argument and the
* property name.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call on each client property update.
*/
static int
luaA_hooks_property(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.property);
}
/** Set the function to be called every N seconds.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam The number of seconds to run function every. Set 0 to disable.
* \lparam A function to call every N seconds (optional).
*/
static int
luaA_hooks_timer(lua_State *L)
{
if(lua_gettop(L) >= 1)
{
globalconf.timer.repeat = luaL_checknumber(L, 1);
if(lua_gettop(L) == 2 && !lua_isnil(L, 2))
luaA_registerfct(L, 2, &globalconf.hooks.timer);
ev_timer_again(globalconf.loop, &globalconf.timer);
}
lua_rawgeti(L, LUA_REGISTRYINDEX, globalconf.hooks.timer);
return 1;
}
/** Set the function called on awesome exit
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam A function to call on awesome exit.
*/
static int
luaA_hooks_exit(lua_State *L)
{
HANDLE_HOOK(L, globalconf.hooks.exit);
}
const struct luaL_reg awesome_hooks_lib[] =
{
{ "focus", luaA_hooks_focus },
{ "unfocus", luaA_hooks_unfocus },
{ "manage", luaA_hooks_manage },
{ "unmanage", luaA_hooks_unmanage },
{ "mouse_enter", luaA_hooks_mouse_enter },
{ "mouse_leave", luaA_hooks_mouse_leave },
{ "property", luaA_hooks_property },
{ "clients", luaA_hooks_clients },
{ "tags", luaA_hooks_tags },
{ "tagged", luaA_hooks_tagged },
{ "timer", luaA_hooks_timer },
{ "exit", luaA_hooks_exit },
{ NULL, NULL }
};
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -1,160 +0,0 @@
---------------------------------------------------------------------------
-- @author Julien Danjou &lt;julien@danjou.info&gt;
-- @copyright 2008 Julien Danjou
-- @release @AWESOME_VERSION@
---------------------------------------------------------------------------
-- Grab environment we need
local pairs = pairs
local table = table
local ipairs = ipairs
local type = type
local math = math
local capi =
{
hooks = hooks
}
local util = require("awful.util")
--- Hooks module for awful.
-- This module is deprecated and should not be used anymore. You are encouraged
-- to use signals.
module("awful.hooks")
-- User hook functions
user = {}
--- Create a new userhook (for external libs).
-- @param name Hook name.
function user.create(name)
_M[name] = {}
_M[name].callbacks = {}
_M[name].register = function (f)
table.insert(_M[name].callbacks, f)
end
_M[name].unregister = function (f)
for k, h in ipairs(_M[name].callbacks) do
if h == f then
table.remove(_M[name].callbacks, k)
break
end
end
end
end
--- Call a created userhook (for external libs).
-- @param name Hook name.
function user.call(name, ...)
for name, callback in pairs(_M[name].callbacks) do
callback(...)
end
end
-- Autodeclare awful.hooks.* functions
-- mapped to awesome hooks.* functions
for name, hook in pairs(capi.hooks) do
_M[name] = {}
if name == 'timer' then
_M[name].register = function (time, f, runnow)
util.deprecate("timer object")
if type(time) ~= 'number' or type(f) ~= 'function' or time <= 0 then
return
end
if not _M[name].callbacks then
_M[name].callbacks = {}
end
for k, v in pairs(_M[name].callbacks) do
if v.callback == f then
_M[name].unregister(f)
_M[name].register(time, f, runnow)
return
end
end
local new_timer
if _M[name].timer then
-- Take the smallest between current and new
new_timer = math.min(time, _M[name].timer)
else
new_timer = time
end
if _M[name].timer ~= new_timer then
_M[name].timer = new_timer
end
hook(_M[name].timer, function (...)
for i, callback in ipairs(_M[name].callbacks) do
callback['counter'] = callback['counter'] + _M[name].timer
if callback['counter'] >= callback['timer'] then
callback['callback'](...)
callback['counter'] = 0
end
end
end)
if runnow then
table.insert(_M[name].callbacks, { callback = f, timer = time, counter = time })
else
table.insert(_M[name].callbacks, { callback = f, timer = time, counter = 0 })
end
end
_M[name].unregister = function (f)
if _M[name].callbacks then
for k, h in ipairs(_M[name].callbacks) do
if h.callback == f then
table.remove(_M[name].callbacks, k)
break
end
end
local delays = { }
for k, h in ipairs(_M[name].callbacks) do
table.insert(delays, h.timer)
end
table.sort(delays)
_M[name].timer = delays[1]
if not delays[1] then delays[1] = 0 end
hook(delays[1], function (...)
for i, callback in ipairs(_M[name].callbacks) do
callback['counter'] = callback['counter'] + _M[name].timer
if callback['counter'] >= callback['timer'] then
callback['callback'](...)
callback['counter'] = 0
end
end
end)
end
end
else
_M[name].register = function (f)
util.deprecate("signals")
if not _M[name].callbacks then
_M[name].callbacks = {}
hook(function (...)
for i, callback in ipairs(_M[name].callbacks) do
callback(...)
end
end)
end
table.insert(_M[name].callbacks, f)
end
end
if name ~= "timer" then
_M[name].unregister = function (f)
if _M[name].callbacks then
for k, h in ipairs(_M[name].callbacks) do
if h == f then
table.remove(_M[name].callbacks, k)
break
end
end
end
end
end
end
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -6,7 +6,6 @@
require("awful.client") require("awful.client")
require("awful.completion") require("awful.completion")
require("awful.hooks")
require("awful.layout") require("awful.layout")
require("awful.placement") require("awful.placement")
require("awful.prompt") require("awful.prompt")

26
luaa.c
View File

@ -48,7 +48,6 @@
#ifdef WITH_DBUS #ifdef WITH_DBUS
extern const struct luaL_reg awesome_dbus_lib[]; extern const struct luaL_reg awesome_dbus_lib[];
#endif #endif
extern const struct luaL_reg awesome_hooks_lib[];
extern const struct luaL_reg awesome_keygrabber_lib[]; extern const struct luaL_reg awesome_keygrabber_lib[];
extern const struct luaL_reg awesome_mousegrabber_lib[]; extern const struct luaL_reg awesome_mousegrabber_lib[];
extern const struct luaL_reg awesome_root_lib[]; extern const struct luaL_reg awesome_root_lib[];
@ -744,10 +743,6 @@ luaA_init(xdgHandle* xdg)
luaL_register(L, "root", awesome_root_lib); luaL_register(L, "root", awesome_root_lib);
lua_pop(L, 1); /* luaL_register() leaves the table on stack */ lua_pop(L, 1); /* luaL_register() leaves the table on stack */
/* Export hooks lib */
luaL_register(L, "hooks", awesome_hooks_lib);
lua_pop(L, 1); /* luaL_register() leaves the table on stack */
#ifdef WITH_DBUS #ifdef WITH_DBUS
/* Export D-Bus lib */ /* Export D-Bus lib */
luaL_register(L, "dbus", awesome_dbus_lib); luaL_register(L, "dbus", awesome_dbus_lib);
@ -792,20 +787,6 @@ luaA_init(xdgHandle* xdg)
/* Export timer */ /* Export timer */
timer_class_setup(L); timer_class_setup(L);
/* init hooks */
globalconf.hooks.manage = LUA_REFNIL;
globalconf.hooks.unmanage = LUA_REFNIL;
globalconf.hooks.focus = LUA_REFNIL;
globalconf.hooks.unfocus = LUA_REFNIL;
globalconf.hooks.mouse_enter = LUA_REFNIL;
globalconf.hooks.mouse_leave = LUA_REFNIL;
globalconf.hooks.clients = LUA_REFNIL;
globalconf.hooks.tags = LUA_REFNIL;
globalconf.hooks.tagged = LUA_REFNIL;
globalconf.hooks.property = LUA_REFNIL;
globalconf.hooks.timer = LUA_REFNIL;
globalconf.hooks.exit = LUA_REFNIL;
/* add Lua search paths */ /* add Lua search paths */
lua_getglobal(L, "package"); lua_getglobal(L, "package");
if (LUA_TTABLE != lua_type(L, 1)) if (LUA_TTABLE != lua_type(L, 1))
@ -918,13 +899,6 @@ bailout:
return ret; return ret;
} }
void
luaA_on_timer(EV_P_ ev_timer *w, int revents)
{
if(globalconf.hooks.timer != LUA_REFNIL)
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.timer, 0, 0);
}
int int
luaA_class_index_miss_property(lua_State *L, lua_object_t *obj) luaA_class_index_miss_property(lua_State *L, lua_object_t *obj)
{ {

11
luaa.h
View File

@ -187,22 +187,11 @@ luaA_warn(lua_State *L, const char *fmt, ...)
void luaA_init(xdgHandle *); void luaA_init(xdgHandle *);
bool luaA_parserc(xdgHandle *, const char *, bool); bool luaA_parserc(xdgHandle *, const char *, bool);
void luaA_on_timer(EV_P_ ev_timer *, int);
bool luaA_hasitem(lua_State *, const void *); bool luaA_hasitem(lua_State *, const void *);
void luaA_table2wtable(lua_State *); void luaA_table2wtable(lua_State *);
int luaA_next(lua_State *, int); int luaA_next(lua_State *, int);
bool luaA_isloop(lua_State *, int); bool luaA_isloop(lua_State *, int);
#define hook_property(obj, prop) \
do { \
if(globalconf.hooks.property != LUA_REFNIL) \
{ \
luaA_object_push(globalconf.L, obj); \
lua_pushliteral(globalconf.L, prop); \
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.property, 2, 0); \
} \
} while(0);
/** Global signals */ /** Global signals */
signal_array_t global_signals; signal_array_t global_signals;

View File

@ -280,7 +280,6 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool doresize)
if(!doresize) if(!doresize)
{ {
hook_property(c, "screen");
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "property::screen", 0); luaA_object_emit_signal(globalconf.L, -1, "property::screen", 0);
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);
@ -333,7 +332,6 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool doresize)
} }
/* move / resize the client */ /* move / resize the client */
client_resize(c, new_geometry, false); client_resize(c, new_geometry, false);
hook_property(c, "screen");
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "property::screen", 0); luaA_object_emit_signal(globalconf.L, -1, "property::screen", 0);
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);

43
tag.c
View File

@ -86,17 +86,6 @@ tag_view(lua_State *L, int udx, bool view)
banning_need_update(tag->screen); banning_need_update(tag->screen);
ewmh_update_net_current_desktop(screen_virttophys(screen_index)); ewmh_update_net_current_desktop(screen_virttophys(screen_index));
if(globalconf.hooks.tags != LUA_REFNIL)
{
lua_pushnumber(globalconf.L, screen_index + 1);
luaA_object_push(globalconf.L, tag);
if(view)
lua_pushliteral(globalconf.L, "select");
else
lua_pushliteral(globalconf.L, "unselect");
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tags, 3, 0);
}
} }
luaA_object_emit_signal(L, udx, "property::selected", 0); luaA_object_emit_signal(L, udx, "property::selected", 0);
@ -133,15 +122,6 @@ tag_append_to_screen(lua_State *L, int udx, screen_t *s)
luaA_object_emit_signal(L, -1, "property::screen", 0); luaA_object_emit_signal(L, -1, "property::screen", 0);
lua_pop(L, 1); lua_pop(L, 1);
/* call hook */
if(globalconf.hooks.tags != LUA_REFNIL)
{
lua_pushnumber(globalconf.L, screen_index + 1);
luaA_object_push(globalconf.L, tag);
lua_pushliteral(globalconf.L, "add");
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tags, 3, 0);
}
luaA_object_push(globalconf.L, tag); luaA_object_push(globalconf.L, tag);
screen_emit_signal(globalconf.L, s, "tag::attach", 1); screen_emit_signal(globalconf.L, s, "tag::attach", 1);
} }
@ -174,15 +154,6 @@ tag_remove_from_screen(tag_t *tag)
ewmh_update_net_desktop_names(phys_screen); ewmh_update_net_desktop_names(phys_screen);
ewmh_update_workarea(phys_screen); ewmh_update_workarea(phys_screen);
/* call hook */
if(globalconf.hooks.tags != LUA_REFNIL)
{
lua_pushnumber(globalconf.L, screen_index + 1);
luaA_object_push(globalconf.L, tag);
lua_pushliteral(globalconf.L, "remove");
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tags, 3, 0);
}
screen_t *s = tag->screen; screen_t *s = tag->screen;
tag->screen = NULL; tag->screen = NULL;
@ -228,13 +199,6 @@ tag_client(client_t *c)
ewmh_client_update_desktop(c); ewmh_client_update_desktop(c);
banning_need_update((c)->screen); banning_need_update((c)->screen);
/* call hook */
if(globalconf.hooks.tagged != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
luaA_object_push(globalconf.L, t);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tagged, 2, 0);
}
tag_client_emit_signal(globalconf.L, t, c, "tagged"); tag_client_emit_signal(globalconf.L, t, c, "tagged");
} }
@ -251,13 +215,6 @@ untag_client(client_t *c, tag_t *t)
client_array_take(&t->clients, i); client_array_take(&t->clients, i);
banning_need_update((c)->screen); banning_need_update((c)->screen);
ewmh_client_update_desktop(c); ewmh_client_update_desktop(c);
/* call hook */
if(globalconf.hooks.tagged != LUA_REFNIL)
{
luaA_object_push(globalconf.L, c);
luaA_object_push(globalconf.L, t);
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tagged, 2, 0);
}
tag_client_emit_signal(globalconf.L, t, c, "untagged"); tag_client_emit_signal(globalconf.L, t, c, "untagged");
luaA_object_unref(globalconf.L, t); luaA_object_unref(globalconf.L, t);
return; return;

View File

@ -209,7 +209,6 @@ titlebar_client_detach(client_t *c)
luaA_object_unref(globalconf.L, c->titlebar); luaA_object_unref(globalconf.L, c->titlebar);
c->titlebar = NULL; c->titlebar = NULL;
hook_property(c, "titlebar");
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "property::titlebar", 0); luaA_object_emit_signal(globalconf.L, -1, "property::titlebar", 0);
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);
@ -271,8 +270,6 @@ titlebar_client_attach(client_t *c)
xcb_map_window(globalconf.connection, t->window); xcb_map_window(globalconf.connection, t->window);
hook_property(c, "titlebar");
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "property::titlebar", 0); luaA_object_emit_signal(globalconf.L, -1, "property::titlebar", 0);
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);
@ -293,7 +290,6 @@ titlebar_set_visible(wibox_t *t, bool visible)
else else
titlebar_ban(t); titlebar_ban(t);
hook_property(t, "visible");
client_stack(); client_stack();
} }
} }
@ -362,12 +358,7 @@ luaA_titlebar_set_position(lua_State *L, int udx)
titlebar->position = position; titlebar->position = position;
client_t *c; client_t *c;
if((c = client_getbytitlebar(titlebar))) if((c = client_getbytitlebar(titlebar)))
{
titlebar_update_geometry(c); titlebar_update_geometry(c);
/* call geometry hook for client because some like to
* set titlebar width in that hook, which make sense */
hook_property(c, "geometry");
}
} }
return 0; return 0;
} }

View File

@ -650,8 +650,6 @@ wibox_set_visible(lua_State *L, int udx, bool v)
} }
luaA_object_emit_signal(L, udx, "property::visible", 0); luaA_object_emit_signal(L, udx, "property::visible", 0);
hook_property(wibox, "visible");
} }
} }
@ -713,8 +711,6 @@ wibox_detach(lua_State *L, int udx)
break; break;
} }
hook_property(wibox, "screen");
if(strut_has_value(&wibox->strut)) if(strut_has_value(&wibox->strut))
screen_emit_signal(L, wibox->screen, "property::workarea", 0); screen_emit_signal(L, wibox->screen, "property::workarea", 0);
@ -773,7 +769,6 @@ wibox_attach(lua_State *L, int udx, screen_t *s)
else else
wibox_need_update(wibox); wibox_need_update(wibox);
hook_property(wibox, "screen");
luaA_object_emit_signal(L, udx, "property::screen", 0); luaA_object_emit_signal(L, udx, "property::screen", 0);
if(strut_has_value(&wibox->strut)) if(strut_has_value(&wibox->strut))