retrieve available screen space through activityid

pull/20/head
Michail Vourlakos 5 years ago
parent 9026f931fd
commit 3689cc406d

@ -531,14 +531,14 @@ QRegion Corona::availableScreenRegion(int id) const
}
QRegion Corona::availableScreenRegionWithCriteria(int id,
QString layoutName,
QString activityid,
QList<Types::Visibility> ignoreModes,
QList<Plasma::Types::Location> ignoreEdges,
bool ignoreExternalPanels,
bool desktopUse) const
{
const QScreen *screen = m_screenPool->screenForId(id);
bool inCurrentLayouts{layoutName.isEmpty()};
bool inCurrentActivity{activityid.isEmpty()};
if (!screen) {
return {};
@ -546,7 +546,15 @@ QRegion Corona::availableScreenRegionWithCriteria(int id,
QRegion available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry();
if (!centralLayout(layoutName) && !inCurrentLayouts) {
QList<Latte::View *> views;
if (inCurrentActivity) {
views = m_layoutsManager->synchronizer()->viewsBasedOnActivityId(m_activitiesConsumer->currentActivity());
} else {
views = m_layoutsManager->synchronizer()->viewsBasedOnActivityId(activityid);
}
if (views.isEmpty()) {
return available;
}
@ -560,14 +568,6 @@ QRegion Corona::availableScreenRegionWithCriteria(int id,
}
bool allEdges = ignoreEdges.isEmpty();
QList<Latte::View *> views;
if (inCurrentLayouts) {
views = m_layoutsManager->synchronizer()->currentViews();
} else {
CentralLayout *central = centralLayout(layoutName);
views = central->latteViews();
}
for (const auto *view : views) {
if (view && view->containment() && view->screen() == screen
@ -725,14 +725,14 @@ QRect Corona::availableScreenRect(int id) const
}
QRect Corona::availableScreenRectWithCriteria(int id,
QString layoutName,
QString activityid,
QList<Types::Visibility> ignoreModes,
QList<Plasma::Types::Location> ignoreEdges,
bool ignoreExternalPanels,
bool desktopUse) const
{
const QScreen *screen = m_screenPool->screenForId(id);
bool inCurrentLayouts{layoutName.isEmpty()};
bool inCurrentActivity{activityid.isEmpty()};
if (!screen) {
return {};
@ -740,7 +740,15 @@ QRect Corona::availableScreenRectWithCriteria(int id,
QRect available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry();
if (!centralLayout(layoutName) && !inCurrentLayouts) {
QList<Latte::View *> views;
if (inCurrentActivity) {
views = m_layoutsManager->synchronizer()->viewsBasedOnActivityId(m_activitiesConsumer->currentActivity());
} else {
views = m_layoutsManager->synchronizer()->viewsBasedOnActivityId(activityid);
}
if (views.isEmpty()) {
return available;
}
@ -754,14 +762,6 @@ QRect Corona::availableScreenRectWithCriteria(int id,
}
bool allEdges = ignoreEdges.isEmpty();
QList<Latte::View *> views;
if (inCurrentLayouts) {
views = m_layoutsManager->synchronizer()->currentViews();
} else {
CentralLayout *central = centralLayout(layoutName);
views = central->latteViews();
}
for (const auto *view : views) {
if (view && view->containment() && view->screen() == screen

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

@ -227,13 +227,12 @@ void Synchronizer::setMenuLayouts(QStringList layouts)
emit menuLayoutsChanged();
}
CentralLayout *Synchronizer::centralLayout(QString id) const
CentralLayout *Synchronizer::centralLayout(QString layoutname) const
{
for (int i = 0; i < m_centralLayouts.size(); ++i) {
CentralLayout *layout = m_centralLayouts.at(i);
if (layout->name() == id) {
if (layout->name() == layoutname) {
return layout;
}
}
@ -244,6 +243,7 @@ CentralLayout *Synchronizer::centralLayout(QString id) const
QList<CentralLayout *> Synchronizer::currentLayouts() const
{
QList<CentralLayout *> layouts;
if (m_manager->memoryUsage() == MemoryUsage::SingleLayout) {
layouts << m_centralLayouts.at(0);
} else {
@ -257,6 +257,23 @@ QList<CentralLayout *> Synchronizer::currentLayouts() const
return layouts;
}
QList<CentralLayout *> Synchronizer::centralLayoutsForActivity(const QString activityid) const
{
QList<CentralLayout *> layouts;
if (m_manager->memoryUsage() == MemoryUsage::SingleLayout) {
layouts << m_centralLayouts.at(0);
} else {
for (auto layout : m_centralLayouts) {
if (layout->isOnAllActivities() || layout->appliedActivities().contains(activityid)) {
layouts << layout;
}
}
}
return layouts;
}
QList<Latte::View *> Synchronizer::currentViews() const
{
QList<Latte::View *> views;
@ -286,9 +303,20 @@ QList<Latte::View *> Synchronizer::sortedCurrentViews() const
return Layout::GenericLayout::sortedLatteViews(views);
}
Layout::GenericLayout *Synchronizer::layout(QString id) const
QList<Latte::View *> Synchronizer::viewsBasedOnActivityId(const QString &id) const
{
QList<Latte::View *> views;
for(auto layout : centralLayoutsForActivity(id)) {
views << layout->latteViews();
}
return views;
}
Layout::GenericLayout *Synchronizer::layout(QString layoutname) const
{
Layout::GenericLayout *l = centralLayout(id);
Layout::GenericLayout *l = centralLayout(layoutname);
return l;
}

@ -105,9 +105,12 @@ public:
QList<Latte::View *> currentViews() const;
QList<Latte::View *> currentViewsWithPlasmaShortcuts() const;
QList<Latte::View *> sortedCurrentViews() const;
QList<Latte::View *> viewsBasedOnActivityId(const QString &id) const;
CentralLayout *centralLayout(QString id) const;
Layout::GenericLayout *layout(QString id) const;
CentralLayout *centralLayout(QString layoutname) const;
Layout::GenericLayout *layout(QString layoutname) const;
QList<CentralLayout *> centralLayoutsForActivity(const QString activityid) const;
KActivities::Controller *activitiesController() const;

@ -519,7 +519,8 @@ void Positioner::immediateSyncGeometry()
}
}
freeRegion = latteCorona->availableScreenRegionWithCriteria(fixedScreen, layoutName, ignoreModes, ignoreEdges);
QString activityid = m_view->layout() ? m_view->layout()->lastUsedActivity() : QString();
freeRegion = latteCorona->availableScreenRegionWithCriteria(fixedScreen, activityid, ignoreModes, ignoreEdges);
maximumRect = maximumNormalGeometry();
QRegion availableRegion = freeRegion.intersected(maximumRect);

@ -315,7 +315,9 @@ void PrimaryConfigView::instantUpdateAvailableScreenGeometry()
ignoreModes.removeAll(Latte::Types::SidebarAutoHide);
}
m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, m_latteView->layout()->name(), ignoreModes, {}, false, true);
QString activityid = m_latteView->layout()->lastUsedActivity();
m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, activityid, ignoreModes, {}, false, true);
emit availableScreenGeometryChanged();
}

@ -390,13 +390,17 @@ void View::disconnectSensitiveSignals()
void View::availableScreenRectChangedFromSlot(View *origin)
{
if (m_inDelete || origin == this)
if (m_inDelete || origin == this || !origin) {
return;
}
if (formFactor() == Plasma::Types::Vertical) {
if (formFactor() == Plasma::Types::Vertical
&& origin->layout()
&& m_layout
&& origin->layout()->lastUsedActivity() == m_layout->lastUsedActivity()) {
//! must be in same activity
m_positioner->syncGeometry();
}
}
void View::setupWaylandIntegration()

@ -793,12 +793,13 @@ void Windows::updateAvailableScreenGeometries()
{
for (const auto view : m_views.keys()) {
if (m_views[view]->enabled()) {
int currentScrId = view->positioner()->currentScreenId();
QRect tempAvailableScreenGeometry = m_wm->corona()->availableScreenRectWithCriteria(currentScrId, QString(), m_ignoreModes, {});
int currentscrid = view->positioner()->currentScreenId();
QString activityid = view->layout() ? view->layout()->lastUsedActivity() : QString();
QRect tempAvailableScreenGeometry = m_wm->corona()->availableScreenRectWithCriteria(currentscrid, activityid, m_ignoreModes, {});
if (tempAvailableScreenGeometry != m_views[view]->availableScreenGeometry()) {
m_views[view]->setAvailableScreenGeometry(tempAvailableScreenGeometry);
updateHints(view);
}
}

@ -536,7 +536,6 @@ FocusScope {
comboBoxMinimumPopUpWidth: actionsModel.count > 1 ? dialog.width / 2 : 150
property var centralLayoutsNames: []
property var sharedLayoutsNames: []
Component.onCompleted: {
comboBox.model = actionsModel;
@ -555,7 +554,7 @@ FocusScope {
if (index==0) {
latteView.copyView();
} else if (index>=1) {
var layouts = actionsComboBtn.sharedLayoutsNames.concat(actionsComboBtn.centralLayoutsNames);
var layouts = actionsComboBtn.centralLayoutsNames;
latteView.positioner.hideDockDuringMovingToLayout(layouts[index-1]);
}
@ -601,23 +600,6 @@ FocusScope {
updateCopyText();
var tempCentralLayouts = layoutsManager.centralLayoutsNames();
var tempSharedLayouts = layoutsManager.sharedLayoutsNames();
if (tempSharedLayouts.length > 0) {
var curIndex = tempSharedLayouts.indexOf(latteView.layout.name);
if (curIndex >=0) {
tempSharedLayouts.splice(curIndex,1);
}
sharedLayoutsNames = tempSharedLayouts;
var icon = "document-share";
for(var i=0; i<sharedLayoutsNames.length; ++i) {
var layout = {actionId: 'move:', enabled: true, name: i18n("Move to: %0").arg(sharedLayoutsNames[i]), icon: icon};
actionsModel.append(layout);
}
}
if (tempCentralLayouts.length > 0) {
var curIndex = tempCentralLayouts.indexOf(latteView.layout.name);

Loading…
Cancel
Save