wasm: Fix minimum and default window sizes

Remove minimum window size restriction. User should be able to change
minimum window size if needed.
Set default size to 160x160 to match other platforms.

Change-Id: Ic199fc34982021ba38d631476fbb1c51370b2e8e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Piotr Wierciński 2024-03-05 15:13:07 +01:00
parent 476e503cfb
commit cd2e1b0b4b
3 changed files with 5 additions and 21 deletions

View File

@ -208,23 +208,9 @@ bool QWasmWindow::onNonClientEvent(const PointerEvent &event)
void QWasmWindow::initialize()
{
QRect rect = windowGeometry();
const auto windowFlags = window()->flags();
const bool shouldRestrictMinSize =
!windowFlags.testFlag(Qt::FramelessWindowHint) && !windowIsPopupType(windowFlags);
const bool isMinSizeUninitialized = window()->minimumSize() == QSize(0, 0);
if (shouldRestrictMinSize && isMinSizeUninitialized)
window()->setMinimumSize(QSize(minSizeForRegularWindows, minSizeForRegularWindows));
const QSize minimumSize = windowMinimumSize();
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.height(), targetSize.height(), maximumSize.height()));
auto initialGeometry = QPlatformWindow::initialGeometry(window(),
windowGeometry(), defaultWindowSize, defaultWindowSize);
m_normalGeometry = initialGeometry;
setWindowState(window()->windowStates());
setWindowFlags(window()->flags());
@ -233,7 +219,6 @@ void QWasmWindow::initialize()
if (window()->isTopLevel())
setWindowIcon(window()->icon());
m_normalGeometry = rect;
QPlatformWindow::setGeometry(m_normalGeometry);
#if QT_CONFIG(accessibility)

View File

@ -105,7 +105,7 @@ public:
private:
friend class QWasmScreen;
static constexpr auto minSizeForRegularWindows = 100;
static constexpr auto defaultWindowSize = 160;
// QWasmWindowTreeNode:
QWasmWindow *asWasmWindow() final;

View File

@ -28,7 +28,6 @@ class WidgetTestCase(unittest.TestCase):
self.addTypeEqualityFunc(Rect, assert_rects_equal)
def test_window_resizing(self):
defaultWindowMinSize = 100
screen = Screen(self._driver, ScreenPosition.FIXED,
x=0, y=0, width=600, height=600)
window = Window(parent=screen, rect=Rect(x=100, y=100, width=200, height=200))
@ -59,7 +58,7 @@ class WidgetTestCase(unittest.TestCase):
self.assertEqual(window.rect, Rect(x=75, y=95, width=215, height=230))
window.drag(Handle.BOTTOM_RIGHT, direction=UP(150) + LEFT(150))
self.assertEqual(window.rect, Rect(x=75, y=95, width=defaultWindowMinSize, height=defaultWindowMinSize))
self.assertEqual(window.rect, Rect(x=75, y=95, width=65, height=80))
def test_cannot_resize_over_screen_top_edge(self):
screen = Screen(self._driver, ScreenPosition.FIXED,