core: shrink the critical section in session_init

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-08-10 01:23:11 +01:00
parent 0ba7761bd5
commit dd21806662
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 23 additions and 27 deletions

View File

@ -1996,40 +1996,36 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
// think there still could be race condition that mandates discarding the events. // think there still could be race condition that mandates discarding the events.
x_discard_events(ps->c); x_discard_events(ps->c);
{ xcb_query_tree_reply_t *query_tree_reply =
xcb_query_tree_reply(ps->c, xcb_query_tree(ps->c, ps->root), NULL);
e = xcb_request_check(ps->c, xcb_ungrab_server(ps->c));
if (e) {
log_error("Failed to ungrad server");
free(e);
}
if (query_tree_reply) {
xcb_window_t *children; xcb_window_t *children;
int nchildren; int nchildren;
xcb_query_tree_reply_t *reply = children = xcb_query_tree_children(query_tree_reply);
xcb_query_tree_reply(ps->c, xcb_query_tree(ps->c, ps->root), NULL); nchildren = xcb_query_tree_children_length(query_tree_reply);
if (reply) {
children = xcb_query_tree_children(reply);
nchildren = xcb_query_tree_children_length(reply);
} else {
children = NULL;
nchildren = 0;
}
for (int i = 0; i < nchildren; i++) { for (int i = 0; i < nchildren; i++) {
add_win_above(ps, children[i], i ? children[i - 1] : XCB_NONE); add_win_above(ps, children[i], i ? children[i - 1] : XCB_NONE);
} }
free(reply); free(query_tree_reply);
}
log_trace("Initial stack:"); log_trace("Initial stack:");
list_foreach(struct win, w, &ps->window_stack, stack_neighbour) { list_foreach(struct win, w, &ps->window_stack, stack_neighbour) {
log_trace("%#010x", w->id); log_trace("%#010x", w->id);
} }
}
ps->pending_updates = true; ps->pending_updates = true;
e = xcb_request_check(ps->c, xcb_ungrab_server(ps->c));
if (e) {
log_error("Failed to ungrad server");
free(e);
}
write_pid(ps); write_pid(ps);
if (fork && stderr_logger) { if (fork && stderr_logger) {