Skip to content

Commit d44b793

Browse files
add lockDenied event to the backend
Lock screens need to know when to exit without an unlock.
1 parent 0b06f6e commit d44b793

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

include/hyprtoolkit/core/Backend.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ namespace Hyprtoolkit {
8787
Get notified when a new output was added.
8888
*/
8989
Hyprutils::Signal::CSignalT<Hyprutils::Memory::CSharedPointer<IOutput>> outputAdded;
90+
91+
/*
92+
Sent when the compositor denies us as the exclusive lock screen client.
93+
*/
94+
Hyprutils::Signal::CSignalT<> lockDenied;
9095
} m_events;
9196

9297
HT_HIDDEN : CBackend();

include/hyprtoolkit/core/Output.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
namespace Hyprtoolkit {
77
class IOutput {
88
public:
9-
virtual ~IOutput() = default;
10-
virtual uint32_t handle() = 0;
11-
virtual std::string port() = 0;
12-
virtual std::string desc() = 0;
9+
virtual ~IOutput() = default;
10+
virtual uint32_t handle() = 0;
11+
virtual std::string port() = 0;
12+
virtual std::string desc() = 0;
1313

1414
struct {
1515
// output removed

src/core/platforms/WaylandPlatform.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ SP<CCExtSessionLockV1> CWaylandPlatform::aquireSessionLock() {
655655

656656
m_waylandState.sessionLockState.lock->setFinished([this](CCExtSessionLockV1* r) {
657657
g_logger->log(HT_LOG_ERROR, "We got denied by the compositor to be the exclusive lock screen client. Is there another lock screen active?");
658+
g_backend->m_events.lockDenied.emit();
659+
658660
for (const auto& w : m_lockSurfaces) {
659661
if (w.expired())
660662
continue;

tests/SimpleSessionLock.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ int main(int argc, char** argv, char** envp) {
121121
}
122122

123123
backend->m_events.outputAdded.listenStatic(createLockSurface);
124+
backend->m_events.lockDenied.listenStatic([] { std::println("Lock denied!"); });
124125

125-
for (const auto& o: backend->getOutputs()) {
126+
for (const auto& o : backend->getOutputs()) {
126127
createLockSurface(o);
127128
}
128129

0 commit comments

Comments
 (0)