aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-05-13 16:16:16 +0100
committerGitHub <noreply@github.com>2018-05-13 16:16:16 +0100
commit4dfb0529f865e9af327ea0740ae97f3d3e4da6f1 (patch)
tree417eb755118e7dedae3badeeaa7d713f204994e2 /sway
parent61aa0937a75d23c0f2a00a8cea52c08bf69164dd (diff)
parent789a877b379cd35c350610be62b971ae00feb542 (diff)
Merge pull request #1935 from heghe/heghe/fix-pango-markup-crash
Fix crash when using pango markup font
Diffstat (limited to 'sway')
-rw-r--r--sway/tree/view.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e2cb8a7a..9bdc5198 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -14,6 +14,8 @@
#include "sway/tree/layout.h"
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
+#include "sway/config.h"
+#include "pango.h"
void view_init(struct sway_view *view, enum sway_view_type type,
const struct sway_view_impl *impl) {
@@ -612,6 +614,19 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) {
return len;
}
+static char *escape_title(char *buffer) {
+ int length = escape_markup_text(buffer, NULL, 0);
+ char *escaped_title = calloc(length + 1, sizeof(char));
+ int result = escape_markup_text(buffer, escaped_title, length);
+ if (result != length) {
+ wlr_log(L_ERROR, "Could not escape title: %s", buffer);
+ free(escaped_title);
+ return buffer;
+ }
+ free(buffer);
+ return escaped_title;
+}
+
void view_update_title(struct sway_view *view, bool force) {
if (!view->swayc) {
return;
@@ -631,11 +646,15 @@ void view_update_title(struct sway_view *view, bool force) {
free(view->swayc->formatted_title);
if (title) {
size_t len = parse_title_format(view, NULL);
- char *buffer = calloc(len + 1, 1);
+ char *buffer = calloc(len + 1, sizeof(char));
if (!sway_assert(buffer, "Unable to allocate title string")) {
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->swayc->name = strdup(title);
view->swayc->formatted_title = buffer;