mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[FancyZones] Move FancyZones out of the runner process (#11818)
* rename dll -> FancyZonesModuleInterface (#11488) * [FancyZones] Rename "fancyzones/tests" -> "fancyzones/FancyZonesTests" (#11492) * [FancyZones] Rename "fancyzones/lib" -> "fancyzones/FancyZonesLib" (#11489) * [FancyZones] New FancyZones project. (#11544) * [FancyZones] Allow single instance of "PowerToys.FancyZones.exe" (#11558) * [FancyZones] Updated bug reports (#11571) * [FancyZones] Updated installer (#11572) * [FancyZones] Update string resources (#11596) * [FancyZones] Terminate FancyZones with runner (#11696) * [FancyZones] Drop support for the module interface API to save settings (#11661) * Settings telemetry for FancyZones (#11766) * commented out test * enable dpi awareness for the process
This commit is contained in:
63
src/modules/fancyzones/FancyZones/FancyZonesApp.h
Normal file
63
src/modules/fancyzones/FancyZones/FancyZonesApp.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/hooks/LowlevelKeyboardEvent.h>
|
||||
|
||||
#include <FancyZonesLib/FancyZones.h>
|
||||
|
||||
class FancyZonesApp
|
||||
{
|
||||
public:
|
||||
FancyZonesApp(const std::wstring& appName, const std::wstring& appKey);
|
||||
~FancyZonesApp();
|
||||
|
||||
void Run();
|
||||
|
||||
private:
|
||||
static inline FancyZonesApp* s_instance = nullptr;
|
||||
static inline HHOOK s_llKeyboardHook = nullptr;
|
||||
|
||||
winrt::com_ptr<IFancyZones> m_app;
|
||||
HWINEVENTHOOK m_objectLocationWinEventHook = nullptr;
|
||||
std::vector<HWINEVENTHOOK> m_staticWinEventHooks;
|
||||
winrt::com_ptr<IFancyZonesSettings> m_settings;
|
||||
|
||||
void DisableModule() noexcept;
|
||||
|
||||
void InitHooks();
|
||||
|
||||
void HandleWinHookEvent(WinHookEvent* data) noexcept;
|
||||
intptr_t HandleKeyboardHookEvent(LowlevelKeyboardEvent* data) noexcept;
|
||||
|
||||
static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LowlevelKeyboardEvent event;
|
||||
if (nCode == HC_ACTION && wParam == WM_KEYDOWN)
|
||||
{
|
||||
event.lParam = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
|
||||
event.wParam = wParam;
|
||||
if (s_instance)
|
||||
{
|
||||
if (s_instance->HandleKeyboardHookEvent(&event) == 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
static void CALLBACK WinHookProc(HWINEVENTHOOK winEventHook,
|
||||
DWORD event,
|
||||
HWND window,
|
||||
LONG object,
|
||||
LONG child,
|
||||
DWORD eventThread,
|
||||
DWORD eventTime)
|
||||
{
|
||||
WinHookEvent data{ event, window, object, child, eventThread, eventTime };
|
||||
if (s_instance)
|
||||
{
|
||||
s_instance->HandleWinHookEvent(&data);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user