@@ -333,18 +333,30 @@ public: | |||||
void setParentWindow (::Window newParent) { parentWindow = newParent; } | void setParentWindow (::Window newParent) { parentWindow = newParent; } | ||||
//============================================================================== | //============================================================================== | ||||
bool isConstrainedNativeWindow() const | |||||
{ | |||||
return constrainer != nullptr | |||||
&& (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable) | |||||
&& ! isKioskMode(); | |||||
} | |||||
void updateWindowBounds() | void updateWindowBounds() | ||||
{ | { | ||||
jassert (windowH != 0); | |||||
if (windowH != 0) | |||||
if (windowH == 0) | |||||
{ | { | ||||
auto physicalBounds = XWindowSystem::getInstance()->getWindowBounds (windowH, parentWindow); | |||||
jassertfalse; | |||||
return; | |||||
} | |||||
updateScaleFactorFromNewBounds (physicalBounds, true); | |||||
if (isConstrainedNativeWindow()) | |||||
XWindowSystem::getInstance()->updateConstraints (windowH); | |||||
bounds = parentWindow == 0 ? Desktop::getInstance().getDisplays().physicalToLogical (physicalBounds) | |||||
: physicalBounds / currentScaleFactor; | |||||
} | |||||
auto physicalBounds = XWindowSystem::getInstance()->getWindowBounds (windowH, parentWindow); | |||||
updateScaleFactorFromNewBounds (physicalBounds, true); | |||||
bounds = parentWindow == 0 ? Desktop::getInstance().getDisplays().physicalToLogical (physicalBounds) | |||||
: physicalBounds / currentScaleFactor; | |||||
} | } | ||||
void updateBorderSize() | void updateBorderSize() | ||||
@@ -1720,6 +1720,8 @@ void XWindowSystem::setBounds (::Window windowH, Rectangle<int> newBounds, bool | |||||
} | } | ||||
} | } | ||||
updateConstraints (windowH, *peer); | |||||
XWindowSystemUtilities::ScopedXLock xLock; | XWindowSystemUtilities::ScopedXLock xLock; | ||||
if (auto hints = makeXFreePtr (X11Symbols::getInstance()->xAllocSizeHints())) | if (auto hints = makeXFreePtr (X11Symbols::getInstance()->xAllocSizeHints())) | ||||
@@ -1729,14 +1731,6 @@ void XWindowSystem::setBounds (::Window windowH, Rectangle<int> newBounds, bool | |||||
hints->y = newBounds.getY(); | hints->y = newBounds.getY(); | ||||
hints->width = newBounds.getWidth(); | hints->width = newBounds.getWidth(); | ||||
hints->height = newBounds.getHeight(); | hints->height = newBounds.getHeight(); | ||||
if ((peer->getStyleFlags() & ComponentPeer::windowIsResizable) == 0) | |||||
{ | |||||
hints->min_width = hints->max_width = hints->width; | |||||
hints->min_height = hints->max_height = hints->height; | |||||
hints->flags |= PMinSize | PMaxSize; | |||||
} | |||||
X11Symbols::getInstance()->xSetWMNormalHints (display, windowH, hints.get()); | X11Symbols::getInstance()->xSetWMNormalHints (display, windowH, hints.get()); | ||||
} | } | ||||
@@ -1750,6 +1744,40 @@ void XWindowSystem::setBounds (::Window windowH, Rectangle<int> newBounds, bool | |||||
} | } | ||||
} | } | ||||
void XWindowSystem::updateConstraints (::Window windowH) const | |||||
{ | |||||
if (auto* peer = getPeerFor (windowH)) | |||||
updateConstraints (windowH, *peer); | |||||
} | |||||
void XWindowSystem::updateConstraints (::Window windowH, ComponentPeer& peer) const | |||||
{ | |||||
XWindowSystemUtilities::ScopedXLock xLock; | |||||
if (auto hints = makeXFreePtr (X11Symbols::getInstance()->xAllocSizeHints())) | |||||
{ | |||||
if ((peer.getStyleFlags() & ComponentPeer::windowIsResizable) == 0) | |||||
{ | |||||
hints->min_width = hints->max_width = peer.getBounds().getWidth(); | |||||
hints->min_height = hints->max_height = peer.getBounds().getHeight(); | |||||
hints->flags = PMinSize | PMaxSize; | |||||
} | |||||
else if (auto* c = peer.getConstrainer()) | |||||
{ | |||||
const auto windowBorder = peer.getFrameSize(); | |||||
const auto leftAndRight = windowBorder.getLeftAndRight(); | |||||
const auto topAndBottom = windowBorder.getTopAndBottom(); | |||||
hints->min_width = jmax (1, c->getMinimumWidth() - leftAndRight); | |||||
hints->max_width = jmax (1, c->getMaximumWidth() - leftAndRight); | |||||
hints->min_height = jmax (1, c->getMinimumHeight() - topAndBottom); | |||||
hints->max_height = jmax (1, c->getMaximumHeight() - topAndBottom); | |||||
hints->flags = PMinSize | PMaxSize; | |||||
} | |||||
X11Symbols::getInstance()->xSetWMNormalHints (display, windowH, hints.get()); | |||||
} | |||||
} | |||||
bool XWindowSystem::contains (::Window windowH, Point<int> localPos) const | bool XWindowSystem::contains (::Window windowH, Point<int> localPos) const | ||||
{ | { | ||||
::Window root, child; | ::Window root, child; | ||||
@@ -177,6 +177,7 @@ public: | |||||
void setIcon (::Window , const Image&) const; | void setIcon (::Window , const Image&) const; | ||||
void setVisible (::Window, bool shouldBeVisible) const; | void setVisible (::Window, bool shouldBeVisible) const; | ||||
void setBounds (::Window, Rectangle<int>, bool fullScreen) const; | void setBounds (::Window, Rectangle<int>, bool fullScreen) const; | ||||
void updateConstraints (::Window) const; | |||||
BorderSize<int> getBorderSize (::Window) const; | BorderSize<int> getBorderSize (::Window) const; | ||||
Rectangle<int> getWindowBounds (::Window, ::Window parentWindow); | Rectangle<int> getWindowBounds (::Window, ::Window parentWindow); | ||||
@@ -316,6 +317,7 @@ private: | |||||
void dismissBlockingModals (LinuxComponentPeer*) const; | void dismissBlockingModals (LinuxComponentPeer*) const; | ||||
void dismissBlockingModals (LinuxComponentPeer*, const XConfigureEvent&) const; | void dismissBlockingModals (LinuxComponentPeer*, const XConfigureEvent&) const; | ||||
void updateConstraints (::Window, ComponentPeer&) const; | |||||
::Window findTopLevelWindowOf (::Window) const; | ::Window findTopLevelWindowOf (::Window) const; | ||||