mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
[Telemetry] Add basic interaction events to FZ (#12793)
* [Telemetry] Add basic interaction events to FZ Adds some basic interaction events to FancyZones, such as: - Starting the drag Window movement. - A newly created window snapping to a zone. - Using the Keyboard to snap or extend to a zone. * Update src/modules/fancyzones/FancyZonesLib/FancyZones.cpp Co-authored-by: Seraphima Zykova <zykovas91@gmail.com> * Update trace.cpp * Rename EventSnapNewWindowIntoZone * Adjust event names according to PR feedback Co-authored-by: Seraphima Zykova <zykovas91@gmail.com>
This commit is contained in:
@@ -330,6 +330,10 @@ void FancyZones::MoveWindowIntoZone(HWND window, winrt::com_ptr<IWorkArea> zoneW
|
|||||||
auto& fancyZonesData = FancyZonesDataInstance();
|
auto& fancyZonesData = FancyZonesDataInstance();
|
||||||
if (!fancyZonesData.IsAnotherWindowOfApplicationInstanceZoned(window, zoneWindow->UniqueId()))
|
if (!fancyZonesData.IsAnotherWindowOfApplicationInstanceZoned(window, zoneWindow->UniqueId()))
|
||||||
{
|
{
|
||||||
|
if (zoneWindow)
|
||||||
|
{
|
||||||
|
Trace::FancyZones::SnapNewWindowIntoZone(zoneWindow->ActiveZoneSet());
|
||||||
|
}
|
||||||
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, zoneIndexSet, zoneWindow);
|
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, zoneIndexSet, zoneWindow);
|
||||||
fancyZonesData.UpdateProcessIdToHandleMap(window, zoneWindow->UniqueId());
|
fancyZonesData.UpdateProcessIdToHandleMap(window, zoneWindow->UniqueId());
|
||||||
}
|
}
|
||||||
@@ -966,8 +970,10 @@ bool FancyZones::OnSnapHotkeyBasedOnZoneNumber(HWND window, DWORD vkCode) noexce
|
|||||||
auto currMonitorInfo = std::find(std::begin(monitorInfo), std::end(monitorInfo), current);
|
auto currMonitorInfo = std::find(std::begin(monitorInfo), std::end(monitorInfo), current);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndIndex(window, vkCode, false /* cycle through zones */, m_workAreaHandler.GetWorkArea(m_currentDesktopId, *currMonitorInfo)))
|
auto zoneWindow = m_workAreaHandler.GetWorkArea(m_currentDesktopId, *currMonitorInfo);
|
||||||
|
if (m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndIndex(window, vkCode, false /* cycle through zones */, zoneWindow))
|
||||||
{
|
{
|
||||||
|
Trace::FancyZones::KeyboardSnapWindowToZone(zoneWindow->ActiveZoneSet());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// We iterated through all zones in current monitor zone layout, move on to next one (or previous depending on direction).
|
// We iterated through all zones in current monitor zone layout, move on to next one (or previous depending on direction).
|
||||||
@@ -991,20 +997,30 @@ bool FancyZones::OnSnapHotkeyBasedOnZoneNumber(HWND window, DWORD vkCode) noexce
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto zoneWindow = m_workAreaHandler.GetWorkArea(m_currentDesktopId, current);
|
||||||
// Single monitor environment, or combined multi-monitor environment.
|
// Single monitor environment, or combined multi-monitor environment.
|
||||||
if (m_settings->GetSettings()->restoreSize)
|
if (m_settings->GetSettings()->restoreSize)
|
||||||
{
|
{
|
||||||
bool moved = m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndIndex(window, vkCode, false /* cycle through zones */, m_workAreaHandler.GetWorkArea(m_currentDesktopId, current));
|
bool moved = m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndIndex(window, vkCode, false /* cycle through zones */, zoneWindow);
|
||||||
if (!moved)
|
if (!moved)
|
||||||
{
|
{
|
||||||
FancyZonesUtils::RestoreWindowOrigin(window);
|
FancyZonesUtils::RestoreWindowOrigin(window);
|
||||||
FancyZonesUtils::RestoreWindowSize(window);
|
FancyZonesUtils::RestoreWindowSize(window);
|
||||||
}
|
}
|
||||||
return true;
|
else
|
||||||
|
{
|
||||||
|
Trace::FancyZones::KeyboardSnapWindowToZone(zoneWindow->ActiveZoneSet());
|
||||||
|
}
|
||||||
|
return moved;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndIndex(window, vkCode, true /* cycle through zones */, m_workAreaHandler.GetWorkArea(m_currentDesktopId, current));
|
bool moved = m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndIndex(window, vkCode, true /* cycle through zones */, zoneWindow);
|
||||||
|
if (moved)
|
||||||
|
{
|
||||||
|
Trace::FancyZones::KeyboardSnapWindowToZone(zoneWindow->ActiveZoneSet());
|
||||||
|
}
|
||||||
|
return moved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1078,6 +1094,7 @@ bool FancyZones::OnSnapHotkeyBasedOnPosition(HWND window, DWORD vkCode) noexcept
|
|||||||
// Moving to another monitor succeeded
|
// Moving to another monitor succeeded
|
||||||
const auto& [trueZoneIdx, zoneWindow] = zoneRectsInfo[chosenIdx];
|
const auto& [trueZoneIdx, zoneWindow] = zoneRectsInfo[chosenIdx];
|
||||||
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, { trueZoneIdx }, zoneWindow);
|
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, { trueZoneIdx }, zoneWindow);
|
||||||
|
Trace::FancyZones::KeyboardSnapWindowToZone(zoneWindow->ActiveZoneSet());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1122,6 +1139,7 @@ bool FancyZones::OnSnapHotkeyBasedOnPosition(HWND window, DWORD vkCode) noexcept
|
|||||||
// Moving to another monitor succeeded
|
// Moving to another monitor succeeded
|
||||||
const auto& [trueZoneIdx, zoneWindow] = zoneRectsInfo[chosenIdx];
|
const auto& [trueZoneIdx, zoneWindow] = zoneRectsInfo[chosenIdx];
|
||||||
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, { trueZoneIdx }, zoneWindow);
|
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, { trueZoneIdx }, zoneWindow);
|
||||||
|
Trace::FancyZones::KeyboardSnapWindowToZone(zoneWindow->ActiveZoneSet());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1157,11 +1175,21 @@ bool FancyZones::ProcessDirectedSnapHotkey(HWND window, DWORD vkCode, bool cycle
|
|||||||
// Check whether Alt is used in the shortcut key combination
|
// Check whether Alt is used in the shortcut key combination
|
||||||
if (GetAsyncKeyState(VK_MENU) & 0x8000)
|
if (GetAsyncKeyState(VK_MENU) & 0x8000)
|
||||||
{
|
{
|
||||||
return m_windowMoveHandler.ExtendWindowByDirectionAndPosition(window, vkCode, zoneWindow);
|
bool result = m_windowMoveHandler.ExtendWindowByDirectionAndPosition(window, vkCode, zoneWindow);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
Trace::FancyZones::KeyboardSnapWindowToZone(zoneWindow->ActiveZoneSet());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndPosition(window, vkCode, cycle, zoneWindow);
|
bool result = m_windowMoveHandler.MoveWindowIntoZoneByDirectionAndPosition(window, vkCode, cycle, zoneWindow);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
Trace::FancyZones::KeyboardSnapWindowToZone(zoneWindow->ActiveZoneSet());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ IFACEMETHODIMP WorkArea::MoveSizeEnter(HWND window) noexcept
|
|||||||
m_highlightZone = {};
|
m_highlightZone = {};
|
||||||
m_initialHighlightZone = {};
|
m_initialHighlightZone = {};
|
||||||
ShowZoneWindow();
|
ShowZoneWindow();
|
||||||
|
Trace::WorkArea::MoveOrResizeStarted(m_activeZoneSet);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +300,7 @@ IFACEMETHODIMP WorkArea::MoveSizeEnd(HWND window, POINT const& ptScreen) noexcep
|
|||||||
SaveWindowProcessToZoneIndex(window);
|
SaveWindowProcessToZoneIndex(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Trace::WorkArea::MoveSizeEnd(m_activeZoneSet);
|
Trace::WorkArea::MoveOrResizeEnd(m_activeZoneSet);
|
||||||
|
|
||||||
HideZoneWindow();
|
HideZoneWindow();
|
||||||
m_windowMoveSize = nullptr;
|
m_windowMoveSize = nullptr;
|
||||||
|
|||||||
@@ -15,7 +15,10 @@
|
|||||||
#define EventSettingsKey "FancyZones_Settings"
|
#define EventSettingsKey "FancyZones_Settings"
|
||||||
#define EventDesktopChangedKey "FancyZones_VirtualDesktopChanged"
|
#define EventDesktopChangedKey "FancyZones_VirtualDesktopChanged"
|
||||||
#define EventZoneWindowKeyUpKey "FancyZones_ZoneWindowKeyUp"
|
#define EventZoneWindowKeyUpKey "FancyZones_ZoneWindowKeyUp"
|
||||||
#define EventMoveSizeEndKey "FancyZones_MoveSizeEnd"
|
#define EventSnapNewWindowIntoZone "FancyZones_SnapNewWindowIntoZone"
|
||||||
|
#define EventKeyboardSnapWindowToZone "FancyZones_KeyboardSnapWindowToZone"
|
||||||
|
#define EventMoveOrResizeStartedKey "FancyZones_MoveOrResizeStarted"
|
||||||
|
#define EventMoveOrResizeEndedKey "FancyZones_MoveOrResizeEnded"
|
||||||
#define EventCycleActiveZoneSetKey "FancyZones_CycleActiveZoneSet"
|
#define EventCycleActiveZoneSetKey "FancyZones_CycleActiveZoneSet"
|
||||||
#define EventQuickLayoutSwitchKey "FancyZones_QuickLayoutSwitch"
|
#define EventQuickLayoutSwitchKey "FancyZones_QuickLayoutSwitch"
|
||||||
|
|
||||||
@@ -78,7 +81,8 @@ struct ZoneSetInfo
|
|||||||
size_t NumberOfWindows = 0;
|
size_t NumberOfWindows = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
ZoneSetInfo GetZoneSetInfo(_In_opt_ winrt::com_ptr<IZoneSet> set) noexcept
|
|
||||||
|
ZoneSetInfo GetZoneSetInfo(_In_opt_ IZoneSet* set) noexcept
|
||||||
{
|
{
|
||||||
ZoneSetInfo info;
|
ZoneSetInfo info;
|
||||||
if (set)
|
if (set)
|
||||||
@@ -97,6 +101,11 @@ ZoneSetInfo GetZoneSetInfo(_In_opt_ winrt::com_ptr<IZoneSet> set) noexcept
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZoneSetInfo GetZoneSetInfo(_In_opt_ winrt::com_ptr<IZoneSet> set) noexcept
|
||||||
|
{
|
||||||
|
return GetZoneSetInfo(set.get());
|
||||||
|
}
|
||||||
|
|
||||||
void Trace::RegisterProvider() noexcept
|
void Trace::RegisterProvider() noexcept
|
||||||
{
|
{
|
||||||
TraceLoggingRegister(g_hProvider);
|
TraceLoggingRegister(g_hProvider);
|
||||||
@@ -247,6 +256,32 @@ void Trace::FancyZones::QuickLayoutSwitched(bool shortcutUsed) noexcept
|
|||||||
TraceLoggingBoolean(shortcutUsed, QuickLayoutSwitchedWithShortcutUsed));
|
TraceLoggingBoolean(shortcutUsed, QuickLayoutSwitchedWithShortcutUsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Trace::FancyZones::SnapNewWindowIntoZone(IZoneSet* activeSet) noexcept
|
||||||
|
{
|
||||||
|
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
||||||
|
TraceLoggingWrite(
|
||||||
|
g_hProvider,
|
||||||
|
EventSnapNewWindowIntoZone,
|
||||||
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||||
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||||
|
TraceLoggingValue(reinterpret_cast<void*>(activeSet), ActiveSetKey),
|
||||||
|
TraceLoggingValue(zoneInfo.NumberOfZones, NumberOfZonesKey),
|
||||||
|
TraceLoggingValue(zoneInfo.NumberOfWindows, NumberOfWindowsKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trace::FancyZones::KeyboardSnapWindowToZone(IZoneSet* activeSet) noexcept
|
||||||
|
{
|
||||||
|
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
||||||
|
TraceLoggingWrite(
|
||||||
|
g_hProvider,
|
||||||
|
EventKeyboardSnapWindowToZone,
|
||||||
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||||
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||||
|
TraceLoggingValue(reinterpret_cast<void*>(activeSet), ActiveSetKey),
|
||||||
|
TraceLoggingValue(zoneInfo.NumberOfZones, NumberOfZonesKey),
|
||||||
|
TraceLoggingValue(zoneInfo.NumberOfWindows, NumberOfWindowsKey));
|
||||||
|
}
|
||||||
|
|
||||||
static std::wstring HotKeyToString(const PowerToysSettings::HotkeyObject& hotkey)
|
static std::wstring HotKeyToString(const PowerToysSettings::HotkeyObject& hotkey)
|
||||||
{
|
{
|
||||||
return L"alt:" + std::to_wstring(hotkey.alt_pressed())
|
return L"alt:" + std::to_wstring(hotkey.alt_pressed())
|
||||||
@@ -316,12 +351,25 @@ void Trace::WorkArea::KeyUp(WPARAM wParam) noexcept
|
|||||||
TraceLoggingValue(wParam, KeyboardValueKey));
|
TraceLoggingValue(wParam, KeyboardValueKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trace::WorkArea::MoveSizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept
|
void Trace::WorkArea::MoveOrResizeStarted(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept
|
||||||
{
|
{
|
||||||
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
||||||
TraceLoggingWrite(
|
TraceLoggingWrite(
|
||||||
g_hProvider,
|
g_hProvider,
|
||||||
EventMoveSizeEndKey,
|
EventMoveOrResizeStartedKey,
|
||||||
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||||
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||||
|
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), ActiveSetKey),
|
||||||
|
TraceLoggingValue(zoneInfo.NumberOfZones, NumberOfZonesKey),
|
||||||
|
TraceLoggingValue(zoneInfo.NumberOfWindows, NumberOfWindowsKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trace::WorkArea::MoveOrResizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept
|
||||||
|
{
|
||||||
|
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
||||||
|
TraceLoggingWrite(
|
||||||
|
g_hProvider,
|
||||||
|
EventMoveOrResizeEndedKey,
|
||||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||||
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), ActiveSetKey),
|
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), ActiveSetKey),
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public:
|
|||||||
static void EditorLaunched(int value) noexcept;
|
static void EditorLaunched(int value) noexcept;
|
||||||
static void Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept;
|
static void Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept;
|
||||||
static void QuickLayoutSwitched(bool shortcutUsed) noexcept;
|
static void QuickLayoutSwitched(bool shortcutUsed) noexcept;
|
||||||
|
static void SnapNewWindowIntoZone(IZoneSet* activeSet) noexcept;
|
||||||
|
static void KeyboardSnapWindowToZone(IZoneSet* activeSet) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SettingsTelemetry(const Settings& settings) noexcept;
|
static void SettingsTelemetry(const Settings& settings) noexcept;
|
||||||
@@ -33,7 +35,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void KeyUp(WPARAM wparam) noexcept;
|
static void KeyUp(WPARAM wparam) noexcept;
|
||||||
static void MoveSizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept;
|
static void MoveOrResizeStarted(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept;
|
||||||
|
static void MoveOrResizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept;
|
||||||
static void CycleActiveZoneSet(_In_opt_ winrt::com_ptr<IZoneSet> activeSet, InputMode mode) noexcept;
|
static void CycleActiveZoneSet(_In_opt_ winrt::com_ptr<IZoneSet> activeSet, InputMode mode) noexcept;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user