diff options
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 |