wibox: fix geometry computing in regards to border width
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4c3e1cebf8
commit
c9caededca
53
wibox.c
53
wibox.c
|
@ -133,17 +133,17 @@ wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
|
||||||
xcb_create_pixmap(globalconf.connection,
|
xcb_create_pixmap(globalconf.connection,
|
||||||
s->root_depth,
|
s->root_depth,
|
||||||
w->ctx.pixmap, s->root,
|
w->ctx.pixmap, s->root,
|
||||||
w->geometry.height - (2 * w->border.width),
|
w->geometry.height,
|
||||||
w->geometry.width - (2 * w->border.width));
|
w->geometry.width);
|
||||||
draw_context_init(&w->ctx, phys_screen,
|
draw_context_init(&w->ctx, phys_screen,
|
||||||
w->geometry.height - (2 * w->border.width),
|
w->geometry.height,
|
||||||
w->geometry.width - (2 * w->border.width),
|
w->geometry.width,
|
||||||
w->ctx.pixmap, &fg, &bg);
|
w->ctx.pixmap, &fg, &bg);
|
||||||
break;
|
break;
|
||||||
case East:
|
case East:
|
||||||
draw_context_init(&w->ctx, phys_screen,
|
draw_context_init(&w->ctx, phys_screen,
|
||||||
w->geometry.width - (2 * w->border.width),
|
w->geometry.width,
|
||||||
w->geometry.height - (2 * w->border.width),
|
w->geometry.height,
|
||||||
w->pixmap, &fg, &bg);
|
w->pixmap, &fg, &bg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,7 @@ wibox_init(wibox_t *w, int phys_screen)
|
||||||
w->window = xcb_generate_id(globalconf.connection);
|
w->window = xcb_generate_id(globalconf.connection);
|
||||||
xcb_create_window(globalconf.connection, s->root_depth, w->window, s->root,
|
xcb_create_window(globalconf.connection, s->root_depth, w->window, s->root,
|
||||||
w->geometry.x, w->geometry.y,
|
w->geometry.x, w->geometry.y,
|
||||||
w->geometry.width - (2 * w->border.width),
|
w->geometry.width, w->geometry.height,
|
||||||
w->geometry.height - (2 * w->border.width),
|
|
||||||
w->border.width, XCB_COPY_FROM_PARENT, s->root_visual,
|
w->border.width, XCB_COPY_FROM_PARENT, s->root_visual,
|
||||||
XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL
|
XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL
|
||||||
| XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
|
| XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
|
||||||
|
@ -182,8 +181,7 @@ wibox_init(wibox_t *w, int phys_screen)
|
||||||
/* Create a pixmap. */
|
/* Create a pixmap. */
|
||||||
w->pixmap = xcb_generate_id(globalconf.connection);
|
w->pixmap = xcb_generate_id(globalconf.connection);
|
||||||
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
|
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
|
||||||
w->geometry.width - (2 * w->border.width),
|
w->geometry.width, w->geometry.height);
|
||||||
w->geometry.height - (2 * w->border.width));
|
|
||||||
|
|
||||||
/* Update draw context physical screen, important for Zaphod. */
|
/* Update draw context physical screen, important for Zaphod. */
|
||||||
w->ctx.phys_screen = phys_screen;
|
w->ctx.phys_screen = phys_screen;
|
||||||
|
@ -238,25 +236,19 @@ wibox_moveresize(wibox_t *w, area_t geometry)
|
||||||
mask_vals |= XCB_CONFIG_WINDOW_Y;
|
mask_vals |= XCB_CONFIG_WINDOW_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t iw = geometry.width - (2 * w->border.width),
|
if(geometry.width > 0 && w->geometry.width != geometry.width)
|
||||||
ih = geometry.height - (2 * w->border.width);
|
|
||||||
|
|
||||||
if(iw > 0 && w->geometry.width != geometry.width)
|
|
||||||
{
|
{
|
||||||
w->geometry.width = geometry.width;
|
w->geometry.width = moveresize_win_vals[number_of_vals++] = geometry.width;
|
||||||
moveresize_win_vals[number_of_vals++] = iw;
|
|
||||||
mask_vals |= XCB_CONFIG_WINDOW_WIDTH;
|
mask_vals |= XCB_CONFIG_WINDOW_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ih > 0 && w->geometry.height != geometry.height)
|
if(geometry.height > 0 && w->geometry.height != geometry.height)
|
||||||
{
|
{
|
||||||
w->geometry.height = geometry.height;
|
w->geometry.height = moveresize_win_vals[number_of_vals++] = geometry.height;
|
||||||
moveresize_win_vals[number_of_vals++] = ih;
|
|
||||||
mask_vals |= XCB_CONFIG_WINDOW_HEIGHT;
|
mask_vals |= XCB_CONFIG_WINDOW_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(iw > 0 && ih > 0
|
if(mask_vals & (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT))
|
||||||
&& (mask_vals & (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT)))
|
|
||||||
{
|
{
|
||||||
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
||||||
/* orientation != East */
|
/* orientation != East */
|
||||||
|
@ -264,7 +256,8 @@ wibox_moveresize(wibox_t *w, area_t geometry)
|
||||||
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
|
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
|
||||||
w->pixmap = xcb_generate_id(globalconf.connection);
|
w->pixmap = xcb_generate_id(globalconf.connection);
|
||||||
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
|
||||||
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root, iw, ih);
|
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
|
||||||
|
w->geometry.width, w->geometry.height);
|
||||||
wibox_draw_context_update(w, s);
|
wibox_draw_context_update(w, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,12 +371,12 @@ wibox_move(wibox_t *wibox, int16_t x, int16_t y)
|
||||||
static void
|
static void
|
||||||
wibox_resize(wibox_t *w, uint16_t width, uint16_t height)
|
wibox_resize(wibox_t *w, uint16_t width, uint16_t height)
|
||||||
{
|
{
|
||||||
int iw = width - 2 * w->border.width;
|
if(width <= 0 || height <= 0 || (w->geometry.width == width && w->geometry.height == height))
|
||||||
int ih = height - 2 * w->border.width;
|
|
||||||
|
|
||||||
if(iw <= 0 || ih <= 0 || (w->geometry.width == width && w->geometry.height == height))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
w->geometry.width = width;
|
||||||
|
w->geometry.height = height;
|
||||||
|
|
||||||
if(w->window)
|
if(w->window)
|
||||||
{
|
{
|
||||||
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
|
||||||
|
@ -393,16 +386,14 @@ wibox_resize(wibox_t *w, uint16_t width, uint16_t height)
|
||||||
if(w->pixmap != w->ctx.pixmap)
|
if(w->pixmap != w->ctx.pixmap)
|
||||||
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
|
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
|
||||||
w->pixmap = xcb_generate_id(globalconf.connection);
|
w->pixmap = xcb_generate_id(globalconf.connection);
|
||||||
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root, iw, ih);
|
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
|
||||||
|
w->geometry.width, w->geometry.height);
|
||||||
xcb_configure_window(globalconf.connection, w->window,
|
xcb_configure_window(globalconf.connection, w->window,
|
||||||
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
||||||
(const uint32_t[]) { iw, ih });
|
(const uint32_t[]) { w->geometry.width, w->geometry.height });
|
||||||
wibox_draw_context_update(w, s);
|
wibox_draw_context_update(w, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->geometry.width = width;
|
|
||||||
w->geometry.height = height;
|
|
||||||
|
|
||||||
wibox_need_update(w);
|
wibox_need_update(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue