core: move the X critical section into a function

Also move handle_root_flags into the critical section.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-09-19 17:20:18 +01:00
parent 7df9245c81
commit ebb52567c0
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 10 additions and 9 deletions

View File

@ -1301,7 +1301,7 @@ static void fade_timer_callback(EV_P attr_unused, ev_timer *w, int revents attr_
queue_redraw(ps);
}
static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
static void handle_pending_updates(EV_P_ struct session *ps) {
if (ps->pending_updates) {
log_debug("Delayed handling of events, entering critical section");
auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c));
@ -1325,10 +1325,11 @@ static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
recheck_focus(ps);
}
// Refresh pixmaps
// Refresh pixmaps and shadows
refresh_stale_images(ps);
ps->server_grabbed = false;
// Handle screen changes
handle_root_flags(ps);
e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c));
if (e) {
@ -1338,9 +1339,14 @@ static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
return quit_compton(ps);
}
ps->server_grabbed = false;
ps->pending_updates = false;
log_debug("Exiting critical section");
log_debug("Exited critical section");
}
}
static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
handle_pending_updates(EV_A_ ps);
if (ps->o.benchmark) {
if (ps->o.benchmark_wid) {
@ -1355,11 +1361,6 @@ static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
}
}
// TODO xcb_grab_server
// TODO clean up event queue
handle_root_flags(ps);
// TODO have a stripped down version of paint_preprocess that is used when screen
// is not redirected. its sole purpose should be to decide whether the screen
// should be redirected.