diff options
Diffstat (limited to 'modules/window/examples/window_create.cpp')
-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; } |