Unify the code that turns StrutAreas into QRegion
This commit is contained in:
parent
69b7b523f8
commit
8979f83e38
1 changed files with 13 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue