commit 1b9b2bd7f8184fdaf554457c4a84f37eab94378e
parent b9d72cb1f024e224618811c2e973276eae4a9b22
Author: Michael Stapelberg <stapelberg@users.noreply.github.com>
Date: Mon, 20 Jan 2020 22:17:01 +0100
set _NET_WM_BYPASS_COMPOSITOR hint to avoid flickering (#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 #204.
related to #204
Diffstat:
| M | xcb.c | | | 31 | +++++++++++++++++++++++++++++++ |
1 file changed, 31 insertions(+), 0 deletions(-)
diff --git a/xcb.c b/xcb.c
@@ -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
@@ -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);