Skip to content

Commit 20cc729

Browse files
committed
wayland/idle-inhibit: fix formatting + lints, destructor, add logs
1 parent a7aa932 commit 20cc729

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

src/wayland/idle_inhibit/inhibitor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ namespace qs::wayland::idle_inhibit {
1313
using QtWaylandClient::QWaylandWindow;
1414

1515
IdleInhibitor::IdleInhibitor() {
16-
this->bBoundWindow.setBinding([this] { return this->bEnabled ? this->bWindowObject.value() : nullptr; });
16+
this->bBoundWindow.setBinding([this] {
17+
return this->bEnabled ? this->bWindowObject.value() : nullptr;
18+
});
1719
}
1820

21+
IdleInhibitor::~IdleInhibitor() { delete this->inhibitor; }
22+
1923
QObject* IdleInhibitor::window() const { return this->bWindowObject; }
2024

2125
void IdleInhibitor::setWindow(QObject* window) {

src/wayland/idle_inhibit/inhibitor.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <qobject.h>
44
#include <qproperty.h>
55
#include <qqmlintegration.h>
6+
#include <qtclasshelpermacros.h>
67
#include <qtmetamacros.h>
78

89
#include "../../window/proxywindow.hpp"
@@ -38,6 +39,8 @@ class IdleInhibitor: public QObject {
3839

3940
public:
4041
IdleInhibitor();
42+
~IdleInhibitor() override;
43+
Q_DISABLE_COPY_MOVE(IdleInhibitor);
4144

4245
[[nodiscard]] QObject* window() const;
4346
void setWindow(QObject* window);

src/wayland/idle_inhibit/proto.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
#include "proto.hpp"
22

33
#include <private/qwaylandwindow_p.h>
4+
#include <qlogging.h>
5+
#include <qloggingcategory.h>
46
#include <qwaylandclientextension.h>
57

8+
#include "../../core/logcat.hpp"
9+
610
namespace qs::wayland::idle_inhibit::impl {
711

12+
namespace {
13+
QS_LOGGING_CATEGORY(logIdleInhibit, "quickshell.wayland.idle_inhibit", QtWarningMsg);
14+
}
15+
816
IdleInhibitManager::IdleInhibitManager(): QWaylandClientExtensionTemplate(1) { this->initialize(); }
917

1018
IdleInhibitManager* IdleInhibitManager::instance() {
@@ -13,10 +21,13 @@ IdleInhibitManager* IdleInhibitManager::instance() {
1321
}
1422

1523
IdleInhibitor* IdleInhibitManager::createIdleInhibitor(QtWaylandClient::QWaylandWindow* surface) {
16-
return new IdleInhibitor(this->create_inhibitor(surface->surface()));
24+
auto* inhibitor = new IdleInhibitor(this->create_inhibitor(surface->surface()));
25+
qCDebug(logIdleInhibit) << "Created inhibitor" << inhibitor;
26+
return inhibitor;
1727
}
1828

1929
IdleInhibitor::~IdleInhibitor() {
30+
qCDebug(logIdleInhibit) << "Destroyed inhibitor" << this;
2031
if (this->isInitialized()) this->destroy();
2132
}
2233

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import Quickshell
4+
import Quickshell.Wayland
5+
6+
FloatingWindow {
7+
id: root
8+
color: contentItem.palette.window
9+
10+
CheckBox {
11+
id: enableCb
12+
anchors.centerIn: parent
13+
text: "Enable Inhibitor"
14+
}
15+
16+
IdleInhibitor {
17+
window: root
18+
enabled: enableCb.checked
19+
}
20+
}

0 commit comments

Comments
 (0)