|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
#include "wayland-desktop-shell-client-protocol.h"
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <wayland-client.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
@ -9,6 +11,7 @@
|
|
|
|
|
#include "client/cairo.h"
|
|
|
|
|
#include "log.h"
|
|
|
|
|
#include "list.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
list_t *surfaces;
|
|
|
|
|
struct registry *registry;
|
|
|
|
@ -32,6 +35,23 @@ void sway_terminate(int exit_code) {
|
|
|
|
|
exit(exit_code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_valid_color(const char *color) {
|
|
|
|
|
int len = strlen(color);
|
|
|
|
|
if (len != 7 || color[0] != '#') {
|
|
|
|
|
sway_log(L_ERROR, "%s is not a valid color for swaybg. Color should be specified as #rrggbb (no alpha).", color);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 1; i < len; ++i) {
|
|
|
|
|
if (!isxdigit(color[i])) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv) {
|
|
|
|
|
init_log(L_INFO);
|
|
|
|
|
surfaces = create_list();
|
|
|
|
@ -57,6 +77,11 @@ int main(int argc, const char **argv) {
|
|
|
|
|
window_make_shell(window);
|
|
|
|
|
list_add(surfaces, window);
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[3], "solid_color") == 0 && is_valid_color(argv[2])) {
|
|
|
|
|
cairo_set_source_u32(window->cairo, parse_color(argv[2]));
|
|
|
|
|
cairo_paint(window->cairo);
|
|
|
|
|
window_render(window);
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef WITH_GDK_PIXBUF
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(argv[2], &err);
|
|
|
|
@ -163,6 +188,7 @@ int main(int argc, const char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cairo_surface_destroy(image);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (wl_display_dispatch(registry->display) != -1);
|
|
|
|
|
|
|
|
|
|