xutil: make xutil_lock_mask_get() asynchronous

This commit is contained in:
Arnaud Fontaine 2008-08-13 01:37:12 +02:00 committed by Julien Danjou
parent 13edc48587
commit 5c9cc7857d
3 changed files with 26 additions and 11 deletions

View file

@ -279,6 +279,7 @@ main(int argc, char **argv)
const char *confpath = NULL;
int xfd, i, screen_nbr, opt, colors_nbr;
xcolor_init_request_t colors_reqs[2];
xcb_get_modifier_mapping_cookie_t xmapping_cookie;
ssize_t cmdlen = 1;
client_t *c;
static struct option long_options[] =
@ -389,9 +390,9 @@ main(int argc, char **argv)
/* Allocate the key symbols */
globalconf.keysyms = xcb_key_symbols_alloc(globalconf.connection);
/* Get the NumLock, ShiftLock and CapsLock masks */
xutil_lock_mask_get(globalconf.connection, globalconf.keysyms, &globalconf.numlockmask,
&globalconf.shiftlockmask, &globalconf.capslockmask);
/* Send the request to get the NumLock, ShiftLock and CapsLock
masks */
xmapping_cookie = xcb_get_modifier_mapping_unchecked(globalconf.connection);
/* init atom cache */
atoms_init(globalconf.connection);
@ -431,6 +432,11 @@ main(int argc, char **argv)
for(colors_nbr = 0; colors_nbr < 2; colors_nbr++)
xcolor_init_reply(globalconf.connection, colors_reqs[colors_nbr]);
/* Process the reply of previously sent mapping request */
xutil_lock_mask_get(globalconf.connection, xmapping_cookie,
globalconf.keysyms, &globalconf.numlockmask,
&globalconf.shiftlockmask, &globalconf.capslockmask);
/* init lua */
luaA_init();

View file

@ -76,9 +76,20 @@ xutil_text_prop_get(xcb_connection_t *conn, xcb_window_t w, xcb_atom_t atom,
return true;
}
/** Get the lock masks (shiftlock, numlock, capslock).
* \param connection The X connection.
* \param cookie The cookie of the request.
* \param keysyms Key symbols.
* \param numlockmask Numlock mask.
* \param shiftlockmask Shiftlock mask.
* \param capslockmask Capslock mask.
*/
void
xutil_lock_mask_get(xcb_connection_t *conn, xcb_key_symbols_t *keysyms,
unsigned int *numlockmask, unsigned int *shiftlockmask,
xutil_lock_mask_get(xcb_connection_t *connection,
xcb_get_modifier_mapping_cookie_t cookie,
xcb_key_symbols_t *keysyms,
unsigned int *numlockmask,
unsigned int *shiftlockmask,
unsigned int *capslockmask)
{
xcb_get_modifier_mapping_reply_t *modmap_r;
@ -86,10 +97,7 @@ xutil_lock_mask_get(xcb_connection_t *conn, xcb_key_symbols_t *keysyms,
unsigned int mask;
int i, j;
modmap_r = xcb_get_modifier_mapping_reply(conn,
xcb_get_modifier_mapping_unchecked(conn),
NULL);
modmap_r = xcb_get_modifier_mapping_reply(connection, cookie, NULL);
modmap = xcb_get_modifier_mapping_keycodes(modmap_r);
for(i = 0; i < 8; i++)

View file

@ -110,8 +110,9 @@ bool xutil_class_hint_get(xcb_connection_t *, xcb_window_t, xutil_class_hint_t *
bool xutil_text_prop_get(xcb_connection_t *, xcb_window_t, xcb_atom_t, char **, ssize_t *);
void xutil_lock_mask_get(xcb_connection_t *, xcb_key_symbols_t *,
unsigned int *, unsigned int *, unsigned int *);
void xutil_lock_mask_get(xcb_connection_t *, xcb_get_modifier_mapping_cookie_t,
xcb_key_symbols_t *, unsigned int *, unsigned int *,
unsigned int *);
/** Set the same handler for all errors */
void xutil_error_handler_catch_all_set(xcb_event_handlers_t *,