mirror of
https://github.com/swaywm/sway.git
synced 2026-03-30 11:10:59 -04:00
commit
af25e8ca90
1 changed files with 29 additions and 25 deletions
|
|
@ -343,6 +343,7 @@ cairo_surface_t *load_image(char *image_path) {
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
const char *scaling_mode_str = "fit", *socket_path = NULL;
|
const char *scaling_mode_str = "fit", *socket_path = NULL;
|
||||||
|
char *image_path = NULL;
|
||||||
int i;
|
int i;
|
||||||
void *images = NULL;
|
void *images = NULL;
|
||||||
config = init_config();
|
config = init_config();
|
||||||
|
|
@ -400,8 +401,6 @@ int main(int argc, char **argv) {
|
||||||
" For more information see `man swaylock`\n";
|
" For more information see `man swaylock`\n";
|
||||||
|
|
||||||
|
|
||||||
registry = registry_poll();
|
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
@ -418,29 +417,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
char *image_path = strchr(optarg, ':');
|
image_path = optarg;
|
||||||
if (image_path == NULL) {
|
|
||||||
if (render_data.num_images == 0) {
|
|
||||||
// Provided image without output
|
|
||||||
render_data.image = load_image(optarg);
|
|
||||||
render_data.num_images = -1;
|
|
||||||
} else {
|
|
||||||
sway_log(L_ERROR, "output must be defined for all --images or no --images");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Provided image for all outputs
|
|
||||||
if (render_data.num_images == 0) {
|
|
||||||
images = calloc(registry->outputs->length, sizeof(char*) * 2);
|
|
||||||
} else if (render_data.num_images == -1) {
|
|
||||||
sway_log(L_ERROR, "output must be defined for all --images or no --images");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
image_path[0] = '\0';
|
|
||||||
((char**) images)[render_data.num_images * 2] = optarg;
|
|
||||||
((char**) images)[render_data.num_images++ * 2 + 1] = ++image_path;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 't':
|
case 't':
|
||||||
|
|
@ -519,6 +496,33 @@ int main(int argc, char **argv) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
registry = registry_poll();
|
||||||
|
|
||||||
|
if (image_path) {
|
||||||
|
char *path = strchr(image_path, ':');
|
||||||
|
if (path == NULL) {
|
||||||
|
if (render_data.num_images == 0) {
|
||||||
|
// Provided image without output
|
||||||
|
render_data.image = load_image(image_path);
|
||||||
|
render_data.num_images = -1;
|
||||||
|
} else {
|
||||||
|
sway_log(L_ERROR, "output must be defined for all --images or no --images");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Provided image for all outputs
|
||||||
|
if (render_data.num_images == 0) {
|
||||||
|
images = calloc(registry->outputs->length, sizeof(char*) * 2);
|
||||||
|
} else if (render_data.num_images == -1) {
|
||||||
|
sway_log(L_ERROR, "output must be defined for all --images or no --images");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
path[0] = '\0';
|
||||||
|
((char**) images)[render_data.num_images * 2] = image_path;
|
||||||
|
((char**) images)[render_data.num_images++ * 2 + 1] = ++path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render_data.scaling_mode = SCALING_MODE_STRETCH;
|
render_data.scaling_mode = SCALING_MODE_STRETCH;
|
||||||
if (strcmp(scaling_mode_str, "stretch") == 0) {
|
if (strcmp(scaling_mode_str, "stretch") == 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue