diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-25 21:07:59 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-25 21:07:59 +1000 |
commit | db38b9bbf3cce4083c538209a7ce5ef1a1cf5f3f (patch) | |
tree | 3ee9f0c2bf76907b2854bf6ba2be8ab124b74fb9 /sway/tree/view.c | |
parent | Merge pull request #2028 from RyanDwyer/fix-move-workspace (diff) | |
download | sway-db38b9bbf3cce4083c538209a7ce5ef1a1cf5f3f.tar.gz sway-db38b9bbf3cce4083c538209a7ce5ef1a1cf5f3f.tar.zst sway-db38b9bbf3cce4083c538209a7ce5ef1a1cf5f3f.zip |
Clean up container title functions
* Add and use lenient_strcat and lenient_strncat functions
* Rename `concatenate_child_titles` function as that's no longer what it
does
* Rename `container_notify_child_title_changed` because we only need to
notify that the tree structure has changed, not titles
* Don't notify parents when a child changes its title
* Update ancestor titles when changing a container's layout
* Eg. create nested tabs and change the inner container to stacking
* No need to store tree presentation in both container->name and
formatted_title
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 07157818..2f718a73 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "sway/tree/workspace.h" | 17 | #include "sway/tree/workspace.h" |
18 | #include "sway/config.h" | 18 | #include "sway/config.h" |
19 | #include "pango.h" | 19 | #include "pango.h" |
20 | #include "stringop.h" | ||
20 | 21 | ||
21 | void view_init(struct sway_view *view, enum sway_view_type type, | 22 | void view_init(struct sway_view *view, enum sway_view_type type, |
22 | const struct sway_view_impl *impl) { | 23 | const struct sway_view_impl *impl) { |
@@ -470,7 +471,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
470 | input_manager_set_focus(input_manager, cont); | 471 | input_manager_set_focus(input_manager, cont); |
471 | 472 | ||
472 | view_update_title(view, false); | 473 | view_update_title(view, false); |
473 | container_notify_child_title_changed(view->swayc->parent); | 474 | container_notify_subtree_changed(view->swayc->parent); |
474 | view_execute_criteria(view); | 475 | view_execute_criteria(view); |
475 | 476 | ||
476 | container_damage_whole(cont); | 477 | container_damage_whole(cont); |
@@ -661,49 +662,35 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { | |||
661 | char *format = view->title_format; | 662 | char *format = view->title_format; |
662 | char *next = strchr(format, '%'); | 663 | char *next = strchr(format, '%'); |
663 | while (next) { | 664 | while (next) { |
664 | if (buffer) { | 665 | // Copy everything up to the % |
665 | // Copy everything up to the % | 666 | lenient_strncat(buffer, format, next - format); |
666 | strncat(buffer, format, next - format); | ||
667 | } | ||
668 | len += next - format; | 667 | len += next - format; |
669 | format = next; | 668 | format = next; |
670 | 669 | ||
671 | if (strncmp(next, "%title", 6) == 0) { | 670 | if (strncmp(next, "%title", 6) == 0) { |
672 | if (buffer && title) { | 671 | lenient_strcat(buffer, title); |
673 | strcat(buffer, title); | ||
674 | } | ||
675 | len += title_len; | 672 | len += title_len; |
676 | format += 6; | 673 | format += 6; |
677 | } else if (strncmp(next, "%class", 6) == 0) { | 674 | } else if (strncmp(next, "%class", 6) == 0) { |
678 | if (buffer && class) { | 675 | lenient_strcat(buffer, class); |
679 | strcat(buffer, class); | ||
680 | } | ||
681 | len += class_len; | 676 | len += class_len; |
682 | format += 6; | 677 | format += 6; |
683 | } else if (strncmp(next, "%instance", 9) == 0) { | 678 | } else if (strncmp(next, "%instance", 9) == 0) { |
684 | if (buffer && instance) { | 679 | lenient_strcat(buffer, instance); |
685 | strcat(buffer, instance); | ||
686 | } | ||
687 | len += instance_len; | 680 | len += instance_len; |
688 | format += 9; | 681 | format += 9; |
689 | } else if (strncmp(next, "%shell", 6) == 0) { | 682 | } else if (strncmp(next, "%shell", 6) == 0) { |
690 | if (buffer) { | 683 | lenient_strcat(buffer, shell); |
691 | strcat(buffer, shell); | ||
692 | } | ||
693 | len += shell_len; | 684 | len += shell_len; |
694 | format += 6; | 685 | format += 6; |
695 | } else { | 686 | } else { |
696 | if (buffer) { | 687 | lenient_strcat(buffer, "%"); |
697 | strcat(buffer, "%"); | ||
698 | } | ||
699 | ++format; | 688 | ++format; |
700 | ++len; | 689 | ++len; |
701 | } | 690 | } |
702 | next = strchr(format, '%'); | 691 | next = strchr(format, '%'); |
703 | } | 692 | } |
704 | if (buffer) { | 693 | lenient_strcat(buffer, format); |
705 | strcat(buffer, format); | ||
706 | } | ||
707 | len += strlen(format); | 694 | len += strlen(format); |
708 | 695 | ||
709 | return len; | 696 | return len; |
@@ -759,7 +746,6 @@ void view_update_title(struct sway_view *view, bool force) { | |||
759 | } | 746 | } |
760 | container_calculate_title_height(view->swayc); | 747 | container_calculate_title_height(view->swayc); |
761 | container_update_title_textures(view->swayc); | 748 | container_update_title_textures(view->swayc); |
762 | container_notify_child_title_changed(view->swayc->parent); | ||
763 | config_update_font_height(false); | 749 | config_update_font_height(false); |
764 | } | 750 | } |
765 | 751 | ||