mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-28 12:45:40 +02:00
Attempt to get changes working on xcb
This commit is contained in:
parent
6716d82dbc
commit
eb296c08e4
1 changed files with 41 additions and 27 deletions
68
bar/xcb.c
68
bar/xcb.c
|
@ -90,6 +90,7 @@ setup(struct bar *_bar)
|
||||||
|
|
||||||
/* Find monitor coordinates and width/height */
|
/* Find monitor coordinates and width/height */
|
||||||
bool found_monitor = false;
|
bool found_monitor = false;
|
||||||
|
int width = bar->width_with_border, height = bar->height_with_border;
|
||||||
for (xcb_randr_monitor_info_iterator_t it =
|
for (xcb_randr_monitor_info_iterator_t it =
|
||||||
xcb_randr_get_monitors_monitors_iterator(monitors);
|
xcb_randr_get_monitors_monitors_iterator(monitors);
|
||||||
it.rem > 0;
|
it.rem > 0;
|
||||||
|
@ -110,9 +111,25 @@ setup(struct bar *_bar)
|
||||||
|
|
||||||
backend->x = mon->x;
|
backend->x = mon->x;
|
||||||
backend->y = mon->y;
|
backend->y = mon->y;
|
||||||
bar->width = mon->width;
|
|
||||||
backend->y += bar->location == BAR_TOP ? 0
|
if(bar->width_with_border == 0)
|
||||||
: screen->height_in_pixels - bar->height_with_border;
|
width = mon->width - (bar->border.left_margin + bar->border.right_margin);
|
||||||
|
if(bar->height_with_border == 0)
|
||||||
|
height = mon->height - (bar->border.top_margin + bar->border.bottom_margin);
|
||||||
|
|
||||||
|
if (bar->location & (BAR_BOTTOM | BAR_TOP)) {
|
||||||
|
if (bar->location == BAR_BOTTOM)
|
||||||
|
backend->y += mon->height - (height + bar->border.bottom_margin);
|
||||||
|
else
|
||||||
|
backend->y += bar->border.top_margin;
|
||||||
|
backend->x += (mon->width / 2) - (width / 2);
|
||||||
|
} else {
|
||||||
|
if (bar->location == BAR_RIGHT)
|
||||||
|
backend->x += mon->width - (width + bar->border.right_margin);
|
||||||
|
else
|
||||||
|
backend->x += bar->border.left_margin;
|
||||||
|
backend->y += (mon->height / 2) - (height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
found_monitor = true;
|
found_monitor = true;
|
||||||
|
|
||||||
|
@ -128,6 +145,9 @@ setup(struct bar *_bar)
|
||||||
}
|
}
|
||||||
free(monitors);
|
free(monitors);
|
||||||
|
|
||||||
|
bar->width_with_border = width;
|
||||||
|
bar->height_with_border = height;
|
||||||
|
|
||||||
if (!found_monitor) {
|
if (!found_monitor) {
|
||||||
if (bar->monitor == NULL)
|
if (bar->monitor == NULL)
|
||||||
LOG_ERR("no monitors found");
|
LOG_ERR("no monitors found");
|
||||||
|
@ -162,7 +182,7 @@ setup(struct bar *_bar)
|
||||||
xcb_create_window(
|
xcb_create_window(
|
||||||
backend->conn,
|
backend->conn,
|
||||||
depth, backend->win, screen->root,
|
depth, backend->win, screen->root,
|
||||||
backend->x, backend->y, bar->width, bar->height_with_border,
|
backend->x, backend->y, bar->width_with_border, bar->height_with_border,
|
||||||
0,
|
0,
|
||||||
XCB_WINDOW_CLASS_INPUT_OUTPUT, vis->visual_id,
|
XCB_WINDOW_CLASS_INPUT_OUTPUT, vis->visual_id,
|
||||||
(XCB_CW_BACK_PIXEL |
|
(XCB_CW_BACK_PIXEL |
|
||||||
|
@ -211,36 +231,30 @@ setup(struct bar *_bar)
|
||||||
backend->conn, backend->win, XCB_CONFIG_WINDOW_STACK_MODE,
|
backend->conn, backend->win, XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
(const uint32_t []){XCB_STACK_MODE_ABOVE});
|
(const uint32_t []){XCB_STACK_MODE_ABOVE});
|
||||||
|
|
||||||
uint32_t top_strut, bottom_strut;
|
uint32_t top_strut, bottom_strut, left_strut, right_strut;
|
||||||
uint32_t top_pair[2], bottom_pair[2];
|
top_strut = bottom_strut = left_strut = right_strut = 0;
|
||||||
|
|
||||||
if (bar->location == BAR_TOP) {
|
if (bar->location == BAR_TOP)
|
||||||
top_strut = bar->height_with_border;
|
top_strut = bar->height_with_border;
|
||||||
top_pair[0] = backend->x;
|
else if (bar->location == BAR_BOTTOM)
|
||||||
top_pair[1] = backend->x + bar->width - 1;
|
|
||||||
|
|
||||||
bottom_strut = 0;
|
|
||||||
bottom_pair[0] = bottom_pair[1] = 0;
|
|
||||||
} else {
|
|
||||||
bottom_strut = bar->height_with_border;
|
bottom_strut = bar->height_with_border;
|
||||||
bottom_pair[0] = backend->x;
|
else if (bar->location == BAR_LEFT)
|
||||||
bottom_pair[1] = backend->x + bar->width - 1;
|
left_strut = bar->width_with_border;
|
||||||
|
else
|
||||||
top_strut = 0;
|
right_strut = bar->width_with_border;
|
||||||
top_pair[0] = top_pair[1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t strut[] = {
|
uint32_t strut[] = {
|
||||||
/* left/right/top/bottom */
|
/* left/right/top/bottom */
|
||||||
0, 0,
|
left_strut,
|
||||||
|
right_strut,
|
||||||
top_strut,
|
top_strut,
|
||||||
bottom_strut,
|
bottom_strut,
|
||||||
|
|
||||||
/* start/end pairs for left/right/top/bottom */
|
/* start/end pairs for left/right/top/bottom */
|
||||||
0, 0,
|
backend->y, backend->y + bar->height_with_border,
|
||||||
0, 0,
|
backend->y, backend->y + bar->height_with_border,
|
||||||
top_pair[0], top_pair[1],
|
backend->x, backend->x + bar->width_with_border,
|
||||||
bottom_pair[0], bottom_pair[1],
|
backend->x, backend->x + bar->width_with_border,
|
||||||
};
|
};
|
||||||
|
|
||||||
xcb_change_property(
|
xcb_change_property(
|
||||||
|
@ -261,12 +275,12 @@ setup(struct bar *_bar)
|
||||||
(const uint32_t []){screen->white_pixel, 0});
|
(const uint32_t []){screen->white_pixel, 0});
|
||||||
|
|
||||||
const uint32_t stride = stride_for_format_and_width(
|
const uint32_t stride = stride_for_format_and_width(
|
||||||
PIXMAN_a8r8g8b8, bar->width);
|
PIXMAN_a8r8g8b8, bar->width_with_border);
|
||||||
|
|
||||||
backend->client_pixmap_size = stride * bar->height_with_border;
|
backend->client_pixmap_size = stride * bar->height_with_border;
|
||||||
backend->client_pixmap = malloc(backend->client_pixmap_size);
|
backend->client_pixmap = malloc(backend->client_pixmap_size);
|
||||||
backend->pix = pixman_image_create_bits_no_clear(
|
backend->pix = pixman_image_create_bits_no_clear(
|
||||||
PIXMAN_a8r8g8b8, bar->width, bar->height_with_border,
|
PIXMAN_a8r8g8b8, bar->width_with_border, bar->height_with_border,
|
||||||
(uint32_t *)backend->client_pixmap, stride);
|
(uint32_t *)backend->client_pixmap, stride);
|
||||||
bar->pix = backend->pix;
|
bar->pix = backend->pix;
|
||||||
|
|
||||||
|
@ -407,7 +421,7 @@ commit(const struct bar *_bar)
|
||||||
|
|
||||||
xcb_put_image(
|
xcb_put_image(
|
||||||
backend->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, backend->win, backend->gc,
|
backend->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, backend->win, backend->gc,
|
||||||
bar->width, bar->height_with_border, 0, 0, 0,
|
bar->width_with_border, bar->height_with_border, 0, 0, 0,
|
||||||
backend->depth, backend->client_pixmap_size, backend->client_pixmap);
|
backend->depth, backend->client_pixmap_size, backend->client_pixmap);
|
||||||
xcb_flush(backend->conn);
|
xcb_flush(backend->conn);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue