quickshell/src/window/windowinterface.cpp
outfoxxed b6a79fe99c
core/proxywindow: improve QsWindowAttached robustness
Can now track window parent window changes.
Added tests.
2024-11-27 23:30:38 -08:00

20 lines
571 B
C++

#include "windowinterface.hpp"
#include <qobject.h>
#include <qquickitem.h>
#include "proxywindow.hpp"
QsWindowAttached::QsWindowAttached(QQuickItem* parent): QObject(parent) {
QObject::connect(parent, &QQuickItem::windowChanged, this, &QsWindowAttached::updateWindow);
}
QsWindowAttached* WindowInterface::qmlAttachedProperties(QObject* object) {
while (object && !qobject_cast<QQuickItem*>(object)) {
object = object->parent();
}
if (!object) return nullptr;
auto* item = static_cast<QQuickItem*>(object); // NOLINT
return new ProxyWindowAttached(item);
}