diff options
-rw-r--r-- | include/sway/config.h | 7 | ||||
-rw-r--r-- | include/sway/tree/view.h | 1 | ||||
-rw-r--r-- | sway/commands/bind.c | 8 | ||||
-rw-r--r-- | sway/commands/output/background.c | 7 | ||||
-rw-r--r-- | sway/config.c | 28 | ||||
-rw-r--r-- | sway/tree/view.c | 12 |
6 files changed, 53 insertions, 10 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 1ff9a104..d02b0d63 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -425,6 +425,8 @@ struct sway_config { | |||
425 | list_t *config_chain; | 425 | list_t *config_chain; |
426 | const char *current_config_path; | 426 | const char *current_config_path; |
427 | const char *current_config; | 427 | const char *current_config; |
428 | int current_config_line_number; | ||
429 | char *current_config_line; | ||
428 | 430 | ||
429 | enum sway_container_border border; | 431 | enum sway_container_border border; |
430 | enum sway_container_border floating_border; | 432 | enum sway_container_border floating_border; |
@@ -490,6 +492,11 @@ bool read_config(FILE *file, struct sway_config *config, | |||
490 | struct swaynag_instance *swaynag); | 492 | struct swaynag_instance *swaynag); |
491 | 493 | ||
492 | /** | 494 | /** |
495 | * Adds a warning entry to the swaynag instance used for errors. | ||
496 | */ | ||
497 | void config_add_swaynag_warning(char *fmt, ...); | ||
498 | |||
499 | /** | ||
493 | * Free config struct | 500 | * Free config struct |
494 | */ | 501 | */ |
495 | void free_config(struct sway_config *config); | 502 | void free_config(struct sway_config *config); |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index d74f1bc9..5cc9777b 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -195,6 +195,7 @@ struct sway_view_child { | |||
195 | 195 | ||
196 | struct sway_view *view; | 196 | struct sway_view *view; |
197 | struct wlr_surface *surface; | 197 | struct wlr_surface *surface; |
198 | bool mapped; | ||
198 | 199 | ||
199 | struct wl_listener surface_commit; | 200 | struct wl_listener surface_commit; |
200 | struct wl_listener surface_new_subsurface; | 201 | struct wl_listener surface_new_subsurface; |
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 34881b0f..9112815f 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c | |||
@@ -255,8 +255,12 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, | |||
255 | for (int i = 0; i < mode_bindings->length; ++i) { | 255 | for (int i = 0; i < mode_bindings->length; ++i) { |
256 | struct sway_binding *config_binding = mode_bindings->items[i]; | 256 | struct sway_binding *config_binding = mode_bindings->items[i]; |
257 | if (binding_key_compare(binding, config_binding)) { | 257 | if (binding_key_compare(binding, config_binding)) { |
258 | wlr_log(WLR_DEBUG, "overwriting old binding with command '%s'", | 258 | wlr_log(WLR_INFO, "Overwriting binding '%s' for device '%s' " |
259 | config_binding->command); | 259 | "from `%s` to `%s`", argv[0], binding->input, |
260 | binding->command, config_binding->command); | ||
261 | config_add_swaynag_warning("Overwriting binding '%s' for device " | ||
262 | "'%s' to `%s` from `%s`", argv[0], binding->input, | ||
263 | binding->command, config_binding->command); | ||
260 | free_sway_binding(config_binding); | 264 | free_sway_binding(config_binding); |
261 | mode_bindings->items[i] = binding; | 265 | mode_bindings->items[i] = binding; |
262 | overwritten = true; | 266 | overwritten = true; |
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c index 30fb47c4..2cd1b76a 100644 --- a/sway/commands/output/background.c +++ b/sway/commands/output/background.c | |||
@@ -116,11 +116,8 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { | |||
116 | if (!can_access) { | 116 | if (!can_access) { |
117 | wlr_log(WLR_ERROR, "Unable to access background file '%s': %s", | 117 | wlr_log(WLR_ERROR, "Unable to access background file '%s': %s", |
118 | src, strerror(errno)); | 118 | src, strerror(errno)); |
119 | if (config->reading && !config->validating) { | 119 | config_add_swaynag_warning("Unable to access background file '%s'", |
120 | swaynag_log(config->swaynag_command, | 120 | src); |
121 | &config->swaynag_config_errors, | ||
122 | "Unable to access background file '%s'", src); | ||
123 | } | ||
124 | free(src); | 121 | free(src); |
125 | } else { | 122 | } else { |
126 | // Escape double quotes in the final path for swaybg | 123 | // Escape double quotes in the final path for swaybg |
diff --git a/sway/config.c b/sway/config.c index ed288060..46322374 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -700,6 +700,8 @@ bool read_config(FILE *file, struct sway_config *config, | |||
700 | free(line); | 700 | free(line); |
701 | return false; | 701 | return false; |
702 | } | 702 | } |
703 | config->current_config_line_number = line_number; | ||
704 | config->current_config_line = line; | ||
703 | struct cmd_results *res; | 705 | struct cmd_results *res; |
704 | if (block && strcmp(block, "<commands>") == 0) { | 706 | if (block && strcmp(block, "<commands>") == 0) { |
705 | // Special case | 707 | // Special case |
@@ -761,10 +763,36 @@ bool read_config(FILE *file, struct sway_config *config, | |||
761 | } | 763 | } |
762 | list_foreach(stack, free); | 764 | list_foreach(stack, free); |
763 | list_free(stack); | 765 | list_free(stack); |
766 | config->current_config_line_number = 0; | ||
767 | config->current_config_line = NULL; | ||
764 | 768 | ||
765 | return success; | 769 | return success; |
766 | } | 770 | } |
767 | 771 | ||
772 | void config_add_swaynag_warning(char *fmt, ...) { | ||
773 | if (config->reading && !config->validating) { | ||
774 | va_list args; | ||
775 | va_start(args, fmt); | ||
776 | size_t length = vsnprintf(NULL, 0, fmt, args) + 1; | ||
777 | va_end(args); | ||
778 | |||
779 | char *temp = malloc(length + 1); | ||
780 | if (!temp) { | ||
781 | wlr_log(WLR_ERROR, "Failed to allocate buffer for warning."); | ||
782 | return; | ||
783 | } | ||
784 | |||
785 | va_start(args, fmt); | ||
786 | vsnprintf(temp, length, fmt, args); | ||
787 | va_end(args); | ||
788 | |||
789 | swaynag_log(config->swaynag_command, &config->swaynag_config_errors, | ||
790 | "Warning on line %i (%s) '%s': %s", | ||
791 | config->current_config_line_number, config->current_config_path, | ||
792 | config->current_config_line, temp); | ||
793 | } | ||
794 | } | ||
795 | |||
768 | char *do_var_replacement(char *str) { | 796 | char *do_var_replacement(char *str) { |
769 | int i; | 797 | int i; |
770 | char *find = str; | 798 | char *find = str; |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 0edefc8e..4c46d0e9 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -711,8 +711,6 @@ static const struct sway_view_child_impl subsurface_impl = { | |||
711 | .destroy = subsurface_destroy, | 711 | .destroy = subsurface_destroy, |
712 | }; | 712 | }; |
713 | 713 | ||
714 | static void view_child_damage(struct sway_view_child *child, bool whole); | ||
715 | |||
716 | static void subsurface_handle_destroy(struct wl_listener *listener, | 714 | static void subsurface_handle_destroy(struct wl_listener *listener, |
717 | void *data) { | 715 | void *data) { |
718 | struct sway_subsurface *subsurface = | 716 | struct sway_subsurface *subsurface = |
@@ -721,6 +719,8 @@ static void subsurface_handle_destroy(struct wl_listener *listener, | |||
721 | view_child_destroy(child); | 719 | view_child_destroy(child); |
722 | } | 720 | } |
723 | 721 | ||
722 | static void view_child_damage(struct sway_view_child *child, bool whole); | ||
723 | |||
724 | static void view_subsurface_create(struct sway_view *view, | 724 | static void view_subsurface_create(struct sway_view *view, |
725 | struct wlr_subsurface *wlr_subsurface) { | 725 | struct wlr_subsurface *wlr_subsurface) { |
726 | struct sway_subsurface *subsurface = | 726 | struct sway_subsurface *subsurface = |
@@ -734,6 +734,9 @@ static void view_subsurface_create(struct sway_view *view, | |||
734 | 734 | ||
735 | wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy); | 735 | wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy); |
736 | subsurface->destroy.notify = subsurface_handle_destroy; | 736 | subsurface->destroy.notify = subsurface_handle_destroy; |
737 | |||
738 | subsurface->child.mapped = true; | ||
739 | view_child_damage(&subsurface->child, true); | ||
737 | } | 740 | } |
738 | 741 | ||
739 | static void view_child_damage(struct sway_view_child *child, bool whole) { | 742 | static void view_child_damage(struct sway_view_child *child, bool whole) { |
@@ -778,6 +781,7 @@ static void view_child_handle_surface_map(struct wl_listener *listener, | |||
778 | void *data) { | 781 | void *data) { |
779 | struct sway_view_child *child = | 782 | struct sway_view_child *child = |
780 | wl_container_of(listener, child, surface_map); | 783 | wl_container_of(listener, child, surface_map); |
784 | child->mapped = true; | ||
781 | view_child_damage(child, true); | 785 | view_child_damage(child, true); |
782 | } | 786 | } |
783 | 787 | ||
@@ -786,6 +790,7 @@ static void view_child_handle_surface_unmap(struct wl_listener *listener, | |||
786 | struct sway_view_child *child = | 790 | struct sway_view_child *child = |
787 | wl_container_of(listener, child, surface_unmap); | 791 | wl_container_of(listener, child, surface_unmap); |
788 | view_child_damage(child, true); | 792 | view_child_damage(child, true); |
793 | child->mapped = false; | ||
789 | } | 794 | } |
790 | 795 | ||
791 | void view_child_init(struct sway_view_child *child, | 796 | void view_child_init(struct sway_view_child *child, |
@@ -804,6 +809,7 @@ void view_child_init(struct sway_view_child *child, | |||
804 | wl_signal_add(&surface->events.destroy, &child->surface_destroy); | 809 | wl_signal_add(&surface->events.destroy, &child->surface_destroy); |
805 | child->surface_destroy.notify = view_child_handle_surface_destroy; | 810 | child->surface_destroy.notify = view_child_handle_surface_destroy; |
806 | 811 | ||
812 | // Not all child views have a map/unmap event | ||
807 | child->surface_map.notify = view_child_handle_surface_map; | 813 | child->surface_map.notify = view_child_handle_surface_map; |
808 | child->surface_unmap.notify = view_child_handle_surface_unmap; | 814 | child->surface_unmap.notify = view_child_handle_surface_unmap; |
809 | 815 | ||
@@ -814,7 +820,7 @@ void view_child_init(struct sway_view_child *child, | |||
814 | } | 820 | } |
815 | 821 | ||
816 | void view_child_destroy(struct sway_view_child *child) { | 822 | void view_child_destroy(struct sway_view_child *child) { |
817 | if (child->view->container != NULL) { | 823 | if (child->mapped && child->view->container != NULL) { |
818 | view_child_damage(child, true); | 824 | view_child_damage(child, true); |
819 | } | 825 | } |
820 | 826 | ||