mirror of
https://github.com/swaywm/sway.git
synced 2025-01-13 07:46:44 +01:00
config/output: return merged config in merge_id_on_name()
Fixes the case where store_output_config() is called with an output config referring to a name, and an existing config exists with an identifier. The existing config would get ignored.
This commit is contained in:
parent
3ef5abd405
commit
995465e0cb
1 changed files with 36 additions and 28 deletions
|
@ -151,10 +151,10 @@ static void merge_wildcard_on_all(struct output_config *wildcard) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void merge_id_on_name(struct output_config *oc) {
|
static struct output_config *merge_id_on_name(struct output_config *oc) {
|
||||||
struct sway_output *output = all_output_by_name_or_id(oc->name);
|
struct sway_output *output = all_output_by_name_or_id(oc->name);
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
return;
|
return oc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *name = output->wlr_output->name;
|
const char *name = output->wlr_output->name;
|
||||||
|
@ -163,29 +163,38 @@ static void merge_id_on_name(struct output_config *oc) {
|
||||||
|
|
||||||
char *id_on_name = format_str("%s on %s", id, name);
|
char *id_on_name = format_str("%s on %s", id, name);
|
||||||
if (!id_on_name) {
|
if (!id_on_name) {
|
||||||
return;
|
return oc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct output_config *ion_oc;
|
||||||
int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name);
|
int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
sway_log(SWAY_DEBUG, "Merging on top of existing id on name config");
|
sway_log(SWAY_DEBUG, "Merging on top of existing id on name config");
|
||||||
merge_output_config(config->output_configs->items[i], oc);
|
ion_oc = config->output_configs->items[i];
|
||||||
} else {
|
} else {
|
||||||
// If both a name and identifier config, exist generate an id on name
|
// If both a name and identifier config, exist generate an id on name
|
||||||
int ni = list_seq_find(config->output_configs, output_name_cmp, name);
|
int ni = list_seq_find(config->output_configs, output_name_cmp, name);
|
||||||
int ii = list_seq_find(config->output_configs, output_name_cmp, id);
|
int ii = list_seq_find(config->output_configs, output_name_cmp, id);
|
||||||
if ((ni >= 0 && ii >= 0) || (ni >= 0 && strcmp(oc->name, id) == 0)
|
bool has_name_config = ni >= 0 || strcmp(oc->name, name) == 0;
|
||||||
|| (ii >= 0 && strcmp(oc->name, name) == 0)) {
|
bool has_id_config = ii >= 0 || strcmp(oc->name, id) == 0;
|
||||||
struct output_config *ion_oc = new_output_config(id_on_name);
|
if (!has_name_config || !has_id_config) {
|
||||||
|
return oc;
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_log(SWAY_DEBUG, "Creating new id on name config");
|
||||||
|
ion_oc = new_output_config(id_on_name);
|
||||||
if (ni >= 0) {
|
if (ni >= 0) {
|
||||||
merge_output_config(ion_oc, config->output_configs->items[ni]);
|
merge_output_config(ion_oc, config->output_configs->items[ni]);
|
||||||
}
|
}
|
||||||
if (ii >= 0) {
|
if (ii >= 0) {
|
||||||
merge_output_config(ion_oc, config->output_configs->items[ii]);
|
merge_output_config(ion_oc, config->output_configs->items[ii]);
|
||||||
}
|
}
|
||||||
merge_output_config(ion_oc, oc);
|
|
||||||
list_add(config->output_configs, ion_oc);
|
list_add(config->output_configs, ion_oc);
|
||||||
sway_log(SWAY_DEBUG, "Generated id on name output config \"%s\""
|
}
|
||||||
|
free(id_on_name);
|
||||||
|
|
||||||
|
merge_output_config(ion_oc, oc);
|
||||||
|
sway_log(SWAY_DEBUG, "Stored id on name output config \"%s\""
|
||||||
" (enabled: %d) (%dx%d@%fHz position %d,%d scale %f "
|
" (enabled: %d) (%dx%d@%fHz position %d,%d scale %f "
|
||||||
"transform %d) (bg %s %s) (power %d) (max render time: %d)",
|
"transform %d) (bg %s %s) (power %d) (max render time: %d)",
|
||||||
ion_oc->name, ion_oc->enabled, ion_oc->width, ion_oc->height,
|
ion_oc->name, ion_oc->enabled, ion_oc->width, ion_oc->height,
|
||||||
|
@ -193,18 +202,11 @@ static void merge_id_on_name(struct output_config *oc) {
|
||||||
ion_oc->transform, ion_oc->background,
|
ion_oc->transform, ion_oc->background,
|
||||||
ion_oc->background_option, ion_oc->power,
|
ion_oc->background_option, ion_oc->power,
|
||||||
ion_oc->max_render_time);
|
ion_oc->max_render_time);
|
||||||
}
|
return ion_oc;
|
||||||
}
|
|
||||||
free(id_on_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct output_config *store_output_config(struct output_config *oc) {
|
struct output_config *store_output_config(struct output_config *oc) {
|
||||||
bool wildcard = strcmp(oc->name, "*") == 0;
|
bool wildcard = strcmp(oc->name, "*") == 0;
|
||||||
if (wildcard) {
|
|
||||||
merge_wildcard_on_all(oc);
|
|
||||||
} else {
|
|
||||||
merge_id_on_name(oc);
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = list_seq_find(config->output_configs, output_name_cmp, oc->name);
|
int i = list_seq_find(config->output_configs, output_name_cmp, oc->name);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
|
@ -239,6 +241,12 @@ struct output_config *store_output_config(struct output_config *oc) {
|
||||||
oc->transform, oc->background, oc->background_option, oc->power,
|
oc->transform, oc->background, oc->background_option, oc->power,
|
||||||
oc->max_render_time);
|
oc->max_render_time);
|
||||||
|
|
||||||
|
if (wildcard) {
|
||||||
|
merge_wildcard_on_all(oc);
|
||||||
|
} else {
|
||||||
|
oc = merge_id_on_name(oc);
|
||||||
|
}
|
||||||
|
|
||||||
return oc;
|
return oc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue