diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 8440dc52..77dd0f9a 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -72,7 +72,9 @@ m_callback (0), m_cursor (NULL), m_icon (NULL), m_keyRepeatEnabled(true), -m_isCursorIn (false) +m_isCursorIn (false), +m_lastSize (0, 0), +m_resizing (false) { if (m_handle) { @@ -90,7 +92,9 @@ m_callback (0), m_cursor (NULL), m_icon (NULL), 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 if (windowCount == 0) @@ -436,20 +440,48 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) // Resize event case WM_SIZE : { - // Ignore size events triggered by a minimize (size == 0 in this case) - if (wParam != SIZE_MINIMIZED) + // Consider only events triggered by a maximize or a un-maximize + if (wParam != SIZE_MINIMIZED && !m_resizing && m_lastSize != getSize()) { - // Get the new size - RECT rectangle; - GetClientRect(m_handle, &rectangle); + // Update the last handled size + m_lastSize = getSize(); + // Push a resize event Event event; event.type = Event::Resized; - event.size.width = rectangle.right - rectangle.left; - event.size.height = rectangle.bottom - rectangle.top; + event.size.width = m_lastSize.x; + event.size.height = m_lastSize.y; 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 diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index 542c57dc..88d1a3ed 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -236,6 +236,8 @@ private : HICON m_icon; ///< Custom icon assigned to the window bool m_keyRepeatEnabled; ///< Automatic key-repeat state for keydown events 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