core: only grab X server when there indeed is new windows
Shouldn't grab X server for nothing. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
46b8eb8d4d
commit
cfbd1819ed
|
@ -378,9 +378,11 @@ typedef struct session {
|
||||||
// Cached blur convolution kernels.
|
// Cached blur convolution kernels.
|
||||||
xcb_render_fixed_t *blur_kerns_cache[MAX_BLUR_PASS];
|
xcb_render_fixed_t *blur_kerns_cache[MAX_BLUR_PASS];
|
||||||
/// Reset program after next paint.
|
/// Reset program after next paint.
|
||||||
bool reset;
|
bool reset:1;
|
||||||
/// If compton should quit
|
/// If compton should quit
|
||||||
bool quit;
|
bool quit:1;
|
||||||
|
/// If new window has been added and not been handled
|
||||||
|
bool has_new_window:1;
|
||||||
|
|
||||||
// === Expose event related ===
|
// === Expose event related ===
|
||||||
/// Pointer to an array of <code>XRectangle</code>-s of exposed region.
|
/// Pointer to an array of <code>XRectangle</code>-s of exposed region.
|
||||||
|
|
|
@ -855,10 +855,9 @@ void configure_win(session_t *ps, xcb_configure_notify_event_t *ce) {
|
||||||
|
|
||||||
// If window geometry change, free old extents
|
// If window geometry change, free old extents
|
||||||
if (mw->g.x != ce->x || mw->g.y != ce->y || mw->g.width != ce->width ||
|
if (mw->g.x != ce->x || mw->g.y != ce->y || mw->g.width != ce->width ||
|
||||||
mw->g.height != ce->height || mw->g.border_width != ce->border_width)
|
mw->g.height != ce->height || mw->g.border_width != ce->border_width) {
|
||||||
{
|
|
||||||
factor_change = true;
|
factor_change = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mw->g.x = ce->x;
|
mw->g.x = ce->x;
|
||||||
mw->g.y = ce->y;
|
mw->g.y = ce->y;
|
||||||
|
@ -1412,6 +1411,7 @@ static void handle_new_windows(session_t *ps) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ps->has_new_window = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1429,24 +1429,31 @@ static void fade_timer_callback(EV_P_ ev_timer *w, int revents) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _draw_callback(EV_P_ session_t *ps, int revents) {
|
static void _draw_callback(EV_P_ session_t *ps, int revents) {
|
||||||
auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c));
|
if (ps->has_new_window) {
|
||||||
if (e) {
|
log_debug("Delayed handling of new window events, entering critical "
|
||||||
log_fatal("failed to grab x server");
|
"section");
|
||||||
x_print_error(e->full_sequence, e->major_code, e->minor_code, e->error_code);
|
auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c));
|
||||||
return quit_compton(ps);
|
if (e) {
|
||||||
}
|
log_fatal("failed to grab x server");
|
||||||
|
x_print_error(e->full_sequence, e->major_code, e->minor_code,
|
||||||
|
e->error_code);
|
||||||
|
return quit_compton(ps);
|
||||||
|
}
|
||||||
|
|
||||||
// Catching up with X server
|
// Catching up with X server
|
||||||
handle_queued_x_events(ps->loop, &ps->event_check, 0);
|
handle_queued_x_events(ps->loop, &ps->event_check, 0);
|
||||||
|
|
||||||
// Call fill_win on new windows
|
// Call fill_win on new windows
|
||||||
handle_new_windows(ps);
|
handle_new_windows(ps);
|
||||||
|
|
||||||
e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c));
|
e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_fatal("failed to ungrab x server");
|
log_fatal("failed to ungrab x server");
|
||||||
x_print_error(e->full_sequence, e->major_code, e->minor_code, e->error_code);
|
x_print_error(e->full_sequence, e->major_code, e->minor_code,
|
||||||
return quit_compton(ps);
|
e->error_code);
|
||||||
|
return quit_compton(ps);
|
||||||
|
}
|
||||||
|
log_debug("Exiting critical section");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps->o.benchmark) {
|
if (ps->o.benchmark) {
|
||||||
|
|
|
@ -958,6 +958,7 @@ static struct win *add_win(session_t *ps, xcb_window_t id, struct list_node *pre
|
||||||
new_w->destroyed = false;
|
new_w->destroyed = false;
|
||||||
|
|
||||||
HASH_ADD_INT(ps->windows, id, new_w);
|
HASH_ADD_INT(ps->windows, id, new_w);
|
||||||
|
ps->has_new_window = true;
|
||||||
return new_w;
|
return new_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue