Modernize QWasmCompositor::windowAt
Use a well-known idiom for finding a matching window in the window stack (std::find_if) Change-Id: I677ef6ad8ee88bbd9eee1405be592ec2527ca3b9 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> (cherry picked from commit 0881b5d75c8ad01b295edb96ffd1392d4b804e61) Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
77a892affc
commit
c0129e6ad3
@ -233,22 +233,14 @@ int QWasmCompositor::windowCount() const
|
|||||||
|
|
||||||
QWindow *QWasmCompositor::windowAt(QPoint targetPointInScreenCoords, int padding) const
|
QWindow *QWasmCompositor::windowAt(QPoint targetPointInScreenCoords, int padding) const
|
||||||
{
|
{
|
||||||
int index = m_windowStack.count() - 1;
|
const auto found = std::find_if(m_windowStack.rbegin(), m_windowStack.rend(),
|
||||||
// qDebug() << "window at" << "point" << p << "window count" << index;
|
[this, padding, &targetPointInScreenCoords](const QWasmWindow* window) {
|
||||||
|
const QRect geometry = window->windowFrameGeometry()
|
||||||
|
.adjusted(-padding, -padding, padding, padding);
|
||||||
|
|
||||||
while (index >= 0) {
|
return m_windowVisibility[window] && geometry.contains(targetPointInScreenCoords);
|
||||||
const QWasmWindow *window = m_windowStack.at(index);
|
});
|
||||||
//qDebug() << "windwAt testing" << compositedWindow.window <<
|
return found != m_windowStack.rend() ? (*found)->window() : nullptr;
|
||||||
|
|
||||||
QRect geometry = window->windowFrameGeometry()
|
|
||||||
.adjusted(-padding, -padding, padding, padding);
|
|
||||||
|
|
||||||
if (m_windowVisibility[window] && geometry.contains(targetPointInScreenCoords))
|
|
||||||
return m_windowStack.at(index)->window();
|
|
||||||
--index;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindow *QWasmCompositor::keyWindow() const
|
QWindow *QWasmCompositor::keyWindow() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user