From 5c9cc7857df09fd157fad73396cb6e817ee5fb14 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Wed, 13 Aug 2008 01:37:12 +0200 Subject: [PATCH] xutil: make xutil_lock_mask_get() asynchronous --- awesome.c | 12 +++++++++--- common/xutil.c | 20 ++++++++++++++------ common/xutil.h | 5 +++-- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/awesome.c b/awesome.c index d1f4042d..d37f2dbf 100644 --- a/awesome.c +++ b/awesome.c @@ -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(); diff --git a/common/xutil.c b/common/xutil.c index 913422ff..244f1ec1 100644 --- a/common/xutil.c +++ b/common/xutil.c @@ -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++) diff --git a/common/xutil.h b/common/xutil.h index e9553df1..da6a98f8 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -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 *,