1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

OpenGL: Ensure window repainting messages are emitted correctly on Windows

This fixes an issue introduced in
340f531c71 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.
This commit is contained in:
reuk 2024-08-28 12:52:12 +01:00
parent 109ec550b9
commit 735f99418c
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -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> dummyComponent;
std::unique_ptr<PlaceholderComponent> placeholderComponent;
std::unique_ptr<ComponentPeer> nativeWindow;
std::unique_ptr<ScopedThreadDPIAwarenessSetter> threadAwarenessSetter;
Component::SafePointer<Component> safeComponent;