Do not allow an empty rect to become a window rect on WASM
For regular windows, the size should not be allowed to be empty. This emulates system-wide minimum size setting on various operating systems. Change-Id: I515fff8c9bfd14762dcfe88fb923ab10d8edd5c1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
f562711c64
commit
3b423f0e9e
@ -109,15 +109,19 @@ void QWasmWindow::initialize()
|
||||
{
|
||||
QRect rect = windowGeometry();
|
||||
|
||||
QPlatformWindow::setGeometry(rect);
|
||||
constexpr int minSizeBoundForDialogsAndRegularWindows = 100;
|
||||
const int windowType = window()->flags() & Qt::WindowType_Mask;
|
||||
const int systemMinSizeLowerBound = windowType == Qt::Window || windowType == Qt::Dialog
|
||||
? minSizeBoundForDialogsAndRegularWindows
|
||||
: 0;
|
||||
|
||||
const QSize minimumSize = windowMinimumSize();
|
||||
if (rect.width() > 0 || rect.height() > 0) {
|
||||
rect.setWidth(qBound(1, rect.width(), 2000));
|
||||
rect.setHeight(qBound(1, rect.height(), 2000));
|
||||
} else if (minimumSize.width() > 0 || minimumSize.height() > 0) {
|
||||
rect.setSize(minimumSize);
|
||||
}
|
||||
const QSize minimumSize(std::max(windowMinimumSize().width(), systemMinSizeLowerBound),
|
||||
std::max(windowMinimumSize().height(), systemMinSizeLowerBound));
|
||||
const QSize maximumSize = windowMaximumSize();
|
||||
const QSize targetSize = !rect.isEmpty() ? rect.size() : minimumSize;
|
||||
|
||||
rect.setWidth(qBound(minimumSize.width(), targetSize.width(), maximumSize.width()));
|
||||
rect.setHeight(qBound(minimumSize.width(), targetSize.height(), maximumSize.height()));
|
||||
|
||||
setWindowState(window()->windowStates());
|
||||
setWindowFlags(window()->flags());
|
||||
@ -125,6 +129,7 @@ void QWasmWindow::initialize()
|
||||
if (window()->isTopLevel())
|
||||
setWindowIcon(window()->icon());
|
||||
m_normalGeometry = rect;
|
||||
QPlatformWindow::setGeometry(m_normalGeometry);
|
||||
}
|
||||
|
||||
QWasmScreen *QWasmWindow::platformScreen() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user