mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
common: refactor common library pt2 (#8588)
- remove common lib - split settings, remove common-md - move ipc interop/kb_layout to interop - rename core -> settings, settings -> old_settings - os-detect header-only; interop -> PowerToysInterop - split notifications, move single-use headers where they're used - winstore lib - rename com utils - rename Updating and Telemetry projects - rename core -> settings-ui and remove examples folder - rename settings-ui folder + consisent common/version include
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdiplus.h"
|
||||
#include <common/monitor_utils.h>
|
||||
#include <common/string_utils.h>
|
||||
#include <common/utils/string_utils.h>
|
||||
|
||||
namespace FancyZonesDataTypes
|
||||
{
|
||||
@@ -95,7 +94,7 @@ namespace FancyZonesUtils
|
||||
inline COLORREF HexToRGB(std::wstring_view hex, const COLORREF fallbackColor = RGB(255, 255, 255))
|
||||
{
|
||||
hex = left_trim<wchar_t>(trim<wchar_t>(hex), L"#");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
const long long tmp = std::stoll(hex.data(), nullptr, 16);
|
||||
@@ -115,6 +114,50 @@ namespace FancyZonesUtils
|
||||
return static_cast<BYTE>(opacity * 2.55);
|
||||
}
|
||||
|
||||
template<RECT MONITORINFO::*member>
|
||||
std::vector<std::pair<HMONITOR, RECT>> GetAllMonitorRects()
|
||||
{
|
||||
using result_t = std::vector<std::pair<HMONITOR, RECT>>;
|
||||
result_t result;
|
||||
|
||||
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL {
|
||||
MONITORINFOEX mi;
|
||||
mi.cbSize = sizeof(mi);
|
||||
result_t& result = *reinterpret_cast<result_t*>(param);
|
||||
if (GetMonitorInfo(monitor, &mi))
|
||||
{
|
||||
result.push_back({ monitor, mi.*member });
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
EnumDisplayMonitors(NULL, NULL, enumMonitors, reinterpret_cast<LPARAM>(&result));
|
||||
return result;
|
||||
}
|
||||
|
||||
template<RECT MONITORINFO::*member>
|
||||
std::vector<std::pair<HMONITOR, MONITORINFOEX>> GetAllMonitorInfo()
|
||||
{
|
||||
using result_t = std::vector<std::pair<HMONITOR, MONITORINFOEX>>;
|
||||
result_t result;
|
||||
|
||||
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL {
|
||||
MONITORINFOEX mi;
|
||||
mi.cbSize = sizeof(mi);
|
||||
result_t& result = *reinterpret_cast<result_t*>(param);
|
||||
if (GetMonitorInfo(monitor, &mi))
|
||||
{
|
||||
result.push_back({ monitor, mi });
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
EnumDisplayMonitors(NULL, NULL, enumMonitors, reinterpret_cast<LPARAM>(&result));
|
||||
return result;
|
||||
}
|
||||
|
||||
template<RECT MONITORINFO::*member>
|
||||
RECT GetAllMonitorsCombinedRect()
|
||||
{
|
||||
@@ -168,4 +211,7 @@ namespace FancyZonesUtils
|
||||
|
||||
RECT PrepareRectForCycling(RECT windowRect, RECT zoneWindowRect, DWORD vkCode) noexcept;
|
||||
size_t ChooseNextZoneByPosition(DWORD vkCode, RECT windowRect, const std::vector<RECT>& zoneRects) noexcept;
|
||||
|
||||
// If HWND is already dead, we assume it wasn't elevated
|
||||
bool IsProcessOfWindowElevated(HWND window);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user