summaryrefslogtreecommitdiff
path: root/usr.bin/kfgwm/kfgwm.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-06-08 01:53:26 -0400
committerIan Moffett <ian@osmora.org>2025-06-08 01:56:08 -0400
commit09d22164c5e159a9e6b6db4864086fcfd3b2587a (patch)
tree98af9a332f4a1e86ad4ef3e805dfeb9dda3c3138 /usr.bin/kfgwm/kfgwm.c
parent833c46b5cd57f02d0bd9f7ae85c628d5a6d93d54 (diff)
usr.bin: kfgwm: Add initial window text support
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/kfgwm/kfgwm.c')
-rw-r--r--usr.bin/kfgwm/kfgwm.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/usr.bin/kfgwm/kfgwm.c b/usr.bin/kfgwm/kfgwm.c
index eb28a8e..3240a0b 100644
--- a/usr.bin/kfgwm/kfgwm.c
+++ b/usr.bin/kfgwm/kfgwm.c
@@ -35,14 +35,38 @@
#include <stddef.h>
#include <unistd.h>
+static struct fbattr fbattr;
+static uint32_t *framep;
+
+static void
+test_win(struct kfg_window *root, kfgpos_t x, kfgpos_t y, const char *str)
+{
+ struct kfg_text text;
+ struct kfg_window test_win;
+
+ test_win.x = x;
+ test_win.y = y;
+ test_win.width = 250;
+ test_win.height = 150;
+ test_win.fb_pitch = fbattr.pitch;
+ test_win.framebuf = framep;
+ test_win.bg = KFG_DARK;
+ test_win.border_bg = KFG_RED;
+
+ text.text = str;
+ text.x = 0;
+ text.y = 0;
+
+ kfg_win_draw(root, &test_win);
+ kfg_win_putstr(&test_win, &text);
+}
+
int
main(void)
{
int fb_fd, fbattr_fd, prot;
size_t fb_size;
- uint32_t *framep;
- struct fbattr fbattr;
- struct kfg_window root_win, test_win;
+ struct kfg_window root_win;
fb_fd = open("/dev/fb0", O_RDWR);
if (fb_fd < 0) {
@@ -70,16 +94,8 @@ main(void)
root_win.framebuf = framep;
root_win.bg = KFG_RED;
root_win.border_bg = KFG_RED;
+ test_win(&root_win, 40, 85, "Hello, World!");
+ test_win(&root_win, 150, 20, "Mrow!");
- test_win.x = 150;
- test_win.y = 85;
- test_win.width = 425;
- test_win.height = 350;
- test_win.fb_pitch = fbattr.pitch;
- test_win.framebuf = framep;
- test_win.bg = KFG_DARK;
- test_win.border_bg = KFG_RED;
-
- kfg_win_draw(&root_win, &test_win);
for (;;);
}