1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

HWNDComponentPeer: Avoid dismissing modals from peer-initiated messages

This commit is contained in:
reuk 2021-05-14 15:44:27 +01:00
parent 1124ec146d
commit c19cd73306
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -1427,6 +1427,8 @@ public:
void setVisible (bool shouldBeVisible) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
ShowWindow (hwnd, shouldBeVisible ? SW_SHOWNA : SW_HIDE);
if (shouldBeVisible)
@ -1468,6 +1470,8 @@ public:
void setBounds (const Rectangle<int>& bounds, bool isNowFullScreen) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
fullScreen = isNowFullScreen;
auto newBounds = windowBorder.addedTo (bounds);
@ -1534,6 +1538,8 @@ public:
void setAlpha (float newAlpha) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
auto intAlpha = (uint8) jlimit (0, 255, (int) (newAlpha * 255.0f));
if (component.isOpaque())
@ -1558,6 +1564,8 @@ public:
void setMinimised (bool shouldBeMinimised) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
if (shouldBeMinimised != isMinimised())
ShowWindow (hwnd, shouldBeMinimised ? SW_MINIMIZE : SW_SHOWNORMAL);
}
@ -1573,6 +1581,8 @@ public:
void setFullScreen (bool shouldBeFullScreen) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
setMinimised (false);
if (isFullScreen() != shouldBeFullScreen)
@ -1656,6 +1666,8 @@ public:
void toFront (bool makeActive) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
setMinimised (false);
const bool oldDeactivate = shouldDeactivateTitleBar;
@ -1674,6 +1686,8 @@ public:
void toBehind (ComponentPeer* other) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
if (auto* otherPeer = dynamic_cast<HWNDComponentPeer*> (other))
{
setMinimised (false);
@ -1698,6 +1712,8 @@ public:
void grabFocus() override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
const bool oldDeactivate = shouldDeactivateTitleBar;
shouldDeactivateTitleBar = ((styleFlags & windowIsTemporary) == 0);
@ -4181,7 +4197,10 @@ private:
void windowShouldDismissModals (HWND originator)
{
if (component.isShowing() && isAncestor (originator, hwnd))
if (shouldIgnoreModalDismiss)
return;
if (isAncestor (originator, hwnd))
sendInputAttemptWhenModalMessage();
}
@ -4249,6 +4268,7 @@ private:
SharedResourcePointer<TopLevelModalDismissBroadcaster> modalDismissBroadcaster;
IMEHandler imeHandler;
bool shouldIgnoreModalDismiss = false;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HWNDComponentPeer)