mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 03:11:27 +00:00
cmd_output: Use list_seq_find() to find matching config
This commit is contained in:
parent
88f372a22a
commit
7d82cd9c0a
|
@ -98,6 +98,7 @@ bool read_config(FILE *file, bool is_active);
|
||||||
* Does variable replacement for a string based on the config's currently loaded variables.
|
* Does variable replacement for a string based on the config's currently loaded variables.
|
||||||
*/
|
*/
|
||||||
char *do_var_replacement(char *str);
|
char *do_var_replacement(char *str);
|
||||||
|
int output_name_cmp(const void *item, const void *data);;
|
||||||
/** Sets up a WLC output handle based on a given output_config.
|
/** Sets up a WLC output handle based on a given output_config.
|
||||||
*/
|
*/
|
||||||
void apply_output_config(struct output_config *oc, swayc_t *output);
|
void apply_output_config(struct output_config *oc, swayc_t *output);
|
||||||
|
|
|
@ -804,14 +804,12 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < config->output_configs->length; ++i) {
|
i = list_seq_find(config->output_configs, output_name_cmp, name);
|
||||||
|
if (i >= 0) {
|
||||||
|
// replace existing config
|
||||||
struct output_config *oc = config->output_configs->items[i];
|
struct output_config *oc = config->output_configs->items[i];
|
||||||
if (strcmp(oc->name, output->name) == 0) {
|
list_del(config->output_configs, i);
|
||||||
// replace existing config
|
free_output_config(oc);
|
||||||
list_del(config->output_configs, i);
|
|
||||||
free_output_config(oc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
list_add(config->output_configs, output);
|
list_add(config->output_configs, output);
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,14 @@ bool read_config(FILE *file, bool is_active) {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int output_name_cmp(const void *item, const void *data)
|
||||||
|
{
|
||||||
|
const struct output_config *output = item;
|
||||||
|
const char *name = data;
|
||||||
|
|
||||||
|
return strcmp(output->name, name);
|
||||||
|
}
|
||||||
|
|
||||||
void apply_output_config(struct output_config *oc, swayc_t *output) {
|
void apply_output_config(struct output_config *oc, swayc_t *output) {
|
||||||
if (oc && oc->width > 0 && oc->height > 0) {
|
if (oc && oc->width > 0 && oc->height > 0) {
|
||||||
output->width = oc->width;
|
output->width = oc->width;
|
||||||
|
|
Loading…
Reference in a new issue