From e5f9ec47232e7635c46975091305638b8fb7e5c5 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 4 Jun 2016 17:39:14 +0200 Subject: [PATCH 1/4] C code: Move docs for signals away from signal_add() Signed-off-by: Uli Schlachter --- luaa.c | 84 ++++++++++++---------- objects/button.c | 32 +++++---- objects/client.c | 170 +++++++++++++++++++++++++-------------------- objects/drawable.c | 77 +++++++++++--------- objects/drawin.c | 77 +++++++++++--------- objects/key.c | 28 ++++---- objects/screen.c | 25 ++++--- objects/tag.c | 25 ++++--- objects/window.c | 42 ++++++----- spawn.c | 45 ++++++------ 10 files changed, 341 insertions(+), 264 deletions(-) diff --git a/luaa.c b/luaa.c index c647fc45..27238b78 100644 --- a/luaa.c +++ b/luaa.c @@ -67,6 +67,54 @@ extern const struct luaL_Reg awesome_root_lib[]; extern const struct luaL_Reg awesome_mouse_methods[]; extern const struct luaL_Reg awesome_mouse_meta[]; +/** A call into the lua code aborted with an error + * @signal debug::error + */ + +/** A deprecated lua function was called + * @signal debug::deprecation + */ + +/** An invalid key was read from an object (e.g. c.foo) + * @signal debug::index::miss + */ + +/** An invalid key was written to an object (e.g. c.foo = "bar") + * @signal debug::newindex::miss + */ + +/** + * @signal systray::update + */ + +/** + * @signal wallpaper_changed + */ + +/** + * @signal xkb::map_changed + */ + +/** + * @signal xkb::group_changed + */ + +/** + * @signal refresh + */ + +/** + * @signal startup + */ + +/** + * @signal exit + */ + +/** + * @signal screen::change + */ + /** Path to config file */ static char *conffile; @@ -676,53 +724,17 @@ luaA_init(xdgHandle* xdg) lua_pop(L, 2); /* pop "package" and "package.loaded" */ - /** A call into the lua code aborted with an error - * @signal debug::error - */ signal_add(&global_signals, "debug::error"); - /** A deprecated lua function was called - * @signal debug::deprecation - */ signal_add(&global_signals, "debug::deprecation"); - /** An invalid key was read from an object (e.g. c.foo) - * @signal debug::index::miss - */ signal_add(&global_signals, "debug::index::miss"); - /** An invalid key was written to an object (e.g. c.foo = "bar") - * @signal debug::newindex::miss - */ signal_add(&global_signals, "debug::newindex::miss"); - /** - * @signal systray::update - */ signal_add(&global_signals, "systray::update"); - /** - * @signal wallpaper_changed - */ signal_add(&global_signals, "wallpaper_changed"); - /** - * @signal xkb::map_changed - */ signal_add(&global_signals, "xkb::map_changed"); - /** - * @signal xkb::group_changed - */ signal_add(&global_signals, "xkb::group_changed"); - /** - * @signal refresh - */ signal_add(&global_signals, "refresh"); - /** - * @signal startup - */ signal_add(&global_signals, "startup"); - /** - * @signal exit - */ signal_add(&global_signals, "exit"); - /** - * @signal screen::change - */ signal_add(&global_signals, "screen::change"); } diff --git a/objects/button.c b/objects/button.c index 1300ca8f..ce45a2f9 100644 --- a/objects/button.c +++ b/objects/button.c @@ -59,6 +59,24 @@ * @function set_newindex_miss_handler */ +/** When bound mouse button + modifiers are pressed. + * @param ... One or more arguments are possible + * @signal .press + */ + +/** When property changes. + * @signal property::button + */ + +/** When property changes. + * @signal property::modifiers + */ + +/** When bound mouse button + modifiers are pressed. + * @param ... One or more arguments are possible + * @signal .release + */ + /** Create a new mouse button bindings. * \param L The Lua VM state. * \return The number of elements pushed on stack. @@ -161,23 +179,9 @@ button_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_button_get_modifiers, (lua_class_propfunc_t) luaA_button_set_modifiers); - /** When bound mouse button + modifiers are pressed. - * @param ... One or more arguments are possible - * @signal .press - */ signal_add(&button_class.signals, "press"); - /** When property changes. - * @signal property::button - */ signal_add(&button_class.signals, "property::button"); - /** When property changes. - * @signal property::modifiers - */ signal_add(&button_class.signals, "property::modifiers"); - /** When bound mouse button + modifiers are pressed. - * @param ... One or more arguments are possible - * @signal .release - */ signal_add(&button_class.signals, "release"); } diff --git a/objects/client.c b/objects/client.c index 69f5be80..f9c92e2e 100644 --- a/objects/client.c +++ b/objects/client.c @@ -109,6 +109,100 @@ * @table object */ +/** When a client gains focus. + * @signal .focus + */ + +/** Before manage, after unmanage, and when clients swap. + * @signal .list + */ + +/** When 2 clients are swapped + * @tparam client client The other client + * @tparam boolean is_source If self is the source or the destination of the swap + * @signal .swapped + */ + +/** + * @signal .manage + */ + +/** + * @signal button::press + */ + +/** + * @signal button::release + */ + +/** + * @signal mouse::enter + */ + +/** + * @signal mouse::leave + */ + +/** + * @signal mouse::move + */ + +/** + * @signal property::window + */ + +/** When a client should get activated (focused and/or raised). + * + * Default implementation: `awful.ewmh.activate`. + * @signal request::activate + * @tparam string context The context where this signal was used. + * @tparam[opt] table hints A table with additional hints: + * @tparam[opt=false] boolean hints.raise should the client be raised? + */ + +/** + * @signal request::geometry + * @tparam client c The client + * @tparam string context Why and what to resize. This is used for the + * handlers to know if they are capable of applying the new geometry. + * @tparam[opt={}] table Additional arguments. Each context handler may + * interpret this differently. + */ + +/** + * @signal request::tag + */ + +/** + * @signal request::urgent + */ + +/** When a client gets tagged. + * @signal .tagged + * @tag t The tag object. + */ + +/** When a client gets unfocused. + * @signal .unfocus + */ + +/** + * @signal .unmanage + */ + +/** When a client gets untagged. + * @signal .untagged + * @tag t The tag object. + */ + +/** + * @signal .raised + */ + +/** + * @signal .lowered + */ + /** * The focused `client` or nil (in case there is none). * @@ -3336,46 +3430,15 @@ client_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_client_get_first_tag, NULL); - /** When a client gains focus. - * @signal .focus - */ signal_add(&client_class.signals, "focus"); - /** Before manage, after unmanage, and when clients swap. - * @signal .list - */ signal_add(&client_class.signals, "list"); - /** When 2 clients are swapped - * @tparam client client The other client - * @tparam boolean is_source If self is the source or the destination of the swap - * @signal .swapped - */ signal_add(&client_class.signals, "swapped"); - /** - * @signal .manage - */ signal_add(&client_class.signals, "manage"); - /** - * @signal button::press - */ signal_add(&client_class.signals, "button::press"); - /** - * @signal button::release - */ signal_add(&client_class.signals, "button::release"); - /** - * @signal mouse::enter - */ signal_add(&client_class.signals, "mouse::enter"); - /** - * @signal mouse::leave - */ signal_add(&client_class.signals, "mouse::leave"); - /** - * @signal mouse::move - */ signal_add(&client_class.signals, "mouse::move"); - - /* Those signals are documented elsewhere */ signal_add(&client_class.signals, "property::above"); signal_add(&client_class.signals, "property::below"); signal_add(&client_class.signals, "property::class"); @@ -3416,63 +3479,18 @@ client_class_setup(lua_State *L) signal_add(&client_class.signals, "property::type"); signal_add(&client_class.signals, "property::urgent"); signal_add(&client_class.signals, "property::width"); - /** - * @signal property::window - */ signal_add(&client_class.signals, "property::window"); signal_add(&client_class.signals, "property::x"); signal_add(&client_class.signals, "property::y"); - /** When a client should get activated (focused and/or raised). - * - * Default implementation: `awful.ewmh.activate`. - * @signal request::activate - * @tparam string context The context where this signal was used. - * @tparam[opt] table hints A table with additional hints: - * @tparam[opt=false] boolean hints.raise should the client be raised? - */ signal_add(&client_class.signals, "request::activate"); - /** - * @signal request::geometry - * @tparam client c The client - * @tparam string context Why and what to resize. This is used for the - * handlers to know if they are capable of applying the new geometry. - * @tparam[opt={}] table Additional arguments. Each context handler may - * interpret this differently. - */ signal_add(&client_class.signals, "request::geometry"); - /** - * @signal request::tag - */ signal_add(&client_class.signals, "request::tag"); - /** - * @signal request::urgent - */ signal_add(&client_class.signals, "request::urgent"); - /** When a client gets tagged. - * @signal .tagged - * @tag t The tag object. - */ signal_add(&client_class.signals, "tagged"); - /** When a client gets unfocused. - * @signal .unfocus - */ signal_add(&client_class.signals, "unfocus"); - /** - * @signal .unmanage - */ signal_add(&client_class.signals, "unmanage"); - /** When a client gets untagged. - * @signal .untagged - * @tag t The tag object. - */ signal_add(&client_class.signals, "untagged"); - /** - * @signal .raised - */ signal_add(&client_class.signals, "raised"); - /** - * @signal .lowered - */ signal_add(&client_class.signals, "lowered"); } diff --git a/objects/drawable.c b/objects/drawable.c index 189d3b5c..63fb36c0 100644 --- a/objects/drawable.c +++ b/objects/drawable.c @@ -43,6 +43,50 @@ * @function drawable */ +/** + * @signal button::press + */ + +/** + * @signal button::release + */ + +/** + * @signal mouse::enter + */ + +/** + * @signal mouse::leave + */ + +/** + * @signal mouse::move + */ + +/** + * @signal property::geometry + */ + +/** + * @signal property::height + */ + +/** + * @signal property::width + */ + +/** + * @signal property::x + */ + +/** + * @signal property::y + */ + +/** + * @signal property::surface + */ + /** Get the number of instances. * * @return The number of drawable objects alive. @@ -197,49 +241,16 @@ drawable_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_drawable_get_surface, NULL); - /** - * @signal button::press - */ signal_add(&drawable_class.signals, "button::press"); - /** - * @signal button::release - */ signal_add(&drawable_class.signals, "button::release"); - /** - * @signal mouse::enter - */ signal_add(&drawable_class.signals, "mouse::enter"); - /** - * @signal mouse::leave - */ signal_add(&drawable_class.signals, "mouse::leave"); - /** - * @signal mouse::move - */ signal_add(&drawable_class.signals, "mouse::move"); - /** - * @signal property::geometry - */ signal_add(&drawable_class.signals, "property::geometry"); - /** - * @signal property::height - */ signal_add(&drawable_class.signals, "property::height"); - /** - * @signal property::width - */ signal_add(&drawable_class.signals, "property::width"); - /** - * @signal property::x - */ signal_add(&drawable_class.signals, "property::x"); - /** - * @signal property::y - */ signal_add(&drawable_class.signals, "property::y"); - /** - * @signal property::surface - */ signal_add(&drawable_class.signals, "property::surface"); } diff --git a/objects/drawin.c b/objects/drawin.c index 33dd66e0..c314aac8 100644 --- a/objects/drawin.c +++ b/objects/drawin.c @@ -67,6 +67,50 @@ * @table drawin */ +/** + * @signal property::geometry + */ + +/** + * @signal property::shape_bounding + */ + +/** + * @signal property::shape_clip + */ + +/** + * @signal property::border_width + */ + +/** + * @signal property::cursor + */ + +/** + * @signal property::height + */ + +/** + * @signal property::ontop + */ + +/** + * @signal property::visible + */ + +/** + * @signal property::width + */ + +/** + * @signal property::x + */ + +/** + * @signal property::y + */ + /** Get or set mouse buttons bindings to a drawin. * * @param buttons_table A table of buttons objects, or nothing. @@ -716,49 +760,16 @@ drawin_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_drawin_get_shape_clip, (lua_class_propfunc_t) luaA_drawin_set_shape_clip); - /** - * @signal property::geometry - */ signal_add(&drawin_class.signals, "property::geometry"); - /** - * @signal property::shape_bounding - */ signal_add(&drawin_class.signals, "property::shape_bounding"); - /** - * @signal property::shape_clip - */ signal_add(&drawin_class.signals, "property::shape_clip"); - /** - * @signal property::border_width - */ signal_add(&drawin_class.signals, "property::border_width"); - /** - * @signal property::cursor - */ signal_add(&drawin_class.signals, "property::cursor"); - /** - * @signal property::height - */ signal_add(&drawin_class.signals, "property::height"); - /** - * @signal property::ontop - */ signal_add(&drawin_class.signals, "property::ontop"); - /** - * @signal property::visible - */ signal_add(&drawin_class.signals, "property::visible"); - /** - * @signal property::width - */ signal_add(&drawin_class.signals, "property::width"); - /** - * @signal property::x - */ signal_add(&drawin_class.signals, "property::x"); - /** - * @signal property::y - */ signal_add(&drawin_class.signals, "property::y"); } diff --git a/objects/key.c b/objects/key.c index 2b7bfa07..c3af2c09 100644 --- a/objects/key.c +++ b/objects/key.c @@ -56,6 +56,22 @@ * @table key */ +/** + * @signal .press + */ + +/** + * @signal property::key + */ + +/** + * @signal property::modifiers + */ + +/** + * @signal .release + */ + /** Get the number of instances. * * @return The number of key objects alive. @@ -358,21 +374,9 @@ key_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_key_get_modifiers, (lua_class_propfunc_t) luaA_key_set_modifiers); - /** - * @signal .press - */ signal_add(&key_class.signals, "press"); - /** - * @signal property::key - */ signal_add(&key_class.signals, "property::key"); - /** - * @signal property::modifiers - */ signal_add(&key_class.signals, "property::modifiers"); - /** - * @signal .release - */ signal_add(&key_class.signals, "release"); } diff --git a/objects/screen.c b/objects/screen.c index f1ad03a0..6771a267 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -66,6 +66,20 @@ * */ +/** + * @signal .primary_changed + */ + +/** + * This signal is emitted when a new screen is added to the current setup. + * @signal .added + */ + +/** + * This signal is emitted when a screen is removed from the setup. + * @signal removed + */ + /** * The primary screen. * @@ -1118,19 +1132,8 @@ screen_class_setup(lua_State *L) signal_add(&screen_class.signals, "property::workarea"); signal_add(&screen_class.signals, "property::geometry"); signal_add(&screen_class.signals, "property::outputs"); - /** - * @signal .primary_changed - */ signal_add(&screen_class.signals, "primary_changed"); - /** - * This signal is emitted when a new screen is added to the current setup. - * @signal .added - */ signal_add(&screen_class.signals, "added"); - /** - * This signal is emitted when a screen is removed from the setup. - * @signal removed - */ signal_add(&screen_class.signals, "removed"); } diff --git a/objects/tag.c b/objects/tag.c index a0512a4c..8e8fab3f 100644 --- a/objects/tag.c +++ b/objects/tag.c @@ -42,6 +42,20 @@ #include "ewmh.h" #include "luaa.h" +/** + * @signal request::select + */ + +/** When a client gets tagged with this tag. + * @signal tagged + * @client c The tagged client. + */ + +/** When a client gets untagged with this tag. + * @signal untagged + * @client c The untagged client. + */ + /** * Tag name. * @@ -415,19 +429,8 @@ tag_class_setup(lua_State *L) signal_add(&tag_class.signals, "property::name"); signal_add(&tag_class.signals, "property::selected"); signal_add(&tag_class.signals, "property::activated"); - /** - * @signal request::select - */ signal_add(&tag_class.signals, "request::select"); - /** When a client gets tagged with this tag. - * @signal tagged - * @client c The tagged client. - */ signal_add(&tag_class.signals, "tagged"); - /** When a client gets untagged with this tag. - * @signal untagged - * @client c The untagged client. - */ signal_add(&tag_class.signals, "untagged"); } diff --git a/objects/window.c b/objects/window.c index 2c02ac0f..3ddeb82e 100644 --- a/objects/window.c +++ b/objects/window.c @@ -27,6 +27,30 @@ * @classmod xproperties */ +/** + * @signal property::border_color + */ + +/** + * @signal property::border_width + */ + +/** + * @signal property::buttons + */ + +/** + * @signal property::opacity + */ + +/** + * @signal property::struts + */ + +/** + * @signal property::type + */ + #include "objects/window.h" #include "common/atoms.h" #include "common/xutil.h" @@ -520,29 +544,11 @@ window_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_window_get_border_width, (lua_class_propfunc_t) luaA_window_set_border_width); - /** - * @signal property::border_color - */ signal_add(&window_class.signals, "property::border_color"); - /** - * @signal property::border_width - */ signal_add(&window_class.signals, "property::border_width"); - /** - * @signal property::buttons - */ signal_add(&window_class.signals, "property::buttons"); - /** - * @signal property::opacity - */ signal_add(&window_class.signals, "property::opacity"); - /** - * @signal property::struts - */ signal_add(&window_class.signals, "property::struts"); - /** - * @signal property::type - */ signal_add(&window_class.signals, "property::type"); } diff --git a/spawn.c b/spawn.c index cbd4a004..b289b7f4 100644 --- a/spawn.c +++ b/spawn.c @@ -27,6 +27,31 @@ * @module awesome */ +/** For some reason the application aborted startup + * @param arg Table which only got the "id" key set + * @signal spawn::canceled + */ + +/** When one of the fields from the @{spawn::initiated} table changes + * @param arg Table which describes the spawn event + * @signal spawn::change + */ + +/** An application finished starting + * @param arg Table which only got the "id" key set + * @signal spawn::completed + */ + +/** When a new client is beginning to start + * @param arg Table which describes the spawn event + * @signal spawn::initiated + */ + +/** An application started a spawn event but didn't start in time. + * @param arg Table which only got the "id" key set + * @signal spawn::timeout + */ + #include "spawn.h" #include @@ -245,30 +270,10 @@ spawn_init(void) spawn_monitor_event, NULL, NULL); - /** For some reason the application aborted startup - * @param arg Table which only got the "id" key set - * @signal spawn::canceled - */ signal_add(&global_signals, "spawn::canceled"); - /** When one of the fields from the @{spawn::initiated} table changes - * @param arg Table which describes the spawn event - * @signal spawn::change - */ signal_add(&global_signals, "spawn::change"); - /** An application finished starting - * @param arg Table which only got the "id" key set - * @signal spawn::completed - */ signal_add(&global_signals, "spawn::completed"); - /** When a new client is beginning to start - * @param arg Table which describes the spawn event - * @signal spawn::initiated - */ signal_add(&global_signals, "spawn::initiated"); - /** An application started a spawn event but didn't start in time. - * @param arg Table which only got the "id" key set - * @signal spawn::timeout - */ signal_add(&global_signals, "spawn::timeout"); } From a964396771194f0e7eb80ab63cac25e518c16214 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 4 Jun 2016 17:51:45 +0200 Subject: [PATCH 2/4] Deprecate signal_add() on C-API objects This commit makes the code automatically add signals when they are first used. Signed-off-by: Uli Schlachter --- common/array.h | 7 ------- common/luaclass.c | 3 --- common/luaclass.h | 2 +- common/luaobject.c | 6 +----- common/luaobject.h | 1 - common/signal.h | 49 ++++++++-------------------------------------- spawn.c | 4 ---- 7 files changed, 10 insertions(+), 62 deletions(-) diff --git a/common/array.h b/common/array.h index b988621f..a5671fbd 100644 --- a/common/array.h +++ b/common/array.h @@ -34,13 +34,6 @@ int len, size; \ } pfx##_array_t; -#define ARRAY_TYPE_EXTRA(type_t, pfx, extra) \ - typedef struct pfx##_array_t { \ - type_t *tab; \ - int len, size; \ - extra; \ - } pfx##_array_t; - #define foreach(var, array) \ for(int __foreach_index_##var = 0; \ __foreach_index_##var < (array).len; \ diff --git a/common/luaclass.c b/common/luaclass.c index 33c99a80..fa234cdc 100644 --- a/common/luaclass.c +++ b/common/luaclass.c @@ -256,9 +256,6 @@ luaA_class_setup(lua_State *L, lua_class_t *class, signal_add(&class->signals, "new"); - if (parent) - class->signals.inherits_from = &parent->signals; - lua_class_array_append(&luaA_classes, class); } diff --git a/common/luaclass.h b/common/luaclass.h index 8f731469..a5ed642a 100644 --- a/common/luaclass.h +++ b/common/luaclass.h @@ -123,7 +123,7 @@ luaA_checkudataornil(lua_State *L, int udx, lua_class_t *class) static inline int \ luaA_##prefix##_class_add_signal(lua_State *L) \ { \ - signal_add(&(lua_class).signals, luaL_checkstring(L, 1)); \ + luaA_deprecate(L, "signal usage without add_signal()"); \ return 0; \ } \ \ diff --git a/common/luaobject.c b/common/luaobject.c index 4f833d4f..8f55ed0a 100644 --- a/common/luaobject.c +++ b/common/luaobject.c @@ -253,8 +253,7 @@ signal_object_emit(lua_State *L, signal_array_t *arr, const char *name, int narg lua_remove(L, - nargs - nbfunc - 1 + i); luaA_dofunction(L, nargs, 0); } - } else - luaA_warn(L, "Trying to emit unknown signal '%s'", name); + } /* remove args */ lua_pop(L, nargs); @@ -304,9 +303,6 @@ luaA_object_emit_signal(lua_State *L, int oud, lua_remove(L, - nargs - nbfunc - 2 + i); luaA_dofunction(L, nargs + 1, 0); } - } else { - luaA_warn(L, "Trying to emit unknown signal '%s'", name); - return; } /* Then emit signal on the class */ diff --git a/common/luaobject.h b/common/luaobject.h index c3e1f056..b57ec43a 100644 --- a/common/luaobject.h +++ b/common/luaobject.h @@ -175,7 +175,6 @@ int luaA_object_emit_signal_simple(lua_State *); lua_setmetatable(L, -2); \ luaA_setuservalue(L, -2); \ lua_pushvalue(L, -1); \ - p->signals.inherits_from = &(lua_class).signals; \ luaA_class_emit_signal(L, &(lua_class), "new", 1); \ return p; \ } diff --git a/common/signal.h b/common/signal.h index f9a4cc1b..22dc7cb4 100644 --- a/common/signal.h +++ b/common/signal.h @@ -45,54 +45,18 @@ signal_wipe(signal_t *sig) cptr_array_wipe(&sig->sigfuncs); } -ARRAY_TYPE_EXTRA(signal_t, signal, struct signal_array_t *inherits_from) -BARRAY_FUNCS(signal_t, signal, signal_wipe, signal_cmp) +DO_BARRAY(signal_t, signal, signal_wipe, signal_cmp) static inline signal_t * signal_array_getbyid(signal_array_t *arr, unsigned long id) { signal_t sig = { .id = id }; - signal_t *result; - - result = signal_array_lookup(arr, &sig); - if(result) - return result; - - /* The signal doesn't exist yet. Check if some of our inherits_from have the - * signal and if yes, add it. - */ - signal_array_t *inherit = arr->inherits_from; - while(inherit != NULL) - { - if(signal_array_lookup(inherit, &sig)) - break; - inherit = inherit->inherits_from; - } - if(inherit) - { - /* Add the signal to this array to pretend it always existed */ - signal_array_insert(arr, sig); - result = signal_array_lookup(arr, &sig); - assert(result != NULL); - } - return result; + return signal_array_lookup(arr, &sig); } -/** Add a signal to a signal array. - * Signals have to be added before they can be added or emitted. - * \param arr The signal array. - * \param name The signal name. - */ static inline void signal_add(signal_array_t *arr, const char *name) { - unsigned long tok = a_strhash((const unsigned char *) name); - signal_t *sigfound = signal_array_getbyid(arr, tok); - if(!sigfound) - { - signal_t sig = { .id = tok }; - signal_array_insert(arr, sig); - } } /** Connect a signal inside a signal array. @@ -109,7 +73,11 @@ signal_connect(signal_array_t *arr, const char *name, const void *ref) if(sigfound) cptr_array_append(&sigfound->sigfuncs, ref); else - warn("Trying to connect to unknown signal '%s'", name); + { + signal_t sig = { .id = tok }; + cptr_array_append(&sig.sigfuncs, ref); + signal_array_insert(arr, sig); + } } /** Disconnect a signal inside a signal array. @@ -131,8 +99,7 @@ signal_disconnect(signal_array_t *arr, const char *name, const void *ref) cptr_array_remove(&sigfound->sigfuncs, func); break; } - } else - warn("Trying to disconnect from unknown signal '%s'", name); + } } #endif diff --git a/spawn.c b/spawn.c index b289b7f4..b7863e5f 100644 --- a/spawn.c +++ b/spawn.c @@ -112,8 +112,6 @@ spawn_monitor_timeout(gpointer sequence) } lua_pop(L, 1); } - else - warn("spawn::timeout signal is missing"); } sn_startup_sequence_unref(sequence); return FALSE; @@ -218,8 +216,6 @@ spawn_monitor_event(SnMonitorEvent *event, void *data) } lua_pop(L, 1); } - else - warn("%s signal is missing", event_type_str); } /** Tell the spawn module that an app has been started. From 231436d9e3e132d6b0fd790feb84133ea4f47665 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 4 Jun 2016 17:57:08 +0200 Subject: [PATCH 3/4] C: Remove unneeded calls to signal_add() Signed-off-by: Uli Schlachter --- common/luaclass.c | 2 -- common/signal.h | 5 ---- dbus.c | 3 --- luaa.c | 13 ---------- objects/button.c | 5 ---- objects/client.c | 63 ---------------------------------------------- objects/drawable.c | 12 --------- objects/drawin.c | 12 --------- objects/key.c | 5 ---- objects/screen.c | 7 ------ objects/tag.c | 7 ------ objects/window.c | 7 ------ property.c | 7 ------ spawn.c | 6 ----- 14 files changed, 154 deletions(-) diff --git a/common/luaclass.c b/common/luaclass.c index fa234cdc..f5a40c29 100644 --- a/common/luaclass.c +++ b/common/luaclass.c @@ -254,8 +254,6 @@ luaA_class_setup(lua_State *L, lua_class_t *class, class->index_miss_handler = LUA_REFNIL; class->newindex_miss_handler = LUA_REFNIL; - signal_add(&class->signals, "new"); - lua_class_array_append(&luaA_classes, class); } diff --git a/common/signal.h b/common/signal.h index 22dc7cb4..f2b15839 100644 --- a/common/signal.h +++ b/common/signal.h @@ -54,11 +54,6 @@ signal_array_getbyid(signal_array_t *arr, unsigned long id) return signal_array_lookup(arr, &sig); } -static inline void -signal_add(signal_array_t *arr, const char *name) -{ -} - /** Connect a signal inside a signal array. * You are in charge of reference counting. * \param arr The signal array. diff --git a/dbus.c b/dbus.c index b6874169..4e796139 100644 --- a/dbus.c +++ b/dbus.c @@ -773,10 +773,7 @@ luaA_dbus_connect_signal(lua_State *L) if(sig) luaA_warn(L, "cannot add signal %s on D-Bus, already existing", name); else - { - signal_add(&dbus_signals, name); signal_connect(&dbus_signals, name, luaA_object_ref(L, 2)); - } return 0; } diff --git a/luaa.c b/luaa.c index 27238b78..37ef6e81 100644 --- a/luaa.c +++ b/luaa.c @@ -723,19 +723,6 @@ luaA_init(xdgHandle* xdg) lua_getfield(L, 1, "loaded"); lua_pop(L, 2); /* pop "package" and "package.loaded" */ - - signal_add(&global_signals, "debug::error"); - signal_add(&global_signals, "debug::deprecation"); - signal_add(&global_signals, "debug::index::miss"); - signal_add(&global_signals, "debug::newindex::miss"); - signal_add(&global_signals, "systray::update"); - signal_add(&global_signals, "wallpaper_changed"); - signal_add(&global_signals, "xkb::map_changed"); - signal_add(&global_signals, "xkb::group_changed"); - signal_add(&global_signals, "refresh"); - signal_add(&global_signals, "startup"); - signal_add(&global_signals, "exit"); - signal_add(&global_signals, "screen::change"); } static void diff --git a/objects/button.c b/objects/button.c index ce45a2f9..84fc7384 100644 --- a/objects/button.c +++ b/objects/button.c @@ -178,11 +178,6 @@ button_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_button_set_modifiers, (lua_class_propfunc_t) luaA_button_get_modifiers, (lua_class_propfunc_t) luaA_button_set_modifiers); - - signal_add(&button_class.signals, "press"); - signal_add(&button_class.signals, "property::button"); - signal_add(&button_class.signals, "property::modifiers"); - signal_add(&button_class.signals, "release"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/client.c b/objects/client.c index f9c92e2e..bb11ba17 100644 --- a/objects/client.c +++ b/objects/client.c @@ -3429,69 +3429,6 @@ client_class_setup(lua_State *L) NULL, (lua_class_propfunc_t) luaA_client_get_first_tag, NULL); - - signal_add(&client_class.signals, "focus"); - signal_add(&client_class.signals, "list"); - signal_add(&client_class.signals, "swapped"); - signal_add(&client_class.signals, "manage"); - signal_add(&client_class.signals, "button::press"); - signal_add(&client_class.signals, "button::release"); - signal_add(&client_class.signals, "mouse::enter"); - signal_add(&client_class.signals, "mouse::leave"); - signal_add(&client_class.signals, "mouse::move"); - signal_add(&client_class.signals, "property::above"); - signal_add(&client_class.signals, "property::below"); - signal_add(&client_class.signals, "property::class"); - signal_add(&client_class.signals, "property::focusable"); - signal_add(&client_class.signals, "property::fullscreen"); - signal_add(&client_class.signals, "property::geometry"); - signal_add(&client_class.signals, "property::group_window"); - signal_add(&client_class.signals, "property::height"); - signal_add(&client_class.signals, "property::hidden"); - signal_add(&client_class.signals, "property::icon"); - signal_add(&client_class.signals, "property::icon_name"); - signal_add(&client_class.signals, "property::instance"); - signal_add(&client_class.signals, "property::keys"); - signal_add(&client_class.signals, "property::machine"); - signal_add(&client_class.signals, "property::maximized"); - signal_add(&client_class.signals, "property::maximized_horizontal"); - signal_add(&client_class.signals, "property::maximized_vertical"); - signal_add(&client_class.signals, "property::minimized"); - signal_add(&client_class.signals, "property::modal"); - signal_add(&client_class.signals, "property::name"); - signal_add(&client_class.signals, "property::ontop"); - signal_add(&client_class.signals, "property::pid"); - signal_add(&client_class.signals, "property::role"); - signal_add(&client_class.signals, "property::screen"); - signal_add(&client_class.signals, "property::shape_bounding"); - signal_add(&client_class.signals, "property::shape_client_bounding"); - signal_add(&client_class.signals, "property::shape_client_clip"); - signal_add(&client_class.signals, "property::shape_clip"); - signal_add(&client_class.signals, "property::size_hints_honor"); - signal_add(&client_class.signals, "property::skip_taskbar"); - signal_add(&client_class.signals, "property::sticky"); - signal_add(&client_class.signals, "property::struts"); - signal_add(&client_class.signals, "property::titlebar_bottom"); - signal_add(&client_class.signals, "property::titlebar_left"); - signal_add(&client_class.signals, "property::titlebar_right"); - signal_add(&client_class.signals, "property::titlebar_top"); - signal_add(&client_class.signals, "property::transient_for"); - signal_add(&client_class.signals, "property::type"); - signal_add(&client_class.signals, "property::urgent"); - signal_add(&client_class.signals, "property::width"); - signal_add(&client_class.signals, "property::window"); - signal_add(&client_class.signals, "property::x"); - signal_add(&client_class.signals, "property::y"); - signal_add(&client_class.signals, "request::activate"); - signal_add(&client_class.signals, "request::geometry"); - signal_add(&client_class.signals, "request::tag"); - signal_add(&client_class.signals, "request::urgent"); - signal_add(&client_class.signals, "tagged"); - signal_add(&client_class.signals, "unfocus"); - signal_add(&client_class.signals, "unmanage"); - signal_add(&client_class.signals, "untagged"); - signal_add(&client_class.signals, "raised"); - signal_add(&client_class.signals, "lowered"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/drawable.c b/objects/drawable.c index 63fb36c0..d1755a31 100644 --- a/objects/drawable.c +++ b/objects/drawable.c @@ -240,18 +240,6 @@ drawable_class_setup(lua_State *L) NULL, (lua_class_propfunc_t) luaA_drawable_get_surface, NULL); - - signal_add(&drawable_class.signals, "button::press"); - signal_add(&drawable_class.signals, "button::release"); - signal_add(&drawable_class.signals, "mouse::enter"); - signal_add(&drawable_class.signals, "mouse::leave"); - signal_add(&drawable_class.signals, "mouse::move"); - signal_add(&drawable_class.signals, "property::geometry"); - signal_add(&drawable_class.signals, "property::height"); - signal_add(&drawable_class.signals, "property::width"); - signal_add(&drawable_class.signals, "property::x"); - signal_add(&drawable_class.signals, "property::y"); - signal_add(&drawable_class.signals, "property::surface"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/drawin.c b/objects/drawin.c index c314aac8..09056b7f 100644 --- a/objects/drawin.c +++ b/objects/drawin.c @@ -759,18 +759,6 @@ drawin_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_drawin_set_shape_clip, (lua_class_propfunc_t) luaA_drawin_get_shape_clip, (lua_class_propfunc_t) luaA_drawin_set_shape_clip); - - signal_add(&drawin_class.signals, "property::geometry"); - signal_add(&drawin_class.signals, "property::shape_bounding"); - signal_add(&drawin_class.signals, "property::shape_clip"); - signal_add(&drawin_class.signals, "property::border_width"); - signal_add(&drawin_class.signals, "property::cursor"); - signal_add(&drawin_class.signals, "property::height"); - signal_add(&drawin_class.signals, "property::ontop"); - signal_add(&drawin_class.signals, "property::visible"); - signal_add(&drawin_class.signals, "property::width"); - signal_add(&drawin_class.signals, "property::x"); - signal_add(&drawin_class.signals, "property::y"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/key.c b/objects/key.c index c3af2c09..01774a46 100644 --- a/objects/key.c +++ b/objects/key.c @@ -373,11 +373,6 @@ key_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_key_set_modifiers, (lua_class_propfunc_t) luaA_key_get_modifiers, (lua_class_propfunc_t) luaA_key_set_modifiers); - - signal_add(&key_class.signals, "press"); - signal_add(&key_class.signals, "property::key"); - signal_add(&key_class.signals, "property::modifiers"); - signal_add(&key_class.signals, "release"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/screen.c b/objects/screen.c index 6771a267..cefca8b1 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -1128,13 +1128,6 @@ screen_class_setup(lua_State *L) NULL, (lua_class_propfunc_t) luaA_screen_get_workarea, NULL); - - signal_add(&screen_class.signals, "property::workarea"); - signal_add(&screen_class.signals, "property::geometry"); - signal_add(&screen_class.signals, "property::outputs"); - signal_add(&screen_class.signals, "primary_changed"); - signal_add(&screen_class.signals, "added"); - signal_add(&screen_class.signals, "removed"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/tag.c b/objects/tag.c index 8e8fab3f..ce1149b3 100644 --- a/objects/tag.c +++ b/objects/tag.c @@ -425,13 +425,6 @@ tag_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_tag_set_activated, (lua_class_propfunc_t) luaA_tag_get_activated, (lua_class_propfunc_t) luaA_tag_set_activated); - - signal_add(&tag_class.signals, "property::name"); - signal_add(&tag_class.signals, "property::selected"); - signal_add(&tag_class.signals, "property::activated"); - signal_add(&tag_class.signals, "request::select"); - signal_add(&tag_class.signals, "tagged"); - signal_add(&tag_class.signals, "untagged"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/window.c b/objects/window.c index 3ddeb82e..a39bf91a 100644 --- a/objects/window.c +++ b/objects/window.c @@ -543,13 +543,6 @@ window_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_window_set_border_width, (lua_class_propfunc_t) luaA_window_get_border_width, (lua_class_propfunc_t) luaA_window_set_border_width); - - signal_add(&window_class.signals, "property::border_color"); - signal_add(&window_class.signals, "property::border_width"); - signal_add(&window_class.signals, "property::buttons"); - signal_add(&window_class.signals, "property::opacity"); - signal_add(&window_class.signals, "property::struts"); - signal_add(&window_class.signals, "property::type"); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/property.c b/property.c index deec41c2..de000d77 100644 --- a/property.c +++ b/property.c @@ -530,15 +530,8 @@ luaA_register_xproperty(lua_State *L) } else { - buffer_t buf; - buffer_inita(&buf, a_strlen(name) + a_strlen("xproperty::") + 1); - buffer_addf(&buf, "xproperty::%s", name); - property.name = a_strdup(name); xproperty_array_insert(&globalconf.xproperties, property); - signal_add(&window_class.signals, buf.s); - signal_add(&global_signals, buf.s); - buffer_wipe(&buf); } return 0; diff --git a/spawn.c b/spawn.c index b7863e5f..40e9ef8c 100644 --- a/spawn.c +++ b/spawn.c @@ -265,12 +265,6 @@ spawn_init(void) globalconf.default_screen, spawn_monitor_event, NULL, NULL); - - signal_add(&global_signals, "spawn::canceled"); - signal_add(&global_signals, "spawn::change"); - signal_add(&global_signals, "spawn::completed"); - signal_add(&global_signals, "spawn::initiated"); - signal_add(&global_signals, "spawn::timeout"); } static gboolean From 0857f6f1b5535a862c840311f5bdad849f42e95d Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 4 Jun 2016 18:23:48 +0200 Subject: [PATCH 4/4] Lua: Remove calls to add_signal() The requirement to call add_signal() was added to catch typos. However, this requirement became increasingly annoying with property:: signals and e.g. gears.object allowing arbitrary properties to be changed. All of this ended up in a single commit because tests/examples fails if I first let add_signal() emit a deprecation warning. Signed-off-by: Uli Schlachter --- docs/common/object.ldoc | 7 --- lib/awful/client.lua | 8 ---- lib/awful/layout/init.lua | 2 - lib/awful/placement.lua | 1 - lib/awful/screen.lua | 2 - lib/awful/spawn.lua | 2 - lib/awful/tag.lua | 25 ---------- lib/awful/tooltip.lua | 1 - lib/awful/wibar.lua | 2 - lib/gears/object.lua | 40 ++++++---------- lib/gears/timer.lua | 5 -- lib/wibox/drawable.lua | 1 - lib/wibox/init.lua | 3 -- lib/wibox/widget/base.lua | 12 +---- spec/awful/screen_spec.lua | 1 - spec/gears/object_spec.lua | 34 ------------- spec/wibox/test_utils.lua | 2 - tests/examples/shims/awesome.lua | 11 ----- tests/examples/shims/client.lua | 48 ------------------- tests/examples/shims/screen.lua | 8 ---- tests/examples/shims/tag.lua | 20 -------- .../examples/text/gears/object/properties.lua | 3 -- tests/examples/text/gears/object/signal.lua | 3 -- tests/test-awful-client.lua | 1 - 24 files changed, 16 insertions(+), 226 deletions(-) diff --git a/docs/common/object.ldoc b/docs/common/object.ldoc index 19dfbd03..24285299 100644 --- a/docs/common/object.ldoc +++ b/docs/common/object.ldoc @@ -2,7 +2,6 @@ --- Disonnect to a signal. -- @tparam string name The name of the signal -- @tparam function func The callback that should be disconnected --- @see add_signal -- @function disconnect_signal --- Emit a signal. @@ -13,15 +12,9 @@ -- that are given to emit_signal() -- @function emit_signal ---- Add a signal to an object. All signals must be added before they can be used. --- --- @tparam string name The name of the new signal. --- @function add_signal - --- Connect to a signal. -- @tparam string name The name of the signal -- @tparam function func The callback to call when the signal is emitted --- @see add_signal -- @function connect_signal --- Connect to a signal weakly. This allows the callback function to be garbage diff --git a/lib/awful/client.lua b/lib/awful/client.lua index e4fed3cd..fcf17a4e 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -1159,25 +1159,17 @@ end --- The last geometry when client was floating. -- @signal property::floating_geometry -capi.client.add_signal("property::floating_geometry") - -capi.client.add_signal("property::floating") - -capi.client.add_signal("property::dockable") --- Emited when a client need to get a titlebar. -- @signal request::titlebars -- @tparam[opt=nil] string content The context (like "rules") -- @tparam[opt=nil] table hints Some hints. -capi.client.add_signal("request::titlebars") --- The client marked signal (deprecated). -- @signal .marked -capi.client.add_signal("marked") --- The client unmarked signal (deprecated). -- @signal unmarked -capi.client.add_signal("unmarked") -- Add clients during startup to focus history. -- This used to happen through ewmh.activate, but that only handles visible diff --git a/lib/awful/layout/init.lua b/lib/awful/layout/init.lua index 114b12b3..08570257 100644 --- a/lib/awful/layout/init.lua +++ b/lib/awful/layout/init.lua @@ -222,8 +222,6 @@ local function arrange_tag(t) layout.arrange(t.screen) end -capi.screen.add_signal("arrange") - capi.tag.connect_signal("property::master_width_factor", arrange_tag) capi.tag.connect_signal("property::master_count", arrange_tag) capi.tag.connect_signal("property::column_count", arrange_tag) diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index 5d2c59ae..c003d3f1 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -558,7 +558,6 @@ attach = function(d, position_f, args) end -- Create a way to detach a placement function - d:add_signal("property::detach_callback") function d.detach_callback() d:disconnect_signal("property::width" , tracker) d:disconnect_signal("property::height" , tracker) diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index cc384f91..9073dd9f 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -465,8 +465,6 @@ function screen.object.set_selected_tag() end --- When the tag history changed. -- @signal tag::history::update -capi.screen.add_signal("padding") - -- Extend the luaobject object.properties(capi.screen, { getter_class = screen.object, diff --git a/lib/awful/spawn.lua b/lib/awful/spawn.lua index e3499815..c9d203cb 100644 --- a/lib/awful/spawn.lua +++ b/lib/awful/spawn.lua @@ -297,7 +297,5 @@ capi.awesome.connect_signal("spawn::canceled" , spawn.on_snid_cancel ) capi.awesome.connect_signal("spawn::timeout" , spawn.on_snid_cancel ) capi.client.connect_signal ("manage" , spawn.on_snid_callback ) -capi.client.add_signal ("spawn::completed_with_payload" ) - return setmetatable(spawn, { __call = function(_, ...) return spawn.spawn(...) end }) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/lib/awful/tag.lua b/lib/awful/tag.lua index 94edb330..8ff168bd 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -1323,22 +1323,6 @@ capi.client.connect_signal("untagged", client_untagged) capi.client.connect_signal("tagged", client_tagged) capi.tag.connect_signal("request::select", tag.object.view_only) -capi.tag.add_signal("property::hide") -capi.tag.add_signal("property::icon") -capi.tag.add_signal("property::icon_only") -capi.tag.add_signal("property::layout") -capi.tag.add_signal("property::mwfact") -capi.tag.add_signal("property::master_width_factor") -capi.tag.add_signal("property::useless_gap") -capi.tag.add_signal("property::master_fill_policy") -capi.tag.add_signal("property::ncol") -capi.tag.add_signal("property::column_count") -capi.tag.add_signal("property::nmaster") -capi.tag.add_signal("property::master_count") -capi.tag.add_signal("property::windowfact") -capi.tag.add_signal("property::screen") -capi.tag.add_signal("property::index") - --- True when a tagged client is urgent -- @signal property::urgent -- @see client.urgent @@ -1347,15 +1331,6 @@ capi.tag.add_signal("property::index") -- @signal property::urgent_count -- @see client.urgent -capi.tag.add_signal("property::urgent") - -capi.tag.add_signal("property::urgent_count") -capi.tag.add_signal("property::volatile") -capi.tag.add_signal("request::screen") -capi.tag.add_signal("removal-pending") - -capi.screen.add_signal("tag::history::update") - capi.screen.connect_signal("tag::history::update", tag.history.update) capi.screen.connect_signal("removed", function(s) diff --git a/lib/awful/tooltip.lua b/lib/awful/tooltip.lua index 2e1ba4df..3a2fec5e 100644 --- a/lib/awful/tooltip.lua +++ b/lib/awful/tooltip.lua @@ -196,7 +196,6 @@ end -- @see set_markup tooltip.new = function(args) local self = setmetatable(object(), instance_mt) - self:add_signal("property::visible") self.visible = false -- private data diff --git a/lib/awful/wibar.lua b/lib/awful/wibar.lua index af095030..9c52a261 100644 --- a/lib/awful/wibar.lua +++ b/lib/awful/wibar.lua @@ -341,11 +341,9 @@ function awfulwibar.new(arg) w._screen = screen --HACK When a screen is removed, then getbycoords wont work w._stretch = arg.stretch == nil and has_to_stretch or arg.stretch - w:add_signal("property::position") w.get_position = get_position w.set_position = set_position - w:add_signal("property::stretch") w.get_stretch = get_stretch w.set_stretch = set_stretch w.remove = remove diff --git a/lib/gears/object.lua b/lib/gears/object.lua index c65582ed..25e4ae63 100644 --- a/lib/gears/object.lua +++ b/lib/gears/object.lua @@ -21,45 +21,36 @@ local object = { properties = properties, mt = {} } --- Verify that obj is indeed a valid object as returned by new() local function check(obj) if type(obj) ~= "table" or type(obj._signals) ~= "table" then - error("add_signal() called on non-object") + error("called on non-object") end end --- Find a given signal -- @tparam table obj The object to search in -- @tparam string name The signal to find --- @tparam string error_msg Error message for if the signal is not found -- @treturn table The signal table -local function find_signal(obj, name, error_msg) +local function find_signal(obj, name) check(obj) if not obj._signals[name] then - error("Trying to " .. error_msg .. " non-existent signal '" .. name .. "'") - end - return obj._signals[name] -end - ---- Add a signal to an object. All signals must be added before they can be used. --- ---@DOC_text_gears_object_signal_EXAMPLE@ --- @tparam string name The name of the new signal. -function object:add_signal(name) - check(self) - assert(type(name) == "string", "name must be a string, got: " .. type(name)) - if not self._signals[name] then - self._signals[name] = { + assert(type(name) == "string", "name must be a string, got: " .. type(name)) + obj._signals[name] = { strong = {}, weak = setmetatable({}, { __mode = "kv" }) } end + return obj._signals[name] +end + +function object.add_signal() + require("awful.util").deprecate("Use signals without explicitly adding them. This is now done implicitly.") end --- Connect to a signal. -- @tparam string name The name of the signal -- @tparam function func The callback to call when the signal is emitted --- @see add_signal function object:connect_signal(name, func) assert(type(func) == "function", "callback must be a function, got: " .. type(func)) - local sig = find_signal(self, name, "connect to") + local sig = find_signal(self, name) assert(sig.weak[func] == nil, "Trying to connect a strong callback which is already connected weakly") sig.strong[func] = true end @@ -100,7 +91,7 @@ end -- @tparam function func The callback to call when the signal is emitted function object:weak_connect_signal(name, func) assert(type(func) == "function", "callback must be a function, got: " .. type(func)) - local sig = find_signal(self, name, "connect to") + local sig = find_signal(self, name) assert(sig.strong[func] == nil, "Trying to connect a weak callback which is already connected strongly") sig.weak[func] = make_the_gc_obey(func) end @@ -108,9 +99,8 @@ end --- Disonnect to a signal. -- @tparam string name The name of the signal -- @tparam function func The callback that should be disconnected --- @see add_signal function object:disconnect_signal(name, func) - local sig = find_signal(self, name, "disconnect from") + local sig = find_signal(self, name) sig.weak[func] = nil sig.strong[func] = nil end @@ -122,7 +112,7 @@ end -- function receives the object as first argument and then any extra arguments -- that are given to emit_signal() function object:emit_signal(name, ...) - local sig = find_signal(self, name, "emit") + local sig = find_signal(self, name) for func in pairs(sig.strong) do func(self, ...) end @@ -163,8 +153,8 @@ local function set_miss(self, key, value) end end ---- Returns a new object. You can call `:emit_signal()`, `:disconnect_signal()`, --- `:connect_signal()` and `:add_signal()` on the resulting object. +--- Returns a new object. You can call `:emit_signal()`, `:disconnect_signal()` +-- and `:connect_signal()` on the resulting object. -- -- Note that `args.enable_auto_signals` is only supported when -- `args.enable_properties` is true. diff --git a/lib/gears/timer.lua b/lib/gears/timer.lua index 7c320ef2..fbd69bcf 100644 --- a/lib/gears/timer.lua +++ b/lib/gears/timer.lua @@ -97,11 +97,6 @@ local timer_instance_mt = { timer.new = function(args) local ret = object() - ret:add_signal("property::timeout") - ret:add_signal("timeout") - ret:add_signal("start") - ret:add_signal("stop") - ret.data = { timeout = 0 } setmetatable(ret, timer_instance_mt) diff --git a/lib/wibox/drawable.lua b/lib/wibox/drawable.lua index 1f2c038e..75cce527 100644 --- a/lib/wibox/drawable.lua +++ b/lib/wibox/drawable.lua @@ -298,7 +298,6 @@ local function setup_signals(_drawable) local d = _drawable.drawable local function clone_signal(name) - _drawable:add_signal(name) -- When "name" is emitted on wibox.drawin, also emit it on wibox d:connect_signal(name, function(_, ...) _drawable:emit_signal(name, ...) diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index e4f4fdf1..23de6ee2 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -89,7 +89,6 @@ end local function setup_signals(_wibox) local obj local function clone_signal(name) - _wibox:add_signal(name) -- When "name" is emitted on wibox.drawin, also emit it on wibox obj:connect_signal(name, function(_, ...) _wibox:emit_signal(name, ...) @@ -225,8 +224,6 @@ local function new(args) return ret end -capi.drawin.add_signal("property::get_wibox") - --- Redraw a wibox. You should never have to call this explicitely because it is -- automatically called when needed. -- @param wibox diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index 54a04cb9..e498875b 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -556,18 +556,8 @@ function base.make_widget(proxy, widget_name, args) class = args.class, } - -- This signal is used by layouts to find out when they have to update. - ret:add_signal("widget::layout_changed") - ret:add_signal("widget::redraw_needed") - -- Mouse input, oh noes! - ret:add_signal("button::press") - ret:add_signal("button::release") - ret:add_signal("mouse::enter") - ret:add_signal("mouse::leave") - -- Backwards compatibility -- TODO: Remove this - ret:add_signal("widget::updated") ret:connect_signal("widget::updated", function() ret:emit_signal("widget::layout_changed") ret:emit_signal("widget::redraw_needed") @@ -648,7 +638,7 @@ end function base.check_widget(widget) assert(type(widget) == "table", "Type should be table, but is " .. tostring(type(widget))) assert(widget.is_widget, "Argument is not a widget!") - for _, func in pairs({ "add_signal", "connect_signal", "disconnect_signal" }) do + for _, func in pairs({ "connect_signal", "disconnect_signal" }) do assert(type(widget[func]) == "function", func .. " is not a function") end end diff --git a/spec/awful/screen_spec.lua b/spec/awful/screen_spec.lua index 6c36daad..7a9a31ee 100644 --- a/spec/awful/screen_spec.lua +++ b/spec/awful/screen_spec.lua @@ -6,7 +6,6 @@ local fake_screens = {} _G.screen = setmetatable({ - add_signal = function() end, set_index_miss_handler = function() end, set_newindex_miss_handler = function() end, }, { diff --git a/spec/gears/object_spec.lua b/spec/gears/object_spec.lua index e73bc43e..4bb0b7d8 100644 --- a/spec/gears/object_spec.lua +++ b/spec/gears/object_spec.lua @@ -9,31 +9,6 @@ describe("gears.object", function() local obj before_each(function() obj = object() - obj:add_signal("signal") - end) - - it("strong connect non-existent signal", function() - assert.has.errors(function() - obj:connect_signal("foo", function() end) - end) - end) - - it("weak connect non-existent signal", function() - assert.has.errors(function() - obj:weak_connect_signal("foo", function() end) - end) - end) - - it("strong disconnect non-existent signal", function() - assert.has.errors(function() - obj:disconnect_signal("foo", function() end) - end) - end) - - it("emitting non-existent signal", function() - assert.has.errors(function() - obj:emit_signal("foo") - end) end) it("strong connecting and emitting signal", function() @@ -188,7 +163,6 @@ describe("gears.object", function() it("auto emit disabled", function() local got_it = false - obj:add_signal("property::foo") obj:connect_signal("property::foo", function() got_it=true end) obj.foo = 42 @@ -199,7 +173,6 @@ describe("gears.object", function() it("auto emit enabled", function() local got_it = false local obj2 = object{enable_auto_signals=true, enable_properties=true} - obj2:add_signal("property::foo") obj2:connect_signal("property::foo", function() got_it=true end) obj2.foo = 42 @@ -207,13 +180,6 @@ describe("gears.object", function() assert.is_true(got_it) end) - it("auto emit enabled", function() - assert.has.errors(function() - local obj2 = object{enable_auto_signals=true, enable_properties=true} - obj2.foo = "bar" - end) - end) - it("auto emit without dynamic properties", function() assert.has.errors(function() object{enable_auto_signals=true, enable_properties=false} diff --git a/spec/wibox/test_utils.lua b/spec/wibox/test_utils.lua index dd895e74..756f2dc1 100644 --- a/spec/wibox/test_utils.lua +++ b/spec/wibox/test_utils.lua @@ -83,8 +83,6 @@ return { widget_stub = function(width, height) local w = object() w._private = {} - w:add_signal("widget::redraw_needed") - w:add_signal("widget::layout_changed") w.is_widget = true w._private.visible = true w._private.opacity = 1 diff --git a/tests/examples/shims/awesome.lua b/tests/examples/shims/awesome.lua index 41c458a9..7dd586c5 100644 --- a/tests/examples/shims/awesome.lua +++ b/tests/examples/shims/awesome.lua @@ -17,12 +17,6 @@ local function _shim_fake_class() return obj._connect_signal(obj, name, func) end - obj._add_signal = obj.add_signal - - function obj.add_signal(name) - return obj._add_signal(obj, name) - end - function obj.set_index_miss_handler(handler) meta.__index = handler end @@ -50,11 +44,6 @@ awesome.startup = true function awesome.register_xproperty() end -awesome.add_signal("refresh") -awesome.add_signal("wallpaper_changed") -awesome.add_signal("spawn::canceled") -awesome.add_signal("spawn::timeout") - return awesome -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/shims/client.lua b/tests/examples/shims/client.lua index 5fcc6486..9b735e3d 100644 --- a/tests/examples/shims/client.lua +++ b/tests/examples/shims/client.lua @@ -4,20 +4,6 @@ local clients = {} local client, meta = awesome._shim_fake_class() -local function add_signals(c) - c:add_signal("property::width") - c:add_signal("property::height") - c:add_signal("property::x") - c:add_signal("property::y") - c:add_signal("property::screen") - c:add_signal("property::geometry") - c:add_signal("request::geometry") - c:add_signal("request::tag") - c:add_signal("swapped") - c:add_signal("raised") - c:add_signal("property::_label") --Used internally -end - -- Keep an history of the geometry for validation and images local function push_geometry(c) table.insert(c._old_geo, c:geometry()) @@ -46,9 +32,6 @@ function client.gen_fake(args) ret[v] = ret[v] or 1 end - - add_signals(ret) - -- Emulate capi.client.geometry function ret:geometry(new) if new then @@ -142,37 +125,6 @@ function client.get(s) return ret end -client:_add_signal("manage") -client:_add_signal("unmanage") -client:_add_signal("property::urgent") -client:_add_signal("untagged") -client:_add_signal("tagged") -client:_add_signal("property::shape_client_bounding") -client:_add_signal("property::shape_client_clip") -client:_add_signal("property::width") -client:_add_signal("property::height") -client:_add_signal("property::x") -client:_add_signal("property::y") -client:_add_signal("property::geometry") -client:_add_signal("focus") -client:_add_signal("new") -client:_add_signal("property::size_hints_honor") -client:_add_signal("property::struts") -client:_add_signal("property::minimized") -client:_add_signal("property::maximized_horizontal") -client:_add_signal("property::maximized_vertical") -client:_add_signal("property::sticky") -client:_add_signal("property::fullscreen") -client:_add_signal("property::border_width") -client:_add_signal("property::hidden") -client:_add_signal("property::screen") -client:_add_signal("request::tag") -client:_add_signal("request::geometry") -client:_add_signal("request::activate") -client:_add_signal("raised") -client:_add_signal("lowered") -client:_add_signal("list") - return client -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/shims/screen.lua b/tests/examples/shims/screen.lua index ca36a063..98de3e7a 100644 --- a/tests/examples/shims/screen.lua +++ b/tests/examples/shims/screen.lua @@ -7,10 +7,6 @@ screen.count = 1 local function create_screen(args) local s = gears_obj() - s:add_signal("property::workarea") - s:add_signal("property::index") - s:add_signal("padding") - -- Copy the geo in case the args are mutated local geo = { x = args.x , @@ -99,10 +95,6 @@ end screen._add_screen {width=320, height=240} -screen.add_signal("property::workarea") -screen.add_signal("added") -screen.add_signal("removed") - return screen -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/shims/tag.lua b/tests/examples/shims/tag.lua index e8fd463e..ff2ab4a7 100644 --- a/tests/examples/shims/tag.lua +++ b/tests/examples/shims/tag.lua @@ -5,20 +5,6 @@ local tag, meta = awesome._shim_fake_class() local function new_tag(_, args) local ret = gears_obj() - ret:add_signal("property::layout") - ret:add_signal("property::name") - ret:add_signal("property::geometry") - ret:add_signal("property::screen") - ret:add_signal("property::master_width_factor") - ret:add_signal("property::mwfact") - ret:add_signal("property::ncol") - ret:add_signal("property::column_count") - ret:add_signal("property::master_count") - ret:add_signal("property::nmaster") - ret:add_signal("property::index") - ret:add_signal("property::useless_gap") - ret:add_signal("property::_wa_tracker") - ret.name = args.name or "test" ret.activated = true ret.selected = true @@ -42,12 +28,6 @@ local function new_tag(_, args) }) end -tag:_add_signal("request::select") -tag:_add_signal("property::selected") -tag:_add_signal("property::activated") -tag:_add_signal("tagged") -tag:_add_signal("untagged") - return setmetatable(tag, { __call = new_tag, }) diff --git a/tests/examples/text/gears/object/properties.lua b/tests/examples/text/gears/object/properties.lua index 032ff9cc..5d69e116 100644 --- a/tests/examples/text/gears/object/properties.lua +++ b/tests/examples/text/gears/object/properties.lua @@ -31,8 +31,6 @@ local o = gears.object { enable_auto_signals = true, } -o:add_signal "property::foo" - print(o.foo) o.foo = 42 @@ -42,7 +40,6 @@ print(o.foo) o:method(1, 2, 3) -- Random properties can also be added, the signal will be emited automatically. -o:add_signal "property::something" o:connect_signal("property::something", function(obj, value) print("In the connection handler!", obj, value) diff --git a/tests/examples/text/gears/object/signal.lua b/tests/examples/text/gears/object/signal.lua index 50f9c198..090aa214 100644 --- a/tests/examples/text/gears/object/signal.lua +++ b/tests/examples/text/gears/object/signal.lua @@ -2,9 +2,6 @@ local gears = require("gears") --DOC_HIDE local o = gears.object{} - -- Add a new signals to the object. This is used to catch typos -o:add_signal "my_signal" - -- Function can be attached to signals local function slot(obj, a, b, c) print("In slot", obj, a, b, c) diff --git a/tests/test-awful-client.lua b/tests/test-awful-client.lua index ea72f031..ca36318c 100644 --- a/tests/test-awful-client.lua +++ b/tests/test-awful-client.lua @@ -18,7 +18,6 @@ client.focus = client.get()[1] local c = client.focus -- local c2 = client.get()[2] -client.add_signal("property::foo") c.foo = "bar" -- Check if the property system works