window: add buttons support
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
af654a75d2
commit
d3c277b8ab
|
@ -41,7 +41,6 @@
|
|||
static void
|
||||
client_wipe(client_t *c)
|
||||
{
|
||||
button_array_wipe(&c->buttons);
|
||||
key_array_wipe(&c->keys);
|
||||
xcb_get_wm_protocols_reply_wipe(&c->protocols);
|
||||
p_delete(&c->machine);
|
||||
|
@ -1904,30 +1903,6 @@ luaA_client_get_size_hints(lua_State *L, client_t *c)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/** Get or set mouse buttons bindings for a client.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of element pushed on stack.
|
||||
* \luastack
|
||||
* \lvalue A client.
|
||||
* \lparam An array of mouse button bindings objects, or nothing.
|
||||
* \return The array of mouse button bindings objects of this client.
|
||||
*/
|
||||
static int
|
||||
luaA_client_buttons(lua_State *L)
|
||||
{
|
||||
client_t *client = luaA_checkudata(L, 1, &client_class);
|
||||
button_array_t *buttons = &client->buttons;
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
luaA_button_array_set(L, 1, 2, buttons);
|
||||
luaA_object_emit_signal(L, 1, "property::buttons", 0);
|
||||
xwindow_buttons_grab(client->window, &client->buttons);
|
||||
}
|
||||
|
||||
return luaA_button_array_get(L, 1, buttons);
|
||||
}
|
||||
|
||||
/** Get or set keys bindings for a client.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of element pushed on stack.
|
||||
|
@ -2019,7 +1994,6 @@ client_class_setup(lua_State *L)
|
|||
{
|
||||
LUA_OBJECT_META(client)
|
||||
LUA_CLASS_META
|
||||
{ "buttons", luaA_client_buttons },
|
||||
{ "keys", luaA_client_keys },
|
||||
{ "isvisible", luaA_client_isvisible },
|
||||
{ "geometry", luaA_client_geometry },
|
||||
|
|
|
@ -122,8 +122,6 @@ struct client_t
|
|||
xcb_get_wm_protocols_reply_t protocols;
|
||||
/** Client physical screen */
|
||||
int phys_screen;
|
||||
/** Button bindings */
|
||||
button_array_t buttons;
|
||||
/** Key bindings */
|
||||
key_array_t keys;
|
||||
/** Icon */
|
||||
|
|
|
@ -66,7 +66,6 @@ wibox_wipe(wibox_t *wibox)
|
|||
{
|
||||
p_delete(&wibox->cursor);
|
||||
wibox_wipe_resources(wibox);
|
||||
button_array_wipe(&wibox->buttons);
|
||||
widget_node_array_wipe(&wibox->widgets);
|
||||
}
|
||||
|
||||
|
@ -1217,28 +1216,6 @@ luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
|
|||
return luaA_object_push_item(L, 1, wibox->widgets_table);
|
||||
}
|
||||
|
||||
/** Get or set mouse buttons bindings to a wibox.
|
||||
* \param L The Lua VM state.
|
||||
* \luastack
|
||||
* \lvalue A wibox.
|
||||
* \lparam An array of mouse button bindings objects, or nothing.
|
||||
* \return The array of mouse button bindings objects of this wibox.
|
||||
*/
|
||||
static int
|
||||
luaA_wibox_buttons(lua_State *L)
|
||||
{
|
||||
wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
luaA_button_array_set(L, 1, 2, &wibox->buttons);
|
||||
luaA_object_emit_signal(L, 1, "property::buttons", 0);
|
||||
xwindow_buttons_grab(wibox->window, &wibox->buttons);
|
||||
}
|
||||
|
||||
return luaA_button_array_get(L, 1, &wibox->buttons);
|
||||
}
|
||||
|
||||
/** Set the wibox border width.
|
||||
* \param L The Lua VM state.
|
||||
* \param wibox The wibox object.
|
||||
|
@ -1310,7 +1287,6 @@ wibox_class_setup(lua_State *L)
|
|||
{
|
||||
LUA_OBJECT_META(wibox)
|
||||
LUA_CLASS_META
|
||||
{ "buttons", luaA_wibox_buttons },
|
||||
{ "geometry", luaA_wibox_geometry },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
|
|
@ -47,8 +47,6 @@ struct wibox_t
|
|||
char *cursor;
|
||||
/** Background image */
|
||||
image_t *bg_image;
|
||||
/** Button bindings */
|
||||
button_array_t buttons;
|
||||
/** The pixmap copied to the window object. */
|
||||
xcb_pixmap_t pixmap;
|
||||
/** The graphic context. */
|
||||
|
|
|
@ -28,6 +28,31 @@
|
|||
|
||||
LUA_CLASS_FUNCS(window, window_class)
|
||||
|
||||
static void
|
||||
window_wipe(window_t *window)
|
||||
{
|
||||
button_array_wipe(&window->buttons);
|
||||
}
|
||||
|
||||
/** Get or set mouse buttons bindings on a window.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on the stack.
|
||||
*/
|
||||
static int
|
||||
luaA_window_buttons(lua_State *L)
|
||||
{
|
||||
window_t *window = luaA_checkudata(L, 1, &window_class);
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
luaA_button_array_set(L, 1, 2, &window->buttons);
|
||||
luaA_object_emit_signal(L, 1, "property::buttons", 0);
|
||||
xwindow_buttons_grab(window->window, &window->buttons);
|
||||
}
|
||||
|
||||
return luaA_button_array_get(L, 1, &window->buttons);
|
||||
}
|
||||
|
||||
/** Return window struts (reserved space at the edge of the screen).
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
|
@ -115,11 +140,12 @@ window_class_setup(lua_State *L)
|
|||
static const struct luaL_reg window_meta[] =
|
||||
{
|
||||
{ "struts", luaA_window_struts },
|
||||
{ "buttons", luaA_window_buttons },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
luaA_class_setup(L, &window_class, "window", NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, (lua_class_collector_t) window_wipe, NULL,
|
||||
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
||||
window_methods, window_meta);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define AWESOME_OBJECTS_WINDOW_H
|
||||
|
||||
#include "strut.h"
|
||||
#include "objects/button.h"
|
||||
#include "common/luaclass.h"
|
||||
|
||||
#define WINDOW_OBJECT_HEADER \
|
||||
|
@ -34,7 +35,9 @@
|
|||
/** Strut */ \
|
||||
strut_t strut; \
|
||||
/** Client logical screen */ \
|
||||
screen_t *screen;
|
||||
screen_t *screen; \
|
||||
/** Button bindings */ \
|
||||
button_array_t buttons;
|
||||
|
||||
/** Window structure */
|
||||
typedef struct
|
||||
|
|
Loading…
Reference in New Issue