Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Drop xcb_flush() before xcb_aux_sync() (#4378)
Browse files Browse the repository at this point in the history
xcb_flush() flushes xcb's output buffer. Thus, after this call, all
previous requests are surely written to the connection with the X11
server.

xcb_aux_sync() synchronises with the X11 server. It makes sure all
previous requests were sent to the X11 server and already processed. It
does this via free(xcb_get_input_focus_reply(xcb_get_input_focus())): It
sends a request and waits for its reply. It is guaranteed that the X11
server processes requests in-order.

This means that the sequence xcb_flush(); xcb_aux_sync() first writes
whatever is in the output buffer and then does another write for the
four bytes of the GetInputFocus request from xcb_aux_sync().

Put differently: xcb_flush(); xcb_aux_sync() doesn't do anything more
than just xcb_aux_sync(). In fact, it has slightly more overhead for the
same result.

Thus, this commit drops all calls to xcb_flush() immediately after
xcb_aux_sync().

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed May 20, 2021
1 parent 60542da commit d65a7ed
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 3 deletions.
1 change: 0 additions & 1 deletion i3bar/src/xcb.c
Expand Up @@ -1532,7 +1532,6 @@ void clean_xcb(void) {
free_font();

xcb_free_cursor(xcb_connection, cursor);
xcb_flush(xcb_connection);
xcb_aux_sync(xcb_connection);
xcb_disconnect(xcb_connection);

Expand Down
2 changes: 0 additions & 2 deletions src/restore_layout.c
Expand Up @@ -134,7 +134,6 @@ static void update_placeholder_contents(placeholder_state *state) {
draw_util_clear_surface(&(state->surface), background);

// TODO: make i3font functions per-connection, at least these two for now…?
xcb_flush(restore_conn);
xcb_aux_sync(restore_conn);

Match *swallows;
Expand Down Expand Up @@ -180,7 +179,6 @@ static void update_placeholder_contents(placeholder_state *state) {
int y = (state->rect.height / 2) - (config.font.height / 2);
draw_util_text(line, &(state->surface), foreground, background, x, y, text_width);
i3string_free(line);
xcb_flush(restore_conn);
xcb_aux_sync(restore_conn);
}

Expand Down

0 comments on commit d65a7ed

Please sign in to comment.