diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-30 15:30:49 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-30 15:32:16 -0400 |
commit | 1061996056666c624130a43e7a4671d10c99f555 (patch) | |
tree | 67bd914203ea281a4a41543aa8063cc6e922f2ad /src/lib/libwidget/include | |
parent | 08b07484f1aa1f9726204e90d3f620eb28aa04f4 (diff) |
libwidget: Add initial window drawing + cleanups
Introduce the initial logic to draw windows as well as tidying up the
interface a bit.
- All callbacks must now have a state arguments
- The libwidget state is now kept internally
- Add helper to get pixel index
- Add initial window drawing
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/lib/libwidget/include')
-rw-r--r-- | src/lib/libwidget/include/libwidget/core.h | 10 | ||||
-rw-r--r-- | src/lib/libwidget/include/libwidget/window.h | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/libwidget/include/libwidget/core.h b/src/lib/libwidget/include/libwidget/core.h index 85b33d4..074edc4 100644 --- a/src/lib/libwidget/include/libwidget/core.h +++ b/src/lib/libwidget/include/libwidget/core.h @@ -30,12 +30,14 @@ #ifndef LIBWIDGET_CORE_H #define LIBWIDGET_CORE_H 1 +#include <sys/fbdev.h> #include <stdint.h> /* Forward declarations */ struct widget; struct libwidget_state { + struct fb_info fbinfo; uint32_t *fbdev; }; @@ -82,8 +84,8 @@ struct blueprint { * @draw: Draw the widget */ struct widget_ops { - int(*init)(struct widget *wp); - int(*draw)(struct widget *wp); + int(*init)(struct libwidget_state *lws, struct widget *wp); + int(*draw)(struct libwidget_state *lws, struct widget *wp); }; /* @@ -106,12 +108,10 @@ struct widget { /* * Initialize the library * - * @lwsp: Libwidget state pointer - * * Returns zero on success, otherwise a less than zero * value on failure. */ -int libwidget_init(struct libwidget_state *lwsp); +int libwidget_init(void); /* * Initialize a widget diff --git a/src/lib/libwidget/include/libwidget/window.h b/src/lib/libwidget/include/libwidget/window.h index 2dc58b1..8823eba 100644 --- a/src/lib/libwidget/include/libwidget/window.h +++ b/src/lib/libwidget/include/libwidget/window.h @@ -30,6 +30,7 @@ #ifndef LIBWIDGET_WINDOW_H #define LIBWIDGET_WINDOW_H +#include <sys/cdefs.h> #include <libwidget/core.h> /* @@ -41,6 +42,12 @@ struct window { struct widget *wp; }; +__always_inline static inline size_t +get_pix_index(struct fb_info *info, uint32_t x, uint32_t y) +{ + return x + y * (info->pitch / 4); +} + extern struct widget_ops g_winops; #endif /* !LIBWIDGET_WINDOW_H */ |