Utility/Window: Window now automatically close on quit event

Former-commit-id: 3e3e84e1e89a2c643e19e183a1286d95550d2965 [formerly 813114f7beb2af1836f8dfd66fe089be66efb6d9] [formerly 881ff104de309ade91fed5b5ffdb66025775bc57 [formerly 3fd695c4ac86999600262c99160d8dd20740409c]]
Former-commit-id: bce06f73894643e2f612c60c73fa340c54a4ad98 [formerly fe4a806707c5339aff9eada8e20e1921d1190141]
Former-commit-id: 7a2012bd3d3930beb958bb729934d41cd6b81e69
This commit is contained in:
Lynix 2016-08-28 01:09:15 +02:00
parent 618449c13a
commit 732a6d9322
2 changed files with 14 additions and 1 deletions

View File

@ -52,6 +52,7 @@ namespace Nz
void Destroy();
inline void EnableCloseOnQuit(bool closeOnQuit);
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable);
void EnableKeyRepeat(bool enable);
void EnableSmoothScrolling(bool enable);
@ -122,6 +123,7 @@ namespace Nz
#endif
EventHandler m_eventHandler;
bool m_closed;
bool m_closeOnQuit;
bool m_eventPolling;
bool m_ownsWindow;
};

View File

@ -16,6 +16,7 @@ namespace Nz
#if NAZARA_UTILITY_THREADED_WINDOW
m_waitForEvent(false),
#endif
m_closeOnQuit(true),
m_eventPolling(false)
{
}
@ -44,10 +45,11 @@ namespace Nz
m_eventCondition(std::move(window.m_eventCondition)),
m_eventMutex(std::move(window.m_eventMutex)),
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
m_eventPolling(window.m_eventPolling),
m_waitForEvent(window.m_waitForEvent),
#endif
m_closed(window.m_closed),
m_closeOnQuit(window.m_closeOnQuit),
m_eventPolling(window.m_eventPolling),
m_ownsWindow(window.m_ownsWindow)
{
window.m_impl = nullptr;
@ -63,6 +65,11 @@ namespace Nz
m_closed = true; // The window will be closed at the next non-const IsOpen() call
}
inline void Window::EnableCloseOnQuit(bool closeOnQuit)
{
m_closeOnQuit = closeOnQuit;
}
inline void Window::EnableEventPolling(bool enable)
{
m_eventPolling = enable;
@ -116,6 +123,9 @@ namespace Nz
if (event.type == WindowEventType_Resized)
OnWindowResized();
if (event.type == WindowEventType_Quit && m_closeOnQuit)
Close();
#if NAZARA_UTILITY_THREADED_WINDOW
m_eventMutex.Unlock();
@ -137,6 +147,7 @@ namespace Nz
Destroy();
m_closed = window.m_closed;
m_closeOnQuit = window.m_closeOnQuit;
m_eventPolling = window.m_eventPolling;
m_impl = window.m_impl;
m_events = std::move(window.m_events);