diff options
author | Brian Ashworth <RedSoxFan@users.noreply.github.com> | 2018-05-14 00:28:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-14 00:28:21 -0400 |
commit | 34b864fb1752fde2528db6aa86d53c23412a8f43 (patch) | |
tree | b387f1e1eb8f8fc16faeb4bf24a0ab6e8ba5787c /sway/tree/view.c | |
parent | Fix titles and detect edges for hide_edge_borders (diff) | |
parent | Actually fix swayidle (diff) | |
download | sway-34b864fb1752fde2528db6aa86d53c23412a8f43.tar.gz sway-34b864fb1752fde2528db6aa86d53c23412a8f43.tar.zst sway-34b864fb1752fde2528db6aa86d53c23412a8f43.zip |
Merge branch 'master' into fix-1975
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index a48a6619..a485e902 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include "sway/tree/layout.h" | 14 | #include "sway/tree/layout.h" |
15 | #include "sway/tree/view.h" | 15 | #include "sway/tree/view.h" |
16 | #include "sway/tree/workspace.h" | 16 | #include "sway/tree/workspace.h" |
17 | #include "sway/config.h" | ||
18 | #include "pango.h" | ||
17 | 19 | ||
18 | void view_init(struct sway_view *view, enum sway_view_type type, | 20 | void view_init(struct sway_view *view, enum sway_view_type type, |
19 | const struct sway_view_impl *impl) { | 21 | const struct sway_view_impl *impl) { |
@@ -74,6 +76,8 @@ const char *view_get_type(struct sway_view *view) { | |||
74 | return "wl_shell"; | 76 | return "wl_shell"; |
75 | case SWAY_VIEW_XDG_SHELL_V6: | 77 | case SWAY_VIEW_XDG_SHELL_V6: |
76 | return "xdg_shell_v6"; | 78 | return "xdg_shell_v6"; |
79 | case SWAY_VIEW_XDG_SHELL: | ||
80 | return "xdg_shell"; | ||
77 | case SWAY_VIEW_XWAYLAND: | 81 | case SWAY_VIEW_XWAYLAND: |
78 | return "xwayland"; | 82 | return "xwayland"; |
79 | } | 83 | } |
@@ -607,6 +611,19 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { | |||
607 | return len; | 611 | return len; |
608 | } | 612 | } |
609 | 613 | ||
614 | static char *escape_title(char *buffer) { | ||
615 | int length = escape_markup_text(buffer, NULL, 0); | ||
616 | char *escaped_title = calloc(length + 1, sizeof(char)); | ||
617 | int result = escape_markup_text(buffer, escaped_title, length); | ||
618 | if (result != length) { | ||
619 | wlr_log(L_ERROR, "Could not escape title: %s", buffer); | ||
620 | free(escaped_title); | ||
621 | return buffer; | ||
622 | } | ||
623 | free(buffer); | ||
624 | return escaped_title; | ||
625 | } | ||
626 | |||
610 | void view_update_title(struct sway_view *view, bool force) { | 627 | void view_update_title(struct sway_view *view, bool force) { |
611 | if (!view->swayc) { | 628 | if (!view->swayc) { |
612 | return; | 629 | return; |
@@ -626,11 +643,15 @@ void view_update_title(struct sway_view *view, bool force) { | |||
626 | free(view->swayc->formatted_title); | 643 | free(view->swayc->formatted_title); |
627 | if (title) { | 644 | if (title) { |
628 | size_t len = parse_title_format(view, NULL); | 645 | size_t len = parse_title_format(view, NULL); |
629 | char *buffer = calloc(len + 1, 1); | 646 | char *buffer = calloc(len + 1, sizeof(char)); |
630 | if (!sway_assert(buffer, "Unable to allocate title string")) { | 647 | if (!sway_assert(buffer, "Unable to allocate title string")) { |
631 | return; | 648 | return; |
632 | } | 649 | } |
633 | parse_title_format(view, buffer); | 650 | parse_title_format(view, buffer); |
651 | // now we have the title, but needs to be escaped when using pango markup | ||
652 | if (config->pango_markup) { | ||
653 | buffer = escape_title(buffer); | ||
654 | } | ||
634 | 655 | ||
635 | view->swayc->name = strdup(title); | 656 | view->swayc->name = strdup(title); |
636 | view->swayc->formatted_title = buffer; | 657 | view->swayc->formatted_title = buffer; |