@@ -607,12 +607,51 @@ void application::swap_frame_buffers()
607607
608608void application::set_fullscreen (bool enable)
609609{
610- // TODO:
610+ auto & ww = get_impl (this ->window_pimpl );
611+
612+ auto flags = [&]() -> uint32_t {
613+ if (enable) {
614+ return SDL_WINDOW_FULLSCREEN_DESKTOP;
615+ } else {
616+ return 0 ;
617+ }
618+ }();
619+
620+ auto error = SDL_SetWindowFullscreen (
621+ ww.window .window , //
622+ flags
623+ );
624+
625+ if (error != 0 ) {
626+ throw std::runtime_error (
627+ utki::cat (
628+ " application::set_fullscreen(): could not switch fullscreen mode, error: " , //
629+ SDL_GetError ()
630+ )
631+ );
632+ }
611633}
612634
613635void application::set_mouse_cursor_visible (bool visible)
614636{
615- // TODO:
637+ int mode = [&]() {
638+ if (visible) {
639+ return SDL_ENABLE;
640+ } else {
641+ return SDL_DISABLE;
642+ }
643+ }();
644+
645+ int error = SDL_ShowCursor (mode);
646+
647+ if (error < 0 ) {
648+ throw std::runtime_error (
649+ utki::cat (
650+ " application::set_mouse_cursor_visible(): could not show/hide mouse cursor, error: " , //
651+ SDL_GetError ()
652+ )
653+ );
654+ }
616655}
617656
618657namespace {
@@ -758,7 +797,7 @@ void main_loop_iteration(void* user_data)
758797 }
759798
760799#if CFG_OS_NAME == CFG_OS_NAME_EMSCRIPTEN
761- if (ww.quit_flag .load ()){
800+ if (ww.quit_flag .load ()) {
762801 std::unique_ptr<ruisapp::application> p (app);
763802 emscripten_cancel_main_loop ();
764803 }
@@ -776,12 +815,7 @@ int main(int argc, const char** argv)
776815 }
777816
778817#if CFG_OS_NAME == CFG_OS_NAME_EMSCRIPTEN
779- emscripten_set_main_loop_arg (
780- &main_loop_iteration,
781- app.release (),
782- 0 ,
783- false
784- );
818+ emscripten_set_main_loop_arg (&main_loop_iteration, app.release (), 0 , false );
785819 return 0 ;
786820#else
787821 while (!get_impl (*app).quit_flag .load ()) {
0 commit comments