summaryrefslogtreecommitdiff
path: root/src/entry.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2021-11-15 19:37:48 +0000
committerPhil Jones <philj56@gmail.com>2021-11-15 19:37:48 +0000
commit49c7405b6a88e56bb69e12189adb719927343e07 (patch)
tree72c7691e746563cc1396c5b555659c813572c12e /src/entry.c
parent108df42e561b7e81ba09a8c278a562129e651bb6 (diff)
Multiple smaller changes.
- Remove the background image and libpng dependency - Add a prompt - Add xmalloc with out-of-memory handling - Add beginnings of a rofi-like run cache
Diffstat (limited to 'src/entry.c')
-rw-r--r--src/entry.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/entry.c b/src/entry.c
index def32b2..644fe39 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -100,6 +100,24 @@ void entry_init(struct entry *entry, uint32_t width, uint32_t height, uint32_t s
pango_context_set_font_description(context, font_description);
pango_font_description_free(font_description);
+ entry->pango.prompt_layout = pango_layout_new(context);
+ pango_layout_set_text(entry->pango.prompt_layout, "run: ", -1);
+ int prompt_width;
+ int prompt_height;
+ pango_layout_get_pixel_size(entry->pango.prompt_layout, &prompt_width, &prompt_height);
+ pango_cairo_update_layout(cr, entry->pango.prompt_layout);
+
+ /* Draw the prompt now, as this only needs to be done once */
+ color = entry->foreground_color;
+ cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
+ pango_cairo_show_layout(cr, entry->pango.prompt_layout);
+
+ /* Move and clip so we don't draw over the prompt */
+ cairo_translate(cr, prompt_width, 0);
+ width -= prompt_width;
+ cairo_rectangle(cr, 0, 0, width, height);
+ cairo_clip(cr);
+
entry->pango.entry_layout = pango_layout_new(context);
pango_layout_set_text(entry->pango.entry_layout, "", -1);
@@ -123,6 +141,7 @@ void entry_destroy(struct entry *entry)
g_object_unref(entry->pango.result_layouts[i]);
}
g_object_unref(entry->pango.entry_layout);
+ g_object_unref(entry->pango.prompt_layout);
g_object_unref(entry->pango.context);
cairo_destroy(entry->cairo.cr);
cairo_surface_destroy(entry->cairo.surface);