feat(wayland): create cross platform window interfaces

Internally this also refactors a ton of code around the wayland
layershell. Note that attachment failures are still broken and
platform interfaces are hardcoded.
This commit is contained in:
outfoxxed 2024-02-25 07:13:54 -08:00
parent 4a82949854
commit c2930783ea
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
20 changed files with 591 additions and 402 deletions

View file

@ -0,0 +1,62 @@
#include "floatingwindow.hpp"
#include <qobject.h>
#include <qqmllist.h>
#include <qquickitem.h>
#include <qtypes.h>
#include "proxywindow.hpp"
#include "windowinterface.hpp"
void ProxyFloatingWindow::setWidth(qint32 width) {
if (this->window == nullptr || !this->window->isVisible()) {
this->ProxyWindowBase::setWidth(width);
}
}
void ProxyFloatingWindow::setHeight(qint32 height) {
if (this->window == nullptr || !this->window->isVisible()) {
this->ProxyWindowBase::setHeight(height);
}
}
// FloatingWindowInterface
FloatingWindowInterface::FloatingWindowInterface(QObject* parent)
: WindowInterface(parent)
, window(new ProxyFloatingWindow(this)) {
// clang-format off
QObject::connect(this->window, &ProxyWindowBase::windowConnected, this, &FloatingWindowInterface::windowConnected);
QObject::connect(this->window, &ProxyWindowBase::visibleChanged, this, &FloatingWindowInterface::visibleChanged);
QObject::connect(this->window, &ProxyWindowBase::heightChanged, this, &FloatingWindowInterface::heightChanged);
QObject::connect(this->window, &ProxyWindowBase::widthChanged, this, &FloatingWindowInterface::widthChanged);
QObject::connect(this->window, &ProxyWindowBase::screenChanged, this, &FloatingWindowInterface::screenChanged);
QObject::connect(this->window, &ProxyWindowBase::colorChanged, this, &FloatingWindowInterface::colorChanged);
QObject::connect(this->window, &ProxyWindowBase::maskChanged, this, &FloatingWindowInterface::maskChanged);
// clang-format on
}
void FloatingWindowInterface::onReload(QObject* oldInstance) {
auto* old = qobject_cast<FloatingWindowInterface*>(oldInstance);
this->window->onReload(old != nullptr ? old->window : nullptr);
}
QQmlListProperty<QObject> FloatingWindowInterface::data() { return this->window->data(); }
QQuickItem* FloatingWindowInterface::contentItem() const { return this->window->contentItem(); }
// NOLINTBEGIN
#define proxyPair(type, get, set) \
type FloatingWindowInterface::get() const { return this->window->get(); } \
void FloatingWindowInterface::set(type value) { this->window->set(value); }
proxyPair(bool, isVisible, setVisible);
proxyPair(qint32, width, setWidth);
proxyPair(qint32, height, setHeight);
proxyPair(QuickShellScreenInfo*, screen, setScreen);
proxyPair(QColor, color, setColor);
proxyPair(PendingRegion*, mask, setMask);
#undef proxyPair
#undef proxySet
#undef proxyGet
// NOLINTEND