MacOS lock/unlock added

This commit is contained in:
Paulchen-Panther
2023-11-14 16:12:21 +01:00
parent 114282ff70
commit a238ebffc0
14 changed files with 107 additions and 33 deletions

View File

@@ -2,7 +2,7 @@
// parent class
#include <api/API.h>
#include <events/Event.h>
#include <events/EventEnum.h>
// hyperion includes
#include <utils/Components.h>

View File

@@ -9,7 +9,7 @@
#include <libcec/cec.h>
#include <utils/settings.h>
#include <events/Event.h>
#include <events/EventEnum.h>
using CECCallbacks = CEC::ICECCallbacks;
using CECAdapter = CEC::ICECAdapter;

View File

@@ -1,5 +1,5 @@
#ifndef EVENT_H
#define EVENT_H
#ifndef EVENTENUM_H
#define EVENTENUM_H
#include <QString>
@@ -47,4 +47,4 @@ inline Event stringToEvent(const QString& event)
}
#endif // EVENT_H
#endif // EVENTENUM_H

View File

@@ -2,24 +2,23 @@
#define EVENTHANDLER_H
#include <utils/settings.h>
#include <events/Event.h>
#include <events/EventEnum.h>
#include <QObject>
class Logger;
class EventHandler : public QObject {
class EventHandler : public QObject
{
Q_OBJECT
public:
EventHandler();
~EventHandler() override;
static EventHandler* getInstance();
public slots:
virtual void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
void suspend(bool sleep);
@@ -36,15 +35,12 @@ public slots:
void handleEvent(Event event);
signals:
void signalEvent(Event event);
protected:
Logger * _log {};
private:
bool _isSuspended;
bool _isIdle;
};

View File

@@ -3,7 +3,7 @@
#include <QObject>
#include <QJsonDocument>
#include <events/Event.h>
#include <events/EventEnum.h>
#if defined(_WIN32)
#include <QAbstractNativeEventFilter>
@@ -16,7 +16,8 @@
class Logger;
class OsEventHandlerBase : public QObject {
class OsEventHandlerBase : public QObject
{
Q_OBJECT
public:
@@ -24,18 +25,15 @@ public:
~OsEventHandlerBase() override;
public slots:
void suspend(bool sleep);
void lock(bool isLocked);
virtual void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
signals:
void signalEvent(Event event);
protected:
virtual bool registerOsEventHandler() { return true; }
virtual void unregisterOsEventHandler() {}
virtual bool registerLockHandler() { return true; }
@@ -49,14 +47,12 @@ protected:
bool _isLockRegistered;
Logger * _log {};
private:
};
#if defined(_WIN32)
class OsEventHandlerWindows : public OsEventHandlerBase, public QAbstractNativeEventFilter {
class OsEventHandlerWindows : public OsEventHandlerBase, public QAbstractNativeEventFilter
{
public:
OsEventHandlerWindows();
@@ -70,7 +66,6 @@ protected:
#endif
private:
bool registerOsEventHandler() override;
void unregisterOsEventHandler() override;
bool registerLockHandler() override;
@@ -83,7 +78,8 @@ private:
using OsEventHandler = OsEventHandlerWindows;
#elif defined(__linux__)
class OsEventHandlerLinux : public OsEventHandlerBase {
class OsEventHandlerLinux : public OsEventHandlerBase
{
Q_OBJECT
static void static_signaleHandler(int signum)
@@ -109,6 +105,33 @@ private:
using OsEventHandler = OsEventHandlerLinux;
#elif defined(__APPLE__)
#include <CoreFoundation/CoreFoundation.h>
class OsEventHandlerMacOS : public OsEventHandlerBase
{
Q_OBJECT
static void notificationCenterCallBack(CFNotificationCenterRef center, void* observer, CFStringRef name, const void* object, CFDictionaryRef userInfo)
{
OsEventHandlerMacOS::getInstance()->handleSignal(name);
}
public:
void handleSignal (CFStringRef lock_unlock);
private:
static OsEventHandlerMacOS* getInstance();
CFStringRef lockSignal = CFSTR("com.apple.screenIsLocked");
CFStringRef unlockSignal = CFSTR("com.apple.screenIsUnlocked");
bool registerLockHandler() override;
void unregisterLockHandler() override;
};
using OsEventHandler = OsEventHandlerMacOS;
#else
using OsEventHandler = OsEventHandlerBase;
#endif

View File

@@ -24,7 +24,7 @@
// Determine the cmake options
#include <HyperionConfig.h>
#include <events/Event.h>
#include <events/EventEnum.h>
///
/// Capture class for V4L2 devices

View File

@@ -11,7 +11,7 @@
#include <utils/Logger.h>
#include <utils/Components.h>
#include <events/Event.h>
#include <events/EventEnum.h>
///
/// @brief The Grabber class is responsible to apply image resizes (with or without ImageResampler)

View File

@@ -18,7 +18,7 @@
#include <grabber/GrabberType.h>
#include <events/Event.h>
#include <events/EventEnum.h>
class Grabber;
class GlobalSignals;

View File

@@ -5,7 +5,7 @@
#include <utils/VideoMode.h>
#include <utils/settings.h>
#include <utils/Components.h>
#include <events/Event.h>
#include <events/EventEnum.h>
// qt
#include <QMap>