aboutsummaryrefslogtreecommitdiff
path: root/apps/wm.c
blob: ffb1b4d832afebcb7c16eecb9e72094bd9deb612 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// MIT License, Copyright (c) 2020 Marvin Borner

#include <def.h>
#include <gui.h>
#include <input.h>
#include <print.h>
#include <random.h>
#include <sys.h>
#include <vesa.h>

void onkey(u32 scancode)
{
	printf("WM KEY EVENT %d\n", scancode);
	if (KEY_ALPHANUMERIC(scancode)) {
		printf("ALPHANUMERIC!\n");
	}
	event_resolve();
}

int main(int argc, char **argv)
{
	srand(time());

	printf("ARGC: %d\n", argc);
	printf("[%s loaded]\n", argv[0]);

	struct vbe *vbe = (struct vbe *)argv[1];

	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()))
			continue;

		switch (msg->type) {
		case MSG_NEW_WINDOW:
			printf("New window for pid %d\n", msg->src);
			break;
		default:
			printf("Unknown WM request!");
		}
	};

	return 0;
}