dynamically load effects that support edge activation

effects can specify in their json file "X-KWin-Border-Activate":true
and will be listed in the edge menus.

Don't hardcode desktop grid and overview in the kcms
This commit is contained in:
Marco Martin 2022-05-03 16:54:36 +00:00
parent 0c69ce50ac
commit 02171495be
36 changed files with 205 additions and 110 deletions

View file

@ -25,3 +25,5 @@ install(PROGRAMS kwinrules-5.19-placement.pl
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(PROGRAMS kwinrules-5.23-virtual-desktop-ids.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(PROGRAMS kwin-5.25-effect-pluginid-config-group.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})

View file

@ -0,0 +1,35 @@
#!/usr/bin/env python3
import fileinput
def migrate_group(old, new, line):
if not "[Effect-{}".format(old) in line:
return
print("# DELETE Effect-{}".format(old))
print("[Effect-{}]\n".format(new))
for line in fileinput.input():
if not "[Effect-" in line:
print(line)
continue
migrate_group("Blur", "blur", line)
migrate_group("DesktopGrid", "desktopgrid", line)
migrate_group("DimInactive", "diminactive", line)
migrate_group("FallApart", "fallapart", line)
migrate_group("Glide", "glide", line)
migrate_group("Kscreen", "kscreen", line)
migrate_group("LookingGlass", "lookingglass", line)
migrate_group("MagicLamp", "magiclamp", line)
migrate_group("Magnifier", "magnifier", line)
migrate_group("MouseClick", "mouseclick", line)
migrate_group("MouseMark", "mousemark", line)
migrate_group("Overview", "overview", line)
migrate_group("PresentWindows", "presentwindows", line)
migrate_group("Sheet", "sheet", line)
migrate_group("ShowFps", "showfps", line)
migrate_group("Slide", "slide", line)
migrate_group("SlidingPopups", "slidingpopups", line)
migrate_group("ThumbnailAside", "thumbnailaside", line)
migrate_group("TrackMouse", "trackmouse", line)
migrate_group("Wobbly", "wobblywindows", line)
migrate_group("Zoom", "zoom", line)

View file

@ -85,3 +85,9 @@ Id=enable-scale-effect-by-default
File=kwinrc
Group=Plugins
Key=kwin4_effect_fadeEnabled,kwin4_effect_scaleEnabled
# Overview config group based upon plugin id
Id=overview-group-plugin-id
File=kwinrc
Options=AllGroups
Script=kwin-5.25-effect-pluginid-config-group.py,python3

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Blur">
<group name="Effect-blur">
<entry name="BlurStrength" type="Int">
<default>15</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-DesktopGrid">
<group name="Effect-desktopgrid">
<entry name="BorderActivate" type="IntList" />
<entry name="TouchBorderActivate" type="IntList" />
<entry name="ZoomDuration" type="Int">

View file

@ -69,6 +69,7 @@
"Name[zh_CN]": "虚拟桌面平铺网格"
},
"X-KDE-ConfigModule": "kwin_desktopgrid_config",
"X-KWin-Border-Activate": true,
"org.kde.kwin.effect": {
"video": "https://files.kde.org/plasma/kwin/effect-videos/desktop_grid.mp4"
}

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-DimInactive">
<group name="Effect-diminactive">
<entry name="Strength" type="Int">
<default>25</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-FallApart">
<group name="Effect-fallapart">
<entry name="BlockSize" type="Int">
<default>40</default>
<min>1</min>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Glide">
<group name="Effect-glide">
<entry name="Duration" type="UInt">
<default>0</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Kscreen">
<group name="Effect-kscreen">
<entry name="Duration" type="Int">
<default>0</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-LookingGlass">
<group name="Effect-lookingglass">
<entry name="Radius" type="UInt">
<default>200</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-MagicLamp">
<group name="Effect-magiclamp">
<entry name="AnimationDuration" type="Int">
<default>0</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Magnifier">
<group name="Effect-magnifier">
<entry name="Width" type="UInt">
<default>200</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-MouseClick">
<group name="Effect-mouseclick">
<entry name="Color1" type="Color">
<default code="true">QColor(Qt::red)</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-MouseMark">
<group name="Effect-mousemark">
<entry name="LineWidth" type="UInt">
<default>3</default>
</entry>

View file

@ -68,6 +68,7 @@
"Name[zh_CN]": "桌面概览"
},
"X-KDE-ConfigModule": "kwin_overview_config",
"X-KWin-Border-Activate": true,
"org.kde.kwin.effect": {
"video": "https://files.kde.org/plasma/kwin/effect-videos/present_windows.mp4"
}

View file

@ -9,7 +9,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Overview">
<group name="Effect-overview">
<entry name="LayoutMode" type="Int">
<default>1</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-PresentWindows">
<group name="Effect-presentwindows">
<entry name="LayoutMode" type="Int">
<default>0</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Sheet">
<group name="Effect-sheet">
<entry name="AnimationTime" type="Int">
<default>0</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-ShowFps">
<group name="Effect-showfps">
<entry name="TextPosition" type="Int">
<default>0</default>
</entry>

View file

@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Slide">
<group name="Effect-slide">
<entry name="Duration" type="UInt">
<default>0</default>
</entry>

View file

@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-SlidingPopups">
<group name="Effect-slidingpopups">
<entry name="SlideInTime" type="Int">
<default>0</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-ThumbnailAside">
<group name="Effect-thumbnailaside">
<entry name="MaxWidth" type="Int">
<default>200</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-TrackMouse">
<group name="Effect-trackmouse">
<entry name="Meta" type="Bool">
<default>true</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Wobbly">
<group name="Effect-wobblywindows">
<entry name="WobblynessLevel" type="UInt">
<default>0</default>
</entry>

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Zoom">
<group name="Effect-zoom">
<entry name="ZoomFactor" type="Double">
<default>1.2</default>
</entry>

View file

@ -23,7 +23,7 @@ kcmutils_generate_module_data(
)
ki18n_wrap_ui(kcm_kwinscreenedges_PART_SRCS main.ui)
kconfig_add_kcfg_files(kcm_kwinscreenedges_PART_SRCS kwinscreenedgesettings.kcfgc kwinscreenedgescriptsettings.kcfgc)
kconfig_add_kcfg_files(kcm_kwinscreenedges_PART_SRCS kwinscreenedgesettings.kcfgc kwinscreenedgescriptsettings.kcfgc kwinscreenedgeeffectsettings.kcfgc)
add_library(kcm_kwinscreenedges MODULE ${kcm_kwinscreenedges_PART_SRCS})
set(kcm_screenedges_LIBS
Qt::DBus
@ -54,7 +54,7 @@ kcmutils_generate_module_data(
)
ki18n_wrap_ui(kcm_kwintouchscreenedges_PART_SRCS main.ui touch.ui)
kconfig_add_kcfg_files(kcm_kwintouchscreenedges_PART_SRCS kwintouchscreensettings.kcfgc kwintouchscreenscriptsettings.kcfgc)
kconfig_add_kcfg_files(kcm_kwintouchscreenedges_PART_SRCS kwintouchscreensettings.kcfgc kwintouchscreenscriptsettings.kcfgc kwintouchscreenedgeeffectsettings.kcfgc)
add_library(kcm_kwintouchscreen MODULE ${kcm_kwintouchscreenedges_PART_SRCS})
target_link_libraries(kcm_kwintouchscreen ${X11_LIBRARIES} ${kcm_screenedges_LIBS})

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc">
<parameter name="EffectName"/>
</kcfgfile>
<group name="Effect-$(EffectName)">
<entry key="BorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
</kcfg>

View file

@ -0,0 +1,7 @@
File=kwinscreenedgeeffectsettings.kcfg
NameSpace=KWin
ClassName=KWinScreenEdgeEffectSettings
IncludeFiles=kwinglobals.h
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc">
<parameter name="EffectName"/>
</kcfgfile>
<group name="Effect-$(EffectName)">
<entry key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
</kcfg>

View file

@ -0,0 +1,7 @@
File=kwintouchscreenedgeeffectsettings.kcfg
NameSpace=KWin
ClassName=KWinTouchScreenEdgeEffectSettings
IncludeFiles=kwinglobals.h
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true

View file

@ -29,16 +29,6 @@
<default>ElectricNone</default>
</entry>
</group>
<group name="Effect-DesktopGrid">
<entry name="TouchBorderActivateDesktopGrid" key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
<group name="Effect-Overview">
<entry name="TouchBorderActivateOverview" key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
<group name="TabBox">
<entry name="TouchBorderActivateTabBox" key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>

View file

@ -23,6 +23,7 @@
#include "kwinscreenedgeconfigform.h"
#include "kwinscreenedgedata.h"
#include "kwinscreenedgeeffectsettings.h"
#include "kwinscreenedgescriptsettings.h"
#include "kwinscreenedgesettings.h"
@ -60,6 +61,9 @@ void KWinScreenEdgesConfig::load()
for (KWinScreenEdgeScriptSettings *setting : qAsConst(m_scriptSettings)) {
setting->load();
}
for (KWinScreenEdgeEffectSettings *setting : qAsConst(m_effectSettings)) {
setting->load();
}
monitorLoadSettings();
monitorLoadDefaultSettings();
@ -76,6 +80,9 @@ void KWinScreenEdgesConfig::save()
for (KWinScreenEdgeScriptSettings *setting : qAsConst(m_scriptSettings)) {
setting->save();
}
for (KWinScreenEdgeEffectSettings *setting : qAsConst(m_effectSettings)) {
setting->save();
}
// Reload saved settings to ScreenEdge UI
monitorLoadSettings();
@ -89,9 +96,10 @@ void KWinScreenEdgesConfig::save()
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Effects"),
QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("overview"));
interface.reconfigureEffect(QStringLiteral("presentwindows"));
interface.reconfigureEffect(QStringLiteral("desktopgrid"));
for (const auto &effectId : qAsConst(m_effects)) {
interface.reconfigureEffect(effectId);
}
KCModule::save();
}
@ -122,25 +130,37 @@ void KWinScreenEdgesConfig::monitorInit()
m_form->monitorAddItem(i18n("Activity Manager"));
m_form->monitorAddItem(i18n("Application Launcher"));
// TODO: Find a better way to get the display name of the present windows, the
// desktop grid, and the overview effect. Maybe install metadata.json files?
// TODO: Find a better way to get the display name of the present windows,
// Maybe install metadata.json files?
const QString presentWindowsName = i18n("Present Windows");
m_form->monitorAddItem(i18n("%1 - All Desktops", presentWindowsName));
m_form->monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName));
m_form->monitorAddItem(i18n("%1 - Current Application", presentWindowsName));
m_form->monitorAddItem(i18n("Desktop Grid"));
m_form->monitorAddItem(i18n("Toggle window switching"));
m_form->monitorAddItem(i18n("Toggle alternative window switching"));
m_form->monitorAddItem(i18n("Toggle Overview"));
KConfigGroup config(m_config, "Plugins");
const auto effects = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), QStringLiteral("kwin/builtin-effects/")) << KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), QStringLiteral("kwin/effects/"));
for (const KPluginMetaData &effect : effects) {
if (!effect.value(QStringLiteral("X-KWin-Border-Activate"), false)) {
continue;
}
if (!config.readEntry(effect.pluginId() + QStringLiteral("Enabled"), effect.isEnabledByDefault())) {
continue;
}
m_effects << effect.pluginId();
m_form->monitorAddItem(effect.name());
m_effectSettings[effect.pluginId()] = new KWinScreenEdgeEffectSettings(effect.pluginId(), this);
}
const QString scriptFolder = QStringLiteral("kwin/scripts/");
const auto scripts = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder);
KConfigGroup config(m_config, "Plugins");
for (const KPluginMetaData &script : scripts) {
if (script.value(QStringLiteral("X-KWin-Border-Activate")) != QLatin1String("true")) {
if (script.value(QStringLiteral("X-KWin-Border-Activate")) != true) {
continue;
}
@ -178,21 +198,22 @@ void KWinScreenEdgesConfig::monitorLoadSettings()
// PresentWindows BorderActivateClass
m_form->monitorChangeEdge(m_data->settings()->borderActivateClass(), PresentWindowsClass);
// Desktop Grid
m_form->monitorChangeEdge(m_data->settings()->borderActivateDesktopGrid(), DesktopGrid);
// TabBox
m_form->monitorChangeEdge(m_data->settings()->borderActivateTabBox(), TabBox);
// Alternative TabBox
m_form->monitorChangeEdge(m_data->settings()->borderAlternativeActivate(), TabBoxAlternative);
// Overview
m_form->monitorChangeEdge(m_data->settings()->borderActivateOverview(), Overview);
// Dinamically loaded effects
int lastIndex = EffectCount;
for (int i = 0; i < m_effects.size(); i++) {
m_form->monitorChangeEdge(m_effectSettings[m_effects[i]]->borderActivate(), lastIndex);
++lastIndex;
}
// Scripts
for (int i = 0; i < m_scripts.size(); i++) {
int index = EffectCount + i;
m_form->monitorChangeEdge(m_scriptSettings[m_scripts[i]]->borderActivate(), index);
m_form->monitorChangeEdge(m_scriptSettings[m_scripts[i]]->borderActivate(), lastIndex);
++lastIndex;
}
}
@ -219,16 +240,10 @@ void KWinScreenEdgesConfig::monitorLoadDefaultSettings()
// PresentWindows BorderActivateClass
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultBorderActivateClassValue(), PresentWindowsClass);
// Desktop Grid
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultBorderActivateDesktopGridValue(), DesktopGrid);
// TabBox
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultBorderActivateTabBoxValue(), TabBox);
// Alternative TabBox
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultBorderAlternativeActivateValue(), TabBoxAlternative);
// Overview
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultBorderActivateOverviewValue(), Overview);
}
void KWinScreenEdgesConfig::monitorSaveSettings()
@ -250,20 +265,21 @@ void KWinScreenEdgesConfig::monitorSaveSettings()
m_data->settings()->setBorderActivatePresentWindows(m_form->monitorCheckEffectHasEdge(PresentWindowsCurrent));
m_data->settings()->setBorderActivateClass(m_form->monitorCheckEffectHasEdge(PresentWindowsClass));
// Desktop Grid
m_data->settings()->setBorderActivateDesktopGrid(m_form->monitorCheckEffectHasEdge(DesktopGrid));
// TabBox
m_data->settings()->setBorderActivateTabBox(m_form->monitorCheckEffectHasEdge(TabBox));
m_data->settings()->setBorderAlternativeActivate(m_form->monitorCheckEffectHasEdge(TabBoxAlternative));
// Overview
m_data->settings()->setBorderActivateOverview(m_form->monitorCheckEffectHasEdge(Overview));
// Dinamically loaded effects
int lastIndex = EffectCount;
for (int i = 0; i < m_effects.size(); i++) {
m_effectSettings[m_effects[i]]->setBorderActivate(m_form->monitorCheckEffectHasEdge(lastIndex));
++lastIndex;
}
// Scripts
for (int i = 0; i < m_scripts.size(); i++) {
int index = EffectCount + i;
m_scriptSettings[m_scripts[i]]->setBorderActivate(m_form->monitorCheckEffectHasEdge(index));
m_scriptSettings[m_scripts[i]]->setBorderActivate(m_form->monitorCheckEffectHasEdge(lastIndex));
++lastIndex;
}
}
@ -277,14 +293,6 @@ void KWinScreenEdgesConfig::monitorShowEvent()
m_form->monitorItemSetEnabled(PresentWindowsCurrent, enabled);
m_form->monitorItemSetEnabled(PresentWindowsAll, enabled);
// Desktop Grid
enabled = config.readEntry("desktopgridEnabled", true);
m_form->monitorItemSetEnabled(DesktopGrid, enabled);
// Overview
enabled = config.readEntry("overviewEnabled", true);
m_form->monitorItemSetEnabled(Overview, enabled);
// tabbox, depends on reasonable focus policy.
KConfigGroup config2(m_config, "Windows");
QString focusPolicy = config2.readEntry("FocusPolicy", QString());

View file

@ -23,6 +23,7 @@ namespace KWin
class KWinScreenEdgeData;
class KWinScreenEdgesConfigForm;
class KWinScreenEdgeScriptSettings;
class KWinScreenEdgeEffectSettings;
class KWinScreenEdgesConfig : public KCModule
{
@ -43,18 +44,18 @@ protected:
private:
KWinScreenEdgesConfigForm *m_form;
KSharedConfigPtr m_config;
QStringList m_effects; // list of effect IDs ordered in the list they are presented in the menu
QStringList m_scripts; // list of script IDs ordered in the list they are presented in the menu
QHash<QString, KWinScreenEdgeScriptSettings *> m_scriptSettings;
QHash<QString, KWinScreenEdgeEffectSettings *> m_effectSettings;
KWinScreenEdgeData *m_data;
enum EffectActions {
PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions
PresentWindowsCurrent,
PresentWindowsClass,
DesktopGrid,
TabBox,
TabBoxAlternative,
Overview,
EffectCount
};

View file

@ -23,6 +23,7 @@
#include "kwintouchscreendata.h"
#include "kwintouchscreenedgeconfigform.h"
#include "kwintouchscreenedgeeffectsettings.h"
#include "kwintouchscreenscriptsettings.h"
#include "kwintouchscreensettings.h"
@ -57,6 +58,9 @@ void KWinScreenEdgesConfig::load()
for (KWinTouchScreenScriptSettings *setting : qAsConst(m_scriptSettings)) {
setting->load();
}
for (KWinTouchScreenEdgeEffectSettings *setting : qAsConst(m_effectSettings)) {
setting->load();
}
monitorLoadSettings();
monitorLoadDefaultSettings();
@ -70,6 +74,9 @@ void KWinScreenEdgesConfig::save()
for (KWinTouchScreenScriptSettings *setting : qAsConst(m_scriptSettings)) {
setting->save();
}
for (KWinTouchScreenEdgeEffectSettings *setting : qAsConst(m_effectSettings)) {
setting->save();
}
// Reload saved settings to ScreenEdge UI
monitorLoadSettings();
@ -82,9 +89,10 @@ void KWinScreenEdgesConfig::save()
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Effects"),
QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("overview"));
interface.reconfigureEffect(QStringLiteral("presentwindows"));
interface.reconfigureEffect(QStringLiteral("desktopgrid"));
for (const auto &effectId : qAsConst(m_effects)) {
interface.reconfigureEffect(effectId);
}
KCModule::save();
}
@ -120,32 +128,44 @@ void KWinScreenEdgesConfig::monitorInit()
m_form->monitorAddItem(i18n("Activity Manager"));
m_form->monitorAddItem(i18n("Application Launcher"));
// TODO: Find a better way to get the display name of the present windows, the
// desktop grid, and the overview effect. Maybe install metadata.json files?
// TODO: Find a better way to get the display name of the present windows,
// Maybe install metadata.json files?
const QString presentWindowsName = i18n("Present Windows");
m_form->monitorAddItem(i18n("%1 - All Desktops", presentWindowsName));
m_form->monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName));
m_form->monitorAddItem(i18n("%1 - Current Application", presentWindowsName));
m_form->monitorAddItem(i18n("Desktop Grid"));
m_form->monitorAddItem(i18n("Toggle window switching"));
m_form->monitorAddItem(i18n("Toggle alternative window switching"));
m_form->monitorAddItem(i18n("Toggle Overview"));
KConfigGroup config(m_config, "Plugins");
const auto effects = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), QStringLiteral("kwin/builtin-effects/")) << KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), QStringLiteral("kwin/effects/"));
for (const KPluginMetaData &effect : effects) {
if (!effect.value(QStringLiteral("X-KWin-Border-Activate"), false)) {
continue;
}
if (!config.readEntry(effect.pluginId() + QStringLiteral("Enabled"), effect.isEnabledByDefault())) {
continue;
}
m_effects << effect.pluginId();
m_form->monitorAddItem(effect.name());
m_effectSettings[effect.pluginId()] = new KWinTouchScreenEdgeEffectSettings(effect.pluginId(), this);
}
const QString scriptFolder = QStringLiteral("kwin/scripts/");
const auto scripts = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder);
KConfigGroup config(m_config, "Plugins");
for (const KPluginMetaData &script : scripts) {
if (script.value(QStringLiteral("X-KWin-Border-Activate")) != QLatin1String("true")) {
if (script.value(QStringLiteral("X-KWin-Border-Activate")) != true) {
continue;
}
if (!config.readEntry(script.pluginId() + QStringLiteral("Enabled"), script.isEnabledByDefault())) {
continue;
}
m_scripts << script.pluginId();
m_effects << script.pluginId();
m_form->monitorAddItem(script.name());
m_scriptSettings[script.pluginId()] = new KWinTouchScreenScriptSettings(script.pluginId(), this);
}
@ -170,21 +190,22 @@ void KWinScreenEdgesConfig::monitorLoadSettings()
// PresentWindows BorderActivateClass
m_form->monitorChangeEdge(m_data->settings()->touchBorderActivateClass(), PresentWindowsClass);
// Desktop Grid BorderActivate
m_form->monitorChangeEdge(m_data->settings()->touchBorderActivateDesktopGrid(), DesktopGrid);
// TabBox BorderActivate
m_form->monitorChangeEdge(m_data->settings()->touchBorderActivateTabBox(), TabBox);
// Alternative TabBox
m_form->monitorChangeEdge(m_data->settings()->touchBorderAlternativeActivate(), TabBoxAlternative);
// Overview
m_form->monitorChangeEdge(m_data->settings()->touchBorderActivateOverview(), Overview);
// Dinamically loaded effects
int lastIndex = EffectCount;
for (int i = 0; i < m_effects.size(); i++) {
m_form->monitorChangeEdge(m_effectSettings[m_effects[i]]->touchBorderActivate(), lastIndex);
++lastIndex;
}
// Scripts
for (int i = 0; i < m_scripts.size(); i++) {
int index = EffectCount + i;
m_form->monitorChangeEdge(m_scriptSettings[m_scripts[i]]->touchBorderActivate(), index);
m_form->monitorChangeEdge(m_scriptSettings[m_scripts[i]]->touchBorderActivate(), lastIndex);
++lastIndex;
}
}
@ -202,16 +223,10 @@ void KWinScreenEdgesConfig::monitorLoadDefaultSettings()
// PresentWindows BorderActivateClass
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultTouchBorderActivateClassValue(), PresentWindowsClass);
// Desktop Grid BorderActivate
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultTouchBorderActivateDesktopGridValue(), DesktopGrid);
// TabBox BorderActivate
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultTouchBorderActivateTabBoxValue(), TabBox);
// Alternative TabBox
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultTouchBorderAlternativeActivateValue(), TabBoxAlternative);
// Overview
m_form->monitorChangeDefaultEdge(m_data->settings()->defaultTouchBorderActivateOverviewValue(), Overview);
}
void KWinScreenEdgesConfig::monitorSaveSettings()
@ -229,20 +244,21 @@ void KWinScreenEdgesConfig::monitorSaveSettings()
m_data->settings()->setTouchBorderActivatePresentWindows(m_form->monitorCheckEffectHasEdge(PresentWindowsCurrent));
m_data->settings()->setTouchBorderActivateClass(m_form->monitorCheckEffectHasEdge(PresentWindowsClass));
// Desktop Grid
m_data->settings()->setTouchBorderActivateDesktopGrid(m_form->monitorCheckEffectHasEdge(DesktopGrid));
// TabBox
m_data->settings()->setTouchBorderActivateTabBox(m_form->monitorCheckEffectHasEdge(TabBox));
m_data->settings()->setTouchBorderAlternativeActivate(m_form->monitorCheckEffectHasEdge(TabBoxAlternative));
// Overview
m_data->settings()->setTouchBorderActivateOverview(m_form->monitorCheckEffectHasEdge(Overview));
// Dinamically loaded effects
int lastIndex = EffectCount;
for (int i = 0; i < m_effects.size(); i++) {
m_effectSettings[m_effects[i]]->setTouchBorderActivate(m_form->monitorCheckEffectHasEdge(lastIndex));
++lastIndex;
}
// Scripts
for (int i = 0; i < m_scripts.size(); i++) {
int index = EffectCount + i;
m_scriptSettings[m_scripts[i]]->setTouchBorderActivate(m_form->monitorCheckEffectHasEdge(index));
m_scriptSettings[m_scripts[i]]->setTouchBorderActivate(m_form->monitorCheckEffectHasEdge(lastIndex));
++lastIndex;
}
}
@ -256,14 +272,6 @@ void KWinScreenEdgesConfig::monitorShowEvent()
m_form->monitorItemSetEnabled(PresentWindowsCurrent, enabled);
m_form->monitorItemSetEnabled(PresentWindowsAll, enabled);
// Desktop Grid
enabled = config.readEntry("desktopgridEnabled", true);
m_form->monitorItemSetEnabled(DesktopGrid, enabled);
// Overview
enabled = config.readEntry("overviewEnabled", true);
m_form->monitorItemSetEnabled(Overview, enabled);
// tabbox, depends on reasonable focus policy.
KConfigGroup config2(m_config, "Windows");
QString focusPolicy = config2.readEntry("FocusPolicy", QString());

View file

@ -23,6 +23,7 @@ namespace KWin
class KWinTouchScreenData;
class KWinTouchScreenEdgeConfigForm;
class KWinTouchScreenScriptSettings;
class KWinTouchScreenEdgeEffectSettings;
class KWinScreenEdgesConfig : public KCModule
{
@ -43,18 +44,18 @@ protected:
private:
KWinTouchScreenEdgeConfigForm *m_form;
KSharedConfigPtr m_config;
QStringList m_effects; // list of effect IDs ordered in the list they are presented in the menu
QStringList m_scripts; // list of script IDs ordered in the list they are presented in the menu
QHash<QString, KWinTouchScreenScriptSettings *> m_scriptSettings;
QHash<QString, KWinTouchScreenEdgeEffectSettings *> m_effectSettings;
KWinTouchScreenData *m_data;
enum EffectActions {
PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions
PresentWindowsCurrent,
PresentWindowsClass,
DesktopGrid,
TabBox,
TabBoxAlternative,
Overview,
EffectCount
};