|
|
@ -64,15 +64,17 @@ bool is_valid_color(const char *color) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void render_frame(struct swaybg_state *state) {
|
|
|
|
static void render_frame(struct swaybg_state *state) {
|
|
|
|
state->current_buffer = get_next_buffer(state->shm, state->buffers,
|
|
|
|
int buffer_width = state->width * state->scale,
|
|
|
|
state->width * state->scale, state->height * state->scale);
|
|
|
|
buffer_height = state->height * state->scale;
|
|
|
|
|
|
|
|
state->current_buffer = get_next_buffer(state->shm,
|
|
|
|
|
|
|
|
state->buffers, buffer_width, buffer_height);
|
|
|
|
cairo_t *cairo = state->current_buffer->cairo;
|
|
|
|
cairo_t *cairo = state->current_buffer->cairo;
|
|
|
|
if (state->args->mode == BACKGROUND_MODE_SOLID_COLOR) {
|
|
|
|
if (state->args->mode == BACKGROUND_MODE_SOLID_COLOR) {
|
|
|
|
cairo_set_source_u32(cairo, state->context.color);
|
|
|
|
cairo_set_source_u32(cairo, state->context.color);
|
|
|
|
cairo_paint(cairo);
|
|
|
|
cairo_paint(cairo);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
render_background_image(cairo, state->context.image,
|
|
|
|
render_background_image(cairo, state->context.image,
|
|
|
|
state->args->mode, state->width, state->height, state->scale);
|
|
|
|
state->args->mode, buffer_width, buffer_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_surface_set_buffer_scale(state->surface, state->scale);
|
|
|
|
wl_surface_set_buffer_scale(state->surface, state->scale);
|
|
|
@ -193,24 +195,10 @@ int main(int argc, const char **argv) {
|
|
|
|
args.output_idx = atoi(argv[1]);
|
|
|
|
args.output_idx = atoi(argv[1]);
|
|
|
|
args.path = argv[2];
|
|
|
|
args.path = argv[2];
|
|
|
|
|
|
|
|
|
|
|
|
args.mode = BACKGROUND_MODE_STRETCH;
|
|
|
|
args.mode = parse_background_mode(argv[3]);
|
|
|
|
if (strcmp(argv[3], "stretch") == 0) {
|
|
|
|
if (args.mode == BACKGROUND_MODE_INVALID) {
|
|
|
|
args.mode = BACKGROUND_MODE_STRETCH;
|
|
|
|
|
|
|
|
} else if (strcmp(argv[3], "fill") == 0) {
|
|
|
|
|
|
|
|
args.mode = BACKGROUND_MODE_FILL;
|
|
|
|
|
|
|
|
} else if (strcmp(argv[3], "fit") == 0) {
|
|
|
|
|
|
|
|
args.mode = BACKGROUND_MODE_FIT;
|
|
|
|
|
|
|
|
} else if (strcmp(argv[3], "center") == 0) {
|
|
|
|
|
|
|
|
args.mode = BACKGROUND_MODE_CENTER;
|
|
|
|
|
|
|
|
} else if (strcmp(argv[3], "tile") == 0) {
|
|
|
|
|
|
|
|
args.mode = BACKGROUND_MODE_TILE;
|
|
|
|
|
|
|
|
} else if (strcmp(argv[3], "solid_color") == 0) {
|
|
|
|
|
|
|
|
args.mode = BACKGROUND_MODE_SOLID_COLOR;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
wlr_log(L_ERROR, "Unsupported background mode: %s", argv[3]);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!prepare_context(&state)) {
|
|
|
|
if (!prepare_context(&state)) {
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -244,10 +232,10 @@ int main(int argc, const char **argv) {
|
|
|
|
zwlr_layer_surface_v1_set_exclusive_zone(state.layer_surface, -1);
|
|
|
|
zwlr_layer_surface_v1_set_exclusive_zone(state.layer_surface, -1);
|
|
|
|
zwlr_layer_surface_v1_add_listener(state.layer_surface,
|
|
|
|
zwlr_layer_surface_v1_add_listener(state.layer_surface,
|
|
|
|
&layer_surface_listener, &state);
|
|
|
|
&layer_surface_listener, &state);
|
|
|
|
state.run_display = true;
|
|
|
|
|
|
|
|
wl_surface_commit(state.surface);
|
|
|
|
wl_surface_commit(state.surface);
|
|
|
|
wl_display_roundtrip(state.display);
|
|
|
|
wl_display_roundtrip(state.display);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state.run_display = true;
|
|
|
|
while (wl_display_dispatch(state.display) != -1 && state.run_display) {
|
|
|
|
while (wl_display_dispatch(state.display) != -1 && state.run_display) {
|
|
|
|
// This space intentionally left blank
|
|
|
|
// This space intentionally left blank
|
|
|
|
}
|
|
|
|
}
|
|
|
|