+void map_window_raised(xcb_window_t);
+void do_sync(void);
+xcb_screen_t *get_screen(int);
+int parse_rgb(const char *, uint16_t *, uint16_t *, uint16_t *);
+
+int
+parse_rgb(const char *rgb, uint16_t *rr, uint16_t *gg, uint16_t *bb)
+{
+ unsigned int tmpr, tmpg, tmpb;
+
+ if (sscanf(rgb, "rgb:%x/%x/%x", &tmpr, &tmpg, &tmpb) != 3)
+ return (-1);
+
+ *rr = tmpr << 8;
+ *gg = tmpg << 8;
+ *bb = tmpb << 8;
+
+ return (0);
+}
+
+xcb_screen_t *
+get_screen(int screen)
+{
+ xcb_screen_iterator_t i;
+
+ i = xcb_setup_roots_iterator(xcb_get_setup(conn));
+ for (; i.rem; --screen, xcb_screen_next(&i))
+ if (screen == 0)
+ return (i.data);
+
+ return (NULL);
+}
+
+void
+do_sync(void)
+{
+ xcb_get_input_focus_cookie_t c;
+ xcb_get_input_focus_reply_t *r;
+
+ /* mimic XSync() */
+ c = xcb_get_input_focus(conn);
+ xcb_flush(conn);
+ r = xcb_get_input_focus_reply(conn, c, NULL);
+ if (r)
+ free(r);
+}
+
+void
+map_window_raised(xcb_window_t win)
+{
+ uint32_t val = XCB_STACK_MODE_ABOVE;
+
+ xcb_configure_window(conn, win,
+ XCB_CONFIG_WINDOW_STACK_MODE, &val);
+
+ xcb_map_window(conn, win);
+ xcb_flush(conn);
+}