[FancyZones] Window switch shortcut fix (#21426)

* rename Layout -> LayoutData

* simplify zone

* split ZoneSet: Layout

* refactoring

* split ZoneSet: LayoutWindows

* update trace

* split ZoneSet: remove ZoneSet

* fix initialization

* split unit tests

* remove unused

* warning

* nullptr  check

* use current rect

* update work area tests

* use current rect

* simplify

* more meaningful name

* dismiss

* safety checks

* resolve conflicts

* reassign windows after switching vd

* avoid double-processing for window on switching vd

* extend windows fix

* check if window is on current desktop before cycling

* separated extend

* not reinit layout windows
This commit is contained in:
Seraphima Zykova
2022-10-31 13:44:25 +02:00
committed by GitHub
parent 6431ccd370
commit ff290eef9d
43 changed files with 2194 additions and 2242 deletions

View File

@@ -1,54 +1,45 @@
#include "pch.h"
#include <Shellscalingapi.h>
#include <common/display/dpi_aware.h>
#include <common/display/monitors.h>
#include "Zone.h"
#include "Settings.h"
#include "util.h"
namespace
Zone::Zone(const RECT& zoneRect, const ZoneIndex zoneIndex) :
m_rect(zoneRect),
m_index(zoneIndex)
{
bool ValidateZoneRect(const RECT& rect)
{
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
return rect.left >= ZoneConstants::MAX_NEGATIVE_SPACING &&
rect.right >= ZoneConstants::MAX_NEGATIVE_SPACING &&
rect.top >= ZoneConstants::MAX_NEGATIVE_SPACING &&
rect.bottom >= ZoneConstants::MAX_NEGATIVE_SPACING &&
width >= 0 && height >= 0;
}
}
struct Zone : winrt::implements<Zone, IZone>
Zone::Zone(const Zone& other) :
m_rect(other.m_rect),
m_index(other.m_index)
{
public:
Zone(RECT zoneRect, const ZoneIndex zoneId) :
m_zoneRect(zoneRect),
m_id(zoneId)
{
}
IFACEMETHODIMP_(RECT) GetZoneRect() const noexcept { return m_zoneRect; }
IFACEMETHODIMP_(long) GetZoneArea() const noexcept { return max(m_zoneRect.bottom - m_zoneRect.top, 0) * max(m_zoneRect.right - m_zoneRect.left, 0); }
IFACEMETHODIMP_(ZoneIndex) Id() const noexcept { return m_id; }
private:
RECT m_zoneRect{};
const ZoneIndex m_id{};
};
winrt::com_ptr<IZone> MakeZone(const RECT& zoneRect, const ZoneIndex zoneId) noexcept
{
if (ValidateZoneRect(zoneRect) && zoneId >= 0)
{
return winrt::make_self<Zone>(zoneRect, zoneId);
}
else
{
return nullptr;
}
}
ZoneIndex Zone::Id() const noexcept
{
return m_index;
}
bool Zone::IsValid() const noexcept
{
return m_index >= 0 && isValid();
}
RECT Zone::GetZoneRect() const noexcept
{
return m_rect;
}
long Zone::GetZoneArea() const noexcept
{
return max(m_rect.bottom - m_rect.top, 0) * max(m_rect.right - m_rect.left, 0);
}
bool Zone::isValid() const noexcept
{
int width = m_rect.right - m_rect.left;
int height = m_rect.bottom - m_rect.top;
return m_rect.left >= ZoneConstants::MAX_NEGATIVE_SPACING &&
m_rect.right >= ZoneConstants::MAX_NEGATIVE_SPACING &&
m_rect.top >= ZoneConstants::MAX_NEGATIVE_SPACING &&
m_rect.bottom >= ZoneConstants::MAX_NEGATIVE_SPACING &&
width >= 0 && height >= 0;
}