wayland/idle-inhibit: fix formatting + lints, destructor, add logs

This commit is contained in:
outfoxxed 2025-09-04 02:51:50 -07:00
parent a7aa9328df
commit 20cc729e73
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 40 additions and 2 deletions

View file

@ -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) {

View file

@ -3,6 +3,7 @@
#include <qobject.h>
#include <qproperty.h>
#include <qqmlintegration.h>
#include <qtclasshelpermacros.h>
#include <qtmetamacros.h>
#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);

View file

@ -1,10 +1,18 @@
#include "proto.hpp"
#include <private/qwaylandwindow_p.h>
#include <qlogging.h>
#include <qloggingcategory.h>
#include <qwaylandclientextension.h>
#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();
}

View file

@ -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
}
}