2019-09-05 00:26:26 +08:00
|
|
|
#include "pch.h"
|
|
|
|
#include "trace.h"
|
2019-12-17 16:21:46 +08:00
|
|
|
#include "lib/ZoneSet.h"
|
|
|
|
#include "lib/Settings.h"
|
2020-02-18 00:40:02 +08:00
|
|
|
#include "lib/JsonHelpers.h"
|
2019-09-05 00:26:26 +08:00
|
|
|
|
|
|
|
TRACELOGGING_DEFINE_PROVIDER(
|
|
|
|
g_hProvider,
|
|
|
|
"Microsoft.PowerToys",
|
|
|
|
// {38e8889b-9731-53f5-e901-e8a7c1753074}
|
|
|
|
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
|
|
|
TraceLoggingOptionProjectTelemetry());
|
|
|
|
|
|
|
|
struct ZoneSetInfo
|
|
|
|
{
|
|
|
|
size_t NumberOfZones = 0;
|
|
|
|
size_t NumberOfWindows = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
ZoneSetInfo GetZoneSetInfo(_In_opt_ winrt::com_ptr<IZoneSet> set) noexcept
|
|
|
|
{
|
|
|
|
ZoneSetInfo info;
|
|
|
|
if (set)
|
|
|
|
{
|
|
|
|
auto zones = set->GetZones();
|
|
|
|
info.NumberOfZones = zones.size();
|
2020-05-26 22:01:12 +08:00
|
|
|
info.NumberOfWindows = 0;
|
|
|
|
for (int i = 0; i < static_cast<int>(zones.size()); i++)
|
2019-09-05 00:26:26 +08:00
|
|
|
{
|
2020-05-26 22:01:12 +08:00
|
|
|
if (!set->IsZoneEmpty(i))
|
|
|
|
{
|
|
|
|
info.NumberOfWindows++;
|
|
|
|
}
|
|
|
|
}
|
2019-09-05 00:26:26 +08:00
|
|
|
}
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Trace::RegisterProvider() noexcept
|
|
|
|
{
|
|
|
|
TraceLoggingRegister(g_hProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Trace::UnregisterProvider() noexcept
|
|
|
|
{
|
|
|
|
TraceLoggingUnregister(g_hProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Trace::FancyZones::EnableFancyZones(bool enabled) noexcept
|
|
|
|
{
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
2019-10-23 21:21:46 +08:00
|
|
|
"FancyZones_EnableFancyZones",
|
2019-09-05 00:26:26 +08:00
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
|
|
|
TraceLoggingBoolean(enabled, "Enabled"));
|
|
|
|
}
|
|
|
|
|
2019-09-11 18:38:20 +08:00
|
|
|
void Trace::FancyZones::OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept
|
2019-09-05 00:26:26 +08:00
|
|
|
{
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
2019-10-23 21:21:46 +08:00
|
|
|
"FancyZones_OnKeyDown",
|
2019-09-05 00:26:26 +08:00
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
2019-09-11 18:38:20 +08:00
|
|
|
TraceLoggingValue(vkCode, "Hotkey"),
|
2019-09-05 00:26:26 +08:00
|
|
|
TraceLoggingBoolean(win, "WindowsKey"),
|
|
|
|
TraceLoggingBoolean(control, "ControlKey"),
|
|
|
|
TraceLoggingBoolean(inMoveSize, "InMoveSize"));
|
|
|
|
}
|
|
|
|
|
2020-02-18 00:40:02 +08:00
|
|
|
void Trace::FancyZones::DataChanged() noexcept
|
|
|
|
{
|
|
|
|
const JSONHelpers::FancyZonesData& data = JSONHelpers::FancyZonesDataInstance();
|
|
|
|
int appsHistorySize = static_cast<int>(data.GetAppZoneHistoryMap().size());
|
|
|
|
const auto& customZones = data.GetCustomZoneSetsMap();
|
|
|
|
const auto& devices = data.GetDeviceInfoMap();
|
|
|
|
|
|
|
|
std::unique_ptr<INT32[]> customZonesArray(new (std::nothrow) INT32[customZones.size()]);
|
|
|
|
if (!customZonesArray)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto getCustomZoneCount = [&data](const std::variant<JSONHelpers::CanvasLayoutInfo, JSONHelpers::GridLayoutInfo>& layoutInfo) -> int {
|
|
|
|
if (std::holds_alternative<JSONHelpers::GridLayoutInfo>(layoutInfo))
|
|
|
|
{
|
|
|
|
const auto& info = std::get<JSONHelpers::GridLayoutInfo>(layoutInfo);
|
|
|
|
return (info.rows() * info.columns());
|
|
|
|
}
|
|
|
|
else if (std::holds_alternative<JSONHelpers::CanvasLayoutInfo>(layoutInfo))
|
|
|
|
{
|
|
|
|
const auto& info = std::get<JSONHelpers::CanvasLayoutInfo>(layoutInfo);
|
|
|
|
return static_cast<int>(info.zones.size());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
//NumberOfZonesForEachCustomZoneSet
|
|
|
|
int i = 0;
|
|
|
|
for (const auto& [id, customZoneSetData] : customZones)
|
|
|
|
{
|
|
|
|
customZonesArray.get()[i] = getCustomZoneCount(customZoneSetData.info);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ActiveZoneSetsList
|
|
|
|
std::wstring activeZoneSetInfo;
|
|
|
|
for (const auto& [id, device] : devices)
|
|
|
|
{
|
|
|
|
const JSONHelpers::ZoneSetLayoutType type = device.activeZoneSet.type;
|
|
|
|
if (!activeZoneSetInfo.empty())
|
|
|
|
{
|
|
|
|
activeZoneSetInfo += L"; ";
|
|
|
|
}
|
|
|
|
activeZoneSetInfo += L"type: " + JSONHelpers::TypeToString(type);
|
|
|
|
|
|
|
|
int zoneCount = -1;
|
|
|
|
if (type == JSONHelpers::ZoneSetLayoutType::Custom)
|
|
|
|
{
|
|
|
|
const auto& activeCustomZone = customZones.find(device.activeZoneSet.uuid);
|
|
|
|
if (activeCustomZone != customZones.end())
|
|
|
|
{
|
|
|
|
zoneCount = getCustomZoneCount(activeCustomZone->second.info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
zoneCount = device.zoneCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zoneCount != -1)
|
|
|
|
{
|
|
|
|
activeZoneSetInfo += L", zone count: " + std::to_wstring(zoneCount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
activeZoneSetInfo += L", custom zone data was deleted";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
|
|
|
"FancyZones_ZoneSettingsChanged",
|
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
|
|
|
TraceLoggingInt32(appsHistorySize, "AppsInHistoryCount"),
|
|
|
|
TraceLoggingInt32(static_cast<int>(customZones.size()), "CustomZoneSetCount"),
|
|
|
|
TraceLoggingInt32Array(customZonesArray.get(), static_cast<int>(customZones.size()), "NumberOfZonesForEachCustomZoneSet"),
|
|
|
|
TraceLoggingInt32(static_cast<int>(devices.size()), "ActiveZoneSetsCount"),
|
|
|
|
TraceLoggingWideString(activeZoneSetInfo.c_str(), "ActiveZoneSetsList"));
|
|
|
|
}
|
|
|
|
|
2020-03-26 18:54:12 +08:00
|
|
|
void Trace::FancyZones::EditorLaunched(int value) noexcept
|
|
|
|
{
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
|
|
|
"FancyZones_EditorLaunch",
|
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
|
|
|
TraceLoggingInt32(value, "Value"));
|
|
|
|
}
|
|
|
|
|
2019-09-05 00:26:26 +08:00
|
|
|
void Trace::SettingsChanged(const Settings& settings) noexcept
|
|
|
|
{
|
2020-02-12 18:08:11 +08:00
|
|
|
const auto& editorHotkey = settings.editorHotkey;
|
|
|
|
std::wstring hotkeyStr = L"alt:" + std::to_wstring(editorHotkey.alt_pressed())
|
|
|
|
+ L", ctrl:" + std::to_wstring(editorHotkey.ctrl_pressed())
|
|
|
|
+ L", shift:" + std::to_wstring(editorHotkey.shift_pressed())
|
|
|
|
+ L", win:" + std::to_wstring(editorHotkey.win_pressed())
|
|
|
|
+ L", code:" + std::to_wstring(editorHotkey.get_code())
|
|
|
|
+ L", keyFromCode:" + editorHotkey.get_key();
|
|
|
|
|
2019-09-05 00:26:26 +08:00
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
2019-10-23 21:21:46 +08:00
|
|
|
"FancyZones_SettingsChanged",
|
2019-09-05 00:26:26 +08:00
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
2019-10-22 14:11:23 +08:00
|
|
|
TraceLoggingBoolean(settings.shiftDrag, "ShiftDrag"),
|
2020-05-07 07:21:32 +08:00
|
|
|
TraceLoggingBoolean(settings.mouseSwitch, "MouseSwitch"),
|
2019-10-22 14:11:23 +08:00
|
|
|
TraceLoggingBoolean(settings.displayChange_moveWindows, "MoveWindowsOnDisplayChange"),
|
|
|
|
TraceLoggingBoolean(settings.zoneSetChange_flashZones, "FlashZonesOnZoneSetChange"),
|
|
|
|
TraceLoggingBoolean(settings.zoneSetChange_moveWindows, "MoveWindowsOnZoneSetChange"),
|
|
|
|
TraceLoggingBoolean(settings.overrideSnapHotkeys, "OverrideSnapHotKeys"),
|
2020-05-01 22:17:16 +08:00
|
|
|
TraceLoggingBoolean(settings.moveWindowAcrossMonitors, "MoveWindowAcrossMonitors"),
|
2020-02-12 18:08:11 +08:00
|
|
|
TraceLoggingBoolean(settings.appLastZone_moveWindows, "MoveWindowsToLastZoneOnAppOpening"),
|
2020-07-08 16:37:42 +08:00
|
|
|
TraceLoggingBoolean(settings.openWindowOnActiveMonitor, "OpenWindowOnActiveMonitor"),
|
2020-07-01 21:36:05 +08:00
|
|
|
TraceLoggingBoolean(settings.restoreSize, "RestoreSize"),
|
2020-02-12 18:08:11 +08:00
|
|
|
TraceLoggingBoolean(settings.use_cursorpos_editor_startupscreen, "UseCursorPosOnEditorStartup"),
|
2020-03-13 22:56:23 +08:00
|
|
|
TraceLoggingBoolean(settings.showZonesOnAllMonitors, "ShowZonesOnAllMonitors"),
|
2020-03-25 22:38:44 +08:00
|
|
|
TraceLoggingBoolean(settings.makeDraggedWindowTransparent, "MakeDraggedWindowTransparent"),
|
|
|
|
TraceLoggingWideString(settings.zoneColor.c_str(), "ZoneColor"),
|
|
|
|
TraceLoggingWideString(settings.zoneBorderColor.c_str(), "ZoneBorderColor"),
|
2020-05-27 22:55:46 +08:00
|
|
|
TraceLoggingWideString(settings.zoneHighlightColor.c_str(), "ZoneHighlightColor"),
|
2020-02-12 18:08:11 +08:00
|
|
|
TraceLoggingInt32(settings.zoneHighlightOpacity, "ZoneHighlightOpacity"),
|
|
|
|
TraceLoggingWideString(hotkeyStr.c_str(), "Hotkey"),
|
2020-02-18 00:40:02 +08:00
|
|
|
TraceLoggingInt32(static_cast<int>(settings.excludedAppsArray.size()), "ExcludedAppsCount"));
|
2019-09-05 00:26:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Trace::VirtualDesktopChanged() noexcept
|
|
|
|
{
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
2019-10-23 21:21:46 +08:00
|
|
|
"FancyZones_VirtualDesktopChanged",
|
2019-09-05 00:26:26 +08:00
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
|
|
|
}
|
|
|
|
|
2019-11-19 07:29:42 +08:00
|
|
|
void Trace::ZoneWindow::KeyUp(WPARAM wParam) noexcept
|
2019-09-05 00:26:26 +08:00
|
|
|
{
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
2019-10-23 21:21:46 +08:00
|
|
|
"FancyZones_ZoneWindowKeyUp",
|
2019-09-05 00:26:26 +08:00
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
2019-11-19 07:29:42 +08:00
|
|
|
TraceLoggingValue(wParam, "KeyboardValue"));
|
2019-09-05 00:26:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Trace::ZoneWindow::MoveSizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept
|
|
|
|
{
|
|
|
|
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
2019-10-23 21:21:46 +08:00
|
|
|
"FancyZones_MoveSizeEnd",
|
2019-09-05 00:26:26 +08:00
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
2019-10-22 14:11:23 +08:00
|
|
|
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), "ActiveSet"),
|
2019-09-05 00:26:26 +08:00
|
|
|
TraceLoggingValue(zoneInfo.NumberOfZones, "NumberOfZones"),
|
2019-11-19 07:29:42 +08:00
|
|
|
TraceLoggingValue(zoneInfo.NumberOfWindows, "NumberOfWindows"));
|
2019-09-05 00:26:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Trace::ZoneWindow::CycleActiveZoneSet(_In_opt_ winrt::com_ptr<IZoneSet> activeSet, InputMode mode) noexcept
|
|
|
|
{
|
|
|
|
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
|
|
|
TraceLoggingWrite(
|
|
|
|
g_hProvider,
|
2019-10-23 21:21:46 +08:00
|
|
|
"FancyZones_CycleActiveZoneSet",
|
2019-09-05 00:26:26 +08:00
|
|
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
|
|
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
2019-10-22 14:11:23 +08:00
|
|
|
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), "ActiveSet"),
|
2019-09-05 00:26:26 +08:00
|
|
|
TraceLoggingValue(zoneInfo.NumberOfZones, "NumberOfZones"),
|
|
|
|
TraceLoggingValue(zoneInfo.NumberOfWindows, "NumberOfWindows"),
|
|
|
|
TraceLoggingValue(static_cast<int>(mode), "InputMode"));
|
|
|
|
}
|