mouse: Stop using a_tokenize()

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-09-02 19:09:34 +02:00
parent f2e9767434
commit 8e0cdc86fd
1 changed files with 5 additions and 15 deletions

20
mouse.c
View File

@ -25,7 +25,6 @@
#include "globalconf.h" #include "globalconf.h"
#include "objects/wibox.h" #include "objects/wibox.h"
#include "luaa.h" #include "luaa.h"
#include "common/tokenize.h"
#include "common/xutil.h" #include "common/xutil.h"
/** Get the pointer position. /** Get the pointer position.
@ -101,24 +100,20 @@ mouse_warp_pointer(xcb_window_t window, int x, int y)
static int static int
luaA_mouse_index(lua_State *L) luaA_mouse_index(lua_State *L)
{ {
size_t len; const char *attr = luaL_checkstring(L, 2);
const char *attr = luaL_checklstring(L, 2, &len);
int16_t mouse_x, mouse_y; int16_t mouse_x, mouse_y;
screen_t *screen; screen_t *screen;
switch(a_tokenize(attr, len)) if(a_strcmp(attr, "screen") == 0)
{ {
case A_TK_SCREEN:
if(!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, NULL)) if(!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, NULL))
return 0; return 0;
screen = screen_getbycoord(mouse_x, mouse_y); screen = screen_getbycoord(mouse_x, mouse_y);
lua_pushnumber(L, screen_array_indexof(&globalconf.screens, screen) + 1); lua_pushnumber(L, screen_array_indexof(&globalconf.screens, screen) + 1);
break; } else
default:
return 0; return 0;
}
return 1; return 1;
} }
@ -130,14 +125,12 @@ luaA_mouse_index(lua_State *L)
static int static int
luaA_mouse_newindex(lua_State *L) luaA_mouse_newindex(lua_State *L)
{ {
size_t len; const char *attr = luaL_checkstring(L, 2);
const char *attr = luaL_checklstring(L, 2, &len);
int x, y = 0; int x, y = 0;
int screen; int screen;
switch(a_tokenize(attr, len)) if(a_strcmp(attr, "screen") == 0)
{ {
case A_TK_SCREEN:
screen = luaL_checknumber(L, 3) - 1; screen = luaL_checknumber(L, 3) - 1;
luaA_checkscreen(screen); luaA_checkscreen(screen);
@ -145,9 +138,6 @@ luaA_mouse_newindex(lua_State *L)
y = globalconf.screens.tab[screen].geometry.y; y = globalconf.screens.tab[screen].geometry.y;
mouse_warp_pointer(globalconf.screen->root, x, y); mouse_warp_pointer(globalconf.screen->root, x, y);
break;
default:
return 0;
} }
return 0; return 0;