Add awesome.composite_manager_running

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2014-02-23 12:14:50 +01:00
parent 019f55a1da
commit 360e1a5f92
2 changed files with 46 additions and 0 deletions

45
luaa.c
View File

@ -27,6 +27,8 @@
#include <basedir_fs.h> #include <basedir_fs.h>
#include <xcb/xcb_atom.h>
#include "awesome.h" #include "awesome.h"
#include "config.h" #include "config.h"
#include "objects/timer.h" #include "objects/timer.h"
@ -60,6 +62,43 @@ extern const struct luaL_Reg awesome_screen_meta[];
/** Path to config file */ /** Path to config file */
static char *conffile; static char *conffile;
/** Check whether a composite manager is running.
* \return True if such a manager is running.
*/
static bool
composite_manager_running(void)
{
xcb_intern_atom_reply_t *atom_r;
xcb_get_selection_owner_reply_t *selection_r;
char *atom_name;
bool result;
if(!(atom_name = xcb_atom_name_by_screen("_NET_WM_CM", globalconf.default_screen)))
{
warn("error getting composite manager atom");
return false;
}
atom_r = xcb_intern_atom_reply(globalconf.connection,
xcb_intern_atom_unchecked(globalconf.connection, false,
a_strlen(atom_name), atom_name),
NULL);
p_delete(&atom_name);
if(!atom_r)
return false;
selection_r = xcb_get_selection_owner_reply(globalconf.connection,
xcb_get_selection_owner_unchecked(globalconf.connection,
atom_r->atom),
NULL);
p_delete(&atom_r);
result = selection_r != NULL && selection_r->owner != XCB_NONE;
p_delete(&selection_r);
return result;
}
/** Quit awesome. /** Quit awesome.
* \param L The Lua VM state. * \param L The Lua VM state.
* \return The number of elements pushed on stack. * \return The number of elements pushed on stack.
@ -423,6 +462,12 @@ luaA_awesome_index(lua_State *L)
return 1; return 1;
} }
if(A_STREQ(buf, "composite_manager_running"))
{
lua_pushboolean(L, composite_manager_running());
return 1;
}
return 0; return 0;
} }

View File

@ -11,6 +11,7 @@ module("awesome")
-- @field version The version of awesome. -- @field version The version of awesome.
-- @field release The release name of awesome. -- @field release The release name of awesome.
-- @field conffile The configuration file which has been loaded. -- @field conffile The configuration file which has been loaded.
-- @field composite_manager_running True if a composite manager is running.
-- @class table -- @class table
-- @name awesome -- @name awesome