1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Windows: Update window style flags when toggling kiosk mode

This is a different approach to the change introduced in
04f87320d5.

Instead of completely recreating the window, we now just update the
window's style flags. This should ensure that window and component focus
are preserved.
This commit is contained in:
reuk 2025-06-30 16:20:36 +01:00
parent 52079652d0
commit a2b2813b93
No known key found for this signature in database

View file

@ -5875,13 +5875,25 @@ void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable,
if (auto* peer = dynamic_cast<HWNDComponentPeer*> (kioskModeComp->getPeer()))
{
const auto prevFlags = (DWORD) GetWindowLong (peer->getHWND(), GWL_STYLE);
const auto nextFlags = peer->computeNativeStyleFlags();
const auto nextVisibility = prevFlags & WS_VISIBLE;
const auto nextFlags = peer->computeNativeStyleFlags() | nextVisibility;
if (nextFlags != prevFlags)
{
const auto styleFlags = peer->getStyleFlags();
kioskModeComp->removeFromDesktop();
kioskModeComp->addToDesktop (styleFlags);
SetWindowLong (peer->getHWND(), GWL_STYLE, nextFlags);
// After changing the window style flags, the window border visibility may have changed.
// Call SetWindowPos with no changes other than SWP_FRAMECHANGED to ensure that
// GetWindowInfo returns up-to-date border-size values.
static constexpr auto frameChangeOnly = SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOREDRAW
| SWP_NOACTIVATE
| SWP_FRAMECHANGED
| SWP_NOOWNERZORDER
| SWP_NOSENDCHANGING;
SetWindowPos (peer->getHWND(), nullptr, 0, 0, 0, 0, frameChangeOnly);
}
}
else