From 7c0d53684c638af98bece65edc7e744cae80806c Mon Sep 17 00:00:00 2001 From: ladevieq Date: Mon, 18 Jan 2021 22:56:18 +0100 Subject: Event logic & handle resize & close for xcb windows --- include/window.hpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'include/window.hpp') diff --git a/include/window.hpp b/include/window.hpp index 3298d36..dae4f00 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -2,6 +2,7 @@ #define __WINDOW_HPP_ #include +#include #include "defines.hpp" @@ -9,23 +10,20 @@ class vkrenderer; #if defined(LINUX) #include +#elif defined(WINDOWS) +#include +#endif -class window { - public: - window(uint32_t width, uint32_t height); - - void poll_events(); - - xcb_connection_t* connection; - xcb_window_t win; - - uint32_t width; - uint32_t height; +enum EVENT_TYPES: int32_t { + QUIT, + RESIZE, +}; - bool isOpen; +struct event { + uint32_t width; + uint32_t height; + EVENT_TYPES type; }; -#elif defined(WINDOWS) -#include class window { public: @@ -33,18 +31,25 @@ class window { void poll_events(); + +#if defined(WINDOWS) LRESULT message_handler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam); static LRESULT CALLBACK window_procedure(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam); HWND win_handle; - vkrenderer* renderer = nullptr; +#elif defined(LINUX) + xcb_connection_t* connection; + xcb_window_t win; + xcb_atom_t win_delete_atom; +#endif + + std::vector events; uint32_t width; uint32_t height; bool isOpen; }; -#endif #endif // !__WINDOW_HPP_ -- cgit v1.3