From 3118ee1e5cd8569cf43a97c1b80a661cfe3f0b6c Mon Sep 17 00:00:00 2001 From: attila Date: Tue, 22 Oct 2024 16:16:02 +0200 Subject: [PATCH] Linux: Prevent stale ConfigureNotify events from overwriting the current window position --- modules/juce_gui_basics/native/juce_Windowing_linux.cpp | 9 ++++++++- .../juce_gui_basics/native/juce_XWindowSystem_linux.cpp | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/native/juce_Windowing_linux.cpp b/modules/juce_gui_basics/native/juce_Windowing_linux.cpp index ae7926bb02..d6d3f322da 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_linux.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_linux.cpp @@ -110,7 +110,13 @@ public: WeakReference deletionChecker (&component); - XWindowSystem::getInstance()->setBounds (windowH, physicalBounds, isNowFullScreen); + // If we are in a ConfigureNotify handler then forceSetBounds is being called as a + // consequence of X11 telling us what the window size is. There's no need to report this + // size back again to X11. By this we are avoiding a pitfall, when we get many subsequent + // ConfigureNotify events, many of which has stale size information. By not calling + // XWindowSystem::setBounds we are not actualising these old, incorrect sizes. + if (! inConfigureNotifyHandler) + XWindowSystem::getInstance()->setBounds (windowH, physicalBounds, isNowFullScreen); fullScreen = isNowFullScreen; @@ -421,6 +427,7 @@ public: //============================================================================== static bool isActiveApplication; bool focused = false; + bool inConfigureNotifyHandler = false; private: //============================================================================== diff --git a/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp b/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp index 57d8ae6f88..8e89116f87 100644 --- a/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp +++ b/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp @@ -3773,6 +3773,8 @@ void XWindowSystem::dismissBlockingModals (LinuxComponentPeer* peer) const void XWindowSystem::handleConfigureNotifyEvent (LinuxComponentPeer* peer, XConfigureEvent& confEvent) const { + const ScopedValueSetter scope { peer->inConfigureNotifyHandler, true }; + peer->updateWindowBounds(); peer->updateBorderSize(); peer->handleMovedOrResized();