mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[AlwaysOnTop] Show borders only for AOT-pinned windows (#15801)
* set prop on aot-pinned window * address pr comments
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
namespace NonLocalizable
|
namespace NonLocalizable
|
||||||
{
|
{
|
||||||
const static wchar_t* TOOL_WINDOW_CLASS_NAME = L"AlwaysOnTopWindow";
|
const static wchar_t* TOOL_WINDOW_CLASS_NAME = L"AlwaysOnTopWindow";
|
||||||
|
const static wchar_t* WINDOW_IS_PINNED_PROP = L"AlwaysOnTop_Pinned";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to common utils
|
// TODO: move to common utils
|
||||||
@@ -227,7 +228,7 @@ void AlwaysOnTop::StartTrackingTopmostWindows()
|
|||||||
|
|
||||||
for (HWND window : result)
|
for (HWND window : result)
|
||||||
{
|
{
|
||||||
if (IsTopmost(window))
|
if (IsPinned(window))
|
||||||
{
|
{
|
||||||
AssignBorder(window);
|
AssignBorder(window);
|
||||||
}
|
}
|
||||||
@@ -315,13 +316,24 @@ bool AlwaysOnTop::IsTopmost(HWND window) const noexcept
|
|||||||
return (exStyle & WS_EX_TOPMOST) == WS_EX_TOPMOST;
|
return (exStyle & WS_EX_TOPMOST) == WS_EX_TOPMOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AlwaysOnTop::IsPinned(HWND window) const noexcept
|
||||||
|
{
|
||||||
|
auto handle = GetProp(window, NonLocalizable::WINDOW_IS_PINNED_PROP);
|
||||||
|
return (handle != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
bool AlwaysOnTop::PinTopmostWindow(HWND window) const noexcept
|
bool AlwaysOnTop::PinTopmostWindow(HWND window) const noexcept
|
||||||
{
|
{
|
||||||
|
if (!SetProp(window, NonLocalizable::WINDOW_IS_PINNED_PROP, (HANDLE)1))
|
||||||
|
{
|
||||||
|
Logger::error(L"SetProp failed");
|
||||||
|
}
|
||||||
return SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
return SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlwaysOnTop::UnpinTopmostWindow(HWND window) const noexcept
|
bool AlwaysOnTop::UnpinTopmostWindow(HWND window) const noexcept
|
||||||
{
|
{
|
||||||
|
RemoveProp(window, NonLocalizable::WINDOW_IS_PINNED_PROP);
|
||||||
return SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
return SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ private:
|
|||||||
|
|
||||||
bool IsTracked(HWND window) const noexcept;
|
bool IsTracked(HWND window) const noexcept;
|
||||||
bool IsTopmost(HWND window) const noexcept;
|
bool IsTopmost(HWND window) const noexcept;
|
||||||
|
bool IsPinned(HWND window) const noexcept;
|
||||||
|
|
||||||
bool PinTopmostWindow(HWND window) const noexcept;
|
bool PinTopmostWindow(HWND window) const noexcept;
|
||||||
bool UnpinTopmostWindow(HWND window) const noexcept;
|
bool UnpinTopmostWindow(HWND window) const noexcept;
|
||||||
|
|||||||
Reference in New Issue
Block a user