1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-08 01:18:21 +03:00

pref option to disable geometries broadcasting

--the user can choose to disable available desktop geometry
broadcasting to Plasma in order to avoid any desktop widgets
moving at all cases
This commit is contained in:
Michail Vourlakos 2021-07-16 18:54:54 +03:00
parent 29df650645
commit 5486730a00
8 changed files with 99 additions and 6 deletions

View File

@ -12,6 +12,7 @@ const bool Preferences::BADGE3DSTYLE;
const bool Preferences::LAYOUTSINFORMATIONWINDOW;
const bool Preferences::AUTOSTART;
const bool Preferences::BORDERLESSMAXIMIZED;
const bool Preferences::ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA;
const bool Preferences::METAPRESSFORAPPLAUNCHER;
const bool Preferences::METAHOLDFORBADGES;
const int Preferences::SCREENSDELAY;
@ -27,6 +28,7 @@ Preferences::Preferences(Preferences &&o)
autostart(o.autostart),
borderlessMaximized(o.borderlessMaximized),
contextMenuAlwaysActions(o.contextMenuAlwaysActions),
isAvailableGeometryBroadcastedToPlasma(o.isAvailableGeometryBroadcastedToPlasma),
metaPressForAppLauncher(o.metaPressForAppLauncher),
metaHoldForBadges(o.metaHoldForBadges),
mouseSensitivity(o.mouseSensitivity),
@ -40,6 +42,7 @@ Preferences::Preferences(const Preferences &o)
autostart(o.autostart),
borderlessMaximized(o.borderlessMaximized),
contextMenuAlwaysActions(o.contextMenuAlwaysActions),
isAvailableGeometryBroadcastedToPlasma(o.isAvailableGeometryBroadcastedToPlasma),
metaPressForAppLauncher(o.metaPressForAppLauncher),
metaHoldForBadges(o.metaHoldForBadges),
mouseSensitivity(o.mouseSensitivity),
@ -54,6 +57,7 @@ Preferences &Preferences::operator=(const Preferences &rhs)
autostart = rhs.autostart;
borderlessMaximized = rhs.borderlessMaximized;
contextMenuAlwaysActions = rhs.contextMenuAlwaysActions;
isAvailableGeometryBroadcastedToPlasma = rhs.isAvailableGeometryBroadcastedToPlasma;
metaPressForAppLauncher = rhs.metaPressForAppLauncher;
metaHoldForBadges = rhs.metaHoldForBadges;
mouseSensitivity = rhs.mouseSensitivity;
@ -69,6 +73,7 @@ Preferences &Preferences::operator=(Preferences &&rhs)
autostart = rhs.autostart;
borderlessMaximized = rhs.borderlessMaximized;
contextMenuAlwaysActions = rhs.contextMenuAlwaysActions;
isAvailableGeometryBroadcastedToPlasma = rhs.isAvailableGeometryBroadcastedToPlasma;
metaPressForAppLauncher = rhs.metaPressForAppLauncher;
metaHoldForBadges = rhs.metaHoldForBadges;
mouseSensitivity = rhs.mouseSensitivity;
@ -84,6 +89,7 @@ bool Preferences::operator==(const Preferences &rhs) const
&& (autostart == rhs.autostart)
&& (borderlessMaximized == rhs.borderlessMaximized)
&& (contextMenuAlwaysActions == rhs.contextMenuAlwaysActions)
&& (isAvailableGeometryBroadcastedToPlasma == rhs.isAvailableGeometryBroadcastedToPlasma)
&& (metaPressForAppLauncher == rhs.metaPressForAppLauncher)
&& (metaHoldForBadges == rhs.metaHoldForBadges)
&& (mouseSensitivity == rhs.mouseSensitivity)
@ -102,6 +108,7 @@ bool Preferences::inDefaultValues() const
&& (autostart == AUTOSTART)
&& (borderlessMaximized == BORDERLESSMAXIMIZED)
&& (contextMenuAlwaysActions == Data::ContextMenu::ACTIONSALWAYSVISIBLE)
&& (isAvailableGeometryBroadcastedToPlasma == ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA)
&& (metaPressForAppLauncher == METAPRESSFORAPPLAUNCHER)
&& (metaHoldForBadges == METAHOLDFORBADGES)
&& (mouseSensitivity == MOUSESENSITIVITY)
@ -115,6 +122,7 @@ void Preferences::setToDefaults()
autostart = AUTOSTART;
borderlessMaximized = BORDERLESSMAXIMIZED;
contextMenuAlwaysActions = Data::ContextMenu::ACTIONSALWAYSVISIBLE;
isAvailableGeometryBroadcastedToPlasma = ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA;
metaPressForAppLauncher = METAPRESSFORAPPLAUNCHER;
metaHoldForBadges = METAHOLDFORBADGES;
mouseSensitivity = MOUSESENSITIVITY;

View File

@ -23,6 +23,7 @@ public:
static const bool LAYOUTSINFORMATIONWINDOW = true;
static const bool AUTOSTART = true;
static const bool BORDERLESSMAXIMIZED = false;
static const bool ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA = true;
static const bool METAPRESSFORAPPLAUNCHER = false;
static const bool METAHOLDFORBADGES = true;
static const int SCREENSDELAY = 2500;
@ -37,6 +38,7 @@ public:
bool layoutsInformationWindow{LAYOUTSINFORMATIONWINDOW};
bool autostart{AUTOSTART};
bool borderlessMaximized{BORDERLESSMAXIMIZED};
bool isAvailableGeometryBroadcastedToPlasma{ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA};
bool metaPressForAppLauncher{METAPRESSFORAPPLAUNCHER};
bool metaHoldForBadges{METAHOLDFORBADGES};
int screensDelay{SCREENSDELAY};

View File

@ -11,6 +11,7 @@
#include "../../view/view.h"
#include "../../layout/genericlayout.h"
#include "../../layouts/manager.h"
#include "../../settings/universalsettings.h"
// Qt
#include <QDebug>
@ -61,6 +62,8 @@ void ScreenGeometries::init()
{
QDBusInterface plasmaStrutsIface(PLASMASERVICE, "/StrutManager", PLASMASTRUTNAMESPACE, QDBusConnection::sessionBus());
connect(m_corona->universalSettings(), &Latte::UniversalSettings::isAvailableGeometryBroadcastedToPlasmaChanged, this, &ScreenGeometries::onBroadcastToPlasmaChanged);
if (plasmaStrutsIface.isValid()) {
m_plasmaInterfaceAvailable = true;
@ -74,11 +77,15 @@ void ScreenGeometries::init()
});
connect(m_corona->activitiesConsumer(), &KActivities::Consumer::currentActivityChanged, this, [&]() {
m_forceGeometryBroadcast = true;
m_publishTimer.start();
if (m_corona->universalSettings()->isAvailableGeometryBroadcastedToPlasma()) {
m_forceGeometryBroadcast = true;
m_publishTimer.start();
}
});
m_publishTimer.start();
if (m_corona->universalSettings()->isAvailableGeometryBroadcastedToPlasma()) {
m_publishTimer.start();
}
}
}
@ -93,7 +100,16 @@ bool ScreenGeometries::screenIsActive(const QString &screenName) const
return false;
}
void ScreenGeometries::updateGeometries()
void ScreenGeometries::onBroadcastToPlasmaChanged()
{
if (m_corona->universalSettings()->isAvailableGeometryBroadcastedToPlasma()) {
m_publishTimer.start();
} else {
clearGeometries();
}
}
void ScreenGeometries::clearGeometries()
{
if (!m_plasmaInterfaceAvailable) {
return;
@ -105,6 +121,32 @@ void ScreenGeometries::updateGeometries()
return;
}
for (QScreen *screen : qGuiApp->screens()) {
QString scrName = screen->name();
int scrId = m_corona->screenPool()->id(screen->name());
if (m_corona->screenPool()->hasScreenId(scrId)) {
plasmaStrutsIface.call("setAvailableScreenRect", LATTESERVICE, scrName, QRect());
plasmaStrutsIface.call("setAvailableScreenRegion", LATTESERVICE, scrName, QVariant());
}
}
m_lastAvailableRect.clear();
m_lastAvailableRegion.clear();
}
void ScreenGeometries::updateGeometries()
{
if (!m_plasmaInterfaceAvailable || !m_corona->universalSettings()->isAvailableGeometryBroadcastedToPlasma()) {
return;
}
QDBusInterface plasmaStrutsIface(PLASMASERVICE, "/StrutManager", PLASMASTRUTNAMESPACE, QDBusConnection::sessionBus());
if (!plasmaStrutsIface.isValid()) {
return;
}
QStringList availableScreenNames;
qDebug() << " PLASMA SCREEN GEOMETRIES, LAST AVAILABLE SCREEN RECTS :: " << m_lastAvailableRect;
@ -185,7 +227,7 @@ void ScreenGeometries::updateGeometries()
void ScreenGeometries::availableScreenGeometryChangedFrom(Latte::View *origin)
{
if (origin && origin->layout() && origin->layout()->isCurrent()) {
if (m_corona->universalSettings()->isAvailableGeometryBroadcastedToPlasma() && origin && origin->layout() && origin->layout()->isCurrent()) {
m_publishTimer.start();
}
}

View File

@ -37,6 +37,9 @@ private slots:
void init();
void updateGeometries();
void clearGeometries();
void onBroadcastToPlasmaChanged();
private slots:
bool screenIsActive(const QString &screenName) const;

View File

@ -522,7 +522,7 @@
<x>0</x>
<y>0</y>
<width>1068</width>
<height>401</height>
<height>428</height>
</rect>
</property>
<property name="sizePolicy">
@ -1116,6 +1116,13 @@ This tracker is used in order to not lose any screen related update.</string>
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="broadcastGeomChkBox">
<property name="text">
<string>Inform Plasma desktop for available desktop space</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -67,6 +67,11 @@ void TabPreferences::initUi()
emit dataChanged();
});
connect(m_ui->broadcastGeomChkBox, &QCheckBox::stateChanged, this, [&]() {
m_preferences.isAvailableGeometryBroadcastedToPlasma = m_ui->broadcastGeomChkBox->isChecked();
emit dataChanged();
});
connect(m_ui->screenTrackerSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [ = ](int i) {
m_preferences.screensDelay = m_ui->screenTrackerSpinBox->value();
emit dataChanged();
@ -100,6 +105,7 @@ void TabPreferences::initSettings()
o_preferences.autostart = m_corona->universalSettings()->autostart();
o_preferences.badgeStyle3D = m_corona->universalSettings()->badges3DStyle();
o_preferences.contextMenuAlwaysActions = m_corona->universalSettings()->contextMenuActionsAlwaysShown();
o_preferences.isAvailableGeometryBroadcastedToPlasma = m_corona->universalSettings()->isAvailableGeometryBroadcastedToPlasma();
o_preferences.layoutsInformationWindow = m_corona->universalSettings()->showInfoWindow();
o_preferences.metaPressForAppLauncher = m_corona->universalSettings()->kwin_metaForwardedToLatte();
o_preferences.metaHoldForBadges = m_corona->universalSettings()->metaPressAndHoldEnabled();
@ -133,6 +139,7 @@ void TabPreferences::updateUi()
m_ui->autostartChkBox->setChecked(m_preferences.autostart);
m_ui->badges3DStyleChkBox->setChecked(m_preferences.badgeStyle3D);
m_ui->infoWindowChkBox->setChecked(m_preferences.layoutsInformationWindow);
m_ui->broadcastGeomChkBox->setChecked(m_preferences.isAvailableGeometryBroadcastedToPlasma);
m_ui->metaPressChkBox->setChecked(m_preferences.metaPressForAppLauncher);
m_ui->metaPressHoldChkBox->setChecked(m_preferences.metaHoldForBadges);
m_ui->noBordersForMaximizedChkBox->setChecked(m_preferences.borderlessMaximized);
@ -184,6 +191,7 @@ void TabPreferences::save()
m_corona->universalSettings()->setBadges3DStyle(m_preferences.badgeStyle3D);
m_corona->universalSettings()->setContextMenuActionsAlwaysShown(m_preferences.contextMenuAlwaysActions);
m_corona->universalSettings()->kwin_forwardMetaToLatte(m_preferences.metaPressForAppLauncher);
m_corona->universalSettings()->setIsAvailableGeometryBroadcastedToPlasma(m_preferences.isAvailableGeometryBroadcastedToPlasma);
m_corona->universalSettings()->setMetaPressAndHoldEnabled(m_preferences.metaHoldForBadges);
m_corona->universalSettings()->setShowInfoWindow(m_preferences.layoutsInformationWindow);
m_corona->universalSettings()->setCanDisableBorders(m_preferences.borderlessMaximized);

View File

@ -46,6 +46,7 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)
connect(this, &UniversalSettings::badges3DStyleChanged, this, &UniversalSettings::saveConfig);
connect(this, &UniversalSettings::canDisableBordersChanged, this, &UniversalSettings::saveConfig);
connect(this, &UniversalSettings::inAdvancedModeForEditSettingsChanged, this, &UniversalSettings::saveConfig);
connect(this, &UniversalSettings::isAvailableGeometryBroadcastedToPlasmaChanged, this, &UniversalSettings::saveConfig);
connect(this, &UniversalSettings::launchersChanged, this, &UniversalSettings::saveConfig);
connect(this, &UniversalSettings::layoutsMemoryUsageChanged, this, &UniversalSettings::saveConfig);
connect(this, &UniversalSettings::metaPressAndHoldEnabledChanged, this, &UniversalSettings::saveConfig);
@ -126,6 +127,21 @@ void UniversalSettings::setInAdvancedModeForEditSettings(const bool &inAdvanced)
emit inAdvancedModeForEditSettingsChanged();
}
bool UniversalSettings::isAvailableGeometryBroadcastedToPlasma() const
{
return m_isAvailableGeometryBroadcastedToPlasma;
}
void UniversalSettings::setIsAvailableGeometryBroadcastedToPlasma(const bool &isBroadcasted)
{
if (m_isAvailableGeometryBroadcastedToPlasma == isBroadcasted) {
return;
}
m_isAvailableGeometryBroadcastedToPlasma = isBroadcasted;
emit isAvailableGeometryBroadcastedToPlasmaChanged();
}
bool UniversalSettings::showInfoWindow() const
{
return m_showInfoWindow;
@ -517,6 +533,7 @@ void UniversalSettings::loadConfig()
m_contextMenuActionsAlwaysShown = m_universalGroup.readEntry("contextMenuActionsAlwaysShown", QStringList());
m_contextMenuActionsAlwaysShown = m_contextMenuActionsAlwaysShown.isEmpty() ? Latte::Data::ContextMenu::ACTIONSALWAYSVISIBLE : m_contextMenuActionsAlwaysShown;
m_inAdvancedModeForEditSettings = m_universalGroup.readEntry("inAdvancedModeForEditSettings", false);
m_isAvailableGeometryBroadcastedToPlasma = m_universalGroup.readEntry("isAvailableGeometryBroadcastedToPlasma", true);
m_launchers = m_universalGroup.readEntry("launchers", QStringList());
m_metaPressAndHoldEnabled = m_universalGroup.readEntry("metaPressAndHoldEnabled", true);
m_screenTrackerInterval = m_universalGroup.readEntry("screenTrackerInterval", 2500);
@ -540,6 +557,7 @@ void UniversalSettings::saveConfig()
m_universalGroup.writeEntry("contextMenuActionsAlwaysShown", (m_contextMenuActionsAlwaysShown == Data::ContextMenu::ACTIONSALWAYSVISIBLE ?
QStringList() : m_contextMenuActionsAlwaysShown));
m_universalGroup.writeEntry("inAdvancedModeForEditSettings", m_inAdvancedModeForEditSettings);
m_universalGroup.writeEntry("isAvailableGeometryBroadcastedToPlasma", m_isAvailableGeometryBroadcastedToPlasma);
m_universalGroup.writeEntry("launchers", m_launchers);
m_universalGroup.writeEntry("metaPressAndHoldEnabled", m_metaPressAndHoldEnabled);
m_universalGroup.writeEntry("screenTrackerInterval", m_screenTrackerInterval);

View File

@ -76,6 +76,9 @@ public:
bool inAdvancedModeForEditSettings() const;
void setInAdvancedModeForEditSettings(const bool &inAdvanced);
bool isAvailableGeometryBroadcastedToPlasma() const;
void setIsAvailableGeometryBroadcastedToPlasma(const bool &isBroadcasted);
bool kwin_metaForwardedToLatte() const;
void kwin_forwardMetaToLatte(bool forward);
@ -133,6 +136,7 @@ signals:
void layoutsWindowSizeChanged();
void launchersChanged();
void layoutsMemoryUsageChanged();
void isAvailableGeometryBroadcastedToPlasmaChanged();
void metaPressAndHoldEnabledChanged();
void sensitivityChanged();
void screensCountChanged();
@ -166,6 +170,7 @@ private:
bool m_canDisableBorders{false};
bool m_colorsScriptIsPresent{false};
bool m_inAdvancedModeForEditSettings{false};
bool m_isAvailableGeometryBroadcastedToPlasma{true};
bool m_metaPressAndHoldEnabled{true};
bool m_showInfoWindow{true};