diff options
author | Anton Kling <anton@kling.gg> | 2024-03-25 21:02:58 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-03-25 21:04:10 +0100 |
commit | 3deb2df8e62a5f0a5535ee734a5aa13b0959f53f (patch) | |
tree | af8841076c95ae3de7dcd4a006026be2607a0fbf /userland/libgui | |
parent | 6baa733f5682f660143c851a635a53dc2c2df7ae (diff) |
Random changes
Diffstat (limited to 'userland/libgui')
-rw-r--r-- | userland/libgui/libgui.c | 13 | ||||
-rw-r--r-- | userland/libgui/libgui.h | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/userland/libgui/libgui.c b/userland/libgui/libgui.c index a344778..2a8361d 100644 --- a/userland/libgui/libgui.c +++ b/userland/libgui/libgui.c @@ -256,6 +256,19 @@ void GUI_EventLoop(GUI_Window *w, void (*event_handler)(WS_EVENT ev)) { } } +void GUI_Resize(GUI_Window *w, uint32_t sx, uint32_t sy) { + ftruncate(w->bitmap_fd, sx * sy * sizeof(uint32_t)); + w->sx = sx; + w->sy = sy; + char buffer[sizeof(uint8_t) + sizeof(uint32_t) * 2]; + uint8_t l = 2; + memcpy(buffer, &l, sizeof(l)); + memcpy(buffer + sizeof(uint8_t), &sx, sizeof(sx)); + memcpy(buffer + sizeof(uint8_t) + sizeof(uint32_t), &sy, sizeof(sy)); + int len = sizeof(uint8_t) + sizeof(uint32_t) * 2; + write(w->ws_socket, buffer, len); +} + GUI_Window *GUI_CreateWindow(uint32_t x, uint32_t y, uint32_t sx, uint32_t sy) { GUI_Window *w = malloc(sizeof(GUI_Window)); if (!w) diff --git a/userland/libgui/libgui.h b/userland/libgui/libgui.h index cb8d9a7..1c3ac95 100644 --- a/userland/libgui/libgui.h +++ b/userland/libgui/libgui.h @@ -5,6 +5,7 @@ #define WINDOWSERVER_EVENT_KEYPRESS 0 #define WINDOWSERVER_EVENT_WINDOW_EXIT 1 +#define WINDOWSERVER_EVENT_WINDOW_RESIZE 2 typedef struct { int ws_socket; @@ -25,7 +26,10 @@ struct KEY_EVENT { typedef struct { int type; - struct KEY_EVENT ev; + union { + struct KEY_EVENT ev; + int vector[2]; + }; } WS_EVENT; GUI_Window *GUI_CreateWindow(uint32_t x, uint32_t y, uint32_t sx, uint32_t sy); @@ -35,4 +39,5 @@ void GUI_OverwriteFont(GUI_Window *w, uint32_t px, uint32_t py, const uint32_t color); void GUI_ClearScreen(GUI_Window *w, uint32_t color); void GUI_EventLoop(GUI_Window *w, void (*event_handler)(WS_EVENT ev)); +void GUI_Resize(GUI_Window *w, uint32_t sx, uint32_t sy); #endif |