Use default black background if no wallpaper is specified

Fixes: https://github.com/SirCmpwn/sway/issues/865
This commit is contained in:
James Murphy 2016-08-20 16:01:48 +00:00
parent f99992a8ae
commit 4c32212ada
2 changed files with 30 additions and 21 deletions

View file

@ -247,6 +247,9 @@ struct sway_config {
int32_t floating_maximum_height; int32_t floating_maximum_height;
int32_t floating_minimum_width; int32_t floating_minimum_width;
int32_t floating_minimum_height; int32_t floating_minimum_height;
char *default_background;
char *default_background_option;
}; };
/** /**

View file

@ -196,6 +196,8 @@ void free_config(struct sway_config *config) {
free(config->floating_scroll_down_cmd); free(config->floating_scroll_down_cmd);
free(config->floating_scroll_left_cmd); free(config->floating_scroll_left_cmd);
free(config->floating_scroll_right_cmd); free(config->floating_scroll_right_cmd);
free(config->default_background);
free(config->default_background_option);
free(config); free(config);
} }
@ -299,6 +301,9 @@ static void config_defaults(struct sway_config *config) {
config->border_colors.placeholder.child_border = 0x0C0C0CFF; config->border_colors.placeholder.child_border = 0x0C0C0CFF;
config->border_colors.background = 0xFFFFFFFF; config->border_colors.background = 0xFFFFFFFF;
config->default_background = strdup("#000000");
config->default_background_option = strdup("solid_color");
} }
static int compare_modifiers(const void *left, const void *right) { static int compare_modifiers(const void *left, const void *right) {
@ -859,7 +864,7 @@ void apply_input_config(struct input_config *ic, struct libinput_device *dev) {
} }
void apply_output_config(struct output_config *oc, swayc_t *output) { void apply_output_config(struct output_config *oc, swayc_t *output) {
if (oc->enabled == 0) { if (oc && oc->enabled == 0) {
destroy_output(output); destroy_output(output);
return; return;
} }
@ -911,30 +916,31 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
} }
} }
if (oc && oc->background) { char *bg = oc && oc->background ? oc->background : config->default_background;
if (output->bg_pid != 0) { char *bg_option = oc && oc->background_option ? oc->background_option : config->default_background_option;
terminate_swaybg(output->bg_pid);
}
sway_log(L_DEBUG, "Setting background for output %d to %s", output_i, oc->background); if (output->bg_pid != 0) {
terminate_swaybg(output->bg_pid);
}
size_t bufsize = 4; sway_log(L_DEBUG, "Setting background for output %d to %s", output_i, bg);
char output_id[bufsize];
snprintf(output_id, bufsize, "%d", output_i);
output_id[bufsize-1] = 0;
char *const cmd[] = { size_t bufsize = 4;
"swaybg", char output_id[bufsize];
output_id, snprintf(output_id, bufsize, "%d", output_i);
oc->background, output_id[bufsize-1] = 0;
oc->background_option,
NULL,
};
output->bg_pid = fork(); char *const cmd[] = {
if (output->bg_pid == 0) { "swaybg",
execvp(cmd[0], cmd); output_id,
} bg,
bg_option,
NULL,
};
output->bg_pid = fork();
if (output->bg_pid == 0) {
execvp(cmd[0], cmd);
} }
// reload swaybars // reload swaybars