mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
* rename * moved applied layouts tests * changed work area id comparison * changed save * changed apply * changed clone * sync applied layouts * save last used vd * replace parent work area ids * proper time for sync * sync layouts considering last used virtual desktop * use ids from work areas on editor opening * update applied layouts tests * sync app zone history vd * fix test * release build fix * app zone history comparison * pass last used vd to sync * clean up unused * dpi unaware values * update GUID_NULL * use registry values only * added more tests * fix failing scenario * added replace condition to zone history * sync time * log * spellcheck * fix pch in project * fixed cloning layout
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
#include "pch.h"
|
|
#include "WorkAreaConfiguration.h"
|
|
|
|
#include <FancyZonesLib/WorkArea.h>
|
|
|
|
WorkArea* const WorkAreaConfiguration::GetWorkArea(HMONITOR monitor) const
|
|
{
|
|
auto iter = m_workAreaMap.find(monitor);
|
|
if (iter != m_workAreaMap.end())
|
|
{
|
|
return iter->second.get();
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
WorkArea* const WorkAreaConfiguration::GetWorkAreaFromCursor() const
|
|
{
|
|
const auto allMonitorsWorkArea = GetWorkArea(nullptr);
|
|
if (allMonitorsWorkArea)
|
|
{
|
|
// First, check if there's a work area spanning all monitors (signalled by the NULL monitor handle)
|
|
return allMonitorsWorkArea;
|
|
}
|
|
else
|
|
{
|
|
// Otherwise, look for the work area based on cursor position
|
|
POINT cursorPoint;
|
|
if (!GetCursorPos(&cursorPoint))
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
return GetWorkArea(MonitorFromPoint(cursorPoint, MONITOR_DEFAULTTONULL));
|
|
}
|
|
}
|
|
|
|
WorkArea* const WorkAreaConfiguration::GetWorkAreaFromWindow(HWND window) const
|
|
{
|
|
const auto allMonitorsWorkArea = GetWorkArea(nullptr);
|
|
if (allMonitorsWorkArea)
|
|
{
|
|
// First, check if there's a work area spanning all monitors (signalled by the NULL monitor handle)
|
|
return allMonitorsWorkArea;
|
|
}
|
|
else
|
|
{
|
|
// Otherwise, look for the work area based on the window's position
|
|
HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONULL);
|
|
return GetWorkArea(monitor);
|
|
}
|
|
}
|
|
|
|
const std::unordered_map<HMONITOR, std::unique_ptr<WorkArea>>& WorkAreaConfiguration::GetAllWorkAreas() const noexcept
|
|
{
|
|
return m_workAreaMap;
|
|
}
|
|
|
|
void WorkAreaConfiguration::AddWorkArea(HMONITOR monitor, std::unique_ptr<WorkArea> workArea)
|
|
{
|
|
m_workAreaMap.insert({ monitor, std::move(workArea) });
|
|
}
|
|
|
|
void WorkAreaConfiguration::Clear() noexcept
|
|
{
|
|
m_workAreaMap.clear();
|
|
}
|