mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-09 17:18:11 +03:00
update kwin disabled borders infrastructure
This commit is contained in:
parent
c7d163fdb6
commit
0ee31eead6
@ -61,24 +61,8 @@ void CentralLayout::init()
|
||||
void CentralLayout::initToCorona(Latte::Corona *corona)
|
||||
{
|
||||
if (GenericLayout::initToCorona(corona)) {
|
||||
connect(m_corona->universalSettings(), &UniversalSettings::canDisableBordersChanged, this, [&]() {
|
||||
if (m_corona->universalSettings()->canDisableBorders()) {
|
||||
kwin_setDisabledMaximizedBorders(disableBordersForMaximizedWindows());
|
||||
} else {
|
||||
kwin_setDisabledMaximizedBorders(false);
|
||||
}
|
||||
});
|
||||
|
||||
if (m_corona->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout && m_corona->universalSettings()->canDisableBorders()) {
|
||||
kwin_setDisabledMaximizedBorders(disableBordersForMaximizedWindows());
|
||||
} else if (m_corona->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts) {
|
||||
connect(m_corona->layoutsManager(), &Layouts::Manager::currentLayoutNameChanged, this, [&]() {
|
||||
if (m_corona->universalSettings()->canDisableBorders()
|
||||
&& m_corona->layoutsManager()->currentLayoutName() == name()) {
|
||||
kwin_setDisabledMaximizedBorders(disableBordersForMaximizedWindows());
|
||||
}
|
||||
});
|
||||
}
|
||||
connect(this, &CentralLayout::disableBordersForMaximizedWindowsChanged,
|
||||
m_corona->layoutsManager()->synchronizer(), &Layouts::Synchronizer::updateKWinDisabledBorders);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,29 +78,10 @@ void CentralLayout::setDisableBordersForMaximizedWindows(bool disable)
|
||||
}
|
||||
|
||||
m_disableBordersForMaximizedWindows = disable;
|
||||
kwin_setDisabledMaximizedBorders(disable);
|
||||
|
||||
emit disableBordersForMaximizedWindowsChanged();
|
||||
}
|
||||
|
||||
bool CentralLayout::kwin_disabledMaximizedBorders() const
|
||||
{
|
||||
if (!m_corona) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_corona->universalSettings()->kwin_borderlessMaximizedWindowsEnabled();
|
||||
}
|
||||
|
||||
void CentralLayout::kwin_setDisabledMaximizedBorders(bool disable)
|
||||
{
|
||||
if (!m_corona) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_corona->universalSettings()->kwin_setDisabledMaximizedBorders(disable);
|
||||
}
|
||||
|
||||
bool CentralLayout::showInMenu() const
|
||||
{
|
||||
return m_showInMenu;
|
||||
@ -215,7 +180,7 @@ const QStringList CentralLayout::appliedActivities()
|
||||
return {};
|
||||
}
|
||||
|
||||
if (isOnAllActivities() || m_corona->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout ) {
|
||||
if (isOnAllActivities() || m_corona->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout) {
|
||||
return QStringList(Data::Layout::ALLACTIVITIESID);
|
||||
} else if (isForFreeActivities()) {
|
||||
return m_corona->layoutsManager()->synchronizer()->freeActivities();
|
||||
|
@ -88,9 +88,6 @@ private:
|
||||
void init();
|
||||
void importLocalLayout(QString file);
|
||||
|
||||
bool kwin_disabledMaximizedBorders() const;
|
||||
void kwin_setDisabledMaximizedBorders(bool disable);
|
||||
|
||||
private:
|
||||
bool m_disableBordersForMaximizedWindows{false};
|
||||
bool m_showInMenu{false};
|
||||
|
@ -52,9 +52,14 @@ Synchronizer::Synchronizer(QObject *parent)
|
||||
{
|
||||
m_manager = qobject_cast<Manager *>(parent);
|
||||
|
||||
//! KWin update Disabled Borders
|
||||
connect(this, &Synchronizer::centralLayoutsChanged, this, &Synchronizer::updateKWinDisabledBorders);
|
||||
connect(m_manager->corona()->universalSettings(), &UniversalSettings::canDisableBordersChanged, this, &Synchronizer::updateKWinDisabledBorders);
|
||||
|
||||
|
||||
//! KActivities tracking
|
||||
connect(m_manager->corona()->activitiesConsumer(), &KActivities::Consumer::currentActivityChanged,
|
||||
this, &Synchronizer::currentActivityChanged);
|
||||
this, &Synchronizer::onCurrentActivityChanged);
|
||||
|
||||
connect(m_manager->corona()->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged,
|
||||
this, [&]() {
|
||||
@ -182,7 +187,7 @@ QStringList Synchronizer::centralLayoutsNames()
|
||||
QStringList names;
|
||||
|
||||
if (m_manager->memoryUsage() == MemoryUsage::SingleLayout) {
|
||||
names << currentLayoutName();
|
||||
names << m_centralLayouts.at(0)->name();
|
||||
} else {
|
||||
for (int i = 0; i < m_centralLayouts.size(); ++i) {
|
||||
CentralLayout *layout = m_centralLayouts.at(i);
|
||||
@ -355,10 +360,11 @@ void Synchronizer::addLayout(CentralLayout *layout)
|
||||
}
|
||||
}
|
||||
|
||||
void Synchronizer::currentActivityChanged(const QString &id)
|
||||
void Synchronizer::onCurrentActivityChanged(const QString &id)
|
||||
{
|
||||
if (m_manager->memoryUsage() == MemoryUsage::MultipleLayouts) {
|
||||
updateCurrentLayoutNameInMultiEnvironment();
|
||||
updateKWinDisabledBorders();
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,6 +620,7 @@ void Synchronizer::syncMultipleLayoutsToActivities()
|
||||
|
||||
QStringList layoutsToUnload;
|
||||
QStringList layoutsToLoad;
|
||||
QStringList currents = centralLayoutsNames();
|
||||
|
||||
//! discover OnAllActivities layouts
|
||||
if (m_assignedLayouts.contains(Data::Layout::ALLACTIVITIESID)) {
|
||||
@ -701,8 +708,38 @@ void Synchronizer::syncMultipleLayoutsToActivities()
|
||||
}
|
||||
}
|
||||
|
||||
qSort(currents);
|
||||
qSort(layoutsToLoad);
|
||||
|
||||
updateCurrentLayoutNameInMultiEnvironment();
|
||||
|
||||
if (currents != layoutsToLoad) {
|
||||
emit centralLayoutsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Synchronizer::updateKWinDisabledBorders()
|
||||
{
|
||||
if (!m_manager->corona()->universalSettings()->canDisableBorders()) {
|
||||
m_manager->corona()->universalSettings()->kwin_setDisabledMaximizedBorders(false);
|
||||
} else {
|
||||
if (m_manager->corona()->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout) {
|
||||
m_manager->corona()->universalSettings()->kwin_setDisabledMaximizedBorders(m_centralLayouts.at(0)->disableBordersForMaximizedWindows());
|
||||
} else if (m_manager->corona()->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts) {
|
||||
QList<CentralLayout *> centrals = centralLayoutsForActivity(m_manager->corona()->activitiesConsumer()->currentActivity());
|
||||
|
||||
for (int i = 0; i < centrals.size(); ++i) {
|
||||
CentralLayout *layout = centrals.at(i);
|
||||
|
||||
if (layout->disableBordersForMaximizedWindows()) {
|
||||
m_manager->corona()->universalSettings()->kwin_setDisabledMaximizedBorders(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_manager->corona()->universalSettings()->kwin_setDisabledMaximizedBorders(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -114,6 +114,9 @@ public:
|
||||
|
||||
KActivities::Controller *activitiesController() const;
|
||||
|
||||
public slots:
|
||||
void updateKWinDisabledBorders();
|
||||
|
||||
signals:
|
||||
void centralLayoutsChanged();
|
||||
void currentLayoutNameChanged();
|
||||
@ -126,7 +129,7 @@ signals:
|
||||
private slots:
|
||||
void updateCurrentLayoutNameInMultiEnvironment();
|
||||
|
||||
void currentActivityChanged(const QString &id);
|
||||
void onCurrentActivityChanged(const QString &id);
|
||||
|
||||
void onLayoutAdded(const QString &layoutpath);
|
||||
|
||||
|
@ -386,6 +386,7 @@ void UniversalSettings::kwin_setDisabledMaximizedBorders(bool disable)
|
||||
|
||||
if (iface.isValid()) {
|
||||
iface.call("reconfigure");
|
||||
m_kwinBorderlessMaximizedWindows = disable;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user