Merge pull request #249 from kimci86/master
Fix behavior of sf::Event::Resized on Windows
This commit is contained in:
commit
d22a3189a1
@ -72,7 +72,9 @@ m_callback (0),
|
|||||||
m_cursor (NULL),
|
m_cursor (NULL),
|
||||||
m_icon (NULL),
|
m_icon (NULL),
|
||||||
m_keyRepeatEnabled(true),
|
m_keyRepeatEnabled(true),
|
||||||
m_isCursorIn (false)
|
m_isCursorIn (false),
|
||||||
|
m_lastSize (0, 0),
|
||||||
|
m_resizing (false)
|
||||||
{
|
{
|
||||||
if (m_handle)
|
if (m_handle)
|
||||||
{
|
{
|
||||||
@ -90,7 +92,9 @@ m_callback (0),
|
|||||||
m_cursor (NULL),
|
m_cursor (NULL),
|
||||||
m_icon (NULL),
|
m_icon (NULL),
|
||||||
m_keyRepeatEnabled(true),
|
m_keyRepeatEnabled(true),
|
||||||
m_isCursorIn (false)
|
m_isCursorIn (false),
|
||||||
|
m_lastSize (mode.width, mode.height),
|
||||||
|
m_resizing (false)
|
||||||
{
|
{
|
||||||
// Register the window class at first call
|
// Register the window class at first call
|
||||||
if (windowCount == 0)
|
if (windowCount == 0)
|
||||||
@ -436,20 +440,48 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
// Resize event
|
// Resize event
|
||||||
case WM_SIZE :
|
case WM_SIZE :
|
||||||
{
|
{
|
||||||
// Ignore size events triggered by a minimize (size == 0 in this case)
|
// Consider only events triggered by a maximize or a un-maximize
|
||||||
if (wParam != SIZE_MINIMIZED)
|
if (wParam != SIZE_MINIMIZED && !m_resizing && m_lastSize != getSize())
|
||||||
{
|
{
|
||||||
// Get the new size
|
// Update the last handled size
|
||||||
RECT rectangle;
|
m_lastSize = getSize();
|
||||||
GetClientRect(m_handle, &rectangle);
|
|
||||||
|
|
||||||
|
// Push a resize event
|
||||||
Event event;
|
Event event;
|
||||||
event.type = Event::Resized;
|
event.type = Event::Resized;
|
||||||
event.size.width = rectangle.right - rectangle.left;
|
event.size.width = m_lastSize.x;
|
||||||
event.size.height = rectangle.bottom - rectangle.top;
|
event.size.height = m_lastSize.y;
|
||||||
pushEvent(event);
|
pushEvent(event);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start resizing
|
||||||
|
case WM_ENTERSIZEMOVE:
|
||||||
|
{
|
||||||
|
m_resizing = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop resizing
|
||||||
|
case WM_EXITSIZEMOVE:
|
||||||
|
{
|
||||||
|
m_resizing = false;
|
||||||
|
|
||||||
|
// Ignore cases where the window has only been moved
|
||||||
|
if(m_lastSize != getSize())
|
||||||
|
{
|
||||||
|
// Update the last handled size
|
||||||
|
m_lastSize = getSize();
|
||||||
|
|
||||||
|
// Push a resize event
|
||||||
|
Event event;
|
||||||
|
event.type = Event::Resized;
|
||||||
|
event.size.width = m_lastSize.x;
|
||||||
|
event.size.height = m_lastSize.y;
|
||||||
|
pushEvent(event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gain focus event
|
// Gain focus event
|
||||||
|
@ -236,6 +236,8 @@ private :
|
|||||||
HICON m_icon; ///< Custom icon assigned to the window
|
HICON m_icon; ///< Custom icon assigned to the window
|
||||||
bool m_keyRepeatEnabled; ///< Automatic key-repeat state for keydown events
|
bool m_keyRepeatEnabled; ///< Automatic key-repeat state for keydown events
|
||||||
bool m_isCursorIn; ///< Is the mouse cursor in the window's area ?
|
bool m_isCursorIn; ///< Is the mouse cursor in the window's area ?
|
||||||
|
Vector2u m_lastSize; ///< The last handled size of the window
|
||||||
|
bool m_resizing; ///< Is the window being resized ?
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
Loading…
Reference in New Issue
Block a user