mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
improve availableScreenR*WithCriteria functions
BUG:416791 FIXED-IN:0.9.8.1
This commit is contained in:
parent
dc35f8faf2
commit
a62c52eb52
@ -476,63 +476,65 @@ QRect Corona::screenGeometry(int id) const
|
||||
return screen->geometry();
|
||||
}
|
||||
|
||||
CentralLayout *Corona::centralLayout(QString name) const
|
||||
{
|
||||
CentralLayout *result{nullptr};
|
||||
|
||||
if (name.isEmpty()) {
|
||||
result = m_layoutsManager->currentLayout();
|
||||
} else {
|
||||
CentralLayout *tempCentral = m_layoutsManager->synchronizer()->centralLayout(name);
|
||||
|
||||
if (!tempCentral) {
|
||||
//! Identify best active layout to be used for metrics calculations.
|
||||
//! Active layouts are always take into account their shared layouts for their metrics
|
||||
SharedLayout *sharedLayout = m_layoutsManager->synchronizer()->sharedLayout(name);
|
||||
|
||||
if (sharedLayout) {
|
||||
tempCentral = sharedLayout->currentCentralLayout();
|
||||
}
|
||||
}
|
||||
|
||||
if (tempCentral) {
|
||||
result = tempCentral;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QRegion Corona::availableScreenRegion(int id) const
|
||||
{
|
||||
return availableScreenRegionWithCriteria(id);
|
||||
}
|
||||
|
||||
QRegion Corona::availableScreenRegionWithCriteria(int id, QString forLayout, bool includeExternalPanels) const
|
||||
QRegion Corona::availableScreenRegionWithCriteria(int id,
|
||||
QString forLayout,
|
||||
QList<Types::Visibility> modes,
|
||||
QList<Plasma::Types::Location> edges,
|
||||
bool includeExternalPanels) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
const QScreen *screen{qGuiApp->primaryScreen()};
|
||||
|
||||
QString screenName;
|
||||
|
||||
if (m_screenPool->hasId(id)) {
|
||||
screenName = m_screenPool->connector(id);
|
||||
}
|
||||
|
||||
for(auto scr : screens) {
|
||||
if (scr->name() == screenName) {
|
||||
screen = scr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const QScreen *screen = m_screenPool->screenForId(id);
|
||||
CentralLayout *layout = centralLayout(forLayout);
|
||||
|
||||
if (!screen) {
|
||||
return QRegion();
|
||||
}
|
||||
|
||||
QList<Latte::View *> views;
|
||||
|
||||
if (forLayout.isEmpty()) {
|
||||
Latte::CentralLayout *currentLayout = m_layoutsManager->currentLayout();
|
||||
views = currentLayout->latteViews();
|
||||
} else {
|
||||
Layout::GenericLayout *generic = m_layoutsManager->synchronizer()->centralLayout(forLayout);
|
||||
|
||||
if (!generic) {
|
||||
//! Identify best active layout to be used for metrics calculations.
|
||||
//! Active layouts are always take into account their shared layouts for their metrics
|
||||
SharedLayout *sharedLayout = m_layoutsManager->synchronizer()->sharedLayout(forLayout);
|
||||
|
||||
if (sharedLayout) {
|
||||
generic = sharedLayout->currentCentralLayout();
|
||||
}
|
||||
}
|
||||
|
||||
if (!generic) {
|
||||
generic = m_layoutsManager->currentLayout();
|
||||
}
|
||||
|
||||
views = generic->latteViews();
|
||||
return {};
|
||||
}
|
||||
|
||||
QRegion available = includeExternalPanels ? screen->availableGeometry() : screen->geometry();
|
||||
|
||||
if (!layout) {
|
||||
return available;
|
||||
}
|
||||
|
||||
bool allModes = modes.isEmpty();
|
||||
bool allEdges = edges.isEmpty();
|
||||
QList<Latte::View *> views = layout->latteViews();
|
||||
|
||||
for (const auto *view : views) {
|
||||
if (view && view->containment() && view->screen() == screen
|
||||
&& view->visibility() && (view->visibility()->mode() != Latte::Types::AutoHide)) {
|
||||
&& ((allEdges || edges.contains(view->location()))
|
||||
&& (allModes || (view->visibility() && modes.contains(view->visibility()->mode()))))) {
|
||||
int realThickness = view->normalThickness();
|
||||
|
||||
// Usually availableScreenRect is used by the desktop,
|
||||
@ -685,39 +687,29 @@ QRect Corona::availableScreenRect(int id) const
|
||||
return availableScreenRectWithCriteria(id);
|
||||
}
|
||||
|
||||
QRect Corona::availableScreenRectWithCriteria(int id, QList<Types::Visibility> modes, QList<Plasma::Types::Location> edges, bool includeExternalPanels) const
|
||||
QRect Corona::availableScreenRectWithCriteria(int id,
|
||||
QString forLayout,
|
||||
QList<Types::Visibility> modes,
|
||||
QList<Plasma::Types::Location> edges,
|
||||
bool includeExternalPanels) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
const QScreen *screen{qGuiApp->primaryScreen()};
|
||||
|
||||
if (m_screenPool->hasId(id)) {
|
||||
QString scrName = m_screenPool->connector(id);
|
||||
|
||||
for(const auto scr : screens) {
|
||||
if (scr->name() == scrName) {
|
||||
screen = scr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const QScreen *screen = m_screenPool->screenForId(id);
|
||||
CentralLayout *layout = centralLayout(forLayout);
|
||||
|
||||
if (!screen) {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool allModes = modes.isEmpty();
|
||||
QRect available = includeExternalPanels ? screen->availableGeometry() : screen->geometry();
|
||||
|
||||
bool allEdges = edges.isEmpty();
|
||||
|
||||
auto available = includeExternalPanels ? screen->availableGeometry() : screen->geometry();
|
||||
|
||||
Latte::CentralLayout *currentLayout = m_layoutsManager->currentLayout();
|
||||
QList<Latte::View *> views;
|
||||
|
||||
if (currentLayout) {
|
||||
views = currentLayout->latteViews();
|
||||
if (!layout) {
|
||||
return available;
|
||||
}
|
||||
|
||||
bool allModes = modes.isEmpty();
|
||||
bool allEdges = edges.isEmpty();
|
||||
QList<Latte::View *> views = layout->latteViews();
|
||||
|
||||
for (const auto *view : views) {
|
||||
if (view && view->containment() && view->screen() == screen
|
||||
&& ((allEdges || edges.contains(view->location()))
|
||||
|
@ -62,6 +62,7 @@ class PlasmaShell;
|
||||
}
|
||||
|
||||
namespace Latte {
|
||||
class CentralLayout;
|
||||
class ScreenPool;
|
||||
class GlobalShortcuts;
|
||||
class UniversalSettings;
|
||||
@ -110,12 +111,15 @@ public:
|
||||
//! arguments mean that all choices are accepted in calculations. includeExternalPanels means that
|
||||
//! external panels should be considered in the calculations
|
||||
QRect availableScreenRectWithCriteria(int id,
|
||||
QString forLayout = QString(),
|
||||
QList<Types::Visibility> modes = QList<Types::Visibility>(),
|
||||
QList<Plasma::Types::Location> edges = QList<Plasma::Types::Location>(),
|
||||
bool includeExternalPanels = false) const;
|
||||
|
||||
QRegion availableScreenRegionWithCriteria(int id,
|
||||
QString forLayout = QString(),
|
||||
QList<Types::Visibility> modes = QList<Types::Visibility>(),
|
||||
QList<Plasma::Types::Location> edges = QList<Plasma::Types::Location>(),
|
||||
bool includeExternalPanels = false) const;
|
||||
|
||||
int screenForContainment(const Plasma::Containment *containment) const override;
|
||||
@ -190,6 +194,10 @@ private:
|
||||
QStringList containmentsIds();
|
||||
QStringList appletsIds();
|
||||
|
||||
CentralLayout *centralLayout(QString name) const;
|
||||
|
||||
private:
|
||||
|
||||
bool m_activitiesStarting{true};
|
||||
bool m_defaultLayoutOnStartup{false}; //! this is used to enforce loading the default layout on startup
|
||||
bool m_quitTimedEnded{false}; //! this is used on destructor in order to delay it and slide-out the views
|
||||
|
@ -364,7 +364,17 @@ void Positioner::syncGeometry()
|
||||
auto latteCorona = qobject_cast<Latte::Corona *>(m_view->corona());
|
||||
int fixedScreen = m_view->onPrimary() ? latteCorona->screenPool()->primaryScreenId() : m_view->containment()->screen();
|
||||
|
||||
freeRegion = latteCorona->availableScreenRegionWithCriteria(fixedScreen, layoutName);
|
||||
QList<Types::Visibility> modes({Latte::Types::AlwaysVisible,
|
||||
Latte::Types::DodgeActive,
|
||||
Latte::Types::DodgeMaximized,
|
||||
Latte::Types::DodgeAllWindows,
|
||||
Latte::Types::WindowsGoBelow});
|
||||
|
||||
QList<Plasma::Types::Location> edges({Plasma::Types::TopEdge,
|
||||
Plasma::Types::BottomEdge});
|
||||
|
||||
freeRegion = latteCorona->availableScreenRegionWithCriteria(fixedScreen, layoutName, modes, edges);
|
||||
|
||||
maximumRect = maximumNormalGeometry();
|
||||
QRegion availableRegion = freeRegion.intersected(maximumRect);
|
||||
availableScreenRect = freeRegion.intersected(maximumRect).boundingRect();
|
||||
|
@ -230,7 +230,7 @@ void PrimaryConfigView::deleteSecondaryWindow()
|
||||
void PrimaryConfigView::updateAvailableScreenGeometry(View *origin)
|
||||
{
|
||||
int currentScrId = m_latteView->positioner()->currentScreenId();
|
||||
m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, {}, {}, true);
|
||||
m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, QString(), {}, {}, true);
|
||||
|
||||
emit availableScreenGeometryChanged();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user