From 735f99418ccca5b0e50902ef9900b057aa16d39a Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 28 Aug 2024 12:52:12 +0100 Subject: [PATCH] OpenGL: Ensure window repainting messages are emitted correctly on Windows This fixes an issue introduced in 340f531c71ebc62979e8c5ae9f18df26bf43a2d8 where embedded OpenGL windows would incorrectly have the WS_EX_LAYERED style bit set, which in turn prevented them from displaying correctly. Before the window-transparency refactoring, OpenGL windows would not have the layered bit set because only peers with windowIsSemiTransparent were created with the layered bit, and the layered bit was only updated if the peer alpha was changed. The new behaviour is to always set WS_EX_LAYERED if the peer's component is non-opaque with no titlebar, or if the component has an alpha < 1.0f. The OpenGLContext's placeholder component has no titlebar, so it must be opaque in order to avoid setting the layered style bit. --- modules/juce_opengl/native/juce_OpenGL_windows.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/juce_opengl/native/juce_OpenGL_windows.h b/modules/juce_opengl/native/juce_OpenGL_windows.h index e6b4363b0a..b9fcd2a156 100644 --- a/modules/juce_opengl/native/juce_OpenGL_windows.h +++ b/modules/juce_opengl/native/juce_OpenGL_windows.h @@ -47,7 +47,7 @@ public: bool /*useMultisampling*/, OpenGLVersion version) { - dummyComponent.reset (new DummyComponent (*this)); + placeholderComponent.reset (new PlaceholderComponent (*this)); createNativeWindow (component); PIXELFORMATDESCRIPTOR pfd; @@ -263,9 +263,13 @@ private: } //============================================================================== - struct DummyComponent : public Component + struct PlaceholderComponent : public Component { - DummyComponent (NativeContext& c) : context (c) {} + explicit PlaceholderComponent (NativeContext& c) + : context (c) + { + setOpaque (true); + } // The windowing code will call this when a paint callback happens void handleCommandMessage (int) override { context.triggerRepaint(); } @@ -295,7 +299,7 @@ private: auto* parentHWND = topComp->getWindowHandle(); ScopedThreadDPIAwarenessSetter setter { parentHWND }; - nativeWindow.reset (createNonRepaintingEmbeddedWindowsPeer (*dummyComponent, topComp)); + nativeWindow.reset (createNonRepaintingEmbeddedWindowsPeer (*placeholderComponent, topComp)); } if (auto* peer = topComp->getPeer()) @@ -383,7 +387,7 @@ private: }; CriticalSection mutex; - std::unique_ptr dummyComponent; + std::unique_ptr placeholderComponent; std::unique_ptr nativeWindow; std::unique_ptr threadAwarenessSetter; Component::SafePointer safeComponent;