mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-18 00:54:19 +00:00
Simplified some component modal state handling code, hopefully also fixing an edge-case problem when showing modal windows on linux
This commit is contained in:
parent
0121cad723
commit
76737287c7
2 changed files with 17 additions and 23 deletions
|
|
@ -1721,50 +1721,46 @@ void Component::enterModalState (const bool shouldTakeKeyboardFocus,
|
|||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
|
||||
ASSERT_MESSAGE_MANAGER_IS_LOCKED
|
||||
|
||||
// Check for an attempt to make a component modal when it already is!
|
||||
// This can cause nasty problems..
|
||||
jassert (! flags.currentlyModalFlag);
|
||||
|
||||
if (! isCurrentlyModal())
|
||||
{
|
||||
ModalComponentManager* const mcm = ModalComponentManager::getInstance();
|
||||
mcm->startModal (this, deleteWhenDismissed);
|
||||
mcm->attachCallback (this, callback);
|
||||
ModalComponentManager& mcm = *ModalComponentManager::getInstance();
|
||||
mcm.startModal (this, deleteWhenDismissed);
|
||||
mcm.attachCallback (this, callback);
|
||||
|
||||
flags.currentlyModalFlag = true;
|
||||
setVisible (true);
|
||||
|
||||
if (shouldTakeKeyboardFocus)
|
||||
grabKeyboardFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Probably a bad idea to try to make a component modal twice!
|
||||
jassertfalse;
|
||||
}
|
||||
}
|
||||
|
||||
void Component::exitModalState (const int returnValue)
|
||||
{
|
||||
if (flags.currentlyModalFlag)
|
||||
if (isCurrentlyModal())
|
||||
{
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread())
|
||||
{
|
||||
ModalComponentManager::getInstance()->endModal (this, returnValue);
|
||||
flags.currentlyModalFlag = false;
|
||||
|
||||
ModalComponentManager::getInstance()->bringModalComponentsToFront();
|
||||
ModalComponentManager& mcm = *ModalComponentManager::getInstance();
|
||||
mcm.endModal (this, returnValue);
|
||||
mcm.bringModalComponentsToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
class ExitModalStateMessage : public CallbackMessage
|
||||
struct ExitModalStateMessage : public CallbackMessage
|
||||
{
|
||||
public:
|
||||
ExitModalStateMessage (Component* const c, const int res)
|
||||
: target (c), result (res) {}
|
||||
ExitModalStateMessage (Component* c, int res) : target (c), result (res) {}
|
||||
|
||||
void messageCallback() override
|
||||
{
|
||||
if (target.get() != nullptr) // (get() required for VS2003 bug)
|
||||
target->exitModalState (result);
|
||||
if (Component* c = target)
|
||||
c->exitModalState (result);
|
||||
}
|
||||
|
||||
private:
|
||||
WeakReference<Component> target;
|
||||
int result;
|
||||
};
|
||||
|
|
@ -1776,8 +1772,7 @@ void Component::exitModalState (const int returnValue)
|
|||
|
||||
bool Component::isCurrentlyModal() const noexcept
|
||||
{
|
||||
return flags.currentlyModalFlag
|
||||
&& getCurrentlyModalComponent() == this;
|
||||
return getCurrentlyModalComponent() == this;
|
||||
}
|
||||
|
||||
bool Component::isCurrentlyBlockedByAnotherModalComponent() const
|
||||
|
|
|
|||
|
|
@ -2277,7 +2277,6 @@ private:
|
|||
bool bufferToImageFlag : 1;
|
||||
bool bringToFrontOnClickFlag : 1;
|
||||
bool repaintOnMouseActivityFlag : 1;
|
||||
bool currentlyModalFlag : 1;
|
||||
bool isDisabledFlag : 1;
|
||||
bool childCompFocusedFlag : 1;
|
||||
bool dontClipGraphicsFlag : 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue