PowerToys interface: remove powertoys events and system_menu_helper functionality (#5323)

This commit is contained in:
Andrey Nekrasov
2020-07-31 14:06:13 +03:00
committed by GitHub
parent cff654ae69
commit 49b56d9b52
42 changed files with 116 additions and 1163 deletions

View File

@@ -9,10 +9,9 @@
extern "C" IMAGE_DOS_HEADER __ImageBase;
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
@@ -27,7 +26,8 @@ BOOL APIENTRY DllMain( HMODULE hModule,
return TRUE;
}
struct ModuleSettings{
struct ModuleSettings
{
} g_settings;
class ColorPicker : public PowertoyModuleIface
@@ -39,8 +39,9 @@ private:
HANDLE m_hProcess;
// Time to wait for process to close after sending WM_CLOSE signal
// Time to wait for process to close after sending WM_CLOSE signal
static const int MAX_WAIT_MILLISEC = 10000;
public:
ColorPicker()
{
@@ -67,13 +68,6 @@ public:
return app_name.c_str();
}
virtual const wchar_t** get_events() override
{
static const wchar_t* events[] = { nullptr };
return events;
}
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
{
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
@@ -111,8 +105,8 @@ public:
}
}
virtual void enable(){
virtual void enable()
{
// use only with new settings?
if (UseNewSettings())
{
@@ -134,12 +128,13 @@ public:
}
};
virtual void disable() {
virtual void disable()
{
if (m_enabled)
{
terminateProcess();
}
m_enabled = false;
}
@@ -148,11 +143,6 @@ public:
return m_enabled;
}
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
{
return 0;
}
static BOOL CALLBACK requestMainWindowClose(HWND nextWindow, LPARAM closePid)
{
DWORD windowPid;
@@ -174,15 +164,9 @@ public:
TerminateProcess(m_hProcess, 1);
}
}
/* Register helper class to handle system menu items related actions. */
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) {}
/* Handle action on system menu item. */
virtual void signal_system_menu_action(const wchar_t* name) {}
};
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
{
return new ColorPicker();
}

View File

@@ -2,9 +2,8 @@
#include <common/settings_objects.h>
#include <common/common.h>
#include <common/debug_control.h>
#include <common/LowlevelKeyboardEvent.h>
#include <interface/powertoy_module_interface.h>
#include <interface/lowlevel_keyboard_event_data.h>
#include <interface/win_hook_event_data.h>
#include <lib/ZoneSet.h>
#include <lib/resource.h>
@@ -44,13 +43,6 @@ public:
return app_name.c_str();
}
// Return array of the names of all events that this powertoy listens for, with
// nullptr as the last element of the array. Nullptr can also be returned for empty list.
virtual PCWSTR* get_events() override
{
return nullptr;
}
// Return JSON with the configuration options.
// These are the settings shown on the settings page along with their current values.
virtual bool get_config(_Out_ PWSTR buffer, _Out_ int* buffer_size) override
@@ -134,15 +126,6 @@ public:
return (m_app != nullptr);
}
// PowertoyModuleIface method, unused
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
{
return 0;
}
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override {}
virtual void signal_system_menu_action(const wchar_t* name) override {}
// Destroy the powertoy and free memory
virtual void destroy() override
{

View File

@@ -16,7 +16,6 @@
#include "VirtualDesktopUtils.h"
#include "MonitorWorkAreaHandler.h"
#include <interface/win_hook_event_data.h>
#include <lib/SecondaryMouseButtonsHook.h>
#include <lib/GenericKeyHook.h>
@@ -365,7 +364,8 @@ bool FancyZones::ShouldProcessNewWindow(HWND window) noexcept
}
std::vector<int> FancyZones::GetZoneIndexSetFromWorkAreaHistory(
HWND window, winrt::com_ptr<IZoneWindow> workArea) noexcept
HWND window,
winrt::com_ptr<IZoneWindow> workArea) noexcept
{
const auto activeZoneSet = workArea->ActiveZoneSet();
if (activeZoneSet)
@@ -458,9 +458,9 @@ RECT FitOnScreen(const RECT& windowRect, const RECT& originMonitorRect, const RE
H = min(H, RectHeight(destMonitorRect) - CUSTOM_POSITIONING_LEFT_TOP_PADDING);
}
return { .left = left,
.top = top,
.right = left + W,
return { .left = left,
.top = top,
.right = left + W,
.bottom = top + H };
}
@@ -506,7 +506,7 @@ FancyZones::WindowCreated(HWND window) noexcept
// creation of new window. We need to check if window being processed is on currently active desktop.
return;
}
const bool moveToAppLastZone = m_settings->GetSettings()->appLastZone_moveWindows;
const bool moveToAppLastZone = m_settings->GetSettings()->appLastZone_moveWindows;
const bool openOnActiveMonitor = m_settings->GetSettings()->openWindowOnActiveMonitor;
if ((moveToAppLastZone || openOnActiveMonitor) && ShouldProcessNewWindow(window))
{

View File

@@ -1,5 +1,7 @@
#pragma once
#include <common/WinHookEvent.h>
interface IZoneWindow;
interface IFancyZonesSettings;
interface IZoneSet;
@@ -11,11 +13,13 @@ interface __declspec(uuid("{50D3F0F5-736E-4186-BDF4-3D6BEE150C3A}")) IFancyZones
/**
* Start and initialize FancyZones.
*/
IFACEMETHOD_(void, Run)() = 0;
IFACEMETHOD_(void, Run)
() = 0;
/**
* Stop FancyZones and do the clean up.
*/
IFACEMETHOD_(void, Destroy)() = 0;
IFACEMETHOD_(void, Destroy)
() = 0;
};
/**
@@ -26,13 +30,15 @@ interface __declspec(uuid("{2CB37E8F-87E6-4AEC-B4B2-E0FDC873343F}")) IFancyZones
/**
* Inform FancyZones that user has switched between virtual desktops.
*/
IFACEMETHOD_(void, VirtualDesktopChanged)() = 0;
IFACEMETHOD_(void, VirtualDesktopChanged)
() = 0;
/**
* Callback from WinEventHook to FancyZones
*
* @param data Handle of window being moved or resized.
*/
IFACEMETHOD_(void, HandleWinHookEvent)(const WinHookEvent* data) = 0;
IFACEMETHOD_(void, HandleWinHookEvent)
(const WinHookEvent* data) = 0;
/**
* Process keyboard event.
*
@@ -40,15 +46,18 @@ interface __declspec(uuid("{2CB37E8F-87E6-4AEC-B4B2-E0FDC873343F}")) IFancyZones
* @returns Boolean indicating if this event should be passed on further to other applications
* in event chain, or should it be suppressed.
*/
IFACEMETHOD_(bool, OnKeyDown)(PKBDLLHOOKSTRUCT info) = 0;
IFACEMETHOD_(bool, OnKeyDown)
(PKBDLLHOOKSTRUCT info) = 0;
/**
* Toggle FancyZones editor application.
*/
IFACEMETHOD_(void, ToggleEditor)() = 0;
IFACEMETHOD_(void, ToggleEditor)
() = 0;
/**
* Callback triggered when user changes FancyZones settings.
*/
IFACEMETHOD_(void, SettingsChanged)() = 0;
IFACEMETHOD_(void, SettingsChanged)
() = 0;
};
/**
@@ -59,31 +68,38 @@ interface __declspec(uuid("{5C8D99D6-34B2-4F4A-A8E5-7483F6869775}")) IZoneWindow
/**
* Assign window to appropriate zone inside new zone layout.
*/
IFACEMETHOD_(void, MoveWindowsOnActiveZoneSetChange)() = 0;
/**
IFACEMETHOD_(void, MoveWindowsOnActiveZoneSetChange)
() = 0;
/**
* @returns Basic zone color.
*/
IFACEMETHOD_(COLORREF, GetZoneColor)() = 0;
/**
IFACEMETHOD_(COLORREF, GetZoneColor)
() = 0;
/**
* @returns Zone border color.
*/
IFACEMETHOD_(COLORREF, GetZoneBorderColor)() = 0;
IFACEMETHOD_(COLORREF, GetZoneBorderColor)
() = 0;
/**
* @returns Color used to highlight zone while giving zone layout hints.
*/
IFACEMETHOD_(COLORREF, GetZoneHighlightColor)() = 0;
IFACEMETHOD_(COLORREF, GetZoneHighlightColor)
() = 0;
/**
* @returns Integer in range [0, 100] indicating opacity of highlighted zone (while giving zone layout hints).
*/
IFACEMETHOD_(int, GetZoneHighlightOpacity)() = 0;
IFACEMETHOD_(int, GetZoneHighlightOpacity)
() = 0;
/**
* @returns Boolean indicating if dragged window should be transparent.
*/
IFACEMETHOD_(bool, isMakeDraggedWindowTransparentActive) () = 0;
IFACEMETHOD_(bool, isMakeDraggedWindowTransparentActive)
() = 0;
/**
* @returns Boolean indicating if move/size operation is currently active.
*/
IFACEMETHOD_(bool, InMoveSize) () = 0;
IFACEMETHOD_(bool, InMoveSize)
() = 0;
};
winrt::com_ptr<IFancyZones> MakeFancyZones(HINSTANCE hinstance, const winrt::com_ptr<IFancyZonesSettings>& settings) noexcept;

View File

@@ -53,15 +53,6 @@ public:
return app_name.c_str();
}
// Return array of the names of all events that this powertoy listens for, with
// nullptr as the last element of the array. Nullptr can also be returned for empty
// list.
virtual const wchar_t** get_events() override
{
static const wchar_t* events[] = { nullptr };
return events;
}
// Return JSON with the configuration options.
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
{
@@ -104,15 +95,6 @@ public:
{
return m_enabled;
}
// Handle incoming event, data is event-specific
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
{
return 0;
}
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override {}
virtual void signal_system_menu_action(const wchar_t* name) override {}
};
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()

View File

@@ -1,45 +0,0 @@
#pragma once
#include <Windows.h>
/*
ll_keyboard - Lowlevel Keyboard Hook
The PowerToys runner installs low-level keyboard hook using
SetWindowsHookEx(WH_KEYBOARD_LL, ...)
See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644985(v%3Dvs.85)
for details.
When a keyboard event is signaled and ncCode equals HC_ACTION, the wParam
and lParam event parameters are passed to all subscribed clients in
the LowlevelKeyboardEvent struct.
The intptr_t data event argument is a pointer to the LowlevelKeyboardEvent struct.
A non-zero return value from any of the subscribed PowerToys will cause
the runner hook proc to return 1, thus swallowing the keyboard event.
Example usage, that makes Windows ignore the L key:
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override {
if (wcscmp(name, ll_keyboard) == 0) {
auto& event = *(reinterpret_cast<LowlevelKeyboardEvent*>(data));
// The L key has vkCode of 0x4C
if (event.wParam == WM_KEYDOWN && event.lParam->vkCode == 0x4C) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
*/
namespace {
const wchar_t* ll_keyboard = L"ll_keyboard";
}
struct LowlevelKeyboardEvent {
KBDLLHOOKSTRUCT* lParam;
WPARAM wParam;
};

View File

@@ -12,7 +12,6 @@
On the received object, the runner will call:
- get_name() to get the name of the PowerToy,
- get_events() to get the list of the events the PowerToy wants to subscribe to,
- enable() to initialize the PowerToy.
While running, the runner might call the following methods between create_powertoy()
@@ -21,58 +20,35 @@
- get_config() to get the available configuration settings,
- set_config() to set various settings,
- call_custom_action() when the user selects clicks a custom action in settings,
- signal_event() to send an event the PowerToy registered to.
When terminating, the runner will:
- call destroy() which should free all the memory and delete the PowerToy object,
- unload the DLL.
*/
class PowertoySystemMenuIface;
class PowertoyModuleIface {
class PowertoyModuleIface
{
public:
/* Returns the name of the PowerToy, this will be cached by the runner. */
virtual const wchar_t* get_name() = 0;
/* Returns a null-terminated table of the names of the events the PowerToy wants to
subscribe to. Available events:
* ll_keyboard
* win_hook_event
A nullptr can be returned to signal that the PowerToy does not want to subscribe
to any event.
*/
virtual const wchar_t** get_events() = 0;
/* Fills a buffer with the available configuration settings.
* If 'buffer' is a null ptr or the buffer size is not large enough
* sets the required buffer size in 'buffer_size' and return false.
* Returns true if successful.
*/
virtual bool get_config(wchar_t* buffer, int *buffer_size) = 0;
/* Sets the configuration values. */
virtual void set_config(const wchar_t* config) = 0;
/* Call custom action from settings screen. */
virtual void call_custom_action(const wchar_t* action) {};
/* Enables the PowerToy. */
virtual void enable() = 0;
/* Disables the PowerToy, should free as much memory as possible. */
virtual void disable() = 0;
/* Should return if the PowerToys is enabled or disabled. */
virtual bool is_enabled() = 0;
/* Handle event. Only the events the PowerToy subscribed to will be signaled.
The data argument and return value meaning are event-specific:
* ll_keyboard: see lowlevel_keyboard_event_data.h.
* win_hook_event: see win_hook_event_data.h
*/
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) = 0;
/* Register helper class to handle system menu items related actions. */
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) = 0;
/* Handle action on system menu item. */
virtual void signal_system_menu_action(const wchar_t* name) = 0;
/* Destroy the PowerToy and free all memory. */
virtual void destroy() = 0;
/* Returns the name of the PowerToy, this will be cached by the runner. */
virtual const wchar_t* get_name() = 0;
/* Fills a buffer with the available configuration settings.
* If 'buffer' is a null ptr or the buffer size is not large enough
* sets the required buffer size in 'buffer_size' and return false.
* Returns true if successful.
*/
virtual bool get_config(wchar_t* buffer, int* buffer_size) = 0;
/* Sets the configuration values. */
virtual void set_config(const wchar_t* config) = 0;
/* Call custom action from settings screen. */
virtual void call_custom_action(const wchar_t* action){};
/* Enables the PowerToy. */
virtual void enable() = 0;
/* Disables the PowerToy, should free as much memory as possible. */
virtual void disable() = 0;
/* Should return if the PowerToys is enabled or disabled. */
virtual bool is_enabled() = 0;
/* Destroy the PowerToy and free all memory. */
virtual void destroy() = 0;
};
/*
@@ -90,4 +66,4 @@ public:
In case of errors return nullptr.
*/
typedef PowertoyModuleIface* (__cdecl *powertoy_create_func)();
typedef PowertoyModuleIface*(__cdecl* powertoy_create_func)();

View File

@@ -1,22 +0,0 @@
#pragma once
#include <string>
class PowertoyModuleIface;
class PowertoySystemMenuIface {
public:
struct ItemInfo {
std::wstring name{};
bool enable{ false };
bool checkBox{ false };
};
/*
* Set configuration of system menu items for specific powertoy module. Configuration
* parameters include item name (and hotkey), item status at creation (enabled/disabled)
* and whether check box will appear next to item name when action is taken.
*/
virtual void SetConfiguration(PowertoyModuleIface* module, const std::vector<ItemInfo>& config) = 0;
/* Process action on specific system menu item. */
virtual void ProcessSelectedItem(PowertoyModuleIface* module, HWND window, const wchar_t* itemName) = 0;
};

View File

@@ -1,50 +0,0 @@
#pragma once
#include <Windows.h>
/*
win_hook_event - Windows Event Hook
The PowerToys runner installs event hook functions for a range of events. See
https://docs.microsoft.com/pl-pl/windows/win32/api/winuser/nf-winuser-setwineventhook
for details.
The intptr_t data event argument is a pointer to the WinHookEvent struct.
The return value of the event handler is ignored.
Example usage, that detects a window being resized:
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override {
if (wcscmp(name, win_hook_event) == 0) {
auto& event = *(reinterpret_cast<WinHookEvent*>(data));
switch (event.event) {
case EVENT_SYSTEM_MOVESIZESTART:
size_start(event.hwnd);
break;
case EVENT_SYSTEM_MOVESIZEEND:
size_end(event.hwnd);
break;
default:
break;
}
}
return 0;
}
Taking too long to process the events has negative impact on the whole system
performance. To address this, the events are signaled from a different
thread, not from the event hook callback itself.
*/
namespace {
const wchar_t* win_hook_event = L"win_hook_event";
}
struct WinHookEvent {
DWORD event;
HWND hwnd;
LONG idObject;
LONG idChild;
DWORD idEventThread;
DWORD dwmsEventTime;
};

View File

@@ -3,8 +3,8 @@
#include <thread>
#include <queue>
#include <mutex>
#include <interface/lowlevel_keyboard_event_data.h>
#include <LowlevelKeyboardEvent.h>
// Available states for the KeyDelay state machine.
enum class KeyDelayState
{

View File

@@ -2,8 +2,8 @@
#include <mutex>
#include "KeyboardManagerConstants.h"
#include "../common/keyboard_layout.h"
#include "../common/LowlevelKeyboardEvent.h"
#include <functional>
#include <interface/lowlevel_keyboard_event_data.h>
#include <variant>
#include "Shortcut.h"
#include "RemapShortcut.h"

View File

@@ -2,7 +2,6 @@
#include "Shortcut.h"
#include "../common/keyboard_layout.h"
#include "../common/shared_constants.h"
#include <interface/lowlevel_keyboard_event_data.h>
#include "Helpers.h"
#include "InputInterface.h"

View File

@@ -1,9 +1,10 @@
#pragma once
#include <interface/lowlevel_keyboard_event_data.h>
#include <map>
#include <mutex>
#include "keyboardmanager/common/KeyboardManagerConstants.h"
#include <common/LowlevelKeyboardEvent.h>
class InputInterface;
class KeyboardManagerState;
class Shortcut;

View File

@@ -1,7 +1,5 @@
#include "pch.h"
#include <interface/powertoy_module_interface.h>
#include <interface/lowlevel_keyboard_event_data.h>
#include <interface/win_hook_event_data.h>
#include <common/settings_objects.h>
#include <common/shared_constants.h>
#include "resource.h"
@@ -235,16 +233,6 @@ public:
return app_name.c_str();
}
// Return array of the names of all events that this powertoy listens for, with
// nullptr as the last element of the array. Nullptr can also be returned for empty
// list.
virtual const wchar_t** get_events() override
{
static const wchar_t* events[] = { ll_keyboard, nullptr };
return events;
}
// Return JSON with the configuration options.
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
{
@@ -339,16 +327,6 @@ public:
return m_enabled;
}
// Handle incoming event, data is event-specific
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
{
return 0;
}
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override {}
virtual void signal_system_menu_action(const wchar_t* name) override {}
// Hook procedure definition
static LRESULT CALLBACK hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
{

View File

@@ -2,7 +2,8 @@
#include <keyboardmanager/common/InputInterface.h>
#include <vector>
#include <functional>
#include <interface/lowlevel_keyboard_event_data.h>
#include <common/LowlevelKeyboardEvent.h>
// Class for mocked keyboard input
class MockedInput :

View File

@@ -1,7 +1,5 @@
#include "pch.h"
#include <interface/powertoy_module_interface.h>
#include <interface/lowlevel_keyboard_event_data.h>
#include <interface/win_hook_event_data.h>
#include <common/settings_objects.h>
#include <common/common.h>
#include "trace.h"
@@ -80,23 +78,6 @@ public:
return app_name.c_str();
}
// Return array of the names of all events that this powertoy listens for, with
// nullptr as the last element of the array. Nullptr can also be returned for empty
// list.
virtual const wchar_t** get_events() override
{
static const wchar_t* events[] = { nullptr };
// Available events:
// - ll_keyboard
// - win_hook_event
//
// static const wchar_t* events[] = { ll_keyboard,
// win_hook_event,
// nullptr };
return events;
}
// Return JSON with the configuration options.
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
{
@@ -232,25 +213,6 @@ public:
return m_enabled;
}
// Handle incoming event, data is event-specific
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
{
if (wcscmp(name, ll_keyboard) == 0)
{
auto& event = *(reinterpret_cast<LowlevelKeyboardEvent*>(data));
// Return 1 if the keypress is to be suppressed (not forwarded to Windows),
// otherwise return 0.
return 0;
}
else if (wcscmp(name, win_hook_event) == 0)
{
auto& event = *(reinterpret_cast<WinHookEvent*>(data));
// Return value is ignored
return 0;
}
return 0;
}
// Callback to send WM_CLOSE signal to each top level window.
static BOOL CALLBACK requestMainWindowClose(HWND nextWindow, LPARAM closePid)
{
@@ -274,11 +236,6 @@ public:
TerminateProcess(m_hProcess, 1);
}
}
/* Register helper class to handle system menu items related actions. */
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) {}
/* Handle action on system menu item. */
virtual void signal_system_menu_action(const wchar_t* name) {}
};
// Load the settings file.

View File

@@ -183,13 +183,6 @@ public:
return m_enabled;
}
// Return array of the names of all events that this powertoy listens for, with
// nullptr as the last element of the array. Nullptr can also be returned for empty list.
virtual PCWSTR* get_events() override
{
return nullptr;
}
// Return JSON with the configuration options.
// These are the settings shown on the settings page along with their current values.
virtual bool get_config(_Out_ PWSTR buffer, _Out_ int* buffer_size) override
@@ -266,15 +259,6 @@ public:
{
}
// Handle incoming event, data is event-specific
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
{
return 0;
}
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override {}
virtual void signal_system_menu_action(const wchar_t* name) override {}
// Destroy the powertoy and free memory
virtual void destroy() override
{

View File

@@ -1,6 +1,4 @@
#include "pch.h"
#include <interface/lowlevel_keyboard_event_data.h>
#include <interface/win_hook_event_data.h>
#include <settings_objects.h>
#include <common.h>
#include "powerpreview.h"
@@ -49,11 +47,6 @@ const wchar_t* PowerPreviewModule::get_name()
return m_moduleName.c_str();
}
const wchar_t** PowerPreviewModule::get_events()
{
return nullptr;
}
// Return JSON with the configuration options.
bool PowerPreviewModule::get_config(_Out_ wchar_t* buffer, _Out_ int* buffer_size)
{
@@ -89,7 +82,6 @@ bool PowerPreviewModule::get_config(_Out_ wchar_t* buffer, _Out_ int* buffer_siz
thumbnailProvider->GetToggleSettingState());
}
return settings.serialize_to_buffer(buffer, buffer_size);
}
@@ -182,12 +174,6 @@ bool PowerPreviewModule::is_enabled()
return this->m_enabled;
}
// Handle incoming event, data is event-specific
intptr_t PowerPreviewModule::signal_event(const wchar_t* name, intptr_t data)
{
return 0;
}
// Load the settings file.
void PowerPreviewModule::init_settings()
{
@@ -207,7 +193,6 @@ void PowerPreviewModule::init_settings()
{
thumbnailProvider->LoadState(settings);
}
}
catch (std::exception const& e)
{

View File

@@ -16,7 +16,7 @@ private:
// The PowerToy state.
bool m_enabled = false;
std::wstring m_moduleName;
std::vector<FileExplorerPreviewSettings *> m_previewHandlers;
std::vector<FileExplorerPreviewSettings*> m_previewHandlers;
std::vector<FileExplorerPreviewSettings*> m_thumbnailProviders;
public:
@@ -39,8 +39,7 @@ public:
GET_RESOURCE_STRING(IDS_PREVPANE_MD_SETTINGS_DESCRIPTION),
L"{45769bcc-e8fd-42d0-947e-02beef77a1f5}",
L"Markdown Preview Handler",
new RegistryWrapper())
}),
new RegistryWrapper()) }),
m_thumbnailProviders(
{ // TODO: MOVE THIS SVG Thumbnail Provider settings object.
new FileExplorerPreviewSettings(
@@ -49,22 +48,17 @@ public:
GET_RESOURCE_STRING(IDS_SVG_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
L"{36B27788-A8BB-4698-A756-DF9F11F64F84}",
L"SVG Thumbnail Provider",
new RegistryWrapper())
})
new RegistryWrapper()) })
{
init_settings();
};
virtual void destroy();
virtual const wchar_t* get_name();
virtual const wchar_t** get_events();
virtual bool get_config(_Out_ wchar_t* buffer, _Out_ int* buffer_size);
virtual void set_config(const wchar_t* config);
virtual void enable();
virtual void disable();
virtual bool is_enabled();
virtual void init_settings();
virtual intptr_t signal_event(const wchar_t* name, intptr_t data);
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override {}
virtual void signal_system_menu_action(const wchar_t* name) override {}
};

View File

@@ -42,11 +42,6 @@ const wchar_t* OverlayWindow::get_name()
return app_name.c_str();
}
const wchar_t** OverlayWindow::get_events()
{
return nullptr;
}
bool OverlayWindow::get_config(wchar_t* buffer, int* buffer_size)
{
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
@@ -213,11 +208,6 @@ bool OverlayWindow::is_enabled()
return _enabled;
}
intptr_t OverlayWindow::signal_event(const wchar_t* name, intptr_t data)
{
return 0;
}
intptr_t OverlayWindow::signal_event(LowlevelKeyboardEvent* event)
{
if (!_enabled)

View File

@@ -1,10 +1,11 @@
#pragma once
#include <interface/powertoy_module_interface.h>
#include <interface/lowlevel_keyboard_event_data.h>
#include "overlay_window.h"
#include "resource.h"
#include <common/LowlevelKeyboardEvent.h>
// We support only one instance of the overlay
extern class OverlayWindow* instance;
@@ -16,7 +17,6 @@ public:
OverlayWindow();
virtual const wchar_t* get_name() override;
virtual const wchar_t** get_events() override;
virtual bool get_config(wchar_t* buffer, int* buffer_size) override;
virtual void set_config(const wchar_t* config) override;
@@ -24,18 +24,11 @@ public:
virtual void disable() override;
virtual bool is_enabled() override;
// PowerToys interface method, not used
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override;
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override {}
virtual void signal_system_menu_action(const wchar_t* name) override {}
void on_held();
void on_held_press(DWORD vkCode);
void quick_hide();
void was_hidden();
// Method called from LowLevelKeyboardProc
intptr_t signal_event(LowlevelKeyboardEvent* event);
virtual void destroy() override;