@@ -4,6 +4,30 @@ JUCE breaking changes | |||||
develop | develop | ||||
======= | ======= | ||||
Change | |||||
------ | |||||
The ComponentPeer::getFrameSize() function has been deprecated on Linux. | |||||
Possible Issues | |||||
--------------- | |||||
Deprecation warnings will be seen when compiling code which uses this function | |||||
and eventually builds will fail when it is later removed from the API. | |||||
Workaround | |||||
---------- | |||||
Use the ComponentPeer::getFrameSizeIfPresent() function. The new function returns | |||||
an OptionalBorderSize object. Use operator bool() to determine if the border size | |||||
is valid, then access the value using operator*() only if it is. | |||||
Rationale | |||||
--------- | |||||
The XWindow system cannot return a valid border size immediately after window | |||||
creation. ComponentPeer::getFrameSize() returns a default constructed | |||||
BorderSize<int> instance in such cases that corresponds to a frame size of | |||||
zero. That however can be a valid value, and needs to be treated differently | |||||
from the situation when the frame size is not yet available. | |||||
Change | Change | ||||
------ | ------ | ||||
The return type of XWindowSystem::getBorderSize() was changed to | The return type of XWindowSystem::getBorderSize() was changed to | ||||
@@ -1012,7 +1012,8 @@ void MainWindowList::checkWindowBounds (MainWindow& windowToCheck) | |||||
auto screenLimits = Desktop::getInstance().getDisplays().getDisplayForRect (windowBounds)->userArea; | auto screenLimits = Desktop::getInstance().getDisplays().getDisplayForRect (windowBounds)->userArea; | ||||
if (auto* peer = windowToCheck.getPeer()) | if (auto* peer = windowToCheck.getPeer()) | ||||
peer->getFrameSize().subtractFrom (screenLimits); | |||||
if (const auto frameSize = peer->getFrameSizeIfPresent()) | |||||
frameSize->subtractFrom (screenLimits); | |||||
auto constrainedX = jlimit (screenLimits.getX(), jmax (screenLimits.getX(), screenLimits.getRight() - windowBounds.getWidth()), windowBounds.getX()); | auto constrainedX = jlimit (screenLimits.getX(), jmax (screenLimits.getX(), screenLimits.getRight() - windowBounds.getWidth()), windowBounds.getX()); | ||||
auto constrainedY = jlimit (screenLimits.getY(), jmax (screenLimits.getY(), screenLimits.getBottom() - windowBounds.getHeight()), windowBounds.getY()); | auto constrainedY = jlimit (screenLimits.getY(), jmax (screenLimits.getY(), screenLimits.getBottom() - windowBounds.getHeight()), windowBounds.getY()); | ||||
@@ -983,7 +983,8 @@ private: | |||||
const auto windowBorders = [&]() -> BorderSize<int> | const auto windowBorders = [&]() -> BorderSize<int> | ||||
{ | { | ||||
if (auto* peer = owner.getPeer()) | if (auto* peer = owner.getPeer()) | ||||
return peer->getFrameSize(); | |||||
if (const auto frameSize = peer->getFrameSizeIfPresent()) | |||||
return *frameSize; | |||||
return {}; | return {}; | ||||
}(); | }(); | ||||
@@ -114,7 +114,8 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* component, | |||||
else | else | ||||
{ | { | ||||
if (auto* peer = component->getPeer()) | if (auto* peer = component->getPeer()) | ||||
border = peer->getFrameSize(); | |||||
if (const auto frameSize = peer->getFrameSizeIfPresent()) | |||||
border = *frameSize; | |||||
auto screenBounds = Desktop::getInstance().getDisplays().getDisplayForPoint (targetBounds.getCentre())->userArea; | auto screenBounds = Desktop::getInstance().getDisplays().getDisplayForPoint (targetBounds.getCentre())->userArea; | ||||
@@ -2390,7 +2390,16 @@ private: | |||||
{ | { | ||||
if (auto* constrainer = owner->getConstrainer()) | if (auto* constrainer = owner->getConstrainer()) | ||||
{ | { | ||||
const auto originalBounds = owner->getFrameSize().addedTo (owner->getComponent().getScreenBounds()).toFloat(); | |||||
const auto originalBounds = [&]() -> Rectangle<float> | |||||
{ | |||||
const auto screenBounds = owner->getComponent().getScreenBounds(); | |||||
if (const auto frameSize = owner->getFrameSizeIfPresent()) | |||||
return frameSize->addedTo (screenBounds).toFloat(); | |||||
return screenBounds.toFloat(); | |||||
}(); | |||||
const auto expanded = originalBounds.withWidth ((float) constrainer->getMaximumWidth()) | const auto expanded = originalBounds.withWidth ((float) constrainer->getMaximumWidth()) | ||||
.withHeight ((float) constrainer->getMaximumHeight()); | .withHeight ((float) constrainer->getMaximumHeight()); | ||||
const auto constrained = expanded.constrainedWithin (convertToRectFloat (flippedScreenRect (r))); | const auto constrained = expanded.constrainedWithin (convertToRectFloat (flippedScreenRect (r))); | ||||
@@ -1744,7 +1744,13 @@ void XWindowSystem::setBounds (::Window windowH, Rectangle<int> newBounds, bool | |||||
X11Symbols::getInstance()->xSetWMNormalHints (display, windowH, hints.get()); | X11Symbols::getInstance()->xSetWMNormalHints (display, windowH, hints.get()); | ||||
} | } | ||||
auto windowBorder = peer->getFrameSize(); | |||||
const auto windowBorder = [&]() -> BorderSize<int> | |||||
{ | |||||
if (const auto& frameSize = peer->getFrameSizeIfPresent()) | |||||
return *frameSize; | |||||
return {}; | |||||
}(); | |||||
X11Symbols::getInstance()->xMoveResizeWindow (display, windowH, | X11Symbols::getInstance()->xMoveResizeWindow (display, windowH, | ||||
newBounds.getX() - windowBorder.getLeft(), | newBounds.getX() - windowBorder.getLeft(), | ||||
@@ -1774,7 +1780,14 @@ void XWindowSystem::updateConstraints (::Window windowH, ComponentPeer& peer) co | |||||
} | } | ||||
else if (auto* c = peer.getConstrainer()) | else if (auto* c = peer.getConstrainer()) | ||||
{ | { | ||||
const auto windowBorder = peer.getFrameSize(); | |||||
const auto windowBorder = [&]() -> BorderSize<int> | |||||
{ | |||||
if (const auto& frameSize = peer.getFrameSizeIfPresent()) | |||||
return *frameSize; | |||||
return {}; | |||||
}(); | |||||
const auto factor = peer.getPlatformScaleFactor(); | const auto factor = peer.getPlatformScaleFactor(); | ||||
const auto leftAndRight = windowBorder.getLeftAndRight(); | const auto leftAndRight = windowBorder.getLeftAndRight(); | ||||
const auto topAndBottom = windowBorder.getTopAndBottom(); | const auto topAndBottom = windowBorder.getTopAndBottom(); | ||||
@@ -260,6 +260,9 @@ public: | |||||
Whether or not the window has a normal window frame depends on the flags | Whether or not the window has a normal window frame depends on the flags | ||||
that were set when the window was created by Component::addToDesktop() | that were set when the window was created by Component::addToDesktop() | ||||
*/ | */ | ||||
#if JUCE_LINUX || JUCE_BSD | |||||
[[deprecated ("Use getFrameSizeIfPresent instead.")]] | |||||
#endif | |||||
virtual BorderSize<int> getFrameSize() const = 0; | virtual BorderSize<int> getFrameSize() const = 0; | ||||
/** This is called when the window's bounds change. | /** This is called when the window's bounds change. | ||||
@@ -532,9 +532,12 @@ String ResizableWindow::getWindowStateAsString() | |||||
#if JUCE_LINUX | #if JUCE_LINUX | ||||
if (auto* peer = isOnDesktop() ? getPeer() : nullptr) | if (auto* peer = isOnDesktop() ? getPeer() : nullptr) | ||||
{ | { | ||||
const auto frameSize = peer->getFrameSize(); | |||||
stateString << " frame " << frameSize.getTop() << ' ' << frameSize.getLeft() | |||||
<< ' ' << frameSize.getBottom() << ' ' << frameSize.getRight(); | |||||
if (const auto optionalFrameSize = peer->getFrameSizeIfPresent()) | |||||
{ | |||||
const auto& frameSize = *optionalFrameSize; | |||||
stateString << " frame " << frameSize.getTop() << ' ' << frameSize.getLeft() | |||||
<< ' ' << frameSize.getBottom() << ' ' << frameSize.getRight(); | |||||
} | |||||
} | } | ||||
#endif | #endif | ||||
@@ -610,7 +613,9 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) | |||||
if (peer != nullptr) | if (peer != nullptr) | ||||
{ | { | ||||
peer->getFrameSize().subtractFrom (newPos); | |||||
if (const auto frameSize = peer->getFrameSizeIfPresent()) | |||||
frameSize->subtractFrom (newPos); | |||||
peer->setNonFullScreenBounds (newPos); | peer->setNonFullScreenBounds (newPos); | ||||
} | } | ||||