mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-01 01:49:06 +08:00
[FancyZones]Additional logs (#16927)
This commit is contained in:
parent
a8fb9e0804
commit
0816714782
@ -106,7 +106,6 @@ public:
|
|||||||
|
|
||||||
void MoveSizeEnd(HWND window, POINT const& ptScreen) noexcept
|
void MoveSizeEnd(HWND window, POINT const& ptScreen) noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
m_windowMoveHandler.MoveSizeEnd(window, ptScreen, m_workAreaHandler.GetWorkAreasByDesktopId(m_currentDesktopId));
|
m_windowMoveHandler.MoveSizeEnd(window, ptScreen, m_workAreaHandler.GetWorkAreasByDesktopId(m_currentDesktopId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +236,7 @@ FancyZones::Run() noexcept
|
|||||||
m_window = CreateWindowExW(WS_EX_TOOLWINDOW, NonLocalizable::ToolWindowClassName, L"", WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, m_hinstance, this);
|
m_window = CreateWindowExW(WS_EX_TOOLWINDOW, NonLocalizable::ToolWindowClassName, L"", WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, m_hinstance, this);
|
||||||
if (!m_window)
|
if (!m_window)
|
||||||
{
|
{
|
||||||
|
Logger::error(L"Failed to create FancyZones window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,8 +333,6 @@ std::pair<winrt::com_ptr<IWorkArea>, ZoneIndexSet> FancyZones::GetAppZoneHistory
|
|||||||
|
|
||||||
void FancyZones::MoveWindowIntoZone(HWND window, winrt::com_ptr<IWorkArea> workArea, const ZoneIndexSet& zoneIndexSet) noexcept
|
void FancyZones::MoveWindowIntoZone(HWND window, winrt::com_ptr<IWorkArea> workArea, const ZoneIndexSet& zoneIndexSet) noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
|
|
||||||
if (!AppZoneHistory::instance().IsAnotherWindowOfApplicationInstanceZoned(window, workArea->UniqueId()))
|
if (!AppZoneHistory::instance().IsAnotherWindowOfApplicationInstanceZoned(window, workArea->UniqueId()))
|
||||||
{
|
{
|
||||||
if (workArea)
|
if (workArea)
|
||||||
@ -344,6 +342,10 @@ void FancyZones::MoveWindowIntoZone(HWND window, winrt::com_ptr<IWorkArea> workA
|
|||||||
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, zoneIndexSet, workArea);
|
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, zoneIndexSet, workArea);
|
||||||
AppZoneHistory::instance().UpdateProcessIdToHandleMap(window, workArea->UniqueId());
|
AppZoneHistory::instance().UpdateProcessIdToHandleMap(window, workArea->UniqueId());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::info(L"Window was already zoned");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FancyZones::MoveToAppLastZone(HWND window, HMONITOR active, HMONITOR primary) noexcept
|
bool FancyZones::MoveToAppLastZone(HWND window, HMONITOR active, HMONITOR primary) noexcept
|
||||||
@ -806,7 +808,8 @@ LRESULT FancyZones::WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lpa
|
|||||||
|
|
||||||
void FancyZones::OnDisplayChange(DisplayChangeType changeType) noexcept
|
void FancyZones::OnDisplayChange(DisplayChangeType changeType) noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
Logger::info(L"Display changed, type: {}", changeType);
|
||||||
|
|
||||||
if (changeType == DisplayChangeType::VirtualDesktop ||
|
if (changeType == DisplayChangeType::VirtualDesktop ||
|
||||||
changeType == DisplayChangeType::Initialization)
|
changeType == DisplayChangeType::Initialization)
|
||||||
{
|
{
|
||||||
@ -852,7 +855,6 @@ void FancyZones::OnDisplayChange(DisplayChangeType changeType) noexcept
|
|||||||
|
|
||||||
void FancyZones::AddWorkArea(HMONITOR monitor, const std::wstring& deviceId) noexcept
|
void FancyZones::AddWorkArea(HMONITOR monitor, const std::wstring& deviceId) noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
if (m_workAreaHandler.IsNewWorkArea(m_currentDesktopId, monitor))
|
if (m_workAreaHandler.IsNewWorkArea(m_currentDesktopId, monitor))
|
||||||
{
|
{
|
||||||
wil::unique_cotaskmem_string virtualDesktopIdStr;
|
wil::unique_cotaskmem_string virtualDesktopIdStr;
|
||||||
@ -978,7 +980,6 @@ void FancyZones::CycleTabs(bool reverse) noexcept
|
|||||||
|
|
||||||
bool FancyZones::OnSnapHotkeyBasedOnZoneNumber(HWND window, DWORD vkCode) noexcept
|
bool FancyZones::OnSnapHotkeyBasedOnZoneNumber(HWND window, DWORD vkCode) noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
HMONITOR current = WorkAreaKeyFromWindow(window);
|
HMONITOR current = WorkAreaKeyFromWindow(window);
|
||||||
|
|
||||||
std::vector<HMONITOR> monitorInfo = GetMonitorsSorted();
|
std::vector<HMONITOR> monitorInfo = GetMonitorsSorted();
|
||||||
@ -1213,8 +1214,6 @@ bool FancyZones::ProcessDirectedSnapHotkey(HWND window, DWORD vkCode, bool cycle
|
|||||||
|
|
||||||
void FancyZones::RegisterVirtualDesktopUpdates() noexcept
|
void FancyZones::RegisterVirtualDesktopUpdates() noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
|
|
||||||
auto guids = m_virtualDesktop.GetVirtualDesktopIdsFromRegistry();
|
auto guids = m_virtualDesktop.GetVirtualDesktopIdsFromRegistry();
|
||||||
if (guids.has_value())
|
if (guids.has_value())
|
||||||
{
|
{
|
||||||
@ -1367,8 +1366,6 @@ std::vector<HMONITOR> FancyZones::GetMonitorsSorted() noexcept
|
|||||||
|
|
||||||
std::vector<std::pair<HMONITOR, RECT>> FancyZones::GetRawMonitorData() noexcept
|
std::vector<std::pair<HMONITOR, RECT>> FancyZones::GetRawMonitorData() noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
|
|
||||||
std::vector<std::pair<HMONITOR, RECT>> monitorInfo;
|
std::vector<std::pair<HMONITOR, RECT>> monitorInfo;
|
||||||
const auto& activeWorkAreaMap = m_workAreaHandler.GetWorkAreasByDesktopId(m_currentDesktopId);
|
const auto& activeWorkAreaMap = m_workAreaHandler.GetWorkAreasByDesktopId(m_currentDesktopId);
|
||||||
for (const auto& [monitor, workArea] : activeWorkAreaMap)
|
for (const auto& [monitor, workArea] : activeWorkAreaMap)
|
||||||
|
@ -50,8 +50,6 @@ void AppZoneHistory::LoadData()
|
|||||||
|
|
||||||
void AppZoneHistory::SaveData()
|
void AppZoneHistory::SaveData()
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
|
|
||||||
bool dirtyFlag = false;
|
bool dirtyFlag = false;
|
||||||
std::unordered_map<std::wstring, std::vector<FancyZonesDataTypes::AppZoneHistoryData>> updatedHistory;
|
std::unordered_map<std::wstring, std::vector<FancyZonesDataTypes::AppZoneHistoryData>> updatedHistory;
|
||||||
if (m_virtualDesktopCheckCallback)
|
if (m_virtualDesktopCheckCallback)
|
||||||
@ -84,8 +82,6 @@ void AppZoneHistory::SaveData()
|
|||||||
|
|
||||||
bool AppZoneHistory::SetAppLastZones(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId, const std::wstring& zoneSetId, const ZoneIndexSet& zoneIndexSet)
|
bool AppZoneHistory::SetAppLastZones(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId, const std::wstring& zoneSetId, const ZoneIndexSet& zoneIndexSet)
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
|
|
||||||
if (IsAnotherWindowOfApplicationInstanceZoned(window, deviceId))
|
if (IsAnotherWindowOfApplicationInstanceZoned(window, deviceId))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -97,6 +93,8 @@ bool AppZoneHistory::SetAppLastZones(HWND window, const FancyZonesDataTypes::Dev
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger::info(L"Add app zone history, device: {}, layout: {}", deviceId.toString(), zoneSetId);
|
||||||
|
|
||||||
DWORD processId = 0;
|
DWORD processId = 0;
|
||||||
GetWindowThreadProcessId(window, &processId);
|
GetWindowThreadProcessId(window, &processId);
|
||||||
|
|
||||||
@ -142,7 +140,7 @@ bool AppZoneHistory::SetAppLastZones(HWND window, const FancyZonesDataTypes::Dev
|
|||||||
|
|
||||||
bool AppZoneHistory::RemoveAppLastZone(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId, const std::wstring_view& zoneSetId)
|
bool AppZoneHistory::RemoveAppLastZone(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId, const std::wstring_view& zoneSetId)
|
||||||
{
|
{
|
||||||
_TRACER_;
|
Logger::info(L"Add app zone history, device: {}, layout: {}", deviceId.toString(), zoneSetId);
|
||||||
|
|
||||||
auto processPath = get_process_path(window);
|
auto processPath = get_process_path(window);
|
||||||
if (!processPath.empty())
|
if (!processPath.empty())
|
||||||
@ -302,12 +300,17 @@ ZoneIndexSet AppZoneHistory::GetAppLastZoneIndexSet(HWND window, const FancyZone
|
|||||||
|
|
||||||
void AppZoneHistory::SyncVirtualDesktops(GUID currentVirtualDesktopId)
|
void AppZoneHistory::SyncVirtualDesktops(GUID currentVirtualDesktopId)
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
// Explorer persists current virtual desktop identifier to registry on a per session basis,
|
// Explorer persists current virtual desktop identifier to registry on a per session basis,
|
||||||
// but only after first virtual desktop switch happens. If the user hasn't switched virtual
|
// but only after first virtual desktop switch happens. If the user hasn't switched virtual
|
||||||
// desktops in this session value in registry will be empty and we will use default GUID in
|
// desktops in this session value in registry will be empty and we will use default GUID in
|
||||||
// that case (00000000-0000-0000-0000-000000000000).
|
// that case (00000000-0000-0000-0000-000000000000).
|
||||||
|
|
||||||
|
auto currentVirtualDesktopStr = FancyZonesUtils::GuidToString(currentVirtualDesktopId);
|
||||||
|
if (currentVirtualDesktopStr)
|
||||||
|
{
|
||||||
|
Logger::info(L"AppZoneHistory Sync virtual desktops: current {}", currentVirtualDesktopStr.value());
|
||||||
|
}
|
||||||
|
|
||||||
bool dirtyFlag = false;
|
bool dirtyFlag = false;
|
||||||
|
|
||||||
for (auto& [path, perDesktopData] : m_history)
|
for (auto& [path, perDesktopData] : m_history)
|
||||||
|
@ -173,8 +173,6 @@ void AppliedLayouts::LoadData()
|
|||||||
|
|
||||||
void AppliedLayouts::SaveData()
|
void AppliedLayouts::SaveData()
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
|
|
||||||
bool dirtyFlag = false;
|
bool dirtyFlag = false;
|
||||||
TAppliedLayoutsMap updatedMap;
|
TAppliedLayoutsMap updatedMap;
|
||||||
if (m_virtualDesktopCheckCallback)
|
if (m_virtualDesktopCheckCallback)
|
||||||
@ -209,12 +207,17 @@ void AppliedLayouts::SetVirtualDesktopCheckCallback(std::function<bool(GUID)> ca
|
|||||||
|
|
||||||
void AppliedLayouts::SyncVirtualDesktops(GUID currentVirtualDesktopId)
|
void AppliedLayouts::SyncVirtualDesktops(GUID currentVirtualDesktopId)
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
// Explorer persists current virtual desktop identifier to registry on a per session basis,
|
// Explorer persists current virtual desktop identifier to registry on a per session basis,
|
||||||
// but only after first virtual desktop switch happens. If the user hasn't switched virtual
|
// but only after first virtual desktop switch happens. If the user hasn't switched virtual
|
||||||
// desktops in this session value in registry will be empty and we will use default GUID in
|
// desktops in this session value in registry will be empty and we will use default GUID in
|
||||||
// that case (00000000-0000-0000-0000-000000000000).
|
// that case (00000000-0000-0000-0000-000000000000).
|
||||||
|
|
||||||
|
auto currentVirtualDesktopStr = FancyZonesUtils::GuidToString(currentVirtualDesktopId);
|
||||||
|
if (currentVirtualDesktopStr)
|
||||||
|
{
|
||||||
|
Logger::info(L"AppliedLayouts Sync virtual desktops: current {}", currentVirtualDesktopStr.value());
|
||||||
|
}
|
||||||
|
|
||||||
bool dirtyFlag = false;
|
bool dirtyFlag = false;
|
||||||
|
|
||||||
std::vector<FancyZonesDataTypes::DeviceIdData> replaceWithCurrentId{};
|
std::vector<FancyZonesDataTypes::DeviceIdData> replaceWithCurrentId{};
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include "VirtualDesktop.h"
|
#include "VirtualDesktop.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#include <common/logger/logger.h>
|
||||||
|
|
||||||
winrt::com_ptr<IWorkArea> MonitorWorkAreaHandler::GetWorkArea(const GUID& desktopId, HMONITOR monitor)
|
winrt::com_ptr<IWorkArea> MonitorWorkAreaHandler::GetWorkArea(const GUID& desktopId, HMONITOR monitor)
|
||||||
{
|
{
|
||||||
auto desktopIt = workAreaMap.find(desktopId);
|
auto desktopIt = workAreaMap.find(desktopId);
|
||||||
@ -83,6 +85,12 @@ void MonitorWorkAreaHandler::AddWorkArea(const GUID& desktopId, HMONITOR monitor
|
|||||||
if (!workAreaMap.contains(desktopId))
|
if (!workAreaMap.contains(desktopId))
|
||||||
{
|
{
|
||||||
workAreaMap[desktopId] = {};
|
workAreaMap[desktopId] = {};
|
||||||
|
|
||||||
|
auto desktopIdStr = FancyZonesUtils::GuidToString(desktopId);
|
||||||
|
if (desktopIdStr)
|
||||||
|
{
|
||||||
|
Logger::info(L"Add work area on the desktop {}", desktopIdStr.value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto& perDesktopData = workAreaMap[desktopId];
|
auto& perDesktopData = workAreaMap[desktopId];
|
||||||
perDesktopData[monitor] = std::move(workArea);
|
perDesktopData[monitor] = std::move(workArea);
|
||||||
|
@ -354,9 +354,15 @@ void WindowMoveHandler::SetWindowTransparency(HWND window) noexcept
|
|||||||
GWL_EXSTYLE,
|
GWL_EXSTYLE,
|
||||||
m_windowTransparencyProperties.draggedWindowExstyle | WS_EX_LAYERED);
|
m_windowTransparencyProperties.draggedWindowExstyle | WS_EX_LAYERED);
|
||||||
|
|
||||||
GetLayeredWindowAttributes(window, &m_windowTransparencyProperties.draggedWindowCrKey, &m_windowTransparencyProperties.draggedWindowInitialAlpha, &m_windowTransparencyProperties.draggedWindowDwFlags);
|
if (!GetLayeredWindowAttributes(window, &m_windowTransparencyProperties.draggedWindowCrKey, &m_windowTransparencyProperties.draggedWindowInitialAlpha, &m_windowTransparencyProperties.draggedWindowDwFlags))
|
||||||
|
{
|
||||||
|
Logger::error(L"SetWindowTransparency: GetLayeredWindowAttributes failed, {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
SetLayeredWindowAttributes(window, 0, (255 * 50) / 100, LWA_ALPHA);
|
if (!SetLayeredWindowAttributes(window, 0, (255 * 50) / 100, LWA_ALPHA))
|
||||||
|
{
|
||||||
|
Logger::error(L"SetWindowTransparency: SetLayeredWindowAttributes failed, {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,8 +370,16 @@ void WindowMoveHandler::ResetWindowTransparency() noexcept
|
|||||||
{
|
{
|
||||||
if (FancyZonesSettings::settings().makeDraggedWindowTransparent && m_windowTransparencyProperties.draggedWindow != nullptr)
|
if (FancyZonesSettings::settings().makeDraggedWindowTransparent && m_windowTransparencyProperties.draggedWindow != nullptr)
|
||||||
{
|
{
|
||||||
SetLayeredWindowAttributes(m_windowTransparencyProperties.draggedWindow, m_windowTransparencyProperties.draggedWindowCrKey, m_windowTransparencyProperties.draggedWindowInitialAlpha, m_windowTransparencyProperties.draggedWindowDwFlags);
|
if (!SetLayeredWindowAttributes(m_windowTransparencyProperties.draggedWindow, m_windowTransparencyProperties.draggedWindowCrKey, m_windowTransparencyProperties.draggedWindowInitialAlpha, m_windowTransparencyProperties.draggedWindowDwFlags))
|
||||||
SetWindowLong(m_windowTransparencyProperties.draggedWindow, GWL_EXSTYLE, m_windowTransparencyProperties.draggedWindowExstyle);
|
{
|
||||||
|
Logger::error(L"ResetWindowTransparency: SetLayeredWindowAttributes failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SetWindowLong(m_windowTransparencyProperties.draggedWindow, GWL_EXSTYLE, m_windowTransparencyProperties.draggedWindowExstyle) == 0)
|
||||||
|
{
|
||||||
|
Logger::error(L"ResetWindowTransparency: SetWindowLong failed, {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
m_windowTransparencyProperties.draggedWindow = nullptr;
|
m_windowTransparencyProperties.draggedWindow = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
#include "WindowUtils.h"
|
#include "WindowUtils.h"
|
||||||
|
|
||||||
#include <common/display/dpi_aware.h>
|
#include <common/display/dpi_aware.h>
|
||||||
|
#include <common/logger/logger.h>
|
||||||
#include <common/utils/process_path.h>
|
#include <common/utils/process_path.h>
|
||||||
|
#include <common/utils/winapi_error.h>
|
||||||
#include <common/utils/window.h>
|
#include <common/utils/window.h>
|
||||||
#include <common/utils/excluded_apps.h>
|
#include <common/utils/excluded_apps.h>
|
||||||
|
|
||||||
@ -292,14 +294,20 @@ void FancyZonesWindowUtils::SwitchToWindow(HWND window) noexcept
|
|||||||
if (IsIconic(window))
|
if (IsIconic(window))
|
||||||
{
|
{
|
||||||
// Show the window since SetForegroundWindow fails on minimized windows
|
// Show the window since SetForegroundWindow fails on minimized windows
|
||||||
ShowWindow(window, SW_RESTORE);
|
if (!ShowWindow(window, SW_RESTORE))
|
||||||
|
{
|
||||||
|
Logger::error(L"ShowWindow failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a hack to bypass the restriction on setting the foreground window
|
// This is a hack to bypass the restriction on setting the foreground window
|
||||||
INPUT inputs[1] = { { .type = INPUT_MOUSE } };
|
INPUT inputs[1] = { { .type = INPUT_MOUSE } };
|
||||||
SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
|
SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
|
||||||
|
|
||||||
SetForegroundWindow(window);
|
if (!SetForegroundWindow(window))
|
||||||
|
{
|
||||||
|
Logger::error(L"SetForegroundWindow failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept
|
void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept
|
||||||
@ -338,10 +346,19 @@ void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept
|
|||||||
|
|
||||||
placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
|
placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
|
||||||
|
|
||||||
::SetWindowPlacement(window, &placement);
|
auto result = ::SetWindowPlacement(window, &placement);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
Logger::error(L"SetWindowPlacement failed, {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
// Do it again, allowing Windows to resize the window and set correct scaling
|
// Do it again, allowing Windows to resize the window and set correct scaling
|
||||||
// This fixes Issue #365
|
// This fixes Issue #365
|
||||||
::SetWindowPlacement(window, &placement);
|
result = ::SetWindowPlacement(window, &placement);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
Logger::error(L"SetWindowPlacement failed, {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyZonesWindowUtils::SaveWindowSizeAndOrigin(HWND window) noexcept
|
void FancyZonesWindowUtils::SaveWindowSizeAndOrigin(HWND window) noexcept
|
||||||
@ -390,6 +407,7 @@ void FancyZonesWindowUtils::RestoreWindowSize(HWND window) noexcept
|
|||||||
{
|
{
|
||||||
rect.right = rect.left + windowSize[0];
|
rect.right = rect.left + windowSize[0];
|
||||||
rect.bottom = rect.top + windowSize[1];
|
rect.bottom = rect.top + windowSize[1];
|
||||||
|
Logger::info("Restore window size");
|
||||||
SizeWindowToRect(window, rect);
|
SizeWindowToRect(window, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,6 +441,8 @@ void FancyZonesWindowUtils::RestoreWindowOrigin(HWND window) noexcept
|
|||||||
rect.right += xOffset;
|
rect.right += xOffset;
|
||||||
rect.top += yOffset;
|
rect.top += yOffset;
|
||||||
rect.bottom += yOffset;
|
rect.bottom += yOffset;
|
||||||
|
|
||||||
|
Logger::info("Restore window origin");
|
||||||
SizeWindowToRect(window, rect);
|
SizeWindowToRect(window, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ namespace
|
|||||||
|
|
||||||
HWND ExtractWindow()
|
HWND ExtractWindow()
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
|
|
||||||
if (m_pool.empty())
|
if (m_pool.empty())
|
||||||
@ -84,7 +83,6 @@ namespace
|
|||||||
|
|
||||||
void FreeZonesOverlayWindow(HWND window)
|
void FreeZonesOverlayWindow(HWND window)
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
Logger::info("Freeing ZonesOverlay window into pool, hWnd = {}", (void*)window);
|
Logger::info("Freeing ZonesOverlay window into pool, hWnd = {}", (void*)window);
|
||||||
SetWindowLongPtrW(window, GWLP_USERDATA, 0);
|
SetWindowLongPtrW(window, GWLP_USERDATA, 0);
|
||||||
ShowWindow(window, SW_HIDE);
|
ShowWindow(window, SW_HIDE);
|
||||||
@ -196,6 +194,7 @@ bool WorkArea::Init(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataT
|
|||||||
mi.cbSize = sizeof(mi);
|
mi.cbSize = sizeof(mi);
|
||||||
if (!GetMonitorInfoW(monitor, &mi))
|
if (!GetMonitorInfoW(monitor, &mi))
|
||||||
{
|
{
|
||||||
|
Logger::error(L"GetMonitorInfo failed on work area initialization");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
workAreaRect = Rect(mi.rcWork);
|
workAreaRect = Rect(mi.rcWork);
|
||||||
@ -212,6 +211,7 @@ bool WorkArea::Init(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataT
|
|||||||
|
|
||||||
if (!m_window)
|
if (!m_window)
|
||||||
{
|
{
|
||||||
|
Logger::error(L"No work area window");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,6 +508,7 @@ void WorkArea::CalculateZoneSet(OverlappingZonesAlgorithm overlappingAlgorithm)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Logger::error(L"CalculateZoneSet: GetMonitorInfo failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <common/logger/logger.h>
|
#include <common/logger/logger.h>
|
||||||
#include <common/display/dpi_aware.h>
|
#include <common/display/dpi_aware.h>
|
||||||
|
#include <common/utils/winapi_error.h>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -304,6 +305,11 @@ ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const Zo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!zoneIds.empty())
|
||||||
|
{
|
||||||
|
Logger::trace(L"Move window into zones {} - {}", zoneIds.front(), zoneIds.back());
|
||||||
|
}
|
||||||
|
|
||||||
// Always clear the info related to SelectManyZones if it's not being used
|
// Always clear the info related to SelectManyZones if it's not being used
|
||||||
if (!m_inExtendWindow)
|
if (!m_inExtendWindow)
|
||||||
{
|
{
|
||||||
@ -460,6 +466,10 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND workAreaWind
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::error(L"GetWindowRect failed, {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -546,6 +556,10 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND workAreaWindow, DW
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::error(L"GetWindowRect failed, {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -666,12 +680,14 @@ ZoneSet::CalculateZones(RECT workAreaRect, int zoneCount, int spacing) noexcept
|
|||||||
//invalid work area
|
//invalid work area
|
||||||
if (workArea.width() == 0 || workArea.height() == 0)
|
if (workArea.width() == 0 || workArea.height() == 0)
|
||||||
{
|
{
|
||||||
|
Logger::error(L"CalculateZones: invalid work area");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//invalid zoneCount, may cause division by zero
|
//invalid zoneCount, may cause division by zero
|
||||||
if (zoneCount <= 0 && m_config.LayoutType != FancyZonesDataTypes::ZoneSetLayoutType::Custom)
|
if (zoneCount <= 0 && m_config.LayoutType != FancyZonesDataTypes::ZoneSetLayoutType::Custom)
|
||||||
{
|
{
|
||||||
|
Logger::error(L"CalculateZones: invalid zone count");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <common/logger/call_tracer.h>
|
#include <common/logger/logger.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ ZonesOverlay::ZonesOverlay(HWND window)
|
|||||||
// Obtain the size of the drawing area.
|
// Obtain the size of the drawing area.
|
||||||
if (!GetClientRect(window, &m_clientRect))
|
if (!GetClientRect(window, &m_clientRect))
|
||||||
{
|
{
|
||||||
Logger::error("couldn't initialize ZonesOverlay: GetClientRect failed");
|
Logger::error(L"couldn't initialize ZonesOverlay: GetClientRect failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ ZonesOverlay::ZonesOverlay(HWND window)
|
|||||||
|
|
||||||
if (!SUCCEEDED(hr))
|
if (!SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
Logger::error("couldn't initialize ZonesOverlay: CreateHwndRenderTarget failed with {}", hr);
|
Logger::error(L"couldn't initialize ZonesOverlay: CreateHwndRenderTarget failed with {}", hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,6 @@ void ZonesOverlay::RenderLoop()
|
|||||||
|
|
||||||
void ZonesOverlay::Hide()
|
void ZonesOverlay::Hide()
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
bool shouldHideWindow = true;
|
bool shouldHideWindow = true;
|
||||||
{
|
{
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
@ -234,7 +233,6 @@ void ZonesOverlay::Hide()
|
|||||||
|
|
||||||
void ZonesOverlay::Show()
|
void ZonesOverlay::Show()
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
bool shouldShowWindow = true;
|
bool shouldShowWindow = true;
|
||||||
{
|
{
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
@ -262,7 +260,6 @@ void ZonesOverlay::Show()
|
|||||||
|
|
||||||
void ZonesOverlay::Flash()
|
void ZonesOverlay::Flash()
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
bool shouldShowWindow = true;
|
bool shouldShowWindow = true;
|
||||||
{
|
{
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
@ -285,7 +282,6 @@ void ZonesOverlay::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
|
|||||||
const Colors::ZoneColors& colors,
|
const Colors::ZoneColors& colors,
|
||||||
const bool showZoneText)
|
const bool showZoneText)
|
||||||
{
|
{
|
||||||
_TRACER_;
|
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
|
|
||||||
m_sceneRects = {};
|
m_sceneRects = {};
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <common/display/dpi_aware.h>
|
#include <common/display/dpi_aware.h>
|
||||||
|
#include <common/logger/logger.h>
|
||||||
#include <common/utils/process_path.h>
|
#include <common/utils/process_path.h>
|
||||||
#include <common/utils/window.h>
|
#include <common/utils/window.h>
|
||||||
#include <common/utils/excluded_apps.h>
|
#include <common/utils/excluded_apps.h>
|
||||||
@ -49,6 +50,8 @@ namespace FancyZonesUtils
|
|||||||
{
|
{
|
||||||
++displayDeviceIdxMap[device];
|
++displayDeviceIdxMap[device];
|
||||||
|
|
||||||
|
Logger::info(L"Get display device: {}", displayDevice.DeviceID);
|
||||||
|
|
||||||
// Only take active monitors (presented as being "on" by the respective GDI view) and monitors that don't
|
// Only take active monitors (presented as being "on" by the respective GDI view) and monitors that don't
|
||||||
// represent a pseudo device used to mirror application drawing.
|
// represent a pseudo device used to mirror application drawing.
|
||||||
if (WI_IsFlagSet(displayDevice.StateFlags, DISPLAY_DEVICE_ACTIVE) &&
|
if (WI_IsFlagSet(displayDevice.StateFlags, DISPLAY_DEVICE_ACTIVE) &&
|
||||||
@ -61,6 +64,7 @@ namespace FancyZonesUtils
|
|||||||
|
|
||||||
if (deviceId.empty())
|
if (deviceId.empty())
|
||||||
{
|
{
|
||||||
|
Logger::info(L"Didn't find display device, set default");
|
||||||
deviceId = GetSystemMetrics(SM_REMOTESESSION) ?
|
deviceId = GetSystemMetrics(SM_REMOTESESSION) ?
|
||||||
L"\\\\?\\DISPLAY#REMOTEDISPLAY#" :
|
L"\\\\?\\DISPLAY#REMOTEDISPLAY#" :
|
||||||
L"\\\\?\\DISPLAY#LOCALDISPLAY#";
|
L"\\\\?\\DISPLAY#LOCALDISPLAY#";
|
||||||
|
Loading…
Reference in New Issue
Block a user