mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[Common]NotificationUtil helper class with FileWatcher (#36720)
* add NotificationUtil helper with file watcher and cache * fix spellcheck * indentation
This commit is contained in:
committed by
GitHub
parent
403060e109
commit
9e1242e8d5
@@ -9,7 +9,6 @@
|
||||
#include <common/utils/process_path.h>
|
||||
|
||||
#include <common/utils/elevation.h>
|
||||
#include <common/notifications/NotificationUtil.h>
|
||||
#include <Generated Files/resource.h>
|
||||
|
||||
#include <interop/shared_constants.h>
|
||||
@@ -36,7 +35,8 @@ AlwaysOnTop::AlwaysOnTop(bool useLLKH, DWORD mainThreadId) :
|
||||
SettingsObserver({SettingId::FrameEnabled, SettingId::Hotkey, SettingId::ExcludeApps}),
|
||||
m_hinstance(reinterpret_cast<HINSTANCE>(&__ImageBase)),
|
||||
m_useCentralizedLLKH(useLLKH),
|
||||
m_mainThreadId(mainThreadId)
|
||||
m_mainThreadId(mainThreadId),
|
||||
m_notificationUtil(std::make_unique<notifications::NotificationUtil>())
|
||||
{
|
||||
s_instance = this;
|
||||
DPIAware::EnableDPIAwarenessForThisProcess();
|
||||
@@ -64,6 +64,7 @@ AlwaysOnTop::AlwaysOnTop(bool useLLKH, DWORD mainThreadId) :
|
||||
AlwaysOnTop::~AlwaysOnTop()
|
||||
{
|
||||
m_running = false;
|
||||
m_notificationUtil.reset();
|
||||
|
||||
if (m_hPinEvent)
|
||||
{
|
||||
@@ -509,7 +510,10 @@ void AlwaysOnTop::HandleWinHookEvent(WinHookEvent* data) noexcept
|
||||
{
|
||||
if (!is_process_elevated() && IsProcessOfWindowElevated(data->hwnd))
|
||||
{
|
||||
notifications::WarnIfElevationIsRequired(GET_RESOURCE_STRING(IDS_ALWAYSONTOP), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_LEARN_MORE), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_DIALOG_DONT_SHOW_AGAIN));
|
||||
m_notificationUtil->WarnIfElevationIsRequired(GET_RESOURCE_STRING(IDS_ALWAYSONTOP),
|
||||
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED),
|
||||
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_LEARN_MORE),
|
||||
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_DIALOG_DONT_SHOW_AGAIN));
|
||||
}
|
||||
RefreshBorders();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <WindowBorder.h>
|
||||
|
||||
#include <common/hooks/WinHookEvent.h>
|
||||
#include <common/notifications/NotificationUtil.h>
|
||||
|
||||
class AlwaysOnTop : public SettingsObserver
|
||||
{
|
||||
@@ -53,6 +54,7 @@ private:
|
||||
std::thread m_thread;
|
||||
const bool m_useCentralizedLLKH;
|
||||
bool m_running = true;
|
||||
std::unique_ptr<notifications::NotificationUtil> m_notificationUtil;
|
||||
|
||||
LRESULT WndProc(HWND, UINT, WPARAM, LPARAM) noexcept;
|
||||
void HandleWinHookEvent(WinHookEvent* data) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user