xutil: remove useless conversion function
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
308ef7de5d
commit
cbcbb68f7e
11
button.c
11
button.c
|
@ -59,7 +59,8 @@ luaA_button_gc(lua_State *L)
|
||||||
static int
|
static int
|
||||||
luaA_button_new(lua_State *L)
|
luaA_button_new(lua_State *L)
|
||||||
{
|
{
|
||||||
int i, len;
|
int len;
|
||||||
|
xcb_button_t xbutton;
|
||||||
button_t *button, *orig;
|
button_t *button, *orig;
|
||||||
luaA_ref press = LUA_REFNIL, release = LUA_REFNIL;
|
luaA_ref press = LUA_REFNIL, release = LUA_REFNIL;
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ luaA_button_new(lua_State *L)
|
||||||
|
|
||||||
luaA_checktable(L, 2);
|
luaA_checktable(L, 2);
|
||||||
/* arg 3 is mouse button */
|
/* arg 3 is mouse button */
|
||||||
i = luaL_checknumber(L, 3);
|
xbutton = luaL_checknumber(L, 3);
|
||||||
|
|
||||||
/* arg 4 and 5 are callback functions, check they are functions... */
|
/* arg 4 and 5 are callback functions, check they are functions... */
|
||||||
if(!lua_isnil(L, 4))
|
if(!lua_isnil(L, 4))
|
||||||
|
@ -107,10 +108,10 @@ luaA_button_new(lua_State *L)
|
||||||
button = button_new(L);
|
button = button_new(L);
|
||||||
button->press = press;
|
button->press = press;
|
||||||
button->release = release;
|
button->release = release;
|
||||||
button->button = xutil_button_fromint(i);
|
button->button = xbutton;
|
||||||
|
|
||||||
len = lua_objlen(L, 2);
|
len = lua_objlen(L, 2);
|
||||||
for(i = 1; i <= len; i++)
|
for(int i = 1; i <= len; i++)
|
||||||
{
|
{
|
||||||
size_t blen;
|
size_t blen;
|
||||||
const char *buf;
|
const char *buf;
|
||||||
|
@ -222,7 +223,7 @@ luaA_button_newindex(lua_State *L)
|
||||||
luaA_registerfct(L, 3, &button->release);
|
luaA_registerfct(L, 3, &button->release);
|
||||||
break;
|
break;
|
||||||
case A_TK_BUTTON:
|
case A_TK_BUTTON:
|
||||||
button->button = xutil_button_fromint(luaL_checknumber(L, 3));
|
button->button = luaL_checknumber(L, 3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
2
button.h
2
button.h
|
@ -32,7 +32,7 @@ struct button_t
|
||||||
/** Key modifiers */
|
/** Key modifiers */
|
||||||
unsigned long mod;
|
unsigned long mod;
|
||||||
/** Mouse button number */
|
/** Mouse button number */
|
||||||
unsigned int button;
|
xcb_button_t button;
|
||||||
/** Lua function to execute on press. */
|
/** Lua function to execute on press. */
|
||||||
luaA_ref press;
|
luaA_ref press;
|
||||||
/** Lua function to execute on release. */
|
/** Lua function to execute on release. */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* common/xutil.c - X-related useful functions
|
* common/xutil.c - X-related useful functions
|
||||||
*
|
*
|
||||||
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -138,54 +138,6 @@ xutil_key_mask_tostr(uint16_t mask, const char **name, size_t *len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Permit to use mouse with many more buttons */
|
|
||||||
#ifndef XCB_BUTTON_INDEX_6
|
|
||||||
#define XCB_BUTTON_INDEX_6 6
|
|
||||||
#endif
|
|
||||||
#ifndef XCB_BUTTON_INDEX_7
|
|
||||||
#define XCB_BUTTON_INDEX_7 7
|
|
||||||
#endif
|
|
||||||
#ifndef XCB_BUTTON_INDEX_8
|
|
||||||
#define XCB_BUTTON_INDEX_8 8
|
|
||||||
#endif
|
|
||||||
#ifndef XCB_BUTTON_INDEX_9
|
|
||||||
#define XCB_BUTTON_INDEX_9 9
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Link a name to a mouse button symbol */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
unsigned int button;
|
|
||||||
} mouse_button_t;
|
|
||||||
|
|
||||||
/** Lookup for a mouse button from its index.
|
|
||||||
* \param button Mouse button index.
|
|
||||||
* \return Mouse button or 0 if not found.
|
|
||||||
*/
|
|
||||||
uint8_t
|
|
||||||
xutil_button_fromint(int button)
|
|
||||||
{
|
|
||||||
/** List of button name and corresponding X11 mask codes */
|
|
||||||
static const mouse_button_t mouse_button_list[] =
|
|
||||||
{
|
|
||||||
{ 1, XCB_BUTTON_INDEX_1 },
|
|
||||||
{ 2, XCB_BUTTON_INDEX_2 },
|
|
||||||
{ 3, XCB_BUTTON_INDEX_3 },
|
|
||||||
{ 4, XCB_BUTTON_INDEX_4 },
|
|
||||||
{ 5, XCB_BUTTON_INDEX_5 },
|
|
||||||
{ 6, XCB_BUTTON_INDEX_6 },
|
|
||||||
{ 7, XCB_BUTTON_INDEX_7 },
|
|
||||||
{ 8, XCB_BUTTON_INDEX_8 },
|
|
||||||
{ 9, XCB_BUTTON_INDEX_9 }
|
|
||||||
};
|
|
||||||
|
|
||||||
if(button >= 1 && button <= countof(mouse_button_list))
|
|
||||||
return mouse_button_list[button - 1].button;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Convert a root window a physical screen ID.
|
/** Convert a root window a physical screen ID.
|
||||||
* \param connection The connection to the X server.
|
* \param connection The connection to the X server.
|
||||||
* \param root Root window.
|
* \param root Root window.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* common/xutil.h - X-related useful functions header
|
* common/xutil.h - X-related useful functions header
|
||||||
*
|
*
|
||||||
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -37,7 +37,6 @@ void xutil_error_handler_catch_all_set(xcb_event_handlers_t *,
|
||||||
|
|
||||||
uint16_t xutil_key_mask_fromstr(const char *, size_t);
|
uint16_t xutil_key_mask_fromstr(const char *, size_t);
|
||||||
void xutil_key_mask_tostr(uint16_t, const char **, size_t *);
|
void xutil_key_mask_tostr(uint16_t, const char **, size_t *);
|
||||||
uint8_t xutil_button_fromint(int);
|
|
||||||
|
|
||||||
/* Get the informations about the screen.
|
/* Get the informations about the screen.
|
||||||
* \param c X connection.
|
* \param c X connection.
|
||||||
|
|
Loading…
Reference in New Issue