aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/bind.c8
-rw-r--r--sway/commands/output/background.c7
-rw-r--r--sway/config.c28
-rw-r--r--sway/tree/view.c12
4 files changed, 45 insertions, 10 deletions
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
772void 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
768char *do_var_replacement(char *str) { 796char *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
714static void view_child_damage(struct sway_view_child *child, bool whole);
715
716static void subsurface_handle_destroy(struct wl_listener *listener, 714static 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
722static void view_child_damage(struct sway_view_child *child, bool whole);
723
724static void view_subsurface_create(struct sway_view *view, 724static 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
739static void view_child_damage(struct sway_view_child *child, bool whole) { 742static 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
791void view_child_init(struct sway_view_child *child, 796void 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
816void view_child_destroy(struct sway_view_child *child) { 822void 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