core: wait for the result xcb_grab_server before doing anything

Make sure X grab server is finished before calling x_discard_events in
session_init. Otherwise x_discard_events won't be able to discard all of
the events that were sent before we grab the server.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-04-19 22:35:52 +01:00
parent 3d2217a112
commit d4fde6a392
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 8 additions and 1 deletions

View File

@ -2077,7 +2077,11 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
ev_set_priority(&ps->event_check, EV_MINPRI); ev_set_priority(&ps->event_check, EV_MINPRI);
ev_prepare_start(ps->loop, &ps->event_check); ev_prepare_start(ps->loop, &ps->event_check);
xcb_grab_server(ps->c); e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c));
if (e) {
log_fatal("Failed to grab X server");
goto err;
}
// We are going to pull latest information from X server now, events sent by X // We are going to pull latest information from X server now, events sent by X
// earlier is irrelavant at this point. // earlier is irrelavant at this point.
@ -2156,6 +2160,9 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
log_remove_target_tls(stderr_logger); log_remove_target_tls(stderr_logger);
} }
return ps; return ps;
err:
free(ps);
return NULL;
} }
/** /**