diff options
| author | Michal Klocek <michal.klocek@qt.io> | 2025-10-29 14:38:43 +0100 |
|---|---|---|
| committer | Michal Klocek <michal.klocek@qt.io> | 2025-12-01 17:11:14 +0100 |
| commit | 68322bd57bd790d609e85599d3c524c9650e31c2 (patch) | |
| tree | 9c307f42d0e84f87675b4e57a1e4bb8beef6ea32 | |
| parent | 85be04668e0d4f176ae44da772b9da58dff388e5 (diff) | |
Make html comoboxes great again (1/2)
During transition from Qt5 to Qt6, we moved some code to
core and in 5d1ef38f9 we moved RWHV delegate to core.
Before that change we used to feed chromium with geometry
and frame geometry of delegated window and later in case
of qquickwindow based delegate we did dome extra 'fixup'
calculations to cover the fact that using geometry()
for view geometry in screen coordinates did not include
actual item delegate offset from the qml scene.
However after the change we use simply mapToGlobal within
the delegate for view geometry which already knows exact
global coordinates for the item within the qml scene.
In e2185036 we have fix for accessibility layout,
however local coordinate mappings makes no sense as it
will always return "0".
this->mapFromItem(this,QPoint(0,0))
Use simply global coordinates here, and remove obsolete
"fixup" calculation for offset in qquickwindow delegate.
Note this patch does not care about rotated qquickwebengineview.
The band-aid patch for that is in followup.
Task-number: QTBUG-135040
Fixes: QTBUG-140321
Fixes: QTBUG-139709
Pick-to: 6.10
Change-Id: I01266b42bc74120e39e2703db78c2b9c3548572f
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
| -rw-r--r-- | src/core/render_widget_host_view_qt_delegate_item.cpp | 4 | ||||
| -rw-r--r-- | src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp | 24 |
2 files changed, 10 insertions, 18 deletions
diff --git a/src/core/render_widget_host_view_qt_delegate_item.cpp b/src/core/render_widget_host_view_qt_delegate_item.cpp index 8c7405381..4886351ba 100644 --- a/src/core/render_widget_host_view_qt_delegate_item.cpp +++ b/src/core/render_widget_host_view_qt_delegate_item.cpp @@ -62,8 +62,8 @@ void RenderWidgetHostViewQtDelegateItem::initAsPopup(const QRect &screenRect) QRectF RenderWidgetHostViewQtDelegateItem::viewGeometry() const { // Transform the entire rect to find the correct top left corner. - const QPointF p1 = mapToGlobal(mapFromItem(this, QPointF(0, 0))); - const QPointF p2 = mapToGlobal(mapFromItem(this, QPointF(width(), height()))); + const QPointF p1 = mapToGlobal(QPointF(0, 0)); + const QPointF p2 = mapToGlobal(QPointF(width(), height())); QRectF geometry = QRectF(p1, p2).normalized(); // But keep the size untransformed to behave like other QQuickItems. geometry.setSize(size()); diff --git a/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp index f0d2b52c8..9e546089b 100644 --- a/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp +++ b/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp @@ -27,16 +27,6 @@ static inline struct ItemTransform getTransformValuesFromItemTree(QQuickItem *it return returnValue; } -static inline QPoint getOffset(QQuickItem *item) -{ - // get parent window (scene) offset - QPointF offset = item->mapFromScene(QPoint(0, 0)); - offset = item->mapToGlobal(offset); - // get local offset - offset -= item->mapToGlobal(QPoint(0, 0)); - return offset.toPoint(); -} - static inline QPointF transformPoint(const QPointF &point, const QTransform &transform, const QPointF &offset, const QQuickItem *parent) { @@ -73,7 +63,7 @@ void RenderWidgetHostViewQtDelegateQuickWindow::setVirtualParent(QQuickItem *vir m_virtualParent = virtualParent; } -// rect is window geometry in form of parent window offset + offset in scene coordinates +// rect is visual geometry in form of global screen coordinates // chromium knows nothing about local transformation void RenderWidgetHostViewQtDelegateQuickWindow::InitAsPopup(const QRect &rect) { @@ -112,9 +102,7 @@ void RenderWidgetHostViewQtDelegateQuickWindow::InitAsPopup(const QRect &rect) m_realDelegate->setRotation(transformValues.rotation); m_realDelegate->setScale(transformValues.scale); } else { - QRect geometry(rect); - geometry.moveTo(rect.topLeft() - getOffset(m_virtualParent)); - setGeometry(geometry); + setGeometry(rect); } m_realDelegate->show(); raise(); @@ -129,8 +117,12 @@ void RenderWidgetHostViewQtDelegateQuickWindow::Resize(int width, int height) void RenderWidgetHostViewQtDelegateQuickWindow::MoveWindow(const QPoint &screenPos) { - if (!m_transformed) - QQuickWindow::setPosition(screenPos - getOffset(m_virtualParent)); + if (!m_transformed) { + // Note we assume popup is frameless (no decorations), as screenPos is from + // visual gemometry and not window gemetry, however here we set + // positon of window frame. + QQuickWindow::setPosition(screenPos); + } } void RenderWidgetHostViewQtDelegateQuickWindow::SetClearColor(const QColor &color) |
