Files
net/gui/wm.c
2025-12-20 18:49:21 -08:00

40 lines
1.2 KiB
C

#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <exec/list.h>
#include <gui/wm.h>
struct List windows;
struct Screen *screen;
struct Theme theme = {
.border_active_color = 0x0000FF00,
.border_inactive_color = 0x00FF0000,
.border_height = 12
};
void WmInit(struct Screen *scr) {
screen = scr;
NewList(&windows, LP_BLOCK);
}
void PaintWindow(struct Window *window) {
for (int y = 0; y < theme.border_height; y++) {
memset32(screen->buffer + screen->width * (window->y + y) + window->x, (window->flags & WF_ACTIVE) ? theme.border_active_color : theme.border_inactive_color, window->width);
}
for (int y = 0; y < window->height; y++) {
memcpy(screen->buffer + screen->width * (window->y + theme.border_height + y) + window->x, window->buffer + window->width * y, window->width * sizeof(uint32_t));
}
}
void AddWindow(struct Window *window) {
Enqueue(&windows, (struct Node *)window);
}
void WmUpdate(void) {
struct Window *window = (struct Window *)windows.head;
while (window != (struct Window *)&windows.tail) {
PaintWindow(window);
window = (struct Window *)window->node.next;
}
}