-/*
- * Reallocate the statusline buffer
- *
- */
-void realloc_sl_buffer(void) {
- DLOG("Re-allocating statusline buffer, statusline_width = %d, root_screen->width_in_pixels = %d\n",
- statusline_width, root_screen->width_in_pixels);
- xcb_free_pixmap(xcb_connection, statusline_pm);
- statusline_pm = xcb_generate_id(xcb_connection);
- xcb_void_cookie_t sl_pm_cookie = xcb_create_pixmap_checked(xcb_connection,
- root_screen->root_depth,
- statusline_pm,
- xcb_root,
- MAX(root_screen->width_in_pixels, statusline_width),
- bar_height);
-
- uint32_t mask = XCB_GC_FOREGROUND;
- uint32_t vals[2] = {colors.bar_bg, colors.bar_bg};
- xcb_free_gc(xcb_connection, statusline_clear);
- statusline_clear = xcb_generate_id(xcb_connection);
- xcb_void_cookie_t clear_ctx_cookie = xcb_create_gc_checked(xcb_connection,
- statusline_clear,
- xcb_root,
- mask,
- vals);
-
- mask |= XCB_GC_BACKGROUND;
- vals[0] = colors.bar_fg;
- xcb_free_gc(xcb_connection, statusline_ctx);
- statusline_ctx = xcb_generate_id(xcb_connection);
- xcb_void_cookie_t sl_ctx_cookie = xcb_create_gc_checked(xcb_connection,
- statusline_ctx,
- xcb_root,
- mask,
- vals);
-
- if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline buffer") ||
- xcb_request_failed(clear_ctx_cookie, "Could not allocate statusline buffer clearcontext") ||
- xcb_request_failed(sl_ctx_cookie, "Could not allocate statusline buffer context")) {
- exit(EXIT_FAILURE);
+/* Strut partial tells i3 where to reserve space for i3bar. This is determined
+ * by the `position` bar config directive. */
+xcb_void_cookie_t config_strut_partial(i3_output *output) {
+ /* A local struct to save the strut_partial property */
+ struct {
+ uint32_t left;
+ uint32_t right;
+ uint32_t top;
+ uint32_t bottom;
+ uint32_t left_start_y;
+ uint32_t left_end_y;
+ uint32_t right_start_y;
+ uint32_t right_end_y;
+ uint32_t top_start_x;
+ uint32_t top_end_x;
+ uint32_t bottom_start_x;
+ uint32_t bottom_end_x;
+ } __attribute__((__packed__)) strut_partial;
+ memset(&strut_partial, 0, sizeof(strut_partial));
+
+ switch (config.position) {
+ case POS_NONE:
+ break;
+ case POS_TOP:
+ strut_partial.top = bar_height;
+ strut_partial.top_start_x = output->rect.x;
+ strut_partial.top_end_x = output->rect.x + output->rect.w;
+ break;
+ case POS_BOT:
+ strut_partial.bottom = bar_height;
+ strut_partial.bottom_start_x = output->rect.x;
+ strut_partial.bottom_end_x = output->rect.x + output->rect.w;
+ break;