diff --git a/sway/commands/primary_selection.c b/sway/commands/primary_selection.c index 585b079d..9e2689c2 100644 --- a/sway/commands/primary_selection.c +++ b/sway/commands/primary_selection.c @@ -12,12 +12,14 @@ struct cmd_results *cmd_primary_selection(int argc, char **argv) { bool primary_selection = parse_boolean(argv[0], true); + // config->primary_selection is reset to the previous value on reload in + // load_main_config() if (config->reloading && config->primary_selection != primary_selection) { return cmd_results_new(CMD_FAILURE, "primary_selection can only be enabled/disabled at launch"); } - config->primary_selection = parse_boolean(argv[0], true); + config->primary_selection = primary_selection; return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/commands/xwayland.c b/sway/commands/xwayland.c index 6ca26923..584a8e3a 100644 --- a/sway/commands/xwayland.c +++ b/sway/commands/xwayland.c @@ -20,6 +20,8 @@ struct cmd_results *cmd_xwayland(int argc, char **argv) { xwayland = XWAYLAND_MODE_DISABLED; } + // config->xwayland is reset to the previous value on reload in + // load_main_config() if (config->reloading && config->xwayland != xwayland) { return cmd_results_new(CMD_FAILURE, "xwayland can only be enabled/disabled at launch"); diff --git a/sway/config.c b/sway/config.c index 4b51dc73..d7b6b693 100644 --- a/sway/config.c +++ b/sway/config.c @@ -475,6 +475,11 @@ bool load_main_config(const char *file, bool is_active, bool validating) { old_config->xwayland ? "enabled" : "disabled"); config->xwayland = old_config->xwayland; + // primary_selection can only be enabled/disabled at launch + sway_log(SWAY_DEBUG, "primary_selection will remain %s", + old_config->primary_selection ? "enabled" : "disabled"); + config->primary_selection = old_config->primary_selection; + if (!config->validating) { if (old_config->swaybg_client != NULL) { wl_client_destroy(old_config->swaybg_client); @@ -494,56 +499,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) { config->reading = true; - // Read security configs - // TODO: Security - bool success = true; - /* - DIR *dir = opendir(SYSCONFDIR "/sway/security.d"); - if (!dir) { - sway_log(SWAY_ERROR, - "%s does not exist, sway will have no security configuration" - " and will probably be broken", SYSCONFDIR "/sway/security.d"); - } else { - list_t *secconfigs = create_list(); - char *base = SYSCONFDIR "/sway/security.d/"; - struct dirent *ent = readdir(dir); - struct stat s; - while (ent != NULL) { - char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1); - strcpy(_path, base); - strcat(_path, ent->d_name); - lstat(_path, &s); - if (S_ISREG(s.st_mode) && ent->d_name[0] != '.') { - list_add(secconfigs, _path); - } - else { - free(_path); - } - ent = readdir(dir); - } - closedir(dir); - - list_qsort(secconfigs, qstrcmp); - for (int i = 0; i < secconfigs->length; ++i) { - char *_path = secconfigs->items[i]; - if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || - (((s.st_mode & 0777) != 0644) && - (s.st_mode & 0777) != 0444)) { - sway_log(SWAY_ERROR, - "Refusing to load %s - it must be owned by root " - "and mode 644 or 444", _path); - success = false; - } else { - success = success && load_config(_path, config); - } - } - - list_free_items_and_destroy(secconfigs); - } - */ - - success = success && load_config(path, config, - &config->swaynag_config_errors); + bool success = load_config(path, config, &config->swaynag_config_errors); if (validating) { free_config(config); diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c index b9a77d94..664db40e 100644 --- a/sway/sway_text_node.c +++ b/sway/sway_text_node.c @@ -58,11 +58,11 @@ struct text_buffer { }; static int get_text_width(struct sway_text_node *props) { + int width = props->width; if (props->max_width) { - return MIN(props->max_width, props->width); + width = MIN(width, props->max_width); } - - return props->width; + return MAX(width, 0); } static void update_source_box(struct text_buffer *buffer) {