core: track whether server is grabbed
This commit is contained in:
parent
02139b7c9f
commit
4e915837a4
|
@ -158,6 +158,8 @@ typedef struct session {
|
||||||
struct ev_loop *loop;
|
struct ev_loop *loop;
|
||||||
|
|
||||||
// === Display related ===
|
// === Display related ===
|
||||||
|
/// Whether the X server is grabbed by us
|
||||||
|
bool server_grabbed;
|
||||||
/// Display in use.
|
/// Display in use.
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
/// Previous handler of X errors
|
/// Previous handler of X errors
|
||||||
|
|
|
@ -1328,6 +1328,8 @@ static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
|
||||||
return quit_compton(ps);
|
return quit_compton(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ps->server_grabbed = true;
|
||||||
|
|
||||||
// Catching up with X server
|
// Catching up with X server
|
||||||
handle_queued_x_events(EV_A_ & ps->event_check, 0);
|
handle_queued_x_events(EV_A_ & ps->event_check, 0);
|
||||||
|
|
||||||
|
@ -1342,6 +1344,8 @@ static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
|
||||||
// Refresh pixmaps
|
// Refresh pixmaps
|
||||||
refresh_stale_images(ps);
|
refresh_stale_images(ps);
|
||||||
|
|
||||||
|
ps->server_grabbed = false;
|
||||||
|
|
||||||
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");
|
||||||
|
@ -1990,6 +1994,8 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ps->server_grabbed = true;
|
||||||
|
|
||||||
// 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.
|
||||||
// A better solution is probably grabbing the server from the very start. But I
|
// A better solution is probably grabbing the server from the very start. But I
|
||||||
|
@ -2000,12 +2006,13 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
xcb_query_tree_reply(ps->c, xcb_query_tree(ps->c, ps->root), NULL);
|
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));
|
e = xcb_request_check(ps->c, xcb_ungrab_server(ps->c));
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
log_error("Failed to ungrab server");
|
log_error("Failed to ungrab server");
|
||||||
free(e);
|
free(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ps->server_grabbed = false;
|
||||||
|
|
||||||
if (query_tree_reply) {
|
if (query_tree_reply) {
|
||||||
xcb_window_t *children;
|
xcb_window_t *children;
|
||||||
int nchildren;
|
int nchildren;
|
||||||
|
|
Loading…
Reference in New Issue