From 608b4fb28d68ea9ba251f31965f533d082cdd816 Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Fri, 8 May 2015 11:27:44 +0200 Subject: [PATCH] Only spawn Resized event when window size changes. --- src/SFML/Window/Unix/WindowImplX11.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index d8c26e06..9a1f4df6 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -1926,12 +1926,21 @@ bool WindowImplX11::processEvent(xcb_generic_event_t* windowEvent) if (passEvent(windowEvent, reinterpret_cast(windowEvent)->window)) return false; + // X notifies about "window configuration events", which also includes moving a window only. Check + // for a different size and only spawn a Resized event when it differs. xcb_configure_notify_event_t* e = reinterpret_cast(windowEvent); - Event event; - event.type = Event::Resized; - event.size.width = e->width; - event.size.height = e->height; - pushEvent(event); + + if (e->width != m_previousSize.x || e->height != m_previousSize.y) + { + m_previousSize.x = e->width; + m_previousSize.y = e->height; + + Event event; + event.type = Event::Resized; + event.size.width = e->width; + event.size.height = e->height; + pushEvent(event); + } break; }