forked from quickshell/quickshell
wayland: namespace type names a bit to prevent future conflicts
This commit is contained in:
parent
1e647cee51
commit
3480707e99
8 changed files with 106 additions and 106 deletions
|
@ -18,8 +18,8 @@
|
|||
#include "../core/reload.hpp"
|
||||
#include "session_lock/session_lock.hpp"
|
||||
|
||||
void SessionLock::onReload(QObject* oldInstance) {
|
||||
auto* old = qobject_cast<SessionLock*>(oldInstance);
|
||||
void WlSessionLock::onReload(QObject* oldInstance) {
|
||||
auto* old = qobject_cast<WlSessionLock*>(oldInstance);
|
||||
|
||||
if (old != nullptr) {
|
||||
QObject::disconnect(old->manager, nullptr, old, nullptr);
|
||||
|
@ -30,18 +30,18 @@ void SessionLock::onReload(QObject* oldInstance) {
|
|||
}
|
||||
|
||||
// clang-format off
|
||||
QObject::connect(this->manager, &SessionLockManager::locked, this, &SessionLock::secureStateChanged);
|
||||
QObject::connect(this->manager, &SessionLockManager::unlocked, this, &SessionLock::secureStateChanged);
|
||||
QObject::connect(this->manager, &SessionLockManager::locked, this, &WlSessionLock::secureStateChanged);
|
||||
QObject::connect(this->manager, &SessionLockManager::unlocked, this, &WlSessionLock::secureStateChanged);
|
||||
|
||||
QObject::connect(this->manager, &SessionLockManager::unlocked, this, &SessionLock::unlock);
|
||||
QObject::connect(this->manager, &SessionLockManager::unlocked, this, &WlSessionLock::unlock);
|
||||
|
||||
auto* app = QCoreApplication::instance();
|
||||
auto* guiApp = qobject_cast<QGuiApplication*>(app);
|
||||
|
||||
if (guiApp != nullptr) {
|
||||
QObject::connect(guiApp, &QGuiApplication::primaryScreenChanged, this, &SessionLock::onScreensChanged);
|
||||
QObject::connect(guiApp, &QGuiApplication::screenAdded, this, &SessionLock::onScreensChanged);
|
||||
QObject::connect(guiApp, &QGuiApplication::screenRemoved, this, &SessionLock::onScreensChanged);
|
||||
QObject::connect(guiApp, &QGuiApplication::primaryScreenChanged, this, &WlSessionLock::onScreensChanged);
|
||||
QObject::connect(guiApp, &QGuiApplication::screenAdded, this, &WlSessionLock::onScreensChanged);
|
||||
QObject::connect(guiApp, &QGuiApplication::screenRemoved, this, &WlSessionLock::onScreensChanged);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
|
@ -53,7 +53,7 @@ void SessionLock::onReload(QObject* oldInstance) {
|
|||
}
|
||||
}
|
||||
|
||||
void SessionLock::updateSurfaces(SessionLock* old) {
|
||||
void WlSessionLock::updateSurfaces(WlSessionLock* old) {
|
||||
if (this->manager->isLocked()) {
|
||||
auto screens = QGuiApplication::screens();
|
||||
|
||||
|
@ -66,7 +66,7 @@ void SessionLock::updateSurfaces(SessionLock* old) {
|
|||
}
|
||||
|
||||
if (this->mSurfaceComponent == nullptr) {
|
||||
qWarning() << "SessionLock.surface is null. Aborting lock.";
|
||||
qWarning() << "WlSessionLock.surface is null. Aborting lock.";
|
||||
this->unlock();
|
||||
return;
|
||||
}
|
||||
|
@ -75,10 +75,10 @@ void SessionLock::updateSurfaces(SessionLock* old) {
|
|||
if (!this->surfaces.contains(screen)) {
|
||||
auto* instanceObj =
|
||||
this->mSurfaceComponent->create(QQmlEngine::contextForObject(this->mSurfaceComponent));
|
||||
auto* instance = qobject_cast<SessionLockSurface*>(instanceObj);
|
||||
auto* instance = qobject_cast<WlSessionLockSurface*>(instanceObj);
|
||||
|
||||
if (instance == nullptr) {
|
||||
qWarning() << "SessionLock.surface does not create a SessionLockSurface. Aborting lock.";
|
||||
qWarning() << "WlSessionLock.surface does not create a WlSessionLockSurface. Aborting lock.";
|
||||
if (instanceObj != nullptr) instanceObj->deleteLater();
|
||||
this->unlock();
|
||||
return;
|
||||
|
@ -100,7 +100,7 @@ void SessionLock::updateSurfaces(SessionLock* old) {
|
|||
}
|
||||
}
|
||||
|
||||
void SessionLock::unlock() {
|
||||
void WlSessionLock::unlock() {
|
||||
if (this->isLocked()) {
|
||||
this->lockTarget = false;
|
||||
this->manager->unlock();
|
||||
|
@ -115,17 +115,17 @@ void SessionLock::unlock() {
|
|||
}
|
||||
}
|
||||
|
||||
void SessionLock::onScreensChanged() { this->updateSurfaces(); }
|
||||
void WlSessionLock::onScreensChanged() { this->updateSurfaces(); }
|
||||
|
||||
bool SessionLock::isLocked() const {
|
||||
bool WlSessionLock::isLocked() const {
|
||||
return this->manager == nullptr ? this->lockTarget : this->manager->isLocked();
|
||||
}
|
||||
|
||||
bool SessionLock::isSecure() const {
|
||||
bool WlSessionLock::isSecure() const {
|
||||
return this->manager != nullptr && SessionLockManager::isSecure();
|
||||
}
|
||||
|
||||
void SessionLock::setLocked(bool locked) {
|
||||
void WlSessionLock::setLocked(bool locked) {
|
||||
if (this->isLocked() == locked) return;
|
||||
this->lockTarget = locked;
|
||||
|
||||
|
@ -143,9 +143,9 @@ void SessionLock::setLocked(bool locked) {
|
|||
}
|
||||
}
|
||||
|
||||
QQmlComponent* SessionLock::surfaceComponent() const { return this->mSurfaceComponent; }
|
||||
QQmlComponent* WlSessionLock::surfaceComponent() const { return this->mSurfaceComponent; }
|
||||
|
||||
void SessionLock::setSurfaceComponent(QQmlComponent* surfaceComponent) {
|
||||
void WlSessionLock::setSurfaceComponent(QQmlComponent* surfaceComponent) {
|
||||
if (this->mSurfaceComponent != nullptr) this->mSurfaceComponent->deleteLater();
|
||||
if (surfaceComponent != nullptr) surfaceComponent->setParent(this);
|
||||
|
||||
|
@ -153,7 +153,7 @@ void SessionLock::setSurfaceComponent(QQmlComponent* surfaceComponent) {
|
|||
emit this->surfaceComponentChanged();
|
||||
}
|
||||
|
||||
SessionLockSurface::SessionLockSurface(QObject* parent)
|
||||
WlSessionLockSurface::WlSessionLockSurface(QObject* parent)
|
||||
: Reloadable(parent)
|
||||
, mContentItem(new QQuickItem())
|
||||
, ext(new LockWindowExtension(this)) {
|
||||
|
@ -161,19 +161,19 @@ SessionLockSurface::SessionLockSurface(QObject* parent)
|
|||
this->mContentItem->setParent(this);
|
||||
|
||||
// clang-format off
|
||||
QObject::connect(this, &SessionLockSurface::widthChanged, this, &SessionLockSurface::onWidthChanged);
|
||||
QObject::connect(this, &SessionLockSurface::heightChanged, this, &SessionLockSurface::onHeightChanged);
|
||||
QObject::connect(this, &WlSessionLockSurface::widthChanged, this, &WlSessionLockSurface::onWidthChanged);
|
||||
QObject::connect(this, &WlSessionLockSurface::heightChanged, this, &WlSessionLockSurface::onHeightChanged);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
SessionLockSurface::~SessionLockSurface() {
|
||||
WlSessionLockSurface::~WlSessionLockSurface() {
|
||||
if (this->window != nullptr) {
|
||||
this->window->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void SessionLockSurface::onReload(QObject* oldInstance) {
|
||||
if (auto* old = qobject_cast<SessionLockSurface*>(oldInstance)) {
|
||||
void WlSessionLockSurface::onReload(QObject* oldInstance) {
|
||||
if (auto* old = qobject_cast<WlSessionLockSurface*>(oldInstance)) {
|
||||
this->window = old->disownWindow();
|
||||
}
|
||||
|
||||
|
@ -190,25 +190,25 @@ void SessionLockSurface::onReload(QObject* oldInstance) {
|
|||
this->window->setColor(this->mColor);
|
||||
|
||||
// clang-format off
|
||||
QObject::connect(this->window, &QWindow::visibilityChanged, this, &SessionLockSurface::visibleChanged);
|
||||
QObject::connect(this->window, &QWindow::widthChanged, this, &SessionLockSurface::widthChanged);
|
||||
QObject::connect(this->window, &QWindow::heightChanged, this, &SessionLockSurface::heightChanged);
|
||||
QObject::connect(this->window, &QWindow::screenChanged, this, &SessionLockSurface::screenChanged);
|
||||
QObject::connect(this->window, &QQuickWindow::colorChanged, this, &SessionLockSurface::colorChanged);
|
||||
QObject::connect(this->window, &QWindow::visibilityChanged, this, &WlSessionLockSurface::visibleChanged);
|
||||
QObject::connect(this->window, &QWindow::widthChanged, this, &WlSessionLockSurface::widthChanged);
|
||||
QObject::connect(this->window, &QWindow::heightChanged, this, &WlSessionLockSurface::heightChanged);
|
||||
QObject::connect(this->window, &QWindow::screenChanged, this, &WlSessionLockSurface::screenChanged);
|
||||
QObject::connect(this->window, &QQuickWindow::colorChanged, this, &WlSessionLockSurface::colorChanged);
|
||||
// clang-format on
|
||||
|
||||
if (auto* parent = qobject_cast<SessionLock*>(this->parent())) {
|
||||
if (auto* parent = qobject_cast<WlSessionLock*>(this->parent())) {
|
||||
if (!this->ext->attach(this->window, parent->manager)) {
|
||||
qWarning(
|
||||
) << "Failed to attach LockWindowExtension to window. Surface will not behave correctly.";
|
||||
}
|
||||
} else {
|
||||
qWarning(
|
||||
) << "SessionLockSurface parent is not a SessionLock. Surface will not behave correctly.";
|
||||
) << "WlSessionLockSurface parent is not a WlSessionLock. Surface will not behave correctly.";
|
||||
}
|
||||
}
|
||||
|
||||
QQuickWindow* SessionLockSurface::disownWindow() {
|
||||
QQuickWindow* WlSessionLockSurface::disownWindow() {
|
||||
QObject::disconnect(this->window, nullptr, this, nullptr);
|
||||
this->mContentItem->setParentItem(nullptr);
|
||||
|
||||
|
@ -217,23 +217,23 @@ QQuickWindow* SessionLockSurface::disownWindow() {
|
|||
return window;
|
||||
}
|
||||
|
||||
void SessionLockSurface::show() { this->ext->setVisible(); }
|
||||
void WlSessionLockSurface::show() { this->ext->setVisible(); }
|
||||
|
||||
QQuickItem* SessionLockSurface::contentItem() const { return this->mContentItem; }
|
||||
QQuickItem* WlSessionLockSurface::contentItem() const { return this->mContentItem; }
|
||||
|
||||
bool SessionLockSurface::isVisible() const { return this->window->isVisible(); }
|
||||
bool WlSessionLockSurface::isVisible() const { return this->window->isVisible(); }
|
||||
|
||||
qint32 SessionLockSurface::width() const {
|
||||
qint32 WlSessionLockSurface::width() const {
|
||||
if (this->window == nullptr) return 0;
|
||||
else return this->window->width();
|
||||
}
|
||||
|
||||
qint32 SessionLockSurface::height() const {
|
||||
qint32 WlSessionLockSurface::height() const {
|
||||
if (this->window == nullptr) return 0;
|
||||
else return this->window->height();
|
||||
}
|
||||
|
||||
QuickshellScreenInfo* SessionLockSurface::screen() const {
|
||||
QuickshellScreenInfo* WlSessionLockSurface::screen() const {
|
||||
QScreen* qscreen = nullptr;
|
||||
|
||||
if (this->window == nullptr) {
|
||||
|
@ -243,18 +243,18 @@ QuickshellScreenInfo* SessionLockSurface::screen() const {
|
|||
}
|
||||
|
||||
return new QuickshellScreenInfo(
|
||||
const_cast<SessionLockSurface*>(this), // NOLINT
|
||||
const_cast<WlSessionLockSurface*>(this), // NOLINT
|
||||
qscreen
|
||||
);
|
||||
}
|
||||
|
||||
void SessionLockSurface::setScreen(QScreen* qscreen) {
|
||||
void WlSessionLockSurface::setScreen(QScreen* qscreen) {
|
||||
if (this->mScreen != nullptr) {
|
||||
QObject::disconnect(this->mScreen, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
if (qscreen != nullptr) {
|
||||
QObject::connect(qscreen, &QObject::destroyed, this, &SessionLockSurface::onScreenDestroyed);
|
||||
QObject::connect(qscreen, &QObject::destroyed, this, &WlSessionLockSurface::onScreenDestroyed);
|
||||
}
|
||||
|
||||
if (this->window == nullptr) {
|
||||
|
@ -263,23 +263,23 @@ void SessionLockSurface::setScreen(QScreen* qscreen) {
|
|||
} else this->window->setScreen(qscreen);
|
||||
}
|
||||
|
||||
void SessionLockSurface::onScreenDestroyed() { this->mScreen = nullptr; }
|
||||
void WlSessionLockSurface::onScreenDestroyed() { this->mScreen = nullptr; }
|
||||
|
||||
QColor SessionLockSurface::color() const {
|
||||
QColor WlSessionLockSurface::color() const {
|
||||
if (this->window == nullptr) return this->mColor;
|
||||
else return this->window->color();
|
||||
}
|
||||
|
||||
void SessionLockSurface::setColor(QColor color) {
|
||||
void WlSessionLockSurface::setColor(QColor color) {
|
||||
if (this->window == nullptr) {
|
||||
this->mColor = color;
|
||||
emit this->colorChanged();
|
||||
} else this->window->setColor(color);
|
||||
}
|
||||
|
||||
QQmlListProperty<QObject> SessionLockSurface::data() {
|
||||
QQmlListProperty<QObject> WlSessionLockSurface::data() {
|
||||
return this->mContentItem->property("data").value<QQmlListProperty<QObject>>();
|
||||
}
|
||||
|
||||
void SessionLockSurface::onWidthChanged() { this->mContentItem->setWidth(this->width()); }
|
||||
void SessionLockSurface::onHeightChanged() { this->mContentItem->setHeight(this->height()); }
|
||||
void WlSessionLockSurface::onWidthChanged() { this->mContentItem->setWidth(this->width()); }
|
||||
void WlSessionLockSurface::onHeightChanged() { this->mContentItem->setHeight(this->height()); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue