From 92a723955042fce11fd4d83362a090a7b92daf54 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 25 Apr 2018 00:10:08 +0300 Subject: [PATCH] fix #1001,disable maximized borders per layout --give the user an option in layout file in order to enable/disable borders for maximized windows. the option is called "disableBordersForMaximizedWindows" and must be put in LayoutSettings section --- app/layout.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ app/layout.h | 8 +++++++ 2 files changed, 72 insertions(+) diff --git a/app/layout.cpp b/app/layout.cpp index 3af9d760f..20800884a 100644 --- a/app/layout.cpp +++ b/app/layout.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -153,6 +154,7 @@ void Layout::init() connect(this, &Layout::backgroundChanged, this, &Layout::saveConfig); connect(this, &Layout::versionChanged, this, &Layout::saveConfig); connect(this, &Layout::colorChanged, this, &Layout::textColorChanged); + connect(this, &Layout::disableBordersForMaximizedWindowsChanged, this, &Layout::saveConfig); connect(this, &Layout::showInMenuChanged, this, &Layout::saveConfig); connect(this, &Layout::textColorChanged, this, &Layout::saveConfig); connect(this, &Layout::launchersChanged, this, &Layout::saveConfig); @@ -179,6 +181,16 @@ void Layout::initToCorona(DockCorona *corona) qDebug() << "Layout ::::: " << name() << " added contaiments ::: " << m_containments.size(); + if (m_corona->layoutManager()->memoryUsage() == Dock::SingleLayout) { + kwin_setDisabledMaximizedBorders(disableBordersForMaximizedWindows()); + } else if (m_corona->layoutManager()->memoryUsage() == Dock::MultipleLayouts) { + connect(m_corona->layoutManager(), &LayoutManager::currentLayoutNameChanged, this, [&]() { + if (m_corona->layoutManager()->currentLayoutName() == name()) { + kwin_setDisabledMaximizedBorders(disableBordersForMaximizedWindows()); + } + }); + } + if (m_layoutName != MultipleLayoutsName) { updateLastUsedActivity(); } @@ -205,6 +217,56 @@ void Layout::setVersion(int ver) emit versionChanged(); } +bool Layout::disableBordersForMaximizedWindows() const +{ + return m_disableBordersForMaximizedWindows; +} + +void Layout::setDisableBordersForMaximizedWindows(bool disable) +{ + if (m_disableBordersForMaximizedWindows == disable) { + return; + } + + m_disableBordersForMaximizedWindows = disable; + + emit disableBordersForMaximizedWindowsChanged(); +} + +bool Layout::kwin_disabledMaximizedBorders() const +{ + //! Indentify Plasma Desktop version + QProcess process; + process.start("kreadconfig5 --file kwinrc --group Windows --key BorderlessMaximizedWindows"); + process.waitForFinished(); + QString output(process.readAllStandardOutput()); + + output = output.remove("\n"); + + return (output == "true"); +} + +void Layout::kwin_setDisabledMaximizedBorders(bool disable) +{ + if (kwin_disabledMaximizedBorders() == disable) { + return; + } + + QString disableText = disable ? "true" : "false"; + + QProcess process; + QString commandStr = "kwriteconfig5 --file kwinrc --group Windows --key BorderlessMaximizedWindows --type bool " + disableText; + process.start(commandStr); + process.waitForFinished(); + + QDBusInterface iface("org.kde.KWin", "/KWin", "", QDBusConnection::sessionBus()); + + if (iface.isValid()) { + iface.call("reconfigure"); + } + +} + bool Layout::showInMenu() const { return m_showInMenu; @@ -567,6 +629,7 @@ void Layout::loadConfig() { m_version = m_layoutGroup.readEntry("version", 2); m_color = m_layoutGroup.readEntry("color", QString("blue")); + m_disableBordersForMaximizedWindows = m_layoutGroup.readEntry("disableBordersForMaximizedWindows", false); m_showInMenu = m_layoutGroup.readEntry("showInMenu", false); m_textColor = m_layoutGroup.readEntry("textColor", QString("fcfcfc")); m_activities = m_layoutGroup.readEntry("activities", QStringList()); @@ -592,6 +655,7 @@ void Layout::saveConfig() m_layoutGroup.writeEntry("version", m_version); m_layoutGroup.writeEntry("showInMenu", m_showInMenu); m_layoutGroup.writeEntry("color", m_color); + m_layoutGroup.writeEntry("disableBordersForMaximizedWindows", m_disableBordersForMaximizedWindows); m_layoutGroup.writeEntry("launchers", m_launchers); m_layoutGroup.writeEntry("background", m_background); m_layoutGroup.writeEntry("activities", m_activities); diff --git a/app/layout.h b/app/layout.h index afac4ee0c..0018f1644 100644 --- a/app/layout.h +++ b/app/layout.h @@ -67,6 +67,9 @@ public: void unloadContainments(); void unloadDockViews(); + bool disableBordersForMaximizedWindows() const; + void setDisableBordersForMaximizedWindows(bool disable); + bool showInMenu() const; void setShowInMenu(bool show); @@ -148,6 +151,7 @@ signals: void activitiesChanged(); void backgroundChanged(); void colorChanged(); + void disableBordersForMaximizedWindowsChanged(); void dockColorizerSupportChanged(); void fileChanged(); void lastUsedActivityChanged(); @@ -175,6 +179,9 @@ private: bool explicitDockOccupyEdge(int screen, Plasma::Types::Location location) const; + bool kwin_disabledMaximizedBorders() const; + void kwin_setDisabledMaximizedBorders(bool disable); + QString availableId(QStringList all, QStringList assigned, int base); //! provides a new file path based the provided file. The new file //! has updated ids for containments and applets based on the corona @@ -184,6 +191,7 @@ private: QList importLayoutFile(QString file); private: + bool m_disableBordersForMaximizedWindows{false}; bool m_showInMenu{false}; //if version doesnt exist it is and old layout file int m_version{2};