summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.c2
-rw-r--r--src/entry.h1
-rw-r--r--src/entry_backend/harfbuzz.c5
-rw-r--r--src/entry_backend/pango.c5
-rw-r--r--src/main.c3
5 files changed, 14 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index aebb8e1..b5e7d49 100644
--- a/src/config.c
+++ b/src/config.c
@@ -263,6 +263,8 @@ bool parse_option(struct tofi *tofi, const char *filename, size_t lineno, const
tofi->window.entry.foreground_color = parse_color(filename, lineno, value, &err);
} else if (strcasecmp(option, "selection-color") == 0) {
tofi->window.entry.selection_foreground_color = parse_color(filename, lineno, value, &err);
+ } else if (strcasecmp(option, "selection-padding") == 0) {
+ tofi->window.entry.selection_background_padding = parse_uint32(filename, lineno, value, &err);
} else if (strcasecmp(option, "selection-background") == 0) {
tofi->window.entry.selection_background_color = parse_color(filename, lineno, value, &err);
} else if (strcasecmp(option, "width") == 0) {
diff --git a/src/entry.h b/src/entry.h
index c45bb85..690cb2f 100644
--- a/src/entry.h
+++ b/src/entry.h
@@ -59,6 +59,7 @@ struct entry {
uint32_t padding_bottom;
uint32_t padding_left;
uint32_t padding_right;
+ uint32_t selection_background_padding;
uint32_t input_width;
uint32_t border_width;
uint32_t outline_width;
diff --git a/src/entry_backend/harfbuzz.c b/src/entry_backend/harfbuzz.c
index af1aad7..db3be66 100644
--- a/src/entry_backend/harfbuzz.c
+++ b/src/entry_backend/harfbuzz.c
@@ -257,7 +257,10 @@ void entry_backend_harfbuzz_update(struct entry *entry)
cairo_save(cr);
color = entry->selection_background_color;
cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
- cairo_rectangle(cr, 0, 0, width, font_extents.height);
+ uint32_t pad = entry->selection_background_padding;
+ cairo_translate(cr, -pad, 0);
+ cairo_rectangle(cr, 0, 0, width + pad * 2, font_extents.height);
+ cairo_translate(cr, pad, 0);
cairo_fill(cr);
cairo_restore(cr);
cairo_paint(cr);
diff --git a/src/entry_backend/pango.c b/src/entry_backend/pango.c
index 3f424ce..bb0847a 100644
--- a/src/entry_backend/pango.c
+++ b/src/entry_backend/pango.c
@@ -109,7 +109,10 @@ void entry_backend_pango_update(struct entry *entry)
cairo_save(cr);
color = entry->selection_background_color;
cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
- cairo_rectangle(cr, 0, 0, (int)(width / PANGO_SCALE), (int)(height / PANGO_SCALE));
+ uint32_t pad = entry->selection_background_padding;
+ cairo_translate(cr, -pad, 0);
+ cairo_rectangle(cr, 0, 0, (int)(width / PANGO_SCALE) + pad * 2, (int)(height / PANGO_SCALE));
+ cairo_translate(cr, pad, 0);
cairo_fill(cr);
cairo_restore(cr);
cairo_paint(cr);
diff --git a/src/main.c b/src/main.c
index 0587304..9a3ace1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -687,6 +687,8 @@ static void usage()
" --prompt-text <string> Prompt text.\n"
" --num-results <n> Maximum number of results to display.\n"
" --selection-color <color> Color of selected result.\n"
+" --selection-padding <px> Extra horizontal padding for selected\n"
+" result background.\n"
" --selection-background <color> Color of selected result background.\n"
" --result-spacing <px> Spacing between results.\n"
" --min-input-width <px> Minimum input width in horizontal mode.\n"
@@ -727,6 +729,7 @@ const struct option long_options[] = {
{"font-size", required_argument, NULL, 0},
{"num-results", required_argument, NULL, 0},
{"selection-color", required_argument, NULL, 0},
+ {"selection-padding", required_argument, NULL, 0},
{"selection-background", required_argument, NULL, 0},
{"outline-width", required_argument, NULL, 0},
{"outline-color", required_argument, NULL, 0},