Changed Window::requestFocus() return type from bool to void

Reasons:
* Consistent with other sf::Window methods
* User can test whether focus succeeded by subsequent hasFocus() call
* Implementation would have to call hasFocus() anyway on some systems

Also: minor code style change in Window::hasFocus()
This commit is contained in:
Jan Haller 2014-05-29 11:39:04 +02:00
parent 6a24eb5eec
commit 4155b2e449
12 changed files with 16 additions and 35 deletions

View File

@ -423,11 +423,10 @@ public:
/// is free to deny the request.
/// This is not to be confused with setActive().
///
/// \return True if operation was successful, false otherwise
/// \see hasFocus
///
////////////////////////////////////////////////////////////
bool requestFocus();
void requestFocus();
////////////////////////////////////////////////////////////
/// \brief Check whether the window has the input focus

View File

@ -188,7 +188,7 @@
////////////////////////////////////////////////////////
-(BOOL)requestFocus
-(void)requestFocus
{
// Note: this doesn't imply that the view will get any event.
// The user has to make sure events are forwarded to the view
@ -197,8 +197,6 @@
// In case the app is not active, make its dock icon bounce for one sec
[NSApp requestUserAttention:NSInformationalRequest];
return [self hasFocus];
}

View File

@ -452,14 +452,12 @@
////////////////////////////////////////////////////////
-(BOOL)requestFocus
-(void)requestFocus
{
[m_window makeKeyAndOrderFront:nil];
// In case the app is not active, make its dock icon bounce for one sec
[NSApp requestUserAttention:NSInformationalRequest];
return [self hasFocus];
}

View File

@ -324,10 +324,8 @@ public:
/// \brief Request the current window to be made the active
/// foreground window
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
virtual bool requestFocus();
virtual void requestFocus();
////////////////////////////////////////////////////////////
/// \brief Check whether the window has the input focus

View File

@ -553,9 +553,9 @@ void WindowImplCocoa::setKeyRepeatEnabled(bool enabled)
////////////////////////////////////////////////////////////
bool WindowImplCocoa::requestFocus()
void WindowImplCocoa::requestFocus()
{
return [m_delegate requestFocus];
[m_delegate requestFocus];
}

View File

@ -170,10 +170,8 @@ namespace sf {
/// \brief Request the current window to be made the active
/// foreground window
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
-(BOOL)requestFocus;
-(void)requestFocus;
////////////////////////////////////////////////////////////
/// \brief Check whether the window has the input focus

View File

@ -484,11 +484,10 @@ void WindowImplX11::setKeyRepeatEnabled(bool enabled)
////////////////////////////////////////////////////////////
bool WindowImplX11::requestFocus()
void WindowImplX11::requestFocus()
{
XRaiseWindow(m_display, m_window);
XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime);
return true;
}

View File

@ -158,10 +158,8 @@ public:
/// \brief Request the current window to be made the active
/// foreground window
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
virtual bool requestFocus();
virtual void requestFocus();
////////////////////////////////////////////////////////////
/// \brief Check whether the window has the input focus

View File

@ -367,9 +367,9 @@ void WindowImplWin32::setKeyRepeatEnabled(bool enabled)
////////////////////////////////////////////////////////////
bool WindowImplWin32::requestFocus()
void WindowImplWin32::requestFocus()
{
return SetForegroundWindow(m_handle);
SetForegroundWindow(m_handle);
}

View File

@ -157,10 +157,8 @@ public:
/// \brief Request the current window to be made the active
/// foreground window
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
virtual bool requestFocus();
virtual void requestFocus();
////////////////////////////////////////////////////////////
/// \brief Check whether the window has the input focus

View File

@ -337,20 +337,17 @@ bool Window::setActive(bool active) const
////////////////////////////////////////////////////////////
bool Window::requestFocus()
void Window::requestFocus()
{
if (m_impl)
return m_impl->requestFocus();
return false;
m_impl->requestFocus();
}
////////////////////////////////////////////////////////////
bool Window::hasFocus() const
{
if (m_impl)
return m_impl->hasFocus();
return false;
return m_impl && m_impl->hasFocus();
}

View File

@ -198,10 +198,8 @@ public:
/// \brief Request the current window to be made the active
/// foreground window
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
virtual bool requestFocus() = 0;
virtual void requestFocus() = 0;
////////////////////////////////////////////////////////////
/// \brief Check whether the window has the input focus