client: Add c.blob property
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
91cc8519b5
commit
a54636751b
|
@ -1,3 +1,4 @@
|
|||
AWESOME_NAQUADAH_BLOB
|
||||
_NET_SUPPORTED
|
||||
_NET_STARTUP_ID
|
||||
_NET_CLIENT_LIST
|
||||
|
|
|
@ -45,6 +45,7 @@ module("client")
|
|||
-- @field shape_clip The client's clip shape as set by awesome as a (native) cairo surface.
|
||||
-- @field shape_client_bounding The client's bounding shape as set by the program as a (native) cairo surface.
|
||||
-- @field shape_client_clip The client's clip shape as set by the program as a (native) cairo surface.
|
||||
-- @field blob A string containing data that will still be available after awesome restarts.
|
||||
-- @class table
|
||||
-- @name client
|
||||
|
||||
|
|
|
@ -431,6 +431,10 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, bool startup)
|
|||
return;
|
||||
}
|
||||
|
||||
xcb_get_property_cookie_t blob_q;
|
||||
blob_q = xcb_get_property(globalconf.connection, false, w, AWESOME_NAQUADAH_BLOB,
|
||||
XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
|
||||
|
||||
/* If this is a new client that just has been launched, then request its
|
||||
* startup id. */
|
||||
xcb_get_property_cookie_t startup_id_q = { 0 };
|
||||
|
@ -496,6 +500,19 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, bool startup)
|
|||
xcb_ungrab_server(globalconf.connection);
|
||||
}
|
||||
|
||||
{
|
||||
/* Request our response */
|
||||
xcb_get_property_reply_t *reply =
|
||||
xcb_get_property_reply(globalconf.connection, blob_q, NULL);
|
||||
|
||||
if (reply)
|
||||
{
|
||||
c->blob.length = xcb_get_property_value_length(reply);
|
||||
c->blob.data = p_dup((char *) xcb_get_property_value(reply), c->blob.length);
|
||||
}
|
||||
p_delete(&reply);
|
||||
}
|
||||
|
||||
/* Do this now so that we don't get any events for the above
|
||||
* (Else, reparent could cause an UnmapNotify) */
|
||||
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
|
||||
|
@ -1767,6 +1784,13 @@ luaA_client_get_icon_name(lua_State *L, client_t *c)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_client_get_blob(lua_State *L, client_t *c)
|
||||
{
|
||||
lua_pushlstring(L, NONULL(c->blob.data), c->blob.length);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, class, lua_pushstring)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, instance, lua_pushstring)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
|
||||
|
@ -2076,6 +2100,23 @@ luaA_client_set_shape_clip(lua_State *L, client_t *c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Set the client's blob.
|
||||
* \param L The Lua VM state.
|
||||
* \param client The client object.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_client_set_blob(lua_State *L, client_t *c)
|
||||
{
|
||||
const char *blob = luaL_checklstring(L, -1, &c->blob.length);
|
||||
|
||||
p_delete(&c->blob.data);
|
||||
c->blob.data = p_dup(blob, c->blob.length);
|
||||
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->window,
|
||||
AWESOME_NAQUADAH_BLOB, AWESOME_NAQUADAH_BLOB, 8, c->blob.length, blob);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Get or set keys bindings for a client.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of element pushed on stack.
|
||||
|
@ -2310,6 +2351,10 @@ client_class_setup(lua_State *L)
|
|||
NULL,
|
||||
(lua_class_propfunc_t) luaA_client_get_client_shape_clip,
|
||||
NULL);
|
||||
luaA_class_add_property(&client_class, "blob",
|
||||
(lua_class_propfunc_t) luaA_client_set_blob,
|
||||
(lua_class_propfunc_t) luaA_client_get_blob,
|
||||
(lua_class_propfunc_t) luaA_client_set_blob);
|
||||
|
||||
signal_add(&client_class.signals, "focus");
|
||||
signal_add(&client_class.signals, "list");
|
||||
|
|
|
@ -124,6 +124,11 @@ struct client_t
|
|||
/** The drawable for this bar. */
|
||||
drawable_t *drawable;
|
||||
} titlebar[CLIENT_TITLEBAR_COUNT];
|
||||
/** The blob! */
|
||||
struct {
|
||||
char *data;
|
||||
size_t length;
|
||||
} blob;
|
||||
};
|
||||
|
||||
ARRAY_FUNCS(client_t *, client, DO_NOTHING)
|
||||
|
|
Loading…
Reference in New Issue