10 #include <condition_variable> 19 struct ext_idle_notifier_v1;
20 struct ext_idle_notification_v1;
24 int64_t GetIdleTimeSeconds();
138 bool Start(
int notification_timeout_ms);
154 ext_idle_notifier_v1* m_idle_notifier;
156 uint32_t m_idle_notifier_id;
157 std::atomic<bool> m_is_idle;
158 std::atomic<int64_t> m_idle_start_time;
175 wl_registry* m_registry;
196 static void HandleGlobal(
void *data, wl_registry *registry, uint32_t name,
const char *interface, uint32_t version);
202 static void HandleIdled(
void *data, ext_idle_notification_v1 *notification);
205 static void HandleResumed(
void *data, ext_idle_notification_v1 *notification);
228 #endif // IDLE_DETECT_H static void HandleIdled(void *data, ext_idle_notification_v1 *notification)
Private method to handle idle notification events.
void IdleDetectControlMonitorThread()
Method to instantiate the tty monitor thread.
Definition: idle_detect.cpp:743
The IdleDetectConfig class. This specializes the Config class and implements the virtual method Proce...
Definition: idle_detect.h:220
bool Start(int notification_timeout_ms)
Initializes the Wayland display and registry, and starts the idle notifier.
Definition: idle_detect.cpp:1024
The WaylandIdleMonitor class implements the ext_idle_notifier_v1 protocol to monitor idle state in Wa...
Definition: idle_detect.h:122
int m_notification_timeout_ms
Timeout for idle notification in milliseconds.
Definition: idle_detect.h:181
std::atomic< bool > m_initialized
This holds the flag as to whether the tty monitor has been initialized and is provided by the IsIniti...
Definition: idle_detect.h:114
void ProcessArgs() override
The is the ProcessArgs() implementation for idle_detect.
Definition: idle_detect.cpp:75
std::atomic< bool > m_interrupt_monitor
Mutex for thread synchronization.
Definition: idle_detect.h:165
void WaylandMonitorThread()
Private method to run the Wayland event loop in a separate thread.
Definition: idle_detect.cpp:1285
static void HandleGlobal(void *data, wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
Private method to handle global events.
void Stop()
Stops the Wayland idle monitor and cleans up resources.
Definition: idle_detect.cpp:1092
std::mutex mtx_idle_detect_control_monitor_thread
This provides lock control for the tty monitor worker thread itself.
Definition: idle_detect.h:100
WaylandIdleMonitor()
Constructor.
Definition: idle_detect.cpp:1000
int m_interrupt_pipe_fd[2]
Pipe for thread interrupt handling.
Definition: idle_detect.h:168
The Config class is a singleton that stores program config read from the config file, with applied defaults if the config file cannot be read, or a config parameter is not in the config file.
Definition: util.h:233
ext_idle_notification_v1 * m_idle_notification
Idle notification object.
Definition: idle_detect.h:178
The IdleDetectControlMonitor class is a singleton that monitors the idle_detect control pipe...
Definition: idle_detect.h:31
~WaylandIdleMonitor()
Destructor.
Definition: idle_detect.cpp:1019
int64_t GetIdleSeconds() const
Provides the number of seconds the session has been idle via the ext_idle_notifier_v1 protocol...
Definition: idle_detect.cpp:1386
IdleDetectControlMonitor()
Constructor.
Definition: idle_detect.cpp:738
void CreateIdleNotification()
Private method to create the idle notification object.
Definition: idle_detect.cpp:1259
Definition: idle_detect.cpp:182
std::thread m_idle_detect_control_monitor_thread
Holds the actual idle_detect monitor thread.
Definition: idle_detect.h:44
std::atomic< bool > m_interrupt_idle_detect_control_monitor
Atomic boolean that interrupts the idle_detect monitor thread.
Definition: idle_detect.h:54
bool IsInitialized() const
Provides a flag to indicate whether the monitor has been initialized. This is used in main in the app...
Definition: idle_detect.cpp:951
bool IsIdle() const
Checks if the Wayland session is idle.
Definition: idle_detect.cpp:1381
std::atomic< bool > m_initialized
Flag to indicate whether the monitor has been initialized.
Definition: idle_detect.h:171
State GetState() const
Returns the state of the idle control monitor. This is NORMAL, FORCED_ACTIVE or FORCED_IDLE.
Definition: idle_detect.cpp:957
std::condition_variable cv_idle_detect_control_monitor_thread
Condition variable for control/synchronization of the idle_detect monitor threads.
Definition: idle_detect.h:49
static void HandleResumed(void *data, ext_idle_notification_v1 *notification)
Private method to handle resumed events.
std::mutex mtx_idle_detect_control_monitor
This is the mutex member that provides lock control for the tty monitor object. This is used to ensur...
Definition: idle_detect.h:95
std::thread m_monitor_thread
The WaylandIdleMonitor thread that monitors the Wayland session for idle state changes.
Definition: idle_detect.h:162
bool InitializeWayland()
Private method to initialize Wayland and set up the idle notification.
Definition: idle_detect.cpp:1142
static void HandleGlobalRemove(void *data, wl_registry *registry, uint32_t name)
Private method to handle global removal events.
bool IsAvailable() const
Checks if the Wayland idle monitor is available.
Definition: idle_detect.cpp:1376
std::atomic< State > m_state
Holds the current state of the idle monitor. NORMAL means idle detect follows the normal threshold (t...
Definition: idle_detect.h:108
static const void * c_registry_listener_ptr
Pointer to the registry listener struct for C linkage.
Definition: idle_detect.h:208
std::string StateToString() const
Returns the string representation of the idle monitor object state.
Definition: idle_detect.cpp:984
void CleanupWayland()
Private method to clean up Wayland resources.
Definition: idle_detect.cpp:1217
static const void * c_idle_notification_listener_ptr
Pointer to the idle notification listener struct for C linkage.
Definition: idle_detect.h:211
wl_display * m_display
Wayland display and registry objects.
Definition: idle_detect.h:174