Make setting QT_SCALE_FACTOR work on Wayland

QWindow geometry accessors return geometry in device
independent pixels. Normally this coordinate system
is equivalent to the Wayland native coordinate system,
but this is not the case when QT_SCALE_FACTOR is set.

Replace QWindow geometry calls with the helpers from
QPlatformWindow which return geometry in the native
coordinate system:

QWindow::geometry() -> QPlatformWindow::windowGeometry()
QWindow::frameGeometry() -> QPlatformWindow::windowFrameGeometry()

Task-number: QTBUG-87762
Fixes: QTBUG-88064
Change-Id: I8c96237b49c754bb978f1739d090962be770c271
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Morten Johan Sørvig 2020-11-13 11:21:50 +01:00
parent f73b8a94f4
commit b18aba6a42
3 changed files with 6 additions and 5 deletions

View File

@ -134,7 +134,7 @@ void QWaylandWlShellSurface::applyConfigure()
{
if ((m_pending.states & (Qt::WindowMaximized|Qt::WindowFullScreen))
&& !(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen))) {
m_normalSize = m_window->window()->frameGeometry().size();
m_normalSize = m_window->windowFrameGeometry().size();
}
if (m_pending.states != m_applied.states)

View File

@ -83,7 +83,7 @@ QWaylandXdgSurface::Toplevel::~Toplevel()
void QWaylandXdgSurface::Toplevel::applyConfigure()
{
if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size();
m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);

View File

@ -192,10 +192,11 @@ void QWaylandWindow::initWindow()
mSurface->set_buffer_scale(scale());
setWindowFlags(window()->flags());
if (window()->geometry().isEmpty())
QRect geometry = windowGeometry();
if (geometry.isEmpty())
setGeometry_helper(QRect(QPoint(), QSize(500,500)));
else
setGeometry_helper(window()->geometry());
setGeometry_helper(geometry);
setMask(window()->mask());
if (mShellSurface)
mShellSurface->requestWindowStates(window()->windowStates());
@ -427,7 +428,7 @@ void QWaylandWindow::setVisible(bool visible)
initWindow();
mDisplay->flushRequests();
setGeometry(window()->geometry());
setGeometry(windowGeometry());
// Don't flush the events here, or else the newly visible window may start drawing, but since
// there was no frame before it will be stuck at the waitForFrameSync() in
// QWaylandShmBackingStore::beginPaint().