From a4164f698ee44e9b45fcff5792f0451ea22d4621 Mon Sep 17 00:00:00 2001 From: boost2017 Date: Sat, 13 Jan 2018 01:57:15 -0500 Subject: [PATCH 1/3] Add ToggleFullscreen Add ToggleFullscreen for Window class. --- SDL2pp/Window.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index 6413ff4..ab9b621 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -142,6 +142,14 @@ Window& Window::SetFullscreen(Uint32 flags) { return *this; } +Window& Window::ToggleFullscreen() { + Uint32 const fullscreenFlag = SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP; + bool const isFullscreen = SDL_GetWindowFlags(mpWindow) & fullscreenFlag; + if (SDL_SetWindowFullscreen(window_, isFullscreen ? SDL_FALSE : SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) + throw Exception("SDL_SetWindowFullscreen"); + return *this; +} + Window& Window::SetSize(int w, int h) { SDL_SetWindowSize(window_, w, h); return *this; From 05c60ad52f95ba4c2b48440f678f8d7194bd9658 Mon Sep 17 00:00:00 2001 From: boost2017 Date: Sat, 13 Jan 2018 01:58:13 -0500 Subject: [PATCH 2/3] Update Window.cc --- SDL2pp/Window.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index ab9b621..534ffa8 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -144,7 +144,7 @@ Window& Window::SetFullscreen(Uint32 flags) { Window& Window::ToggleFullscreen() { Uint32 const fullscreenFlag = SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP; - bool const isFullscreen = SDL_GetWindowFlags(mpWindow) & fullscreenFlag; + bool const isFullscreen = SDL_GetWindowFlags(window_) & fullscreenFlag; if (SDL_SetWindowFullscreen(window_, isFullscreen ? SDL_FALSE : SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) throw Exception("SDL_SetWindowFullscreen"); return *this; From 6fe57dec0d8c5845b03cc86fb9931840dd6e2293 Mon Sep 17 00:00:00 2001 From: boost2017 Date: Sat, 13 Jan 2018 02:03:46 -0500 Subject: [PATCH 3/3] Add to ToggleFullscreen() header file --- SDL2pp/Window.hh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index 1679567..52b590d 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -302,6 +302,18 @@ public: //////////////////////////////////////////////////////////// Window& SetFullscreen(Uint32 flags); + //////////////////////////////////////////////////////////// + /// \brief Toggle the window's fullscreen state + /// + /// \returns Reference to self + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowFullscreen + /// + //////////////////////////////////////////////////////////// + Window& ToggleFullscreen(); + //////////////////////////////////////////////////////////// /// \brief Set the size of a window's client area ///