diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2015-01-15 22:18:23 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2015-01-15 22:18:23 +0200 |
commit | 2bf8bbfcde0f2cb4d2ddc7a633d1f03933368c0a (patch) | |
tree | bb41f5c4abacd887f257004ebb171388ac95df11 /lib/renderers/wayland | |
parent | 9baca87123f9da3fbf53360fee7527b43197efc5 (diff) | |
download | bemenu-2bf8bbfcde0f2cb4d2ddc7a633d1f03933368c0a.tar.gz bemenu-2bf8bbfcde0f2cb4d2ddc7a633d1f03933368c0a.tar.bz2 bemenu-2bf8bbfcde0f2cb4d2ddc7a633d1f03933368c0a.zip |
Working pango code.
Diffstat (limited to 'lib/renderers/wayland')
-rw-r--r-- | lib/renderers/wayland/wayland.c | 5 | ||||
-rw-r--r-- | lib/renderers/wayland/wayland.h | 4 | ||||
-rw-r--r-- | lib/renderers/wayland/window.c | 31 |
3 files changed, 20 insertions, 20 deletions
diff --git a/lib/renderers/wayland/wayland.c b/lib/renderers/wayland/wayland.c index 3852a6d..18f335f 100644 --- a/lib/renderers/wayland/wayland.c +++ b/lib/renderers/wayland/wayland.c @@ -39,10 +39,7 @@ render(const struct bm_menu *menu) } if (wayland->input.code != wayland->input.last_code) { - uint32_t count; - bm_menu_get_filtered_items(menu, &count); - uint32_t lines = (count < menu->lines ? count : menu->lines) + 1; - bm_wl_window_render(&wayland->window, menu, lines); + bm_wl_window_render(&wayland->window, menu); wayland->input.last_code = wayland->input.code; } } diff --git a/lib/renderers/wayland/wayland.h b/lib/renderers/wayland/wayland.h index 886a0fd..d6c0915 100644 --- a/lib/renderers/wayland/wayland.h +++ b/lib/renderers/wayland/wayland.h @@ -85,7 +85,7 @@ struct window { uint32_t displayed; struct { - uint32_t (*render)(struct cairo *cairo, uint32_t width, uint32_t height, const struct bm_menu *menu); + void (*render)(struct cairo *cairo, uint32_t width, uint32_t height, const struct bm_menu *menu, struct cairo_paint_result *result); } notify; }; @@ -111,7 +111,7 @@ struct wayland { void bm_wl_repeat(struct wayland *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, uint32_t lines); +void bm_wl_window_render(struct window *window, const struct bm_menu *menu); 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); diff --git a/lib/renderers/wayland/window.c b/lib/renderers/wayland/window.c index d70d43b..a9c9edc 100644 --- a/lib/renderers/wayland/window.c +++ b/lib/renderers/wayland/window.c @@ -248,7 +248,7 @@ static const struct wl_callback_listener listener = { }; void -bm_wl_window_render(struct window *window, const struct bm_menu *menu, uint32_t lines) +bm_wl_window_render(struct window *window, const struct bm_menu *menu) { assert(window && menu); @@ -256,22 +256,25 @@ bm_wl_window_render(struct window *window, const struct bm_menu *menu, uint32_t return; struct buffer *buffer; - if (!(buffer = next_buffer(window))) { - fprintf(stderr, "could not get next buffer"); - exit(EXIT_FAILURE); - } + for (int tries = 0; tries < 2; ++tries) { + if (!(buffer = next_buffer(window))) { + fprintf(stderr, "could not get next buffer"); + exit(EXIT_FAILURE); + } - cairo_font_extents_t fe; - bm_cairo_get_font_extents(&buffer->cairo, &menu->font, &fe); - window->height = MIN(lines * (fe.height + 4), window->max_height); + if (!window->notify.render) + break; - if (window->height != buffer->height && !(buffer = next_buffer(window))) { - fprintf(stderr, "could not get next buffer"); - exit(EXIT_FAILURE); - } + struct cairo_paint_result result; + window->notify.render(&buffer->cairo, buffer->width, buffer->height, menu, &result); + window->displayed = result.displayed; + + if (window->height == result.height) + break; - if (window->notify.render) - window->displayed = window->notify.render(&buffer->cairo, buffer->width, buffer->height, menu); + window->height = result.height; + destroy_buffer(buffer); + } window->frame_cb = wl_surface_frame(window->surface); wl_callback_add_listener(window->frame_cb, &listener, window); |