sway-patched-tray-menu/swaybg/main.c

46 lines
1.1 KiB
C
Raw Normal View History

#include "wayland-desktop-shell-client-protocol.h"
#include <stdio.h>
#include <stdlib.h>
#include <wayland-client.h>
#include <time.h>
#include "client/client.h"
#include "log.h"
struct client_state *state;
void sway_terminate(void) {
client_teardown(state);
exit(1);
}
int main(int argc, char **argv) {
init_log(L_INFO);
if (!(state = client_setup(100, 100, false))) {
2015-11-13 20:42:45 +01:00
return -1;
}
if (!state->desktop_shell) {
sway_abort("swaybg requires the compositor to support the desktop-shell extension.");
}
2015-11-18 14:36:08 +01:00
struct output_state *output = state->outputs->items[0];
state->width = output->width;
state->height = output->height;
desktop_shell_set_background(state->desktop_shell, output->output, state->surface);
2015-11-18 15:55:55 +01:00
uint8_t r = 0, g = 0, b = 0;
do {
2015-11-18 14:36:08 +01:00
if (client_prerender(state) && state->cairo) {
cairo_set_source_rgb(state->cairo, r / 256.0, g / 256.0, b / 256.0);
cairo_rectangle(state->cairo, 0, 0, state->width, state->height);
cairo_fill(state->cairo);
client_render(state);
2015-11-18 15:55:55 +01:00
r++; g += 2; b += 4;
}
} while (wl_display_dispatch(state->display) != -1);
client_teardown(state);
return 0;
}