diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-08-06 16:13:50 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-08-06 16:13:50 +0200 |
commit | 6a5d5b204569fc6abe6cb5a8ac338350eb5e923d (patch) | |
tree | 04339a65d987c0bed58c9e1eeb0a3742e7c95705 /modules/window/examples | |
parent | e42c3750013e634bbe1834e3e684367e42814b97 (diff) |
Fixed xcb windows
Diffstat (limited to 'modules/window/examples')
-rw-r--r-- | modules/window/examples/window_create.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/window/examples/window_create.cpp b/modules/window/examples/window_create.cpp index dde8295..3517dae 100644 --- a/modules/window/examples/window_create.cpp +++ b/modules/window/examples/window_create.cpp @@ -1,4 +1,54 @@ +#include "../c++/window.hpp" + +#include <iostream> + int main(){ + auto eo_aio = saw::setup_async_io(); + if(eo_aio.is_error()){ + auto& err = eo_aio.get_error(); + std::cerr<<"Error: "<<err.get_category(); + + auto err_msg = err.get_message(); + if(err_msg.size() > 0u){ + std::cerr<<" - "<<err_msg; + } + + std::cerr<<std::endl; + return err.get_id(); + } + auto& aio = eo_aio.get_value(); + saw::wait_scope wait{aio.event_loop}; + + auto eo_device = saw::gfx::create_xcb_device(*aio.io); + if(eo_device.is_error()){ + auto& err = eo_device.get_error(); + std::cerr<<"Error: "<<err.get_category(); + + auto err_msg = err.get_message(); + if(err_msg.size() > 0u){ + std::cerr<<" - "<<err_msg; + } + + std::cerr<<std::endl; + return err.get_id(); + } + auto& device = eo_device.get_value(); + + auto window = device->create_window({}, "foo"); + if(!window){ + return 42; + } + window->show(); + + bool running = true; + + aio.event_port.on_signal(saw::Signal::Terminate).then([&running](){ + running = false; + }).detach(); + while(running){ + device->flush(); + wait.wait(std::chrono::seconds{1u}); + } return 0; } |