aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarvin Borner2020-08-24 13:45:08 +0200
committerMarvin Borner2020-08-24 13:45:08 +0200
commit0724b54018c379850e672ad6571e05b3f848150d (patch)
treedf24acfb9c9e4d84d816a34b83ef1809b3c9eaec /apps
parent0a4c8dd2d6048fe9851b8d92a311bba7aaa83a57 (diff)
Added window borders
Diffstat (limited to 'apps')
-rw-r--r--apps/test.c8
-rw-r--r--apps/wm.c25
2 files changed, 16 insertions, 17 deletions
diff --git a/apps/test.c b/apps/test.c
index 0fecbf4..efc7432 100644
--- a/apps/test.c
+++ b/apps/test.c
@@ -9,16 +9,10 @@ int main()
print("[test loaded]\n");
struct window *win = gui_new_window();
- u32 color[3] = { 0xff, 0, 0 };
+ u32 color[3] = { 0xff, 0xff, 0xff };
gui_fill(win, color);
- u32 last_time = 0;
while (1) {
- u32 current_time = time();
- if (current_time - last_time > 1000 / 60) { // 60Hz
- win->x += 10;
- };
- last_time = current_time;
yield();
}
return 0;
diff --git a/apps/wm.c b/apps/wm.c
index 45fbff0..c4ed193 100644
--- a/apps/wm.c
+++ b/apps/wm.c
@@ -14,6 +14,7 @@ struct vbe *vbe;
struct window *direct; // Direct video memory window
struct window *root; // Root window (wallpaper etc.)
struct window *exchange; // Exchange buffer
+struct window *focused; // The focused window
struct list *windows;
static struct window *new_window(int x, int y, u16 width, u16 height)
@@ -49,6 +50,8 @@ int main(int argc, char **argv)
const u32 background[3] = { 0x0, 0x0, 0x0 };
gui_fill(root, background);
+ const u32 border[3] = { 0xff, 0xff, 0xff };
+ gui_border(root, border, 2);
// TODO: Fix wallpaper
/* gui_load_wallpaper(root, "/wall.bmp"); */
@@ -56,15 +59,6 @@ int main(int argc, char **argv)
struct message *msg;
while (1) {
- if (windows->head && windows->head->data) {
- struct node *iterator = windows->head;
- do {
- struct window *win = iterator->data;
- gui_win_on_win(win, exchange, win->x, win->y);
- } while ((iterator = iterator->next) != NULL);
- gui_win_on_win(exchange, direct, 0, 0);
- }
-
if (!(msg = msg_receive())) {
yield();
continue;
@@ -73,12 +67,23 @@ int main(int argc, char **argv)
switch (msg->type) {
case MSG_NEW_WINDOW:
printf("New window for pid %d\n", msg->src);
- struct window *win = new_window(0, 0, 200, 200);
+ struct window *win =
+ new_window(vbe->width / 2 - 100, vbe->height / 2 - 100, 200, 200);
msg_send(msg->src, MSG_NEW_WINDOW, win);
list_add(windows, win);
+ focused = win;
break;
case EVENT_KEYBOARD:
printf("Keypress %d!\n", msg->data);
+ focused->x += 50;
+ if (windows->head && windows->head->data) {
+ struct node *iterator = windows->head;
+ do {
+ struct window *win = iterator->data;
+ gui_win_on_win(exchange, win, win->x, win->y);
+ } while ((iterator = iterator->next) != NULL);
+ gui_win_on_win(direct, exchange, 0, 0);
+ }
break;
default:
printf("Unknown WM request %d from pid %d", msg->type, msg->src);