add initial saver program

This commit is contained in:
Andrew Pamment 2023-05-21 22:19:48 +10:00
parent 65cada6951
commit afcf23e775
6 changed files with 2054 additions and 25 deletions

17
gui.c
View File

@ -22,6 +22,7 @@ struct gui_colour_scheme_t sys_color;
// extern const struct bitmap_font font; // extern const struct bitmap_font font;
#define WIN_REQ_FLAG_NO_TITLE 0x01 #define WIN_REQ_FLAG_NO_TITLE 0x01
#define WIN_REQ_FLAG_NO_MOUSE 0x02
#define BochsBreak() \ #define BochsBreak() \
outportw(0x8A00, 0x8A00); \ outportw(0x8A00, 0x8A00); \
@ -851,8 +852,22 @@ void gui_flip() {
} }
// draw mouse // draw mouse
gui_display_pointer(); int mouse_visible = 1;
for (i = ptr_vector_len(&vwindows) - 1; i >= 0; i--) {
struct window_t *win = (struct window_t *)ptr_vector_get(&vwindows, i);
if (!win->minimized) {
if (mouse_pos_x >= win->posx && mouse_pos_x <= win->posx + win->width && mouse_pos_y >= win->posy && mouse_pos_y <= win->posy + win->height) {
if (win->flags & WIN_REQ_FLAG_NO_MOUSE) {
mouse_visible = 0;
}
break;
}
}
}
if (mouse_visible) {
gui_display_pointer();
}
// flip // flip
/* /*
for (int j = 0; j < bytesPerLine * height; j++) { for (int j = 0; j < bytesPerLine * height; j++) {

View File

@ -129,6 +129,13 @@ i686-quinn-strip sysfont.exe
mv sysfont.exe $HOME/Quinn/fsroot/gui mv sysfont.exe $HOME/Quinn/fsroot/gui
rm sysfont.o rm sysfont.o
cd $HOME/Quinn/src/quinn-os/programs/gui/saver/
i686-quinn-gcc $CFLAGS -I$HOME/Quinn/sysroot/usr/include -c saver.c
i686-quinn-gcc $CFLAGS saver.o $HOME/Quinn/sysroot/usr/lib/libquinn.a $HOME/Quinn/sysroot/usr/lib/libfreetype.a $HOME/Quinn/sysroot/usr/lib/libpng.a $HOME/Quinn/sysroot/usr/lib/libz.a -o saver.exe
i686-quinn-strip saver.exe
mv saver.exe $HOME/Quinn/fsroot/gui
rm saver.o
cd $HOME/Quinn/src/quinn-os/programs/gui/terminal/ cd $HOME/Quinn/src/quinn-os/programs/gui/terminal/
i686-quinn-gcc $CFLAGS -I$HOME/Quinn/sysroot/usr/include -c terminal.c i686-quinn-gcc $CFLAGS -I$HOME/Quinn/sysroot/usr/include -c terminal.c
i686-quinn-gcc $CFLAGS -c font.c i686-quinn-gcc $CFLAGS -c font.c

View File

@ -2,6 +2,7 @@
#define __QUINN_H #define __QUINN_H
#define WIN_REQ_FLAG_NO_TITLE 0x01 #define WIN_REQ_FLAG_NO_TITLE 0x01
#define WIN_REQ_FLAG_NO_MOUSE 0x02
struct event_msg_t { struct event_msg_t {
int type; int type;

View File

@ -0,0 +1,80 @@
#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();
}

File diff suppressed because it is too large Load Diff