aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarvin Borner2020-08-23 23:02:32 +0200
committerMarvin Borner2020-08-23 23:02:32 +0200
commita1ab3aac9cd9f03a421ff1681c0da3487097deae (patch)
treeab2b322a121e6fed371b96fadc1bdbaeaabd6ee3 /apps
parentc2cccf6f2ef4f6f8c828074e68be2d95255a89b5 (diff)
Some window buffer switching
Diffstat (limited to 'apps')
-rw-r--r--apps/test.c10
-rw-r--r--apps/wm.c40
2 files changed, 31 insertions, 19 deletions
diff --git a/apps/test.c b/apps/test.c
index 3bbe824..ee5792d 100644
--- a/apps/test.c
+++ b/apps/test.c
@@ -7,12 +7,12 @@ int main()
print("[test loaded]\n");
/* 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;
+ /* msg_send(1, MSG_NEW_WINDOW, NULL); */
+ /* struct message *msg = msg_receive_loop(); */
+ /* struct window *win = (struct window *)msg->data; */
- const u32 color[3] = { 0xff, 0, 0 };
- gui_fill(win, color);
+ /* const u32 color[3] = { 0xff, 0, 0 }; */
+ /* gui_fill(win, color); */
while (1) {
};
diff --git a/apps/wm.c b/apps/wm.c
index 97bab76..a010928 100644
--- a/apps/wm.c
+++ b/apps/wm.c
@@ -11,6 +11,8 @@
#include <vesa.h>
struct vbe *vbe;
+struct window *direct; // Direct video memory window
+struct window *root; // Root window (wallpaper etc.)
struct list *windows;
void onkey(u32 scancode)
@@ -29,8 +31,9 @@ static struct window *new_window(int x, int y, u16 width, u16 height)
win->y = y;
win->width = width;
win->height = height;
- win->vbe = vbe;
- win->fb = malloc(width * height * (vbe->bpp >> 3));
+ win->bpp = vbe->bpp;
+ win->pitch = win->width * (win->bpp >> 3);
+ win->fb = malloc(height * win->pitch);
return win;
}
@@ -38,27 +41,36 @@ 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 };
vesa_fill(vbe, color);
gui_init("/font/spleen-16x32.psfu");
- gui_load_wallpaper(vbe, "/wall.bmp");
- event_map(EVENT_KEYBOARD, onkey);
+ windows = list_new();
+ root = new_window(0, 0, vbe->width, vbe->height);
+ direct = malloc(sizeof(*direct));
+ memcpy(direct, root, sizeof(*direct));
+ direct->fb = vbe->fb;
+
+ const u32 background[3] = { 0x10, 0x10, 0x10 };
+ gui_fill(root, background);
+ gui_load_wallpaper(root, "/wall.bmp");
+ list_add(windows, root);
+
+ // TODO: Remove async events completely
+ /* event_map(EVENT_KEYBOARD, onkey); */
u32 last_time = 0;
struct message *msg;
- while (1) { // TODO: Remove continuous polling?
- /* u32 current_time = time(); */
- /* if (current_time - last_time > 1000 / 60) { // 60Hz */
- /* struct window *win = windows->head->data; */
- /* memcpy(vbe->fb, windows->head->data, */
- /* win->width * win->height * (vbe->bpp >> 3)); */
- /* } */
- /* last_time = current_time; */
+ while (1) {
+ u32 current_time = time();
+ if (current_time - last_time > 1000 / 60) { // 60Hz
+ struct window *win;
+ if (windows->head && (win = windows->head->data))
+ gui_win_on_win(win, direct, 0, 0);
+ }
+ last_time = current_time;
if (!(msg = msg_receive())) {
yield();