diff options
author | Marvin Borner | 2020-08-22 23:31:47 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-22 23:31:47 +0200 |
commit | b667ea0fbd26af222f828199e7b9a7e62ad98081 (patch) | |
tree | 90dac52e2cf0a898da0097e9b1375506309b673f /apps | |
parent | 32f63ffc96f7f7ec6c504b8f50292316f026dd21 (diff) |
Some window fb and yield implementation
Diffstat (limited to 'apps')
-rw-r--r-- | apps/init.c | 1 | ||||
-rw-r--r-- | apps/test.c | 15 | ||||
-rw-r--r-- | apps/wm.c | 35 |
3 files changed, 40 insertions, 11 deletions
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; @@ -3,11 +3,16 @@ #include <def.h> #include <gui.h> #include <input.h> +#include <list.h> +#include <mem.h> #include <print.h> #include <random.h> #include <sys.h> #include <vesa.h> +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); } }; |