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/wm.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'apps/wm.c') 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