mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
DropShadower: Detect when window is no longer being displayed on the current desktop and hide shadows
This commit is contained in:
parent
b72b155443
commit
acddcd550d
2 changed files with 67 additions and 11 deletions
|
|
@ -75,7 +75,8 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE (ShadowWindow)
|
||||
};
|
||||
|
||||
class ParentVisibilityChangedListener : public ComponentListener
|
||||
class ParentVisibilityChangedListener : public ComponentListener,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
ParentVisibilityChangedListener (Component& r, ComponentListener& l)
|
||||
|
|
@ -83,6 +84,9 @@ public:
|
|||
{
|
||||
if (auto* firstParent = root->getParentComponent())
|
||||
updateParentHierarchy (firstParent);
|
||||
|
||||
if ((SystemStats::getOperatingSystemType() & SystemStats::Windows) != 0)
|
||||
startTimerHz (20);
|
||||
}
|
||||
|
||||
~ParentVisibilityChangedListener() override
|
||||
|
|
@ -146,6 +150,11 @@ private:
|
|||
withDifference (observedComponents, lastSeenComponents, [this] (auto& comp) { comp.addComponentListener (this); });
|
||||
}
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
listener->componentVisibilityChanged (*root);
|
||||
}
|
||||
|
||||
Component* root = nullptr;
|
||||
ComponentListener* listener = nullptr;
|
||||
std::set<ComponentWithWeakReference> observedComponents;
|
||||
|
|
@ -246,15 +255,11 @@ void DropShadower::updateShadows()
|
|||
|
||||
const ScopedValueSetter<bool> setter (reentrant, true);
|
||||
|
||||
if (owner == nullptr)
|
||||
{
|
||||
shadowWindows.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (owner->isShowing()
|
||||
&& owner->getWidth() > 0 && owner->getHeight() > 0
|
||||
&& (Desktop::canUseSemiTransparentWindows() || owner->getParentComponent() != nullptr))
|
||||
if (owner != nullptr
|
||||
&& owner->isShowing()
|
||||
&& owner->getWidth() > 0 && owner->getHeight() > 0
|
||||
&& (Desktop::canUseSemiTransparentWindows() || owner->getParentComponent() != nullptr)
|
||||
&& isWindowOnCurrentVirtualDesktop (owner->getWindowHandle()))
|
||||
{
|
||||
while (shadowWindows.size() < 4)
|
||||
shadowWindows.add (new ShadowWindow (owner, shadow));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue