commit fcec5817483ba279b714acf6d81f5d7a3688b092
parent 04904ab9a57ff397702d6736523abeaa25d5d05b
Author: Simon Ser <contact@emersion.fr>
Date: Tue, 28 Feb 2023 12:51:59 +0100
Use output_match_name_or_id() in apply_output_config_to_outputs()
Diffstat:
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/sway/output.h b/include/sway/output.h
@@ -96,6 +96,9 @@ void output_damage_box(struct sway_output *output, struct wlr_box *box);
void output_damage_whole_container(struct sway_output *output,
struct sway_container *con);
+bool output_match_name_or_id(struct sway_output *output,
+ const char *name_or_id);
+
// this ONLY includes the enabled outputs
struct sway_output *output_by_name_or_id(const char *name_or_id);
diff --git a/sway/config/output.c b/sway/config/output.c
@@ -722,12 +722,11 @@ void apply_output_config_to_outputs(struct output_config *oc) {
// this is during startup then there will be no container and config
// will be applied during normal "new output" event from wlroots.
bool wildcard = strcmp(oc->name, "*") == 0;
- char id[128];
struct sway_output *sway_output, *tmp;
wl_list_for_each_safe(sway_output, tmp, &root->all_outputs, link) {
- char *name = sway_output->wlr_output->name;
- output_get_identifier(id, sizeof(id), sway_output);
- if (wildcard || !strcmp(name, oc->name) || !strcmp(id, oc->name)) {
+ if (output_match_name_or_id(sway_output, oc->name)) {
+ char id[128];
+ output_get_identifier(id, sizeof(id), sway_output);
struct output_config *current = get_output_config(id, sway_output);
if (!current) {
// No stored output config matched, apply oc directly
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
@@ -36,8 +36,12 @@
#include <wlr/types/wlr_drm_lease_v1.h>
#endif
-static bool output_match_name_or_id(struct sway_output *output,
+bool output_match_name_or_id(struct sway_output *output,
const char *name_or_id) {
+ if (strcmp(name_or_id, "*") == 0) {
+ return true;
+ }
+
char identifier[128];
output_get_identifier(identifier, sizeof(identifier), output);
return strcasecmp(identifier, name_or_id) == 0