Ungrab the server before parsing the config
This moves the loading of the rc.lua and managing of pre-existing clients to after we ungrab the server during startup. To make sure we have no races with clients which start up parallel to awesome, we do the QueryTree for all the clients that we have to manage before the ungrab, but start managing the clients only after the ungrab. This means that we have already selected our event mask on the root window in scan() and thus received an UnmapNotify event when we reparent windows into a frame window. This has the effect that we immediately unmanage the client again, whoops. To fix this, we grab the server again and remove our event mask on the root window again while we reparent. This should hopefully fix all cases where we deadlock during startup because pulseaudio wants to talk to the X server, but is being ignored because we have the server grabbed while at the same time we are waiting for pulseaudio. Signed-off-by: Uli Schlachter <psychon@znc.in> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
0e44a6282e
commit
092813cd63
44
awesome.c
44
awesome.c
|
@ -53,12 +53,6 @@
|
||||||
|
|
||||||
awesome_t globalconf;
|
awesome_t globalconf;
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
xcb_window_t id;
|
|
||||||
xcb_query_tree_cookie_t tree_cookie;
|
|
||||||
} root_win_t;
|
|
||||||
|
|
||||||
/** Call before exiting.
|
/** Call before exiting.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
@ -96,31 +90,20 @@ awesome_atexit(bool restart)
|
||||||
/** Scan X to find windows to manage.
|
/** Scan X to find windows to manage.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
scan(void)
|
scan(xcb_query_tree_cookie_t tree_c[])
|
||||||
{
|
{
|
||||||
int i, phys_screen, tree_c_len;
|
int i, phys_screen, tree_c_len;
|
||||||
const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
|
const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
|
||||||
root_win_t root_wins[screen_max];
|
|
||||||
xcb_query_tree_reply_t *tree_r;
|
xcb_query_tree_reply_t *tree_r;
|
||||||
xcb_window_t *wins = NULL;
|
xcb_window_t *wins = NULL;
|
||||||
xcb_get_window_attributes_reply_t *attr_r;
|
xcb_get_window_attributes_reply_t *attr_r;
|
||||||
xcb_get_geometry_reply_t *geom_r;
|
xcb_get_geometry_reply_t *geom_r;
|
||||||
long state;
|
long state;
|
||||||
|
|
||||||
for(phys_screen = 0; phys_screen < screen_max; phys_screen++)
|
|
||||||
{
|
|
||||||
/* Get the root window ID associated to this screen */
|
|
||||||
root_wins[phys_screen].id = xutil_screen_get(globalconf.connection, phys_screen)->root;
|
|
||||||
|
|
||||||
/* Get the window tree associated to this screen */
|
|
||||||
root_wins[phys_screen].tree_cookie = xcb_query_tree_unchecked(globalconf.connection,
|
|
||||||
root_wins[phys_screen].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(phys_screen = 0; phys_screen < screen_max; phys_screen++)
|
for(phys_screen = 0; phys_screen < screen_max; phys_screen++)
|
||||||
{
|
{
|
||||||
tree_r = xcb_query_tree_reply(globalconf.connection,
|
tree_r = xcb_query_tree_reply(globalconf.connection,
|
||||||
root_wins[phys_screen].tree_cookie,
|
tree_c[phys_screen],
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if(!tree_r)
|
if(!tree_r)
|
||||||
|
@ -486,10 +469,12 @@ main(int argc, char **argv)
|
||||||
&globalconf.shiftlockmask, &globalconf.capslockmask,
|
&globalconf.shiftlockmask, &globalconf.capslockmask,
|
||||||
&globalconf.modeswitchmask);
|
&globalconf.modeswitchmask);
|
||||||
|
|
||||||
|
/* Get the window tree associated to this screen */
|
||||||
|
const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
|
||||||
|
xcb_query_tree_cookie_t tree_c[screen_max];
|
||||||
|
|
||||||
/* do this only for real screen */
|
/* do this only for real screen */
|
||||||
for(screen_nbr = 0;
|
for(screen_nbr = 0; screen_nbr < screen_max; screen_nbr++)
|
||||||
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
|
|
||||||
screen_nbr++)
|
|
||||||
{
|
{
|
||||||
/* select for events */
|
/* select for events */
|
||||||
const uint32_t change_win_vals[] =
|
const uint32_t change_win_vals[] =
|
||||||
|
@ -503,6 +488,9 @@ main(int argc, char **argv)
|
||||||
| XCB_EVENT_MASK_FOCUS_CHANGE
|
| XCB_EVENT_MASK_FOCUS_CHANGE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tree_c[screen_nbr] = xcb_query_tree_unchecked(globalconf.connection,
|
||||||
|
xutil_screen_get(globalconf.connection, screen_nbr)->root);
|
||||||
|
|
||||||
xcb_change_window_attributes(globalconf.connection,
|
xcb_change_window_attributes(globalconf.connection,
|
||||||
xutil_screen_get(globalconf.connection, screen_nbr)->root,
|
xutil_screen_get(globalconf.connection, screen_nbr)->root,
|
||||||
XCB_CW_EVENT_MASK,
|
XCB_CW_EVENT_MASK,
|
||||||
|
@ -514,19 +502,15 @@ main(int argc, char **argv)
|
||||||
/* init spawn (sn) */
|
/* init spawn (sn) */
|
||||||
spawn_init();
|
spawn_init();
|
||||||
|
|
||||||
|
/* we will receive events, stop grabbing server */
|
||||||
|
xcb_ungrab_server(globalconf.connection);
|
||||||
|
|
||||||
/* Parse and run configuration file */
|
/* Parse and run configuration file */
|
||||||
if (!luaA_parserc(&xdg, confpath, true))
|
if (!luaA_parserc(&xdg, confpath, true))
|
||||||
fatal("couldn't find any rc file");
|
fatal("couldn't find any rc file");
|
||||||
|
|
||||||
p_delete(&confpath);
|
scan(tree_c);
|
||||||
|
|
||||||
xdgWipeHandle(&xdg);
|
|
||||||
|
|
||||||
/* scan existing windows */
|
|
||||||
scan();
|
|
||||||
|
|
||||||
/* we will receive events, stop grabbing server */
|
|
||||||
xcb_ungrab_server(globalconf.connection);
|
|
||||||
xcb_flush(globalconf.connection);
|
xcb_flush(globalconf.connection);
|
||||||
|
|
||||||
/* main event loop */
|
/* main event loop */
|
||||||
|
|
Loading…
Reference in New Issue