aboutsummaryrefslogtreecommitdiff
path: root/sway/config
diff options
context:
space:
mode:
Diffstat (limited to 'sway/config')
-rw-r--r--sway/config/bar.c26
-rw-r--r--sway/config/input.c62
-rw-r--r--sway/config/output.c4
-rw-r--r--sway/config/seat.c2
4 files changed, 60 insertions, 34 deletions
diff --git a/sway/config/bar.c b/sway/config/bar.c
index f83b37d1..48a632fb 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -165,7 +165,7 @@ cleanup:
return NULL;
}
-void invoke_swaybar(struct bar_config *bar) {
+static void invoke_swaybar(struct bar_config *bar) {
// Pipe to communicate errors
int filedes[2];
if (pipe(filedes) == -1) {
@@ -219,27 +219,13 @@ void invoke_swaybar(struct bar_config *bar) {
close(filedes[1]);
}
-void load_swaybars() {
+void load_swaybars(void) {
for (int i = 0; i < config->bars->length; ++i) {
struct bar_config *bar = config->bars->items[i];
- bool apply = false;
- if (bar->outputs) {
- for (int j = 0; j < bar->outputs->length; ++j) {
- char *o = bar->outputs->items[j];
- if (!strcmp(o, "*") || output_by_name(o)) {
- apply = true;
- break;
- }
- }
- } else {
- apply = true;
- }
- if (apply) {
- if (bar->pid != 0) {
- terminate_swaybar(bar->pid);
- }
- wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
- invoke_swaybar(bar);
+ if (bar->pid != 0) {
+ terminate_swaybar(bar->pid);
}
+ wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
+ invoke_swaybar(bar);
}
}
diff --git a/sway/config/input.c b/sway/config/input.c
index ad5b96c8..794d5194 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -20,6 +20,7 @@ struct input_config *new_input_config(const char* identifier) {
input->tap = INT_MIN;
input->tap_button_map = INT_MIN;
+ input->drag = INT_MIN;
input->drag_lock = INT_MIN;
input->dwt = INT_MIN;
input->send_events = INT_MIN;
@@ -40,22 +41,24 @@ struct input_config *new_input_config(const char* identifier) {
}
void merge_input_config(struct input_config *dst, struct input_config *src) {
- if (src->identifier) {
- free(dst->identifier);
- dst->identifier = strdup(src->identifier);
- }
if (src->accel_profile != INT_MIN) {
dst->accel_profile = src->accel_profile;
}
if (src->click_method != INT_MIN) {
dst->click_method = src->click_method;
}
+ if (src->drag != INT_MIN) {
+ dst->drag = src->drag;
+ }
if (src->drag_lock != INT_MIN) {
dst->drag_lock = src->drag_lock;
}
if (src->dwt != INT_MIN) {
dst->dwt = src->dwt;
}
+ if (src->left_handed != INT_MIN) {
+ dst->left_handed = src->left_handed;
+ }
if (src->middle_emulation != INT_MIN) {
dst->middle_emulation = src->middle_emulation;
}
@@ -125,14 +128,51 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
}
}
-struct input_config *copy_input_config(struct input_config *ic) {
- struct input_config *copy = calloc(1, sizeof(struct input_config));
- if (copy == NULL) {
- wlr_log(WLR_ERROR, "could not allocate input config");
- return NULL;
+static void merge_wildcard_on_all(struct input_config *wildcard) {
+ for (int i = 0; i < config->input_configs->length; i++) {
+ struct input_config *ic = config->input_configs->items[i];
+ if (strcmp(wildcard->identifier, ic->identifier) != 0) {
+ wlr_log(WLR_DEBUG, "Merging input * config on %s", ic->identifier);
+ merge_input_config(ic, wildcard);
+ }
}
- merge_input_config(copy, ic);
- return copy;
+}
+
+struct input_config *store_input_config(struct input_config *ic) {
+ bool wildcard = strcmp(ic->identifier, "*") == 0;
+ if (wildcard) {
+ merge_wildcard_on_all(ic);
+ }
+
+ int i = list_seq_find(config->input_configs, input_identifier_cmp,
+ ic->identifier);
+ if (i >= 0) {
+ wlr_log(WLR_DEBUG, "Merging on top of existing input config");
+ struct input_config *current = config->input_configs->items[i];
+ merge_input_config(current, ic);
+ free_input_config(ic);
+ ic = current;
+ } else if (!wildcard) {
+ wlr_log(WLR_DEBUG, "Adding non-wildcard input config");
+ i = list_seq_find(config->input_configs, input_identifier_cmp, "*");
+ if (i >= 0) {
+ wlr_log(WLR_DEBUG, "Merging on top of input * config");
+ struct input_config *current = new_input_config(ic->identifier);
+ merge_input_config(current, config->input_configs->items[i]);
+ merge_input_config(current, ic);
+ free_input_config(ic);
+ ic = current;
+ }
+ list_add(config->input_configs, ic);
+ } else {
+ // New wildcard config. Just add it
+ wlr_log(WLR_DEBUG, "Adding input * config");
+ list_add(config->input_configs, ic);
+ }
+
+ wlr_log(WLR_DEBUG, "Config stored for input %s", ic->identifier);
+
+ return ic;
}
void free_input_config(struct input_config *ic) {
diff --git a/sway/config/output.c b/sway/config/output.c
index 74d79130..6f337b66 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -237,7 +237,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
wlr_log(WLR_DEBUG, "Setting background for output %d to %s",
output_i, oc->background);
- size_t len = snprintf(NULL, 0, "%s %d %s %s %s",
+ size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s",
config->swaybg_command ? config->swaybg_command : "swaybg",
output_i, oc->background, oc->background_option,
oc->background_fallback ? oc->background_fallback : "");
@@ -246,7 +246,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
wlr_log(WLR_DEBUG, "Unable to allocate swaybg command");
return;
}
- snprintf(command, len + 1, "%s %d %s %s %s",
+ snprintf(command, len + 1, "%s %d \"%s\" %s %s",
config->swaybg_command ? config->swaybg_command : "swaybg",
output_i, oc->background, oc->background_option,
oc->background_fallback ? oc->background_fallback : "");
diff --git a/sway/config/seat.c b/sway/config/seat.c
index 83dac4c0..46456caf 100644
--- a/sway/config/seat.c
+++ b/sway/config/seat.c
@@ -30,7 +30,7 @@ struct seat_config *new_seat_config(const char* name) {
return seat;
}
-struct seat_attachment_config *seat_attachment_config_new() {
+struct seat_attachment_config *seat_attachment_config_new(void) {
struct seat_attachment_config *attachment =
calloc(1, sizeof(struct seat_attachment_config));
if (!attachment) {