From 09d22164c5e159a9e6b6db4864086fcfd3b2587a Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 8 Jun 2025 01:53:26 -0400 Subject: usr.bin: kfgwm: Add initial window text support Signed-off-by: Ian Moffett --- usr.bin/kfgwm/kfgwm.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'usr.bin/kfgwm/kfgwm.c') 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 #include +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 (;;); } -- cgit v1.2.3