mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[FancyZones] Remove Editor tmp files paths cmd args and make Editor 'debugable' easier (#4279)
* Remove Editor cmd args - tmp files Add 'Debug mode' startup for Editor * Remove fixed device info string * Move if file exist check * Add enum to improve readability * Introduce ParseDeviceMode enum * Organize strings * Move title to localizable strings
This commit is contained in:
@@ -8,60 +8,52 @@
|
||||
|
||||
#include <ShellScalingApi.h>
|
||||
#include <mutex>
|
||||
#include <fileapi.h>
|
||||
|
||||
#include <gdiplus.h>
|
||||
|
||||
namespace ZoneWindowUtils
|
||||
{
|
||||
const std::wstring& GetActiveZoneSetTmpPath()
|
||||
const wchar_t ActiveZoneSetsTmpFileName[] = L"FancyZonesActiveZoneSets.json";
|
||||
const wchar_t AppliedZoneSetsTmpFileName[] = L"FancyZonesAppliedZoneSets.json";
|
||||
const wchar_t DeletedCustomZoneSetsTmpFileName[] = L"FancyZonesDeletedCustomZoneSets.json";
|
||||
|
||||
const std::wstring& GetTempDirPath()
|
||||
{
|
||||
static std::wstring activeZoneSetTmpFileName;
|
||||
static std::wstring tmpDirPath;
|
||||
static std::once_flag flag;
|
||||
|
||||
std::call_once(flag, []() {
|
||||
wchar_t fileName[L_tmpnam_s];
|
||||
wchar_t buffer[MAX_PATH];
|
||||
|
||||
if (_wtmpnam_s(fileName, L_tmpnam_s) != 0)
|
||||
abort();
|
||||
auto charsWritten = GetTempPath(MAX_PATH, buffer);
|
||||
if (charsWritten > MAX_PATH || (charsWritten == 0))
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
activeZoneSetTmpFileName = std::wstring{ fileName };
|
||||
tmpDirPath = std::wstring{ buffer };
|
||||
});
|
||||
|
||||
return tmpDirPath;
|
||||
}
|
||||
|
||||
const std::wstring& GetActiveZoneSetTmpPath()
|
||||
{
|
||||
static std::wstring activeZoneSetTmpFileName = GetTempDirPath() + ActiveZoneSetsTmpFileName;
|
||||
return activeZoneSetTmpFileName;
|
||||
}
|
||||
|
||||
const std::wstring& GetAppliedZoneSetTmpPath()
|
||||
{
|
||||
static std::wstring appliedZoneSetTmpFileName;
|
||||
static std::once_flag flag;
|
||||
|
||||
std::call_once(flag, []() {
|
||||
wchar_t fileName[L_tmpnam_s];
|
||||
|
||||
if (_wtmpnam_s(fileName, L_tmpnam_s) != 0)
|
||||
abort();
|
||||
|
||||
appliedZoneSetTmpFileName = std::wstring{ fileName };
|
||||
});
|
||||
|
||||
static std::wstring appliedZoneSetTmpFileName = GetTempDirPath() + AppliedZoneSetsTmpFileName;
|
||||
return appliedZoneSetTmpFileName;
|
||||
}
|
||||
|
||||
const std::wstring& GetCustomZoneSetsTmpPath()
|
||||
const std::wstring& GetDeletedCustomZoneSetsTmpPath()
|
||||
{
|
||||
static std::wstring customZoneSetsTmpFileName;
|
||||
static std::once_flag flag;
|
||||
|
||||
std::call_once(flag, []() {
|
||||
wchar_t fileName[L_tmpnam_s];
|
||||
|
||||
if (_wtmpnam_s(fileName, L_tmpnam_s) != 0)
|
||||
abort();
|
||||
|
||||
customZoneSetsTmpFileName = std::wstring{ fileName };
|
||||
});
|
||||
|
||||
return customZoneSetsTmpFileName;
|
||||
static std::wstring deletedCustomZoneSetsTmpFileName = GetTempDirPath() + DeletedCustomZoneSetsTmpFileName;
|
||||
return deletedCustomZoneSetsTmpFileName;
|
||||
}
|
||||
|
||||
std::wstring GenerateUniqueId(HMONITOR monitor, PCWSTR deviceId, PCWSTR virtualDesktopId)
|
||||
|
||||
Reference in New Issue
Block a user