80 lines
1.8 KiB
C
80 lines
1.8 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include "saver_big.xpm"
|
|
#include "quinn.h"
|
|
#include "convertxpm.h"
|
|
|
|
void surf_callback(int x, int y, void *data) {
|
|
quinn_exit();
|
|
exit(0);
|
|
}
|
|
|
|
void exit_callback(int wh) {
|
|
quinn_exit();
|
|
exit(0);
|
|
}
|
|
|
|
void surf_char(char c) {
|
|
quinn_exit();
|
|
exit(0);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
struct widget_t *surfw;
|
|
int direction_x = 1;
|
|
int direction_y = 1;
|
|
|
|
int pos_x = rand() % (1024 - 256);
|
|
int pos_y = rand() % (768 - 256);
|
|
|
|
unsigned char *logo;
|
|
|
|
quinn_init();
|
|
struct window_req_t *req = (struct window_req_t *)malloc(sizeof(struct window_req_t));
|
|
unsigned char *surf;
|
|
|
|
req->x = 0;
|
|
req->y = 0;
|
|
req->width = 1024;
|
|
req->height = 768;
|
|
req->icon = NULL;
|
|
req->flags = WIN_REQ_FLAG_NO_TITLE | WIN_REQ_FLAG_NO_MOUSE;
|
|
strcpy(req->name, "Screen Saver");
|
|
|
|
int window_handle = quinn_req_window(req, exit_callback);
|
|
free(req);
|
|
|
|
|
|
surfw = quinn_add_surface(window_handle, 0, 0, 1024, 768, surf_callback, NULL, surf_char, surf_char);
|
|
surf = quinn_surface_get_surface(surfw);
|
|
|
|
convert_xpm(saver_big_xpm, &logo);
|
|
|
|
while (1) {
|
|
if (direction_x) {
|
|
pos_x+=2;
|
|
} else {
|
|
pos_x-=2;
|
|
}
|
|
if (direction_y) {
|
|
pos_y+=2;
|
|
} else {
|
|
pos_y-=2;
|
|
}
|
|
|
|
if (pos_x <= 4 || pos_x >= 1024 - 260) {
|
|
direction_x = !direction_x;
|
|
}
|
|
if (pos_y <= 4 || pos_y >= 768 - 260) {
|
|
direction_y = !direction_y;
|
|
}
|
|
quinn_fill_rect(window_handle, surf, 1024, 768, 0, 0, 1024, 768, 0xff000000);
|
|
quinn_render(window_handle, surf, logo, 256, 256, pos_x, pos_y, 1024, 768);
|
|
|
|
if (!quinn_process(0)) {
|
|
quinn_yield();
|
|
}
|
|
}
|
|
quinn_exit();
|
|
} |