mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[Shotcut Guide]Dismiss with mouse click (#23991)
* dismiss with mouse * fix spellcheck
This commit is contained in:
parent
0b281677df
commit
320cc56b7e
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@ -176,6 +176,7 @@ buildtask
|
|||||||
buildtransitive
|
buildtransitive
|
||||||
Burkina
|
Burkina
|
||||||
Buryatia
|
Buryatia
|
||||||
|
BUTTONUP
|
||||||
BValue
|
BValue
|
||||||
BYPOSITION
|
BYPOSITION
|
||||||
bytearray
|
bytearray
|
||||||
|
@ -160,6 +160,30 @@ namespace
|
|||||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if (nCode >= 0)
|
||||||
|
{
|
||||||
|
switch (wParam)
|
||||||
|
{
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
case WM_XBUTTONUP:
|
||||||
|
// Don't close with mouse click if activation is windows key and the key is pressed
|
||||||
|
if (!overlay_window_instance->win_key_activation() || !isWinPressed())
|
||||||
|
{
|
||||||
|
overlay_window_instance->CloseWindow(HideWindowType::MOUSE_BUTTONUP);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CallNextHookEx(0, nCode, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
std::wstring ToWstring(HideWindowType type)
|
std::wstring ToWstring(HideWindowType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
@ -172,6 +196,8 @@ namespace
|
|||||||
return L"WIN_SHORTCUT_PRESSED";
|
return L"WIN_SHORTCUT_PRESSED";
|
||||||
case HideWindowType::THE_SHORTCUT_PRESSED:
|
case HideWindowType::THE_SHORTCUT_PRESSED:
|
||||||
return L"THE_SHORTCUT_PRESSED";
|
return L"THE_SHORTCUT_PRESSED";
|
||||||
|
case HideWindowType::MOUSE_BUTTONUP:
|
||||||
|
return L"MOUSE_BUTTONUP";
|
||||||
}
|
}
|
||||||
|
|
||||||
return L"";
|
return L"";
|
||||||
@ -191,6 +217,12 @@ OverlayWindow::OverlayWindow(HWND activeWindow)
|
|||||||
{
|
{
|
||||||
Logger::warn(L"Failed to create low level keyboard hook. {}", get_last_error_or_default(GetLastError()));
|
Logger::warn(L"Failed to create low level keyboard hook. {}", get_last_error_or_default(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouseHook = SetWindowsHookEx(WH_MOUSE_LL, LowLevelMouseProc, GetModuleHandle(NULL), NULL);
|
||||||
|
if (!mouseHook)
|
||||||
|
{
|
||||||
|
Logger::warn(L"Failed to create low level mouse hook. {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWindow::ShowWindow()
|
void OverlayWindow::ShowWindow()
|
||||||
@ -316,6 +348,11 @@ bool OverlayWindow::overlay_visible() const
|
|||||||
return target_state->active();
|
return target_state->active();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OverlayWindow::win_key_activation() const
|
||||||
|
{
|
||||||
|
return shouldReactToPressedWinKey.value;
|
||||||
|
}
|
||||||
|
|
||||||
void OverlayWindow::init_settings()
|
void OverlayWindow::init_settings()
|
||||||
{
|
{
|
||||||
auto settings = GetSettings();
|
auto settings = GetSettings();
|
||||||
|
@ -18,7 +18,8 @@ enum class HideWindowType
|
|||||||
ESC_PRESSED,
|
ESC_PRESSED,
|
||||||
WIN_RELEASED,
|
WIN_RELEASED,
|
||||||
WIN_SHORTCUT_PRESSED,
|
WIN_SHORTCUT_PRESSED,
|
||||||
THE_SHORTCUT_PRESSED
|
THE_SHORTCUT_PRESSED,
|
||||||
|
MOUSE_BUTTONUP
|
||||||
};
|
};
|
||||||
|
|
||||||
class OverlayWindow
|
class OverlayWindow
|
||||||
@ -34,6 +35,7 @@ public:
|
|||||||
void was_hidden();
|
void was_hidden();
|
||||||
|
|
||||||
bool overlay_visible() const;
|
bool overlay_visible() const;
|
||||||
|
bool win_key_activation() const;
|
||||||
|
|
||||||
bool is_disabled_app(wchar_t* exePath);
|
bool is_disabled_app(wchar_t* exePath);
|
||||||
|
|
||||||
@ -52,6 +54,7 @@ private:
|
|||||||
void update_disabled_apps();
|
void update_disabled_apps();
|
||||||
HWND activeWindow;
|
HWND activeWindow;
|
||||||
HHOOK keyboardHook;
|
HHOOK keyboardHook;
|
||||||
|
HHOOK mouseHook;
|
||||||
|
|
||||||
struct OverlayOpacity
|
struct OverlayOpacity
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user