2019-09-05 00:26:26 +08:00
|
|
|
#pragma once
|
2019-11-12 18:48:14 +08:00
|
|
|
|
2019-09-05 00:26:26 +08:00
|
|
|
#include <interface/powertoy_module_interface.h>
|
2019-11-12 18:48:14 +08:00
|
|
|
#include <interface/win_hook_event_data.h>
|
2019-09-05 00:26:26 +08:00
|
|
|
#include <string>
|
2020-04-30 04:02:18 +08:00
|
|
|
#include <shared_mutex>
|
2019-09-05 00:26:26 +08:00
|
|
|
|
2019-12-27 00:26:11 +08:00
|
|
|
class PowertoysEvents
|
|
|
|
{
|
2019-09-05 00:26:26 +08:00
|
|
|
public:
|
2019-12-27 00:26:11 +08:00
|
|
|
void register_receiver(const std::wstring& event, PowertoyModuleIface* module);
|
|
|
|
void unregister_receiver(PowertoyModuleIface* module);
|
2019-11-12 18:48:14 +08:00
|
|
|
|
2019-12-27 00:26:11 +08:00
|
|
|
void register_system_menu_action(PowertoyModuleIface* module);
|
|
|
|
void unregister_system_menu_action(PowertoyModuleIface* module);
|
|
|
|
void handle_system_menu_action(const WinHookEvent& data);
|
|
|
|
|
|
|
|
intptr_t signal_event(const std::wstring& event, intptr_t data);
|
2019-11-12 18:48:14 +08:00
|
|
|
|
2019-09-05 00:26:26 +08:00
|
|
|
private:
|
2019-12-27 00:26:11 +08:00
|
|
|
std::shared_mutex mutex;
|
|
|
|
std::unordered_map<std::wstring, std::vector<PowertoyModuleIface*>> receivers;
|
|
|
|
std::unordered_set<PowertoyModuleIface*> system_menu_receivers;
|
2019-09-05 00:26:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
PowertoysEvents& powertoys_events();
|
|
|
|
|
|
|
|
void first_subscribed(const std::wstring& event);
|
|
|
|
void last_unsubscribed(const std::wstring& event);
|