mirror of
https://github.com/Cloudef/bemenu
synced 2024-06-01 04:16:21 +02:00
Use real font height for window height.
This commit is contained in:
parent
8d08365645
commit
fb6a49e690
|
@ -32,6 +32,15 @@ struct cairo_result {
|
|||
static size_t blen = 0;
|
||||
static char *buffer = NULL;
|
||||
|
||||
__attribute__((unused)) static void
|
||||
bm_cairo_get_font_extents(struct cairo *cairo, const struct bm_font *font, cairo_font_extents_t *fe)
|
||||
{
|
||||
assert(cairo && font && fe);
|
||||
cairo_select_font_face(cairo->cr, font->name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size(cairo->cr, font->size);
|
||||
cairo_font_extents(cairo->cr, fe);
|
||||
}
|
||||
|
||||
__attribute__((unused)) BM_LOG_ATTR(3, 4) static bool
|
||||
bm_cairo_get_text_extents(struct cairo *cairo, struct cairo_result *result, const char *fmt, ...)
|
||||
{
|
||||
|
@ -100,12 +109,9 @@ bm_cairo_paint(struct cairo *cairo, uint32_t width, uint32_t height, const struc
|
|||
cairo_rectangle(cairo->cr, 0, 0, width, height);
|
||||
cairo_fill(cairo->cr);
|
||||
|
||||
cairo_select_font_face(cairo->cr, menu->font.name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size(cairo->cr, menu->font.size);
|
||||
|
||||
struct cairo_paint paint;
|
||||
memset(&paint, 0, sizeof(paint));
|
||||
cairo_font_extents(cairo->cr, &paint.fe);
|
||||
bm_cairo_get_font_extents(cairo, &menu->font, &paint.fe);
|
||||
|
||||
struct cairo_result result;
|
||||
memset(&result, 0, sizeof(result));
|
||||
|
|
|
@ -11,10 +11,11 @@ static void
|
|||
render(const struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
|
||||
uint32_t count;
|
||||
bm_menu_get_filtered_items(menu, &count);
|
||||
wayland->window.height = ((count < menu->lines ? count : menu->lines) + 1) * menu->font.size + 4;
|
||||
bm_wl_window_render(&wayland->window, menu);
|
||||
uint32_t lines = (count < menu->lines ? count : menu->lines) + 1;
|
||||
bm_wl_window_render(&wayland->window, menu, lines);
|
||||
|
||||
if (wl_display_dispatch(wayland->display) < 0)
|
||||
wayland->input.sym = XKB_KEY_Escape;
|
||||
|
|
|
@ -92,7 +92,7 @@ struct wayland {
|
|||
|
||||
bool bm_wl_registry_register(struct wayland *wayland);
|
||||
void bm_wl_registry_destroy(struct wayland *wayland);
|
||||
void bm_wl_window_render(struct window *window, const struct bm_menu *menu);
|
||||
void bm_wl_window_render(struct window *window, const struct bm_menu *menu, uint32_t lines);
|
||||
bool bm_wl_window_create(struct window *window, struct wl_shm *shm, struct wl_shell *shell, struct xdg_shell *xdg_shell, struct wl_surface *surface);
|
||||
void bm_wl_window_destroy(struct window *window);
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
|||
};
|
||||
|
||||
void
|
||||
bm_wl_window_render(struct window *window, const struct bm_menu *menu)
|
||||
bm_wl_window_render(struct window *window, const struct bm_menu *menu, uint32_t lines)
|
||||
{
|
||||
assert(window && menu);
|
||||
|
||||
|
@ -255,6 +255,13 @@ bm_wl_window_render(struct window *window, const struct bm_menu *menu)
|
|||
if (!(buffer = next_buffer(window)))
|
||||
return;
|
||||
|
||||
cairo_font_extents_t fe;
|
||||
bm_cairo_get_font_extents(&buffer->cairo, &menu->font, &fe);
|
||||
window->height = lines * fe.height + 4;
|
||||
|
||||
if (window->height != buffer->height && !(buffer = next_buffer(window)))
|
||||
return;
|
||||
|
||||
if (window->notify.render)
|
||||
window->displayed = window->notify.render(&buffer->cairo, buffer->width, buffer->height, menu);
|
||||
|
||||
|
|
Loading…
Reference in New Issue