fixes for corona available areas calcs

pull/20/head
Michail Vourlakos
parent 951668fff9
commit 9026f931fd

@ -507,14 +507,8 @@ CentralLayout *Corona::centralLayout(QString name) const
{ {
CentralLayout *result{nullptr}; CentralLayout *result{nullptr};
if (name.isEmpty()) { if (!name.isEmpty()) {
result = m_layoutsManager->currentLayout(); result = m_layoutsManager->synchronizer()->centralLayout(name);
} else {
CentralLayout *tempCentral = m_layoutsManager->synchronizer()->centralLayout(name);
if (tempCentral) {
result = tempCentral;
}
} }
return result; return result;
@ -524,14 +518,8 @@ Layout::GenericLayout *Corona::layout(QString name) const
{ {
Layout::GenericLayout *result{nullptr}; Layout::GenericLayout *result{nullptr};
if (name.isEmpty()) { if (!name.isEmpty()) {
result = m_layoutsManager->currentLayout();
} else {
result = m_layoutsManager->synchronizer()->layout(name); result = m_layoutsManager->synchronizer()->layout(name);
if (!result) {
result = m_layoutsManager->currentLayout();
}
} }
return result; return result;
@ -543,14 +531,14 @@ QRegion Corona::availableScreenRegion(int id) const
} }
QRegion Corona::availableScreenRegionWithCriteria(int id, QRegion Corona::availableScreenRegionWithCriteria(int id,
QString forLayout, QString layoutName,
QList<Types::Visibility> ignoreModes, QList<Types::Visibility> ignoreModes,
QList<Plasma::Types::Location> ignoreEdges, QList<Plasma::Types::Location> ignoreEdges,
bool ignoreExternalPanels, bool ignoreExternalPanels,
bool desktopUse) const bool desktopUse) const
{ {
const QScreen *screen = m_screenPool->screenForId(id); const QScreen *screen = m_screenPool->screenForId(id);
CentralLayout *layout = centralLayout(forLayout); bool inCurrentLayouts{layoutName.isEmpty()};
if (!screen) { if (!screen) {
return {}; return {};
@ -558,7 +546,7 @@ QRegion Corona::availableScreenRegionWithCriteria(int id,
QRegion available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry(); QRegion available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry();
if (!layout) { if (!centralLayout(layoutName) && !inCurrentLayouts) {
return available; return available;
} }
@ -572,7 +560,14 @@ QRegion Corona::availableScreenRegionWithCriteria(int id,
} }
bool allEdges = ignoreEdges.isEmpty(); bool allEdges = ignoreEdges.isEmpty();
QList<Latte::View *> views = layout->latteViews(); QList<Latte::View *> views;
if (inCurrentLayouts) {
views = m_layoutsManager->synchronizer()->currentViews();
} else {
CentralLayout *central = centralLayout(layoutName);
views = central->latteViews();
}
for (const auto *view : views) { for (const auto *view : views) {
if (view && view->containment() && view->screen() == screen if (view && view->containment() && view->screen() == screen
@ -730,14 +725,14 @@ QRect Corona::availableScreenRect(int id) const
} }
QRect Corona::availableScreenRectWithCriteria(int id, QRect Corona::availableScreenRectWithCriteria(int id,
QString forLayout, QString layoutName,
QList<Types::Visibility> ignoreModes, QList<Types::Visibility> ignoreModes,
QList<Plasma::Types::Location> ignoreEdges, QList<Plasma::Types::Location> ignoreEdges,
bool ignoreExternalPanels, bool ignoreExternalPanels,
bool desktopUse) const bool desktopUse) const
{ {
const QScreen *screen = m_screenPool->screenForId(id); const QScreen *screen = m_screenPool->screenForId(id);
CentralLayout *layout = centralLayout(forLayout); bool inCurrentLayouts{layoutName.isEmpty()};
if (!screen) { if (!screen) {
return {}; return {};
@ -745,7 +740,7 @@ QRect Corona::availableScreenRectWithCriteria(int id,
QRect available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry(); QRect available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry();
if (!layout) { if (!centralLayout(layoutName) && !inCurrentLayouts) {
return available; return available;
} }
@ -759,7 +754,14 @@ QRect Corona::availableScreenRectWithCriteria(int id,
} }
bool allEdges = ignoreEdges.isEmpty(); bool allEdges = ignoreEdges.isEmpty();
QList<Latte::View *> views = layout->latteViews(); QList<Latte::View *> views;
if (inCurrentLayouts) {
views = m_layoutsManager->synchronizer()->currentViews();
} else {
CentralLayout *central = centralLayout(layoutName);
views = central->latteViews();
}
for (const auto *view : views) { for (const auto *view : views) {
if (view && view->containment() && view->screen() == screen if (view && view->containment() && view->screen() == screen
@ -1194,11 +1196,10 @@ QStringList Corona::contextMenuData()
{ {
QStringList data; QStringList data;
Types::ViewType viewType{Types::DockView}; Types::ViewType viewType{Types::DockView};
auto view = m_layoutsManager->synchronizer()->viewForContainment(m_contextMenuViewId);
Latte::CentralLayout *currentLayout = m_layoutsManager->currentLayout(); if (view) {
viewType = view->type();
if (currentLayout) {
viewType = currentLayout->latteViewType(m_contextMenuViewId);
} }
data << QString::number((int)m_layoutsManager->memoryUsage()); data << QString::number((int)m_layoutsManager->memoryUsage());
@ -1234,10 +1235,16 @@ void Corona::setBroadcastedBackgroundsEnabled(QString activity, QString screenNa
void Corona::toggleHiddenState(QString layoutName, QString screenName, int screenEdge) void Corona::toggleHiddenState(QString layoutName, QString screenName, int screenEdge)
{ {
Layout::GenericLayout *gLayout = layout(layoutName); if (layoutName.isEmpty()) {
for(auto layout : m_layoutsManager->currentLayouts()) {
layout->toggleHiddenState(screenName, (Plasma::Types::Location)screenEdge);
}
} else {
Layout::GenericLayout *gLayout = layout(layoutName);
if (gLayout) { if (gLayout) {
gLayout->toggleHiddenState(screenName, (Plasma::Types::Location)screenEdge); gLayout->toggleHiddenState(screenName, (Plasma::Types::Location)screenEdge);
}
} }
} }

@ -117,14 +117,14 @@ public:
//! arguments mean that all choices are accepted in calculations. ignoreExternalPanels means that //! arguments mean that all choices are accepted in calculations. ignoreExternalPanels means that
//! external panels should be not considered in the calculations //! external panels should be not considered in the calculations
QRect availableScreenRectWithCriteria(int id, QRect availableScreenRectWithCriteria(int id,
QString forLayout = QString(), QString layoutName = QString(),
QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(), QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(),
QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(), QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(),
bool ignoreExternalPanels = true, bool ignoreExternalPanels = true,
bool desktopUse = false) const; bool desktopUse = false) const;
QRegion availableScreenRegionWithCriteria(int id, QRegion availableScreenRegionWithCriteria(int id,
QString forLayout = QString(), QString layoutName = QString(),
QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(), QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(),
QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(), QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(),
bool ignoreExternalPanels = true, bool ignoreExternalPanels = true,

@ -370,6 +370,17 @@ void GenericLayout::setLastConfigViewFor(Latte::View *view)
emit lastConfigViewForChanged(view); emit lastConfigViewForChanged(view);
} }
Latte::View *GenericLayout::viewForContainment(uint id) const
{
for(auto view : m_latteViews) {
if (view && view->containment()->id() == id) {
return view;
}
}
return nullptr;
}
Latte::View *GenericLayout::viewForContainment(Plasma::Containment *containment) const Latte::View *GenericLayout::viewForContainment(Plasma::Containment *containment) const
{ {
if (m_containments.contains(containment) && m_latteViews.contains(containment)) { if (m_containments.contains(containment) && m_latteViews.contains(containment)) {
@ -384,9 +395,14 @@ QList<Latte::View *> GenericLayout::latteViews()
return m_latteViews.values(); return m_latteViews.values();
} }
QList<Latte::View *> GenericLayout::sortedLatteViews()
{
return sortedLatteViews(latteViews());
}
QList<Latte::View *> GenericLayout::sortedLatteViews(QList<Latte::View *> views) QList<Latte::View *> GenericLayout::sortedLatteViews(QList<Latte::View *> views)
{ {
QList<Latte::View *> sortedViews = views.isEmpty() ? latteViews() : views; QList<Latte::View *> sortedViews = views;
qDebug() << " -------- "; qDebug() << " -------- ";

@ -98,8 +98,14 @@ public:
const QList<Plasma::Containment *> *containments() const; const QList<Plasma::Containment *> *containments() const;
Latte::View *highestPriorityView(); Latte::View *highestPriorityView();
Latte::View *viewForContainment(uint id) const;
Latte::View *viewForContainment(Plasma::Containment *containment) const; Latte::View *viewForContainment(Plasma::Containment *containment) const;
virtual QList<Latte::View *> sortedLatteViews(QList<Latte::View *> views = QList<Latte::View *>());
static bool viewAtLowerScreenPriority(Latte::View *test, Latte::View *base);
static bool viewAtLowerEdgePriority(Latte::View *test, Latte::View *base);
static QList<Latte::View *> sortedLatteViews(QList<Latte::View *> views);
QList<Latte::View *> sortedLatteViews();
virtual QList<Latte::View *> viewsWithPlasmaShortcuts(); virtual QList<Latte::View *> viewsWithPlasmaShortcuts();
virtual QList<Latte::View *> latteViews(); virtual QList<Latte::View *> latteViews();
ViewsMap validViewsMap(ViewsMap *occupiedMap = nullptr); ViewsMap validViewsMap(ViewsMap *occupiedMap = nullptr);
@ -184,9 +190,6 @@ private:
bool explicitDockOccupyEdge(int screen, Plasma::Types::Location location) const; bool explicitDockOccupyEdge(int screen, Plasma::Types::Location location) const;
bool primaryDockOccupyEdge(Plasma::Types::Location location) const; bool primaryDockOccupyEdge(Plasma::Types::Location location) const;
bool viewAtLowerScreenPriority(Latte::View *test, Latte::View *base);
bool viewAtLowerEdgePriority(Latte::View *test, Latte::View *base);
bool viewDataAtLowerEdgePriority(const ViewData &test, const ViewData &base) const; bool viewDataAtLowerEdgePriority(const ViewData &test, const ViewData &base) const;
bool viewDataAtLowerScreenPriority(const ViewData &test, const ViewData &base) const; bool viewDataAtLowerScreenPriority(const ViewData &test, const ViewData &base) const;
bool viewDataAtLowerStatePriority(const ViewData &test, const ViewData &base) const; bool viewDataAtLowerStatePriority(const ViewData &test, const ViewData &base) const;

@ -178,9 +178,9 @@ QStringList Manager::centralLayoutsNames()
return m_synchronizer->centralLayoutsNames(); return m_synchronizer->centralLayoutsNames();
} }
CentralLayout *Manager::currentLayout() const QList<CentralLayout *> Manager::currentLayouts() const
{ {
return m_synchronizer->currentLayout(); return m_synchronizer->currentLayouts();
} }
bool Manager::switchToLayout(QString layoutName, int previousMemoryUsage) bool Manager::switchToLayout(QString layoutName, int previousMemoryUsage)

@ -98,7 +98,7 @@ public:
void setMemoryUsage(MemoryUsage::LayoutsMemory memoryUsage); void setMemoryUsage(MemoryUsage::LayoutsMemory memoryUsage);
//! returns the current and central layout based on activities and user preferences //! returns the current and central layout based on activities and user preferences
CentralLayout *currentLayout() const; QList<CentralLayout *>currentLayouts() const;
LaunchersSignals *launchersSignals() const; LaunchersSignals *launchersSignals() const;
Synchronizer *synchronizer() const; Synchronizer *synchronizer() const;

@ -241,25 +241,49 @@ CentralLayout *Synchronizer::centralLayout(QString id) const
return nullptr; return nullptr;
} }
CentralLayout *Synchronizer::currentLayout() const QList<CentralLayout *> Synchronizer::currentLayouts() const
{ {
QList<CentralLayout *> layouts;
if (m_manager->memoryUsage() == MemoryUsage::SingleLayout) { if (m_manager->memoryUsage() == MemoryUsage::SingleLayout) {
return m_centralLayouts.at(0); layouts << m_centralLayouts.at(0);
} else { } else {
for (auto layout : m_centralLayouts) { for (auto layout : m_centralLayouts) {
if (layout->activities().contains(m_manager->corona()->activitiesConsumer()->currentActivity())) { if (layout->isOnAllActivities() || layout->appliedActivities().contains(m_manager->corona()->activitiesConsumer()->currentActivity())) {
return layout; layouts << layout;
} }
} }
}
for (auto layout : m_centralLayouts) { return layouts;
if (layout->activities().isEmpty()) { }
return layout;
} QList<Latte::View *> Synchronizer::currentViews() const
} {
QList<Latte::View *> views;
for(auto layout : currentLayouts()) {
views << layout->latteViews();
} }
return nullptr; return views;
}
QList<Latte::View *> Synchronizer::currentViewsWithPlasmaShortcuts() const
{
QList<Latte::View *> views;
for(auto layout : currentLayouts()) {
views << layout->viewsWithPlasmaShortcuts();
}
return views;
}
QList<Latte::View *> Synchronizer::sortedCurrentViews() const
{
QList<Latte::View *> views = currentViews();
return Layout::GenericLayout::sortedLatteViews(views);
} }
Layout::GenericLayout *Synchronizer::layout(QString id) const Layout::GenericLayout *Synchronizer::layout(QString id) const
@ -269,6 +293,19 @@ Layout::GenericLayout *Synchronizer::layout(QString id) const
return l; return l;
} }
Latte::View *Synchronizer::viewForContainment(uint id)
{
for (auto layout : m_centralLayouts) {
Latte::View *view = layout->viewForContainment(id);
if (view) {
return view;
}
}
return nullptr;
}
Latte::View *Synchronizer::viewForContainment(Plasma::Containment *containment) Latte::View *Synchronizer::viewForContainment(Plasma::Containment *containment)
{ {
for (auto layout : m_centralLayouts) { for (auto layout : m_centralLayouts) {

@ -99,8 +99,13 @@ public:
QStringList freeActivities(); //! These are activities that haven't been assigned to specific layout QStringList freeActivities(); //! These are activities that haven't been assigned to specific layout
Latte::View *viewForContainment(Plasma::Containment *containment); Latte::View *viewForContainment(Plasma::Containment *containment);
Latte::View *viewForContainment(uint id);
QList<CentralLayout *> currentLayouts() const;
QList<Latte::View *> currentViews() const;
QList<Latte::View *> currentViewsWithPlasmaShortcuts() const;
QList<Latte::View *> sortedCurrentViews() const;
CentralLayout *currentLayout() const;
CentralLayout *centralLayout(QString id) const; CentralLayout *centralLayout(QString id) const;
Layout::GenericLayout *layout(QString id) const; Layout::GenericLayout *layout(QString id) const;

@ -244,12 +244,7 @@ void GlobalShortcuts::activateLauncherMenu()
return; return;
} }
QList<Latte::View *> sortedViews; QList<Latte::View *> sortedViews = m_corona->layoutsManager()->synchronizer()->sortedCurrentViews();
CentralLayout *currentLayout = m_corona->layoutsManager()->currentLayout();
if (currentLayout) {
sortedViews = currentLayout->sortedLatteViews();
}
Latte::View *highestPriorityView = highestApplicationLauncherView(sortedViews); Latte::View *highestPriorityView = highestApplicationLauncherView(sortedViews);
@ -356,12 +351,7 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier)
{ {
m_lastInvokedAction = dynamic_cast<QAction *>(sender()); m_lastInvokedAction = dynamic_cast<QAction *>(sender());
QList<Latte::View *> sortedViews; QList<Latte::View *> sortedViews = m_corona->layoutsManager()->synchronizer()->sortedCurrentViews();
CentralLayout *currentLayout = m_corona->layoutsManager()->currentLayout();
if (currentLayout) {
sortedViews = currentLayout->sortedLatteViews();
}
Latte::View *highest{nullptr}; Latte::View *highest{nullptr};
@ -386,12 +376,7 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier)
//! update badge for specific view item //! update badge for specific view item
void GlobalShortcuts::updateViewItemBadge(QString identifier, QString value) void GlobalShortcuts::updateViewItemBadge(QString identifier, QString value)
{ {
CentralLayout *currentLayout = m_corona->layoutsManager()->currentLayout(); QList<Latte::View *> views = m_corona->layoutsManager()->synchronizer()->currentViews();
QList<Latte::View *> views;
if (currentLayout) {
views = currentLayout->latteViews();
}
// update badges in all Latte Tasks plasmoids // update badges in all Latte Tasks plasmoids
for (const auto &view : views) { for (const auto &view : views) {
@ -407,12 +392,7 @@ void GlobalShortcuts::showViews()
m_lastInvokedAction = m_singleMetaAction; m_lastInvokedAction = m_singleMetaAction;
} }
QList<Latte::View *> sortedViews; QList<Latte::View *> sortedViews = m_corona->layoutsManager()->synchronizer()->sortedCurrentViews();
CentralLayout *currentLayout = m_corona->layoutsManager()->currentLayout();
if (currentLayout) {
sortedViews = currentLayout->sortedLatteViews();
}
Latte::View *viewWithTasks{nullptr}; Latte::View *viewWithTasks{nullptr};
Latte::View *viewWithMeta{nullptr}; Latte::View *viewWithMeta{nullptr};
@ -469,11 +449,7 @@ void GlobalShortcuts::showViews()
} }
//! show all the rest views that contain plasma shortcuts //! show all the rest views that contain plasma shortcuts
QList<Latte::View *> viewsWithShortcuts; QList<Latte::View *> viewsWithShortcuts = m_corona->layoutsManager()->synchronizer()->currentViewsWithPlasmaShortcuts();
if (currentLayout) {
viewsWithShortcuts = currentLayout->viewsWithPlasmaShortcuts();
}
if (viewsWithShortcuts.count() > 0) { if (viewsWithShortcuts.count() > 0) {
viewFound = true; viewFound = true;
@ -514,12 +490,7 @@ bool GlobalShortcuts::viewsToHideAreValid()
void GlobalShortcuts::showSettings() void GlobalShortcuts::showSettings()
{ {
QList<Latte::View *> sortedViews; QList<Latte::View *> sortedViews = m_corona->layoutsManager()->synchronizer()->sortedCurrentViews();
CentralLayout *currentLayout = m_corona->layoutsManager()->currentLayout();
if (currentLayout) {
sortedViews = currentLayout->sortedLatteViews();
}
//! find which is the next view to show its settings //! find which is the next view to show its settings
if (sortedViews.count() > 0) { if (sortedViews.count() > 0) {
@ -527,8 +498,14 @@ void GlobalShortcuts::showSettings()
//! find last view that showed its config view //! find last view that showed its config view
for (int i = 0; i < sortedViews.size(); ++i) { for (int i = 0; i < sortedViews.size(); ++i) {
if (sortedViews[i] == currentLayout->lastConfigViewFor()) { for (auto currentLayout : m_corona->layoutsManager()->currentLayouts()) {
openSettings = i; if (sortedViews[i] == currentLayout->lastConfigViewFor()) {
openSettings = i;
break;
}
}
if (openSettings >= 0) {
break; break;
} }
} }

Loading…
Cancel
Save