aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorArthur Gautier <baloo@gandi.net>2018-11-23 17:42:18 -0800
committerArthur Gautier <baloo@gandi.net>2018-11-24 08:26:43 -0800
commitcaee2dff03fc007dc46cf121e013f5347ac46ba9 (patch)
treeb8fa2f22a25ab6e95d15398a6c57ffb38f62f4a3 /sway/tree
parent77554f545e1b386ae0f4896bdf4c817524a15e60 (diff)
downloadsway-caee2dff03fc007dc46cf121e013f5347ac46ba9.tar.xz
fixes pango_markup support with title_format
The support for pango_markup was broken in title_format because the formated title was escaped. I think only the payload should be escaped. This commit fixes 789a877b379cd35c350610be62b971ae00feb542
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/view.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index d7110619..63bb8e26 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -824,12 +824,30 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
return NULL;
}
+static char *escape_pango_markup(const char *buffer) {
+ size_t length = escape_markup_text(buffer, NULL);
+ char *escaped_title = calloc(length + 1, sizeof(char));
+ escape_markup_text(buffer, escaped_title);
+ return escaped_title;
+}
+
static size_t append_prop(char *buffer, const char *value) {
if (!value) {
return 0;
}
- lenient_strcat(buffer, value);
- return strlen(value);
+ // if using pango_markup in font, we need to escape all markup char
+ // from values to avoid messing with pango markup
+ if (!config->pango_markup) {
+ char *escaped_value = escape_pango_markup(value);
+
+ lenient_strcat(buffer, escaped_value);
+ size_t len = strlen(escaped_value);
+ free(escaped_value);
+ return len;
+ } else {
+ lenient_strcat(buffer, value);
+ return strlen(value);
+ }
}
/**
@@ -882,14 +900,6 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) {
return len;
}
-static char *escape_title(char *buffer) {
- size_t length = escape_markup_text(buffer, NULL);
- char *escaped_title = calloc(length + 1, sizeof(char));
- escape_markup_text(buffer, escaped_title);
- free(buffer);
- return escaped_title;
-}
-
void view_update_title(struct sway_view *view, bool force) {
const char *title = view_get_title(view);
@@ -912,10 +922,6 @@ void view_update_title(struct sway_view *view, bool force) {
return;
}
parse_title_format(view, buffer);
- // now we have the title, but needs to be escaped when using pango markup
- if (config->pango_markup) {
- buffer = escape_title(buffer);
- }
view->container->title = strdup(title);
view->container->formatted_title = buffer;