strut: move table conversion to luaA_tostrut()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
c57bef8332
commit
b249c67af9
26
client.c
26
client.c
|
@ -1582,35 +1582,11 @@ luaA_client_struts(lua_State *L)
|
|||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
strut_t struts;
|
||||
area_t screen_area = display_area_get(c->phys_screen);
|
||||
|
||||
struts.left = luaA_getopt_number(L, 2, "left", c->strut.left);
|
||||
struts.right = luaA_getopt_number(L, 2, "right", c->strut.right);
|
||||
struts.top = luaA_getopt_number(L, 2, "top", c->strut.top);
|
||||
struts.bottom = luaA_getopt_number(L, 2, "bottom", c->strut.bottom);
|
||||
|
||||
if(struts.left != c->strut.left || struts.right != c->strut.right ||
|
||||
struts.top != c->strut.top || struts.bottom != c->strut.bottom) {
|
||||
/* Struts are not so well defined in the context of xinerama. So we just
|
||||
* give the entire root window and let the window manager decide. */
|
||||
struts.left_start_y = 0;
|
||||
struts.left_end_y = !struts.left ? 0 : screen_area.height;
|
||||
struts.right_start_y = 0;
|
||||
struts.right_end_y = !struts.right ? 0 : screen_area.height;
|
||||
struts.top_start_x = 0;
|
||||
struts.top_end_x = !struts.top ? 0 : screen_area.width;
|
||||
struts.bottom_start_x = 0;
|
||||
struts.bottom_end_x = !struts.bottom ? 0 : screen_area.width;
|
||||
|
||||
c->strut = struts;
|
||||
|
||||
luaA_tostrut(L, 2, &c->strut);
|
||||
ewmh_update_strut(c->window, &c->strut);
|
||||
|
||||
hook_property(c, "struts");
|
||||
luaA_object_emit_signal(L, 1, "property::struts", 0);
|
||||
}
|
||||
}
|
||||
|
||||
return luaA_pushstrut(L, c->strut);
|
||||
}
|
||||
|
|
16
strut.c
16
strut.c
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "strut.h"
|
||||
#include "luaa.h"
|
||||
|
||||
/** Push a strut type to a table on stack.
|
||||
* \param L The Lua VM state.
|
||||
|
@ -41,4 +42,19 @@ luaA_pushstrut(lua_State *L, strut_t strut)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/** Convert a table to a strut_t structure.
|
||||
* \param L The Lua VM state.
|
||||
* \param idx The index of the table on the stack.
|
||||
* \param struts The strut to fill. Current values will be used as default.
|
||||
*/
|
||||
void
|
||||
luaA_tostrut(lua_State *L, int idx, strut_t *strut)
|
||||
{
|
||||
luaA_checktable(L, idx);
|
||||
strut->left = luaA_getopt_number(L, idx, "left", strut->left);
|
||||
strut->right = luaA_getopt_number(L, idx, "right", strut->right);
|
||||
strut->top = luaA_getopt_number(L, idx, "top", strut->top);
|
||||
strut->bottom = luaA_getopt_number(L, idx, "bottom", strut->bottom);
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue