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

Partially revert "ComponentPeer: Add isShowing() member, which more closely matches expected behaviour of Component::isShowing"

This partially reverts commit 555b667d22.

Using ComponentPeer::isShowing instead of ComponentPeer::isMinimised
inside Component::isShowing can cause problems when displaying OpenGL
components.

Specifically, OpenGL components use a ComponentMovementWatcher to
determine when they should be attached/detached from the parent window.
The ComponentMovementWatcher updates whenever a component visibility
change event is emitted, which happens in two cases:
- Component::setVisible is called on the OpenGL component or an ancestor
- ComponentPeer::handleMovedOrResized is called in response to a
  minimisation state change

When handling either of these events, the ComponentMovementWatcher will
call Component::isShowing to determine whether or not the component is
really showing.

The problem is that the result of ComponentPeer::isShowing may change
independently of changes to the Component visiblity state or
ComponentPeer minimisation state, so the ComponentPeerWatcher might not
notify its listeners when a component is really shown/hidden.

One potential workaround would be for the ComponentPeer to send
notifications when the showing state of the window changes, so that the
ComponentMovementWatcher can forward those notifications. The main
problem with this approach is that on Windows, the window doesn't seem
to receive a message on hide/show, and it's not clear whether there
exists some other approach to detect a hide/show event.

If there were some event we could listen for on Windows, then we could
call Component::sendVisibilityChangeMessage in response to this event
and things would *likely* work at that point, but this may still have
unintended side-effect. As a result, I think the best approach to
restore the old behaviour is to revert the change to
Component::isShowing. The implementations of ComponentPeer::isShowing
have been left in place so that users can do still query the real
visibility state of native windows if necessary.
This commit is contained in:
reuk 2024-09-30 11:55:06 +01:00
parent 77d4198091
commit f5f758c032
2 changed files with 2 additions and 2 deletions

View file

@ -343,7 +343,7 @@ bool Component::isShowing() const
return parentComponent->isShowing();
if (auto* peer = getPeer())
return peer->isShowing();
return ! peer->isMinimised();
return false;
}

View file

@ -206,7 +206,7 @@ public:
bool isShowing() const override
{
return XWindowSystem::getInstance()->isMinimised (windowH);
return ! XWindowSystem::getInstance()->isMinimised (windowH);
}
void setFullScreen (bool shouldBeFullScreen) override