Skip to content

Commit 451088d

Browse files
stapelbergnathanr
authored and
nathanr
committed
set _NET_WM_BYPASS_COMPOSITOR hint to avoid flickering (i3#256)
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
1 parent 8c7b990 commit 451088d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

xcb.c

+31
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ extern auth_state_t auth_state;
2929
xcb_connection_t *conn;
3030
xcb_screen_t *screen;
3131

32+
static xcb_atom_t _NET_WM_BYPASS_COMPOSITOR = XCB_NONE;
33+
void _init_net_wm_bypass_compositor(xcb_connection_t *conn) {
34+
if (_NET_WM_BYPASS_COMPOSITOR != XCB_NONE) {
35+
/* already initialized */
36+
return;
37+
}
38+
xcb_generic_error_t *err;
39+
xcb_intern_atom_reply_t *atom_reply = xcb_intern_atom_reply(
40+
conn,
41+
xcb_intern_atom(conn, 0, strlen("_NET_WM_BYPASS_COMPOSITOR"), "_NET_WM_BYPASS_COMPOSITOR"),
42+
&err);
43+
if (atom_reply == NULL) {
44+
fprintf(stderr, "X11 Error %d\n", err->error_code);
45+
free(err);
46+
return;
47+
}
48+
_NET_WM_BYPASS_COMPOSITOR = atom_reply->atom;
49+
free(atom_reply);
50+
}
51+
3252
#define curs_invisible_width 8
3353
#define curs_invisible_height 8
3454

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

181+
const uint32_t bypass_compositor = 1; /* disable compositing */
182+
_init_net_wm_bypass_compositor(conn);
183+
xcb_change_property(conn,
184+
XCB_PROP_MODE_REPLACE,
185+
win,
186+
_NET_WM_BYPASS_COMPOSITOR,
187+
XCB_ATOM_CARDINAL,
188+
32,
189+
1,
190+
&bypass_compositor);
191+
161192
/* Map the window (= make it visible) */
162193
xcb_map_window(conn, win);
163194

0 commit comments

Comments
 (0)