From b8fa424f85b681772eab1948ff8b02808832748c Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 4 Sep 2025 02:51:50 -0700 Subject: [PATCH] wayland/idle-inhibit: fix formatting + lints, destructor, add logs --- src/wayland/idle_inhibit/inhibitor.cpp | 6 +++++- src/wayland/idle_inhibit/inhibitor.hpp | 3 +++ src/wayland/idle_inhibit/proto.cpp | 13 +++++++++++- .../idle_inhibit/test/manual/idle_inhibit.qml | 20 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/wayland/idle_inhibit/test/manual/idle_inhibit.qml diff --git a/src/wayland/idle_inhibit/inhibitor.cpp b/src/wayland/idle_inhibit/inhibitor.cpp index 697f127..efeeae1 100644 --- a/src/wayland/idle_inhibit/inhibitor.cpp +++ b/src/wayland/idle_inhibit/inhibitor.cpp @@ -13,9 +13,13 @@ namespace qs::wayland::idle_inhibit { using QtWaylandClient::QWaylandWindow; IdleInhibitor::IdleInhibitor() { - this->bBoundWindow.setBinding([this] { return this->bEnabled ? this->bWindowObject.value() : nullptr; }); + this->bBoundWindow.setBinding([this] { + return this->bEnabled ? this->bWindowObject.value() : nullptr; + }); } +IdleInhibitor::~IdleInhibitor() { delete this->inhibitor; } + QObject* IdleInhibitor::window() const { return this->bWindowObject; } void IdleInhibitor::setWindow(QObject* window) { diff --git a/src/wayland/idle_inhibit/inhibitor.hpp b/src/wayland/idle_inhibit/inhibitor.hpp index 3d16bd4..c1a3e95 100644 --- a/src/wayland/idle_inhibit/inhibitor.hpp +++ b/src/wayland/idle_inhibit/inhibitor.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "../../window/proxywindow.hpp" @@ -38,6 +39,8 @@ class IdleInhibitor: public QObject { public: IdleInhibitor(); + ~IdleInhibitor() override; + Q_DISABLE_COPY_MOVE(IdleInhibitor); [[nodiscard]] QObject* window() const; void setWindow(QObject* window); diff --git a/src/wayland/idle_inhibit/proto.cpp b/src/wayland/idle_inhibit/proto.cpp index 0caab91..25701a7 100644 --- a/src/wayland/idle_inhibit/proto.cpp +++ b/src/wayland/idle_inhibit/proto.cpp @@ -1,10 +1,18 @@ #include "proto.hpp" #include +#include +#include #include +#include "../../core/logcat.hpp" + namespace qs::wayland::idle_inhibit::impl { +namespace { +QS_LOGGING_CATEGORY(logIdleInhibit, "quickshell.wayland.idle_inhibit", QtWarningMsg); +} + IdleInhibitManager::IdleInhibitManager(): QWaylandClientExtensionTemplate(1) { this->initialize(); } IdleInhibitManager* IdleInhibitManager::instance() { @@ -13,10 +21,13 @@ IdleInhibitManager* IdleInhibitManager::instance() { } IdleInhibitor* IdleInhibitManager::createIdleInhibitor(QtWaylandClient::QWaylandWindow* surface) { - return new IdleInhibitor(this->create_inhibitor(surface->surface())); + auto* inhibitor = new IdleInhibitor(this->create_inhibitor(surface->surface())); + qCDebug(logIdleInhibit) << "Created inhibitor" << inhibitor; + return inhibitor; } IdleInhibitor::~IdleInhibitor() { + qCDebug(logIdleInhibit) << "Destroyed inhibitor" << this; if (this->isInitialized()) this->destroy(); } diff --git a/src/wayland/idle_inhibit/test/manual/idle_inhibit.qml b/src/wayland/idle_inhibit/test/manual/idle_inhibit.qml new file mode 100644 index 0000000..f80e647 --- /dev/null +++ b/src/wayland/idle_inhibit/test/manual/idle_inhibit.qml @@ -0,0 +1,20 @@ +import QtQuick +import QtQuick.Controls +import Quickshell +import Quickshell.Wayland + +FloatingWindow { + id: root + color: contentItem.palette.window + + CheckBox { + id: enableCb + anchors.centerIn: parent + text: "Enable Inhibitor" + } + + IdleInhibitor { + window: root + enabled: enableCb.checked + } +}