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>
This commit is contained in:
parent
ea668ff163
commit
0881b5d75c
@ -233,22 +233,14 @@ int QWasmCompositor::windowCount() const
|
||||
|
||||
QWindow *QWasmCompositor::windowAt(QPoint targetPointInScreenCoords, int padding) const
|
||||
{
|
||||
int index = m_windowStack.count() - 1;
|
||||
// qDebug() << "window at" << "point" << p << "window count" << index;
|
||||
const auto found = std::find_if(m_windowStack.rbegin(), m_windowStack.rend(),
|
||||
[this, padding, &targetPointInScreenCoords](const QWasmWindow* window) {
|
||||
const QRect geometry = window->windowFrameGeometry()
|
||||
.adjusted(-padding, -padding, padding, padding);
|
||||
|
||||
while (index >= 0) {
|
||||
const QWasmWindow *window = m_windowStack.at(index);
|
||||
//qDebug() << "windwAt testing" << compositedWindow.window <<
|
||||
|
||||
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;
|
||||
return m_windowVisibility[window] && geometry.contains(targetPointInScreenCoords);
|
||||
});
|
||||
return found != m_windowStack.rend() ? (*found)->window() : nullptr;
|
||||
}
|
||||
|
||||
QWindow *QWasmCompositor::keyWindow() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user