Merge branch 'master' into feature/swap-workspace

This commit is contained in:
Fabian Specht 2024-02-05 12:28:51 +01:00 committed by GitHub
commit 5c335716f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 54 deletions

View file

@ -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);
}

View file

@ -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");

View file

@ -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);

View file

@ -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) {