Skip to content

Commit

Permalink
set _NET_WM_BYPASS_COMPOSITOR hint to avoid flickering
Browse files Browse the repository at this point in the history
For compositors which support it (picom >v7.5, formerly known as compton), this
should result in the i3lock window no longer being composited, hence fixing
issue i3#204.

related to i3#204
  • Loading branch information
stapelberg committed Jan 20, 2020
1 parent b9d72cb commit c7a2c85
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions xcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ extern auth_state_t auth_state;
xcb_connection_t *conn;
xcb_screen_t *screen;

static xcb_atom_t _NET_WM_BYPASS_COMPOSITOR = XCB_NONE;
void _init_net_wm_bypass_compositor(xcb_connection_t *conn) {
if (_NET_WM_BYPASS_COMPOSITOR != XCB_NONE) {
/* already initialized */
return;
}
xcb_generic_error_t *err;
xcb_intern_atom_reply_t *atom_reply = xcb_intern_atom_reply(
conn,
xcb_intern_atom(conn, 0, strlen("_NET_WM_BYPASS_COMPOSITOR"), "_NET_WM_BYPASS_COMPOSITOR"),
&err);
if (atom_reply == NULL) {
fprintf(stderr, "X11 Error %d\n", err->error_code);
free(err);
return;
}
_NET_WM_BYPASS_COMPOSITOR = atom_reply->atom;
free(atom_reply);
}

#define curs_invisible_width 8
#define curs_invisible_height 8

Expand Down Expand Up @@ -158,6 +178,17 @@ xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, c
2 * (strlen("i3lock") + 1),
"i3lock\0i3lock\0");

const uint32_t bypass_compositor = 1; // disable compositing
_init_net_wm_bypass_compositor(conn);
xcb_change_property(conn,
XCB_PROP_MODE_REPLACE,
win,
_NET_WM_BYPASS_COMPOSITOR,
XCB_ATOM_CARDINAL,
32,
1,
&bypass_compositor);

/* Map the window (= make it visible) */
xcb_map_window(conn, win);

Expand Down

0 comments on commit c7a2c85

Please sign in to comment.