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 { list_t *config_chain; const char *current_config_path; const char *current_config; + int current_config_line_number; + char *current_config_line; enum sway_container_border border; enum sway_container_border floating_border; @@ -490,6 +492,11 @@ bool read_config(FILE *file, struct sway_config *config, struct swaynag_instance *swaynag); /** + * Adds a warning entry to the swaynag instance used for errors. + */ +void config_add_swaynag_warning(char *fmt, ...); + +/** * Free config struct */ 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 { struct sway_view *view; struct wlr_surface *surface; + bool mapped; struct wl_listener surface_commit; 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, for (int i = 0; i < mode_bindings->length; ++i) { struct sway_binding *config_binding = mode_bindings->items[i]; if (binding_key_compare(binding, config_binding)) { - wlr_log(WLR_DEBUG, "overwriting old binding with command '%s'", - config_binding->command); + wlr_log(WLR_INFO, "Overwriting binding '%s' for device '%s' " + "from `%s` to `%s`", argv[0], binding->input, + binding->command, config_binding->command); + config_add_swaynag_warning("Overwriting binding '%s' for device " + "'%s' to `%s` from `%s`", argv[0], binding->input, + binding->command, config_binding->command); free_sway_binding(config_binding); mode_bindings->items[i] = binding; 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) { if (!can_access) { wlr_log(WLR_ERROR, "Unable to access background file '%s': %s", src, strerror(errno)); - if (config->reading && !config->validating) { - swaynag_log(config->swaynag_command, - &config->swaynag_config_errors, - "Unable to access background file '%s'", src); - } + config_add_swaynag_warning("Unable to access background file '%s'", + src); free(src); } else { // 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, free(line); return false; } + config->current_config_line_number = line_number; + config->current_config_line = line; struct cmd_results *res; if (block && strcmp(block, "<commands>") == 0) { // Special case @@ -761,10 +763,36 @@ bool read_config(FILE *file, struct sway_config *config, } list_foreach(stack, free); list_free(stack); + config->current_config_line_number = 0; + config->current_config_line = NULL; return success; } +void config_add_swaynag_warning(char *fmt, ...) { + if (config->reading && !config->validating) { + va_list args; + va_start(args, fmt); + size_t length = vsnprintf(NULL, 0, fmt, args) + 1; + va_end(args); + + char *temp = malloc(length + 1); + if (!temp) { + wlr_log(WLR_ERROR, "Failed to allocate buffer for warning."); + return; + } + + va_start(args, fmt); + vsnprintf(temp, length, fmt, args); + va_end(args); + + swaynag_log(config->swaynag_command, &config->swaynag_config_errors, + "Warning on line %i (%s) '%s': %s", + config->current_config_line_number, config->current_config_path, + config->current_config_line, temp); + } +} + char *do_var_replacement(char *str) { int i; 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 = { .destroy = subsurface_destroy, }; -static void view_child_damage(struct sway_view_child *child, bool whole); - static void subsurface_handle_destroy(struct wl_listener *listener, void *data) { struct sway_subsurface *subsurface = @@ -721,6 +719,8 @@ static void subsurface_handle_destroy(struct wl_listener *listener, view_child_destroy(child); } +static void view_child_damage(struct sway_view_child *child, bool whole); + static void view_subsurface_create(struct sway_view *view, struct wlr_subsurface *wlr_subsurface) { struct sway_subsurface *subsurface = @@ -734,6 +734,9 @@ static void view_subsurface_create(struct sway_view *view, wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy); subsurface->destroy.notify = subsurface_handle_destroy; + + subsurface->child.mapped = true; + view_child_damage(&subsurface->child, true); } 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, void *data) { struct sway_view_child *child = wl_container_of(listener, child, surface_map); + child->mapped = true; view_child_damage(child, true); } @@ -786,6 +790,7 @@ static void view_child_handle_surface_unmap(struct wl_listener *listener, struct sway_view_child *child = wl_container_of(listener, child, surface_unmap); view_child_damage(child, true); + child->mapped = false; } void view_child_init(struct sway_view_child *child, @@ -804,6 +809,7 @@ void view_child_init(struct sway_view_child *child, wl_signal_add(&surface->events.destroy, &child->surface_destroy); child->surface_destroy.notify = view_child_handle_surface_destroy; + // Not all child views have a map/unmap event child->surface_map.notify = view_child_handle_surface_map; child->surface_unmap.notify = view_child_handle_surface_unmap; @@ -814,7 +820,7 @@ void view_child_init(struct sway_view_child *child, } void view_child_destroy(struct sway_view_child *child) { - if (child->view->container != NULL) { + if (child->mapped && child->view->container != NULL) { view_child_damage(child, true); } |