diff --git a/include/SFML/Graphics/RenderWindow.h b/include/SFML/Graphics/RenderWindow.h index 989502f..4b46a5f 100644 --- a/include/SFML/Graphics/RenderWindow.h +++ b/include/SFML/Graphics/RenderWindow.h @@ -247,6 +247,35 @@ CSFML_GRAPHICS_API void sfRenderWindow_setKeyRepeatEnabled(sfRenderWindow* rende //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfBool sfRenderWindow_setActive(sfRenderWindow* renderWindow, sfBool active); +/////////////////////////////////////////////////////////// +/// \brief Request the current render window to be made the active +/// foreground window +/// +/// At any given time, only one window may have the input focus +/// to receive input events such as keystrokes or mouse events. +/// If a window requests focus, it only hints to the operating +/// system, that it would like to be focused. The operating system +/// is free to deny the request. +/// This is not to be confused with sfWindow_setActive(). +/// +/// \see hasFocus +/// +/////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfRenderWindow_requestFocus(sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// \brief Check whether the render window has the input focus +/// +/// At any given time, only one window may have the input focus +/// to receive input events such as keystrokes or most mouse +/// events. +/// +/// \return True if window has focus, false otherwise +/// \see requestFocus +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfRenderWindow_hasFocus(const sfRenderWindow* renderWindow); + //////////////////////////////////////////////////////////// /// \brief Display a render window on screen /// diff --git a/include/SFML/Window/Window.h b/include/SFML/Window/Window.h index 29527a1..bd9873d 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -349,6 +349,7 @@ CSFML_WINDOW_API void sfWindow_setKeyRepeatEnabled(sfWindow* window, sfBool enab /// on the previous thread first if it was active. /// Only one window can be active on a thread at a time, thus /// the window previously active (if any) automatically gets deactivated. +/// This is not to be confused with sfWindow_requestFocus(). /// /// \param window Window object /// \param active sfTrue to activate, sfFalse to deactivate @@ -358,6 +359,35 @@ CSFML_WINDOW_API void sfWindow_setKeyRepeatEnabled(sfWindow* window, sfBool enab //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfBool sfWindow_setActive(sfWindow* window, sfBool active); +/////////////////////////////////////////////////////////// +/// \brief Request the current window to be made the active +/// foreground window +/// +/// At any given time, only one window may have the input focus +/// to receive input events such as keystrokes or mouse events. +/// If a window requests focus, it only hints to the operating +/// system, that it would like to be focused. The operating system +/// is free to deny the request. +/// This is not to be confused with sfWindow_setActive(). +/// +/// \see hasFocus +/// +/////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfWindow_requestFocus(sfWindow* window); + +//////////////////////////////////////////////////////////// +/// \brief Check whether the window has the input focus +/// +/// At any given time, only one window may have the input focus +/// to receive input events such as keystrokes or most mouse +/// events. +/// +/// \return True if window has focus, false otherwise +/// \see requestFocus +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfBool sfWindow_hasFocus(const sfWindow* window); + //////////////////////////////////////////////////////////// /// \brief Display on screen what has been rendered to the /// window so far diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 6a9ffaa..464bc5a 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -295,6 +295,20 @@ sfBool sfRenderWindow_setActive(sfRenderWindow* renderWindow, sfBool active) } +//////////////////////////////////////////////////////////// +void sfRenderWindow_requestFocus(sfRenderWindow* renderWindow) +{ + CSFML_CALL(renderWindow, requestFocus()); +} + + +//////////////////////////////////////////////////////////// +sfBool sfRenderWindow_hasFocus(const sfRenderWindow* renderWindow) +{ + CSFML_CALL_RETURN(renderWindow, hasFocus(), sfFalse); +} + + //////////////////////////////////////////////////////////// void sfRenderWindow_display(sfRenderWindow* renderWindow) { diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 5c5cd52..602f5fc 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -279,6 +279,20 @@ sfBool sfWindow_setActive(sfWindow* window, sfBool active) } +//////////////////////////////////////////////////////////// +void sfWindow_requestFocus(sfWindow* window) +{ + CSFML_CALL(window, requestFocus()); +} + + +//////////////////////////////////////////////////////////// +sfBool sfWindow_hasFocus(const sfWindow* window) +{ + CSFML_CALL_RETURN(window, hasFocus(), sfFalse); +} + + //////////////////////////////////////////////////////////// void sfWindow_display(sfWindow* window) {