From 9c2e2c7db3a2d5a48feacde0535ea80e665e1d56 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Thu, 24 Apr 2025 11:28:49 +0200 Subject: [PATCH] Revert "envmanager: Handle SSD toggling with kwin rules" This reverts commit c45f9ed4464bfa8be5eb95d578f35055a93ea06b. The kwin rules setting causes all desktop windows to have window decorations. Revert this for now until we figure out a solution. --- envmanager/config.h | 44 +------------------ envmanager/settings.cpp | 35 ++------------- envmanager/settings.h | 7 +-- .../convergentwindows/contents/ui/main.qml | 40 ++++++++--------- 4 files changed, 25 insertions(+), 101 deletions(-) diff --git a/envmanager/config.h b/envmanager/config.h index b5dc14a9..0d410173 100644 --- a/envmanager/config.h +++ b/envmanager/config.h @@ -72,47 +72,5 @@ QMap> getKwinrcSettings(KSharedConfig::Ptr m_mo const QList KWIN_EFFECTS = {"blur", "mobiletaskswitcher", "screenedge"}; const QList KWIN_SCRIPTS = {"convergentwindows"}; -// ksmserver +//ksmserver const QMap> KSMSERVER_SETTINGS = {{"General", {{"loginMode", "emptySession"}}}}; - -// kwinrulesrc -const QList KWIN_RULES = {"plasma-mobile-desktop", "plasma-mobile-maximized-no-border"}; - -QMap> getKwinrulesrcSettings(KSharedConfig::Ptr m_mobileConfig, bool isMobileSession) -{ - auto group = KConfigGroup{m_mobileConfig, QStringLiteral("General")}; - bool convergenceModeEnabled = group.readEntry("convergenceModeEnabled", false); - - if (convergenceModeEnabled || !isMobileSession) { - return {{"plasma-mobile-desktop", - { - {"Description", "Desktop windows (controlled by Plasma Mobile)"}, - {"maximizehoriz", true}, - {"maximizehorizrule", 1}, - {"maximizevert", true}, - {"maximizevertrule", 1}, - {"noborderrule", 2}, - }}, - {"General", - { - {"count", 1}, - {"rules", "plasma-mobile-desktop"}, - }}}; - } else { - return {{"plasma-mobile-maximized-no-border", - { - {"Description", "Mobile windows (controlled by Plasma Mobile)"}, - {"maximizehoriz", true}, - {"maximizehorizrule", 2}, - {"maximizevert", true}, - {"maximizevertrule", 2}, - {"noborder", true}, - {"noborderrule", 2}, - }}, - {"General", - { - {"count", 1}, - {"rules", "plasma-mobile-maximized-no-border"}, - }}}; - } -} diff --git a/envmanager/settings.cpp b/envmanager/settings.cpp index efa0c675..136617e8 100644 --- a/envmanager/settings.cpp +++ b/envmanager/settings.cpp @@ -26,7 +26,6 @@ Settings::Settings(QObject *parent) , m_appBlacklistConfig{KSharedConfig::openConfig(u"applications-blacklistrc"_s, KConfig::SimpleConfig)} , m_kdeglobalsConfig{KSharedConfig::openConfig(u"kdeglobals"_s, KConfig::SimpleConfig)} , m_ksmServerConfig{KSharedConfig::openConfig(u"ksmserverrc"_s, KConfig::SimpleConfig)} - , m_kwinrulesrcConfig{KSharedConfig::openConfig(u"kwinrulesrc"_s, KConfig::SimpleConfig)} , m_configWatcher{KConfigWatcher::create(m_mobileConfig)} { } @@ -55,14 +54,6 @@ void Settings::loadSavedConfiguration() // kwinrc loadKeys(u"kwinrc"_s, m_kwinrcConfig, getKwinrcSettings(m_mobileConfig)); m_kwinrcConfig->sync(); - - // kwinrules - for (const auto &groupName : KWIN_RULES) { - m_kwinrulesrcConfig->deleteGroup(groupName); - } - writeKeys(u"kwinrulesrc"_s, m_kwinrulesrcConfig, getKwinrulesrcSettings(m_mobileConfig, false), false, false); - m_kwinrulesrcConfig->sync(); - reloadKWinConfig(); // applications-blacklistrc @@ -83,14 +74,6 @@ void Settings::applyMobileConfiguration() // kwinrc writeKeys(u"kwinrc"_s, m_kwinrcConfig, getKwinrcSettings(m_mobileConfig), false); m_kwinrcConfig->sync(); - - // kwinrules - for (const auto &groupName : KWIN_RULES) { - m_kwinrulesrcConfig->deleteGroup(groupName); - } - writeKeys(u"kwinrulesrc"_s, m_kwinrulesrcConfig, getKwinrulesrcSettings(m_mobileConfig, true), false, false); - m_kwinrulesrcConfig->sync(); - reloadKWinConfig(); // applications-blacklistrc @@ -114,11 +97,7 @@ void Settings::applyMobileConfiguration() m_mobileConfig->sync(); } -void Settings::writeKeys(const QString &fileName, - KSharedConfig::Ptr &config, - const QMap> &settings, - bool overwriteOnlyIfEmpty, - bool saveSettings) +void Settings::writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap> &settings, bool overwriteOnlyIfEmpty) { const auto groupNames = settings.keys(); for (const auto &groupName : groupNames) { @@ -128,9 +107,7 @@ void Settings::writeKeys(const QString &fileName, for (const auto &key : keys) { if (!group.hasKey(key) || !overwriteOnlyIfEmpty) { // save key - if (saveSettings) { - saveConfigSetting(fileName, groupName, key, group.readEntry(key)); - } + saveConfigSetting(fileName, groupName, key, group.readEntry(key)); // overwrite with mobile setting group.writeEntry(key, settings[groupName][key], KConfigGroup::Notify); @@ -230,10 +207,6 @@ void Settings::reloadKWinConfig() } // Call "start" to load enabled KWin scripts. - QDBusMessage startScriptsMessage = QDBusMessage::createMethodCall(u"org.kde.KWin"_s, u"/Scripting"_s, u"org.kde.kwin.Scripting"_s, u"start"_s); - QDBusConnection::sessionBus().send(startScriptsMessage); - - // Call reconfigure - QDBusMessage reconfigureMessage = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reconfigure"); - QDBusConnection::sessionBus().send(reconfigureMessage); + QDBusMessage message = QDBusMessage::createMethodCall(u"org.kde.KWin"_s, u"/Scripting"_s, u"org.kde.kwin.Scripting"_s, u"start"_s); + QDBusConnection::sessionBus().send(message); } diff --git a/envmanager/settings.h b/envmanager/settings.h index f0b06e9b..d8d9814a 100644 --- a/envmanager/settings.h +++ b/envmanager/settings.h @@ -28,11 +28,7 @@ private: // applies our mobile configuration void applyMobileConfiguration(); - void writeKeys(const QString &fileName, - KSharedConfig::Ptr &config, - const QMap> &settings, - bool overwriteOnlyIfEmpty, - bool saveSettings = true); + void writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap> &settings, bool overwriteOnlyIfEmpty); void loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap> &settings); void saveConfigSetting(const QString &fileName, const QString &group, const QString &key, const QVariant value); const QString loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key, bool write = true); @@ -47,7 +43,6 @@ private: KSharedConfig::Ptr m_appBlacklistConfig; KSharedConfig::Ptr m_kdeglobalsConfig; KSharedConfig::Ptr m_ksmServerConfig; - KSharedConfig::Ptr m_kwinrulesrcConfig; KConfigWatcher::Ptr m_configWatcher; }; diff --git a/kwin/scripts/convergentwindows/contents/ui/main.qml b/kwin/scripts/convergentwindows/contents/ui/main.qml index 0733e54b..3eaf2a63 100644 --- a/kwin/scripts/convergentwindows/contents/ui/main.qml +++ b/kwin/scripts/convergentwindows/contents/ui/main.qml @@ -6,11 +6,6 @@ import QtQuick import org.kde.kwin as KWinComponents import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings -// This script ensures that windows stay maximized in the shell. -// -// We eventually want to replace this with the window rules implementation, -// but it seems that window maximize rules still don't work for all cases just yet -// (ex. unmaximizing fullscreen window) Loader { id: root @@ -28,26 +23,29 @@ Loader { } if (ShellSettings.Settings.convergenceModeEnabled) { - return; - } + window.noBorder = false; + } else { + if (!window.fullScreen) { + const output = window.output; + const desktop = window.desktops[0]; // assume it's the first desktop that the window is on + if (desktop === undefined) { + return; + } + const maximizeRect = KWinComponents.Workspace.clientArea(KWinComponents.Workspace.MaximizeArea, output, desktop); - if (!window.fullScreen) { - const output = window.output; - const desktop = window.desktops[0]; // assume it's the first desktop that the window is on - if (desktop === undefined) { - return; + // set the window to the maximized size and position instantly, avoiding race condition + // between maximizing and window decorations being turned off (changing window height) + // see: https://invent.kde.org/teams/plasma-mobile/issues/-/issues/256 + window.frameGeometry = maximizeRect; } - const maximizeRect = KWinComponents.Workspace.clientArea(KWinComponents.Workspace.MaximizeArea, output, desktop); - // set the window to the maximized size and position instantly, avoiding race condition - // between maximizing and window decorations being turned off (changing window height) - // see: https://invent.kde.org/teams/plasma-mobile/issues/-/issues/256 - window.frameGeometry = maximizeRect; - } + // turn off window decorations + window.noBorder = true; - if (!window.fullScreen) { - // run maximize after to ensure the state is maximized - window.setMaximize(true, true); + if (!window.fullScreen) { + // run maximize after to ensure the state is maximized + window.setMaximize(true, true); + } } }