Unify the code that turns StrutAreas into QRegion

This commit is contained in:
Aleix Pol 2021-05-12 03:42:05 +02:00 committed by Aleix Pol Gonzalez
parent 69b7b523f8
commit 8979f83e38

View file

@ -2326,17 +2326,25 @@ QRect Workspace::clientArea(clientAreaOption opt, const AbstractClient* c) const
return clientArea(opt, c->frameGeometry().center(), c->desktop());
}
QRegion Workspace::restrictedMoveArea(int desktop, StrutAreas areas) const
static QRegion strutsToRegion(int desktop, StrutAreas areas, const QVector<StrutRects> &struts)
{
if (desktop == NETWinInfo::OnAllDesktops || desktop == 0)
desktop = VirtualDesktopManager::self()->current();
QRegion region;
foreach (const StrutRect & rect, restrictedmovearea[desktop])
if (areas & rect.area())
region += rect;
const StrutRects &rects = struts[desktop];
for (const StrutRect &rect : rects) {
if (areas & rect.area()) {
region += rect;
}
}
return region;
}
QRegion Workspace::restrictedMoveArea(int desktop, StrutAreas areas) const
{
return strutsToRegion(desktop, areas, restrictedmovearea);
}
bool Workspace::inUpdateClientArea() const
{
return !oldrestrictedmovearea.isEmpty();
@ -2344,13 +2352,7 @@ bool Workspace::inUpdateClientArea() const
QRegion Workspace::previousRestrictedMoveArea(int desktop, StrutAreas areas) const
{
if (desktop == NETWinInfo::OnAllDesktops || desktop == 0)
desktop = VirtualDesktopManager::self()->current();
QRegion region;
foreach (const StrutRect & rect, oldrestrictedmovearea.at(desktop))
if (areas & rect.area())
region += rect;
return region;
return strutsToRegion(desktop, areas, oldrestrictedmovearea);
}
QVector< QRect > Workspace::previousScreenSizes() const