From ba427a469a8394cb2fafa1a0602d6fd78c5c4d68 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Fri, 2 Feb 2024 00:35:53 +0100 Subject: [PATCH 1/5] Ensure get_text_width() returns a positive value Closes: https://github.com/swaywm/sway/issues/7940 --- sway/sway_text_node.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) { From 88e99fa84fc4537653adbd99aa0d11781c184774 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 3 Feb 2024 23:00:52 +0100 Subject: [PATCH 2/5] Drop old security config remnants --- sway/config.c | 51 +-------------------------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/sway/config.c b/sway/config.c index 4b51dc73..64ad9c70 100644 --- a/sway/config.c +++ b/sway/config.c @@ -494,56 +494,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); From 6b2aa8324681b2623f660c3851397761df9b70dc Mon Sep 17 00:00:00 2001 From: Violet Purcell Date: Sat, 3 Feb 2024 12:12:37 -0500 Subject: [PATCH 3/5] sway/config.c: only reset primary_selection at launch Otherwise, an error will be shown whenever reloading due to the value of primary_selection being reset to true. --- sway/config.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sway/config.c b/sway/config.c index 64ad9c70..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); From ecfef1348aeacc5a815a22c011ad09e5bb8ff49c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 5 Feb 2024 11:05:52 +0100 Subject: [PATCH 4/5] commands/primary_selection: drop duplicate bool parsing --- sway/commands/primary_selection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/commands/primary_selection.c b/sway/commands/primary_selection.c index 585b079d..3edef945 100644 --- a/sway/commands/primary_selection.c +++ b/sway/commands/primary_selection.c @@ -17,7 +17,7 @@ struct cmd_results *cmd_primary_selection(int argc, char **argv) { "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); } From f7a0f06dffb655a3335981c0ca010f25ac18c39d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 5 Feb 2024 11:07:33 +0100 Subject: [PATCH 5/5] commands: note how xwayland/primary_selection are reset on reload --- sway/commands/primary_selection.c | 2 ++ sway/commands/xwayland.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sway/commands/primary_selection.c b/sway/commands/primary_selection.c index 3edef945..9e2689c2 100644 --- a/sway/commands/primary_selection.c +++ b/sway/commands/primary_selection.c @@ -12,6 +12,8 @@ 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"); 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");