Add awesome.sync()

This function should only be necessary for the test suite. It makes sure
that the X11 server received and handled all previous requests that
awesome sent. This will be needed, for example, in tests that use
root.fake_input().

After a call to awesome.sync(), we are sure that "faking input" has been
done and the next main loop iteration will handle the input event.
Without the sync, it could happen that the X11 server did not yet fake
the input in the next iteration.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-01-01 14:18:59 +01:00
parent 0f755c8f12
commit 54dd973e3f
1 changed files with 13 additions and 0 deletions

13
luaa.c
View File

@ -54,6 +54,7 @@
#include <basedir_fs.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_aux.h>
#include <unistd.h> /* for gethostname() */
@ -214,6 +215,17 @@ luaA_kill(lua_State *L)
return 1;
}
/** Synchronize with the X11 server. This is needed in the test suite to avoid
* some race conditions. You should never need to use this function.
* @function sync
*/
static int
luaA_sync(lua_State *L)
{
xcb_aux_sync(globalconf.connection);
return 0;
}
/** Load an image from a given path.
*
* @param name The file name.
@ -647,6 +659,7 @@ luaA_init(xdgHandle* xdg, string_array_t *searchpath)
{ "xkb_get_group_names", luaA_xkb_get_group_names},
{ "xrdb_get_value", luaA_xrdb_get_value},
{ "kill", luaA_kill},
{ "sync", luaA_sync},
{ NULL, NULL }
};