From 6a5d5b204569fc6abe6cb5a8ac338350eb5e923d Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Tue, 6 Aug 2024 16:13:50 +0200 Subject: Fixed xcb windows --- modules/window/c++/xcb.cpp | 56 +++++++++++++++++++++++++++++++++++++++++----- modules/window/c++/xcb.hpp | 6 ++--- 2 files changed, 53 insertions(+), 9 deletions(-) (limited to 'modules/window/c++') diff --git a/modules/window/c++/xcb.cpp b/modules/window/c++/xcb.cpp index e90fa5a..9d4ae58 100644 --- a/modules/window/c++/xcb.cpp +++ b/modules/window/c++/xcb.cpp @@ -261,25 +261,69 @@ void window::resize(uint64_t w, uint64_t h){ conveyor> window::on_event() { auto caf = new_conveyor_and_feeder>(); - event_feeder = std::move(caf.feeder); + event_feeder_ = std::move(caf.feeder); return std::move(caf.conveyor); } void window::resize_event(uint64_t x, uint64_t y, uint64_t width, uint64_t height){ - /// @todo implement - assert(false); + video_mode_.width = width; + video_mode_.height = height; + + if(event_feeder_) { + /// @TODO implement + assert(false); + } } void window::mouse_event(int16_t x, int16_t y, uint16_t state, bool pressed){ - /// @todo implement + if(x < 0 || y < 0){ + return; + } + + uint32_t ux = static_cast(x); + uint32_t uy = static_cast(y); + + if( ux >= video_mode_.width || uy >= video_mode_.height){ + return; + } + + if(event_feeder_){ + /// @TODO implement assert(false); + } } + void window::mouse_move_event(int16_t x, int16_t y){ - /// @todo implement + if(x < 0 || y < 0){ + return; + } + uint32_t ux = static_cast(x); + uint32_t uy = static_cast(y); + + if( ux >= video_mode_.width || uy >= video_mode_.height){ + return; + } + + if(event_feeder_){ + /// @TODO implement assert(false); + } } + void window::keyboard_event(int16_t x, int16_t y, uint32_t keycode, bool pressed, bool repeat){ - /// @todo implement + if(x < 0 || y < 0){ + return; + } + uint32_t ux = static_cast(x); + uint32_t uy = static_cast(y); + + if( ux >= video_mode_.width || uy >= video_mode_.height){ + return; + } + + if(event_feeder_){ + /// @TODO implement assert(false); + } } xcb_window_t window::get_xcb_window_handle() const{ diff --git a/modules/window/c++/xcb.hpp b/modules/window/c++/xcb.hpp index 1694923..2f84133 100644 --- a/modules/window/c++/xcb.hpp +++ b/modules/window/c++/xcb.hpp @@ -10,8 +10,8 @@ #include -#include -#include +#include +#include namespace saw { namespace gfx { @@ -76,7 +76,7 @@ private: video_mode video_mode_; std::string window_title_; - own>> event_feeder = nullptr; + own>> event_feeder_ = nullptr; public: window(device& dev_, xcb_window_t xcb_win, xcb_colormap_t xcb_colormap_, const video_mode& vid_mode_, const std::string_view& title_view_); -- cgit v1.2.3