wayland/idle-inhibit: fix formatting + lints, destructor, add logs
This commit is contained in:
parent
a7aa9328df
commit
20cc729e73
4 changed files with 40 additions and 2 deletions
|
@ -13,9 +13,13 @@ namespace qs::wayland::idle_inhibit {
|
||||||
using QtWaylandClient::QWaylandWindow;
|
using QtWaylandClient::QWaylandWindow;
|
||||||
|
|
||||||
IdleInhibitor::IdleInhibitor() {
|
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; }
|
QObject* IdleInhibitor::window() const { return this->bWindowObject; }
|
||||||
|
|
||||||
void IdleInhibitor::setWindow(QObject* window) {
|
void IdleInhibitor::setWindow(QObject* window) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qproperty.h>
|
#include <qproperty.h>
|
||||||
#include <qqmlintegration.h>
|
#include <qqmlintegration.h>
|
||||||
|
#include <qtclasshelpermacros.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
#include "../../window/proxywindow.hpp"
|
#include "../../window/proxywindow.hpp"
|
||||||
|
@ -38,6 +39,8 @@ class IdleInhibitor: public QObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IdleInhibitor();
|
IdleInhibitor();
|
||||||
|
~IdleInhibitor() override;
|
||||||
|
Q_DISABLE_COPY_MOVE(IdleInhibitor);
|
||||||
|
|
||||||
[[nodiscard]] QObject* window() const;
|
[[nodiscard]] QObject* window() const;
|
||||||
void setWindow(QObject* window);
|
void setWindow(QObject* window);
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
#include "proto.hpp"
|
#include "proto.hpp"
|
||||||
|
|
||||||
#include <private/qwaylandwindow_p.h>
|
#include <private/qwaylandwindow_p.h>
|
||||||
|
#include <qlogging.h>
|
||||||
|
#include <qloggingcategory.h>
|
||||||
#include <qwaylandclientextension.h>
|
#include <qwaylandclientextension.h>
|
||||||
|
|
||||||
|
#include "../../core/logcat.hpp"
|
||||||
|
|
||||||
namespace qs::wayland::idle_inhibit::impl {
|
namespace qs::wayland::idle_inhibit::impl {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
QS_LOGGING_CATEGORY(logIdleInhibit, "quickshell.wayland.idle_inhibit", QtWarningMsg);
|
||||||
|
}
|
||||||
|
|
||||||
IdleInhibitManager::IdleInhibitManager(): QWaylandClientExtensionTemplate(1) { this->initialize(); }
|
IdleInhibitManager::IdleInhibitManager(): QWaylandClientExtensionTemplate(1) { this->initialize(); }
|
||||||
|
|
||||||
IdleInhibitManager* IdleInhibitManager::instance() {
|
IdleInhibitManager* IdleInhibitManager::instance() {
|
||||||
|
@ -13,10 +21,13 @@ IdleInhibitManager* IdleInhibitManager::instance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
IdleInhibitor* IdleInhibitManager::createIdleInhibitor(QtWaylandClient::QWaylandWindow* surface) {
|
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() {
|
IdleInhibitor::~IdleInhibitor() {
|
||||||
|
qCDebug(logIdleInhibit) << "Destroyed inhibitor" << this;
|
||||||
if (this->isInitialized()) this->destroy();
|
if (this->isInitialized()) this->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
src/wayland/idle_inhibit/test/manual/idle_inhibit.qml
Normal file
20
src/wayland/idle_inhibit/test/manual/idle_inhibit.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue