+static int do_ewmh_init_atoms(void)
+{
+ xcb_intern_atom_cookie_t *cookies =
+ xcb_ewmh_init_atoms(conn, &ewmh);
+ if (!cookies)
+ return warn("do_ewmh_init_atoms: no cookies");
+
+ int status =
+ xcb_ewmh_init_atoms_replies(&ewmh, cookies, NULL);
+ if (!status)
+ return warn("do_ewmh_init_atoms: no status");
+ return status;
+}
+
+static int do_get_strut(xcb_window_t win, strut_t *strut)
+{
+ xcb_get_property_cookie_t cookie =
+ xcb_ewmh_get_wm_strut(&ewmh, win);
+ if (!cookie.sequence)
+ return warn("do_get_strut: bad cookie");
+
+ xcb_ewmh_get_extents_reply_t ext = {};
+ int status =
+ xcb_ewmh_get_wm_strut_reply(&ewmh, cookie, &ext, NULL);
+ if (!status)
+ return warn("do_get_strut: no status");
+
+ strut->left = ext.left;
+ strut->right = ext.right;
+ strut->top = ext.top;
+ strut->bottom = ext.bottom;
+
+ return ext.left || ext.right || ext.top || ext.bottom;
+}
+