Skip to content

Commit 11c441c

Browse files
redstrateWaqar144
authored andcommitted
Take into account the space between above or below a QQuickWidget
Applications such as KDE Plasma's System Settings or the simpler Qt's Quick Widgets Example are cases where there's space around the QQuickWidget. For System Settings there is a toolbar below the widget, and in the Qt example it's an MDI window. GammaRay failed at capturing both of these, but this is easy to fix. If we detect that we're inside a bigger window, take the height difference into account. This completely fixes the capture of the aforementioned examples, and doesn't seem to regress in other cases. I only changed and tested on the >=6.8 ifdef branch, since I assume this was broken when porting for the single surface changes.
1 parent ee964e7 commit 11c441c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugins/quickinspector/quickscreengrabber.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,14 @@ void OpenGLScreenGrabber::windowAfterRendering()
627627
QPoint offset;
628628
rc->renderWindow(&offset);
629629

630+
// If we are rendering into a window, we need to take into account the space between us and the bottom of the window (if any)
631+
const auto renderWindow = rc->renderWindowFor(m_window);
632+
if (renderWindow != nullptr) {
633+
yOff = renderWindow->height() - m_renderInfo.windowSize.height() - offset.y();
634+
}
630635
xOff = offset.x();
631636
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
632-
yOff = 0;
637+
yOff = static_cast<int>(std::floor(yOff * m_renderInfo.dpr));
633638
xOff = static_cast<int>(std::floor(xOff * m_renderInfo.dpr));
634639
#else
635640
const auto viewportHeight = viewport[3];

0 commit comments

Comments
 (0)