From b667ea0fbd26af222f828199e7b9a7e62ad98081 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 22 Aug 2020 23:31:47 +0200 Subject: Some window fb and yield implementation --- apps/init.c | 1 + apps/test.c | 15 ++++++++++++++- apps/wm.c | 35 +++++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 11 deletions(-) (limited to 'apps') diff --git a/apps/init.c b/apps/init.c index f00110e..05d1a3c 100644 --- a/apps/init.c +++ b/apps/init.c @@ -11,5 +11,6 @@ int main(int argc, char **argv) int wm = exec("/wm", "wm", argv[1], NULL); int test = exec("/test", "test", NULL); + return wm + test; } diff --git a/apps/test.c b/apps/test.c index 8004b34..b511ab3 100644 --- a/apps/test.c +++ b/apps/test.c @@ -5,7 +5,20 @@ int main() { print("[test loaded]\n"); - gui_new_window(); + printf("TIME: %d\n", time()); + + /* struct window *win = gui_new_window(); */ + msg_send(1, MSG_NEW_WINDOW, NULL); + struct message *msg = msg_receive_loop(); + struct window *win = (struct window *)msg->data; + + // TODO: Fix window transmitting + printf("\nReceived %d from %d\n", win->x, msg->src); + printf("Received %d from %d\n", win->y, msg->src); + printf("Received %d from %d\n", win->width, msg->src); + printf("Received %d from %d\n", win->height, msg->src); + printf("Received %d from %d\n", win->fb, msg->src); + while (1) { }; return 0; diff --git a/apps/wm.c b/apps/wm.c index ffb1b4d..3984abc 100644 --- a/apps/wm.c +++ b/apps/wm.c @@ -3,11 +3,16 @@ #include #include #include +#include +#include #include #include #include #include +struct vbe *vbe; +struct list *windows; + void onkey(u32 scancode) { printf("WM KEY EVENT %d\n", scancode); @@ -17,36 +22,46 @@ void onkey(u32 scancode) event_resolve(); } -int main(int argc, char **argv) +static struct window *new_window(int x, int y, u16 width, u16 height) { - srand(time()); - - printf("ARGC: %d\n", argc); - printf("[%s loaded]\n", argv[0]); + struct window *win = malloc(sizeof(*win)); + win->x = x; + win->y = y; + win->width = width; + win->height = height; + win->fb = malloc(width * height * (vbe->bpp >> 3)); + return win; +} - struct vbe *vbe = (struct vbe *)argv[1]; +int main(int argc, char **argv) +{ + (void)argc; + vbe = (struct vbe *)argv[1]; + windows = list_new(); printf("VBE: %dx%d\n", vbe->width, vbe->height); const u32 color[3] = { 0, 0, 0 }; - const u32 text[3] = { 0xff, 0xff, 0xff }; vesa_fill(vbe, color); gui_init("/font/spleen-16x32.psfu"); - gui_write(vbe, 50, 50, text, "hallo"); event_map(EVENT_KEYBOARD, onkey); struct message *msg; while (1) { // TODO: Remove continuous polling? - if (!(msg = msg_receive())) + if (!(msg = msg_receive())) { + yield(); continue; + } switch (msg->type) { case MSG_NEW_WINDOW: printf("New window for pid %d\n", msg->src); + struct window *win = new_window(50, 50, 200, 200); + msg_send(msg->src, MSG_NEW_WINDOW, win); break; default: - printf("Unknown WM request!"); + printf("Unknown WM request %d from pid %d", msg->type, msg->src); } }; -- cgit v1.2.3