Require "integer" instead of "number" in more places
E.g. trying to press mouse button 1.5 via root.fake_input() doesn't make sense. Previously the code silently truncated the number to an integer. Now it complains about this instead. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
051d0de85f
commit
d09ece6b5a
|
@ -84,7 +84,7 @@ luaA_object_incref(lua_State *L, int tud, int oud)
|
|||
/* Get the number of references */
|
||||
lua_rawget(L, -2);
|
||||
/* Get the number of references and increment it */
|
||||
int count = lua_tonumber(L, -1) + 1;
|
||||
int count = lua_tointeger(L, -1) + 1;
|
||||
lua_pop(L, 1);
|
||||
/* Push the pointer (key) */
|
||||
lua_pushlightuserdata(L, pointer);
|
||||
|
@ -121,8 +121,8 @@ luaA_object_decref(lua_State *L, int tud, const void *pointer)
|
|||
/* Get the number of references */
|
||||
lua_rawget(L, -2);
|
||||
/* Get the number of references and decrement it */
|
||||
int count = lua_tonumber(L, -1) - 1;
|
||||
/* Did we find the item in our table? (tonumber(nil)-1) is -1 */
|
||||
int count = lua_tointeger(L, -1) - 1;
|
||||
/* Did we find the item in our table? (tointeger(nil)-1) is -1 */
|
||||
if (count < 0)
|
||||
{
|
||||
buffer_t buf;
|
||||
|
|
|
@ -116,7 +116,7 @@ luaA_button_set_modifiers(lua_State *L, button_t *b)
|
|||
static int
|
||||
luaA_button_set_button(lua_State *L, button_t *b)
|
||||
{
|
||||
b->button = luaL_checknumber(L, -1);
|
||||
b->button = luaL_checkinteger(L, -1);
|
||||
luaA_object_emit_signal(L, -3, "property::button", 0);
|
||||
return 0;
|
||||
}
|
||||
|
|
12
root.c
12
root.c
|
@ -171,7 +171,7 @@ luaA_root_fake_input(lua_State *L)
|
|||
if(lua_type(L, 2) == LUA_TSTRING) {
|
||||
detail = _string_to_key_code(lua_tostring(L, 2)); /* keysym */
|
||||
} else {
|
||||
detail = luaL_checknumber(L, 2); /* keycode */
|
||||
detail = luaL_checkinteger(L, 2); /* keycode */
|
||||
}
|
||||
}
|
||||
else if(A_STREQ(stype, "key_release"))
|
||||
|
@ -180,25 +180,25 @@ luaA_root_fake_input(lua_State *L)
|
|||
if(lua_type(L, 2) == LUA_TSTRING) {
|
||||
detail = _string_to_key_code(lua_tostring(L, 2)); /* keysym */
|
||||
} else {
|
||||
detail = luaL_checknumber(L, 2); /* keycode */
|
||||
detail = luaL_checkinteger(L, 2); /* keycode */
|
||||
}
|
||||
}
|
||||
else if(A_STREQ(stype, "button_press"))
|
||||
{
|
||||
type = XCB_BUTTON_PRESS;
|
||||
detail = luaL_checknumber(L, 2); /* button number */
|
||||
detail = luaL_checkinteger(L, 2); /* button number */
|
||||
}
|
||||
else if(A_STREQ(stype, "button_release"))
|
||||
{
|
||||
type = XCB_BUTTON_RELEASE;
|
||||
detail = luaL_checknumber(L, 2); /* button number */
|
||||
detail = luaL_checkinteger(L, 2); /* button number */
|
||||
}
|
||||
else if(A_STREQ(stype, "motion_notify"))
|
||||
{
|
||||
type = XCB_MOTION_NOTIFY;
|
||||
detail = luaA_checkboolean(L, 2); /* relative to the current position or not */
|
||||
x = luaL_checknumber(L, 3);
|
||||
y = luaL_checknumber(L, 4);
|
||||
x = luaL_checkinteger(L, 3);
|
||||
y = luaL_checkinteger(L, 4);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
|
8
strut.c
8
strut.c
|
@ -51,10 +51,10 @@ 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);
|
||||
strut->left = luaA_getopt_integer(L, idx, "left", strut->left);
|
||||
strut->right = luaA_getopt_integer(L, idx, "right", strut->right);
|
||||
strut->top = luaA_getopt_integer(L, idx, "top", strut->top);
|
||||
strut->bottom = luaA_getopt_integer(L, idx, "bottom", strut->bottom);
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue