From 68b51734a91054b607dc9f565a11b43426da2e5a Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sat, 18 May 2013 20:48:55 +0200 Subject: [PATCH] Fake resize events are no longer sent when the window is moved, on Linux --- src/SFML/Window/Linux/WindowImplX11.cpp | 23 ++++++++++++++++------- src/SFML/Window/Linux/WindowImplX11.hpp | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/SFML/Window/Linux/WindowImplX11.cpp b/src/SFML/Window/Linux/WindowImplX11.cpp index 36620ced9..c7e06ed98 100644 --- a/src/SFML/Window/Linux/WindowImplX11.cpp +++ b/src/SFML/Window/Linux/WindowImplX11.cpp @@ -72,7 +72,8 @@ m_isExternal (true), m_atomClose (0), m_oldVideoMode(-1), m_hiddenCursor(0), -m_keyRepeat (true) +m_keyRepeat (true), +m_previousSize(-1, -1) { // Open a connection with the X server m_display = OpenDisplay(); @@ -101,7 +102,8 @@ m_isExternal (false), m_atomClose (0), m_oldVideoMode(-1), m_hiddenCursor(0), -m_keyRepeat (true) +m_keyRepeat (true), +m_previousSize(-1, -1) { // Open a connection with the X server m_display = OpenDisplay(); @@ -647,11 +649,18 @@ bool WindowImplX11::processEvent(XEvent windowEvent) // Resize event case ConfigureNotify : { - Event event; - event.type = Event::Resized; - event.size.width = windowEvent.xconfigure.width; - event.size.height = windowEvent.xconfigure.height; - pushEvent(event); + // ConfigureNotify can be triggered for other reasons, check if the size has acutally changed + if ((windowEvent.xconfigure.width != m_previousSize.x) || (windowEvent.xconfigure.height != m_previousSize.y)) + { + Event event; + event.type = Event::Resized; + event.size.width = windowEvent.xconfigure.width; + event.size.height = windowEvent.xconfigure.height; + pushEvent(event); + + m_previousSize.x = windowEvent.xconfigure.width; + m_previousSize.y = windowEvent.xconfigure.height; + } break; } diff --git a/src/SFML/Window/Linux/WindowImplX11.hpp b/src/SFML/Window/Linux/WindowImplX11.hpp index 91aacefdb..476148d59 100644 --- a/src/SFML/Window/Linux/WindowImplX11.hpp +++ b/src/SFML/Window/Linux/WindowImplX11.hpp @@ -223,6 +223,7 @@ private : Cursor m_hiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one bool m_keyRepeat; ///< Is the KeyRepeat feature enabled ? XEvent m_lastKeyReleaseEvent; ///< Last key release event we received (needed for discarding repeated key events) + Vector2i m_previousSize; ///< Previous size of the window, to find if a ConfigureNotify event is a resize event (could be a move event only) }; } // namespace priv