mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Replace the convergentwindows KWin script SSD toggling with KWin rules to ensure windows are maximized and have no window border (and toggle off for docked mode). KWin rules work immediately at window creation, which is more efficient than listening to window creation events and manually changing properties on them. Currently, window rules setting maximization don't seem to address all cases where a window gets unmaximized, so for the time being we will still need the logic in convergentwindows to handle any sidecases.
118 lines
5.9 KiB
C
118 lines
5.9 KiB
C
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
// SPDX-FileCopyrightText: 2024 Luis Büchi <luis.buechi@kdemail.net>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <utility>
|
|
|
|
#include <QMap>
|
|
#include <QString>
|
|
#include <QVariant>
|
|
|
|
#include <KConfigGroup>
|
|
#include <KSharedConfig>
|
|
|
|
// applications-blacklistrc
|
|
// NOTE: we only write these entries if they are not already defined in the config
|
|
const QMap<QString, QMap<QString, QVariant>> APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS = {
|
|
{"Applications",
|
|
{{"blacklist",
|
|
"assistant,assistant-qt5,avahi-discover,bssh,bvnc,ciborium,cuttlefish,designer,designer-qt5,htop,ktelnetservice5,linguist,linguist-qt5,"
|
|
"org.kde.kcharselect,org.kde.kfind,org.kde.klipper,org.kde.kmag,org.kde.kmenuedit,org.kde.kmousetool,org.kde.krfb,"
|
|
"org.kde.kuserfeedback-console,org.kde.kwalletmanager5,org.kde.okular,org.kde.perusecreator,org.kde.plasma.themeexplorer,org.kde.plasma-welcome,"
|
|
"nvtop,qt5-qdbusviewer,qv4l2,qvidcap,syncmonitorhelper,UserFeedbackConsole,waydroid.com.android.calculator2,waydroid.com.android.camera2,"
|
|
"waydroid.com.android.contacts,waydroid.com.android.deskclock,waydroid.com.android.documentsui,waydroid.com.android.gallery3d,"
|
|
"waydroid.com.android.inputmethod.latin,waydroid.com.android.settings,waydroid.org.lineageos.eleven,waydroid.org.lineageos.etar,"
|
|
"waydroid.org.lineageos.jelly,waydroid.org.lineageos.recorder,wordview"}}}};
|
|
|
|
// kdeglobals
|
|
// NOTE: we only write these entries if they are not already defined in the config
|
|
const QMap<QString, QMap<QString, QVariant>> KDEGLOBALS_DEFAULT_SETTINGS = {{"General", {{"BrowserApplication", "angelfish"}}}};
|
|
|
|
const QMap<QString, QMap<QString, QVariant>> KDEGLOBALS_SETTINGS = {{"KDE", {{"LookAndFeelPackage", "org.kde.breeze.mobile"}}}};
|
|
|
|
// kwinrc
|
|
QMap<QString, QMap<QString, QVariant>> getKwinrcSettings(KSharedConfig::Ptr m_mobileConfig)
|
|
{
|
|
auto group = KConfigGroup{m_mobileConfig, QStringLiteral("General")};
|
|
bool convergenceModeEnabled = group.readEntry("convergenceModeEnabled", false);
|
|
|
|
return {{"Windows",
|
|
{
|
|
{"Placement", convergenceModeEnabled ? "Centered" : "Maximizing"}, // maximize all windows by default if we aren't in convergence mode
|
|
{"InteractiveWindowMoveEnabled", convergenceModeEnabled} // only allow window moving in convergence mode
|
|
}},
|
|
{"Plugins",
|
|
{
|
|
{"blurEnabled", false}, // disable blur for performance reasons, we could reconsider in the future for more powerful devices
|
|
{"convergentwindowsEnabled", true}, // enable our convergent window plugin
|
|
{"mobiletaskswitcherEnabled", true}, // ensure the mobile task switcher plugin is enabled
|
|
{"screenedgeEnabled", false} // disable the blue highlighting of screen edge effects. TODO would be nice if we could only deactivate it on
|
|
// touchscreen gestures and not mouse as well
|
|
}},
|
|
{"Wayland",
|
|
{
|
|
{"InputMethod", "/usr/share/applications/com.github.maliit.keyboard.desktop"}, // ensure maliit is our vkbd
|
|
{"VirtualKeyboardEnabled", true} // enable vkbd
|
|
}},
|
|
{"org.kde.kdecoration2",
|
|
{
|
|
{"ButtonsOnRight", convergenceModeEnabled ? "HIAX" : "H"}, // ButtonsOnRight changes depending on whether the device is in convergence mode
|
|
{"NoPlugin", false} // ensure that the window decoration plugin is always enabled, otherwise we get Qt default window decorations
|
|
}},
|
|
{"Input",
|
|
{
|
|
{"TabletMode", convergenceModeEnabled ? "off" : "auto"} // TabletMode changes depending on whether the device is in convergence mode
|
|
}}};
|
|
}
|
|
|
|
// Have a separate list here because we need to trigger DBus calls to load/unload each effect/script.
|
|
// Make sure that the effect/script is added to the kwinrc "Plugins" section above!
|
|
const QList<QString> KWIN_EFFECTS = {"blur", "mobiletaskswitcher", "screenedge"};
|
|
const QList<QString> KWIN_SCRIPTS = {"convergentwindows"};
|
|
|
|
// ksmserver
|
|
const QMap<QString, QMap<QString, QVariant>> KSMSERVER_SETTINGS = {{"General", {{"loginMode", "emptySession"}}}};
|
|
|
|
// kwinrulesrc
|
|
const QList<QString> KWIN_RULES = {"plasma-mobile-desktop", "plasma-mobile-maximized-no-border"};
|
|
|
|
QMap<QString, QMap<QString, QVariant>> 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"},
|
|
}}};
|
|
}
|
|
}
|