diff --git a/luaa.c b/luaa.c index 025eaf3a9..c287d1a2e 100644 --- a/luaa.c +++ b/luaa.c @@ -1,7 +1,7 @@ /* * lua.c - Lua configuration management * - * Copyright © 2008 Julien Danjou + * Copyright © 2008-2009 Julien Danjou * * 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 @@ -48,6 +48,7 @@ #include "screen.h" #include "event.h" #include "mouse.h" +#include "selection.h" #include "common/socket.h" #include "common/buffer.h" @@ -76,8 +77,6 @@ extern const struct luaL_reg awesome_wibox_meta[]; extern const struct luaL_reg awesome_key_methods[]; extern const struct luaL_reg awesome_key_meta[]; extern const struct luaL_reg awesome_keybinding_methods[]; -extern const struct luaL_reg awesome_selection_methods[]; -extern const struct luaL_reg awesome_selection_meta[]; static struct sockaddr_un *addr; static ev_io csio = { .fd = -1 }; @@ -388,6 +387,10 @@ luaA_fixups(lua_State *L) lua_pushliteral(L, "type"); lua_pushcfunction(L, luaAe_type); lua_settable(L, LUA_GLOBALSINDEX); + /* set selection */ + lua_pushliteral(L, "selection"); + lua_pushcfunction(L, luaA_selection_get); + lua_settable(L, LUA_GLOBALSINDEX); } /** __next function for wtable objects. @@ -894,9 +897,6 @@ luaA_init(void) luaA_openlib(L, "key", awesome_key_methods, awesome_key_meta); luaA_openlib(L, "keybinding", awesome_keybinding_methods, awesome_key_meta); - /* Export selection */ - luaA_openlib(L, "selection", awesome_selection_methods, awesome_selection_meta); - lua_pushliteral(L, "AWESOME_VERSION"); lua_pushstring(L, AWESOME_VERSION); lua_settable(L, LUA_GLOBALSINDEX); diff --git a/selection.c b/selection.c index 2d7ff7634..f1e4f7485 100644 --- a/selection.c +++ b/selection.c @@ -22,6 +22,7 @@ #include +#include "selection.h" #include "structs.h" #include "event.h" #include "common/atoms.h" @@ -36,7 +37,7 @@ static xcb_window_t selection_window = XCB_NONE; * \luastack * \lreturn A string with the current X selection buffer. */ -static int +int luaA_selection_get(lua_State *L) { if(selection_window == XCB_NONE) @@ -116,14 +117,3 @@ luaA_selection_get(lua_State *L) p_delete(&event); return 0; } - -const struct luaL_reg awesome_selection_methods[] = -{ - { "__call", luaA_selection_get }, - { NULL, NULL } -}; - -const struct luaL_reg awesome_selection_meta[] = -{ - { NULL, NULL } -}; diff --git a/selection.h b/selection.h new file mode 100644 index 000000000..2ef686afa --- /dev/null +++ b/selection.h @@ -0,0 +1,30 @@ +/* + * selection.h - Selection handling header + * + * Copyright © 2009 Julien Danjou + * + * 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. + * + */ + +#ifndef AWESOME_SELECTION_H +#define AWESOME_SELECTION_H + +#include + +int luaA_selection_get(lua_State *); + +#endif +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80