diff --git a/kcmkwin/kwinscreenedges/CMakeLists.txt b/kcmkwin/kwinscreenedges/CMakeLists.txt index 9921b66b2..ddd513ea4 100644 --- a/kcmkwin/kwinscreenedges/CMakeLists.txt +++ b/kcmkwin/kwinscreenedges/CMakeLists.txt @@ -1,27 +1,28 @@ # KI18N Translation Domain for this library add_definitions(-DTRANSLATION_DOMAIN=\"kcmkwinscreenedges\") include_directories(${KWIN_SOURCE_DIR}/effects) set( kcm_kwinscreenedges_PART_SRCS main.cpp monitor.cpp screenpreviewwidget.cpp ) ki18n_wrap_ui( kcm_kwinscreenedges_PART_SRCS main.ui ) qt5_add_dbus_interface( kcm_kwinscreenedges_PART_SRCS ${KWIN_SOURCE_DIR}/org.kde.kwin.Effects.xml kwin_effects_interface) add_library( kcm_kwinscreenedges MODULE ${kcm_kwinscreenedges_PART_SRCS} ) target_link_libraries( kcm_kwinscreenedges ${X11_LIBRARIES} Qt5::DBus KF5::Completion KF5::ConfigCore KF5::ConfigWidgets KF5::I18n KF5::Service + KF5::Package KF5::Plasma kwin4_effect_builtins ) install( TARGETS kcm_kwinscreenedges DESTINATION ${PLUGIN_INSTALL_DIR} ) install( FILES kwinscreenedges.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kcmkwin/kwinscreenedges/main.cpp b/kcmkwin/kwinscreenedges/main.cpp index cf864bc22..975e2d515 100644 --- a/kcmkwin/kwinscreenedges/main.cpp +++ b/kcmkwin/kwinscreenedges/main.cpp @@ -1,499 +1,535 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 Martin Gräßlin Copyright (C) 2009 Lucas Murray This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "main.h" #include #include #include #include #include #include +#include +#include +#include #include K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin();) namespace KWin { KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm(QWidget* parent) : QWidget(parent) { setupUi(this); } KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args) : KCModule(parent, args) , m_config(KSharedConfig::openConfig("kwinrc")) { m_ui = new KWinScreenEdgesConfigForm(this); QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(m_ui); monitorInit(); connect(m_ui->monitor, SIGNAL(changed()), this, SLOT(changed())); connect(m_ui->desktopSwitchCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); connect(m_ui->activationDelaySpin, SIGNAL(valueChanged(int)), this, SLOT(sanitizeCooldown())); connect(m_ui->activationDelaySpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->triggerCooldownSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->quickMaximizeBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); connect(m_ui->quickTileBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); connect(m_ui->electricBorderCornerRatio, SIGNAL(valueChanged(int)), this, SLOT(changed())); // Visual feedback of action group conflicts connect(m_ui->desktopSwitchCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(groupChanged())); connect(m_ui->quickMaximizeBox, SIGNAL(stateChanged(int)), this, SLOT(groupChanged())); connect(m_ui->quickTileBox, SIGNAL(stateChanged(int)), this, SLOT(groupChanged())); load(); sanitizeCooldown(); } KWinScreenEdgesConfig::~KWinScreenEdgesConfig() { } void KWinScreenEdgesConfig::groupChanged() { // Monitor conflicts bool hide = false; if (m_ui->desktopSwitchCombo->currentIndex() == 2) hide = true; monitorHideEdge(ElectricTop, hide); monitorHideEdge(ElectricRight, hide); monitorHideEdge(ElectricBottom, hide); monitorHideEdge(ElectricLeft, hide); } void KWinScreenEdgesConfig::load() { KCModule::load(); monitorLoad(); KConfigGroup config(m_config, "Windows"); m_ui->desktopSwitchCombo->setCurrentIndex(config.readEntry("ElectricBorders", 0)); m_ui->activationDelaySpin->setValue(config.readEntry("ElectricBorderDelay", 150)); m_ui->triggerCooldownSpin->setValue(config.readEntry("ElectricBorderCooldown", 350)); m_ui->quickMaximizeBox->setChecked(config.readEntry("ElectricBorderMaximize", true)); m_ui->quickTileBox->setChecked(config.readEntry("ElectricBorderTiling", true)); m_ui->electricBorderCornerRatio->setValue(qRound(config.readEntry("ElectricBorderCornerRatio", 0.25)*100)); emit changed(false); } void KWinScreenEdgesConfig::save() { KCModule::save(); monitorSave(); KConfigGroup config(m_config, "Windows"); config.writeEntry("ElectricBorders", m_ui->desktopSwitchCombo->currentIndex()); config.writeEntry("ElectricBorderDelay", m_ui->activationDelaySpin->value()); config.writeEntry("ElectricBorderCooldown", m_ui->triggerCooldownSpin->value()); config.writeEntry("ElectricBorderMaximize", m_ui->quickMaximizeBox->isChecked()); config.writeEntry("ElectricBorderTiling", m_ui->quickTileBox->isChecked()); config.writeEntry("ElectricBorderCornerRatio", m_ui->electricBorderCornerRatio->value()/100.0); config.sync(); // Reload KWin. QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); // and reconfigure the effects OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus()); interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::PresentWindows)); interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::DesktopGrid)); interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::Cube)); emit changed(false); } void KWinScreenEdgesConfig::defaults() { monitorDefaults(); m_ui->desktopSwitchCombo->setCurrentIndex(0); m_ui->activationDelaySpin->setValue(150); m_ui->triggerCooldownSpin->setValue(350); m_ui->quickMaximizeBox->setChecked(true); m_ui->quickTileBox->setChecked(true); m_ui->electricBorderCornerRatio->setValue(25); emit changed(true); } void KWinScreenEdgesConfig::showEvent(QShowEvent* e) { KCModule::showEvent(e); monitorShowEvent(); } void KWinScreenEdgesConfig::sanitizeCooldown() { m_ui->triggerCooldownSpin->setMinimum(m_ui->activationDelaySpin->value() + 50); } // Copied from kcmkwin/kwincompositing/main.cpp bool KWinScreenEdgesConfig::effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const { return cfg.readEntry(BuiltInEffects::nameForEffect(effect) + "Enabled", BuiltInEffects::enabledByDefault(effect)); } //----------------------------------------------------------------------------- // Monitor void KWinScreenEdgesConfig::monitorAddItem(const QString& item) { for (int i = 0; i < 8; i++) m_ui->monitor->addEdgeItem(i, item); } void KWinScreenEdgesConfig::monitorItemSetEnabled(int index, bool enabled) { for (int i = 0; i < 8; i++) m_ui->monitor->setEdgeItemEnabled(i, index, enabled); } void KWinScreenEdgesConfig::monitorInit() { monitorAddItem(i18n("No Action")); monitorAddItem(i18n("Show Desktop")); monitorAddItem(i18n("Lock Screen")); monitorAddItem(i18nc("Open krunner", "Run Command")); monitorAddItem(i18n("Activity Manager")); monitorAddItem(i18n("Application Launcher")); // Add the effects const QString presentWindowsName = BuiltInEffects::effectData(BuiltInEffect::PresentWindows).displayName; monitorAddItem(i18n("%1 - All Desktops", presentWindowsName)); monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName)); monitorAddItem(i18n("%1 - Current Application", presentWindowsName)); monitorAddItem(BuiltInEffects::effectData(BuiltInEffect::DesktopGrid).displayName); const QString cubeName = BuiltInEffects::effectData(BuiltInEffect::Cube).displayName; monitorAddItem(i18n("%1 - Cube", cubeName)); monitorAddItem(i18n("%1 - Cylinder", cubeName)); monitorAddItem(i18n("%1 - Sphere", cubeName)); monitorAddItem(i18n("Toggle window switching")); monitorAddItem(i18n("Toggle alternative window switching")); + 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")) { + continue; + } + + if (!config.readEntry(script.pluginId() + QStringLiteral("Enabled"), script.isEnabledByDefault())) { + continue; + } + m_scripts << script.pluginId(); + monitorAddItem(script.name()); + } + monitorShowEvent(); } void KWinScreenEdgesConfig::monitorLoadAction(ElectricBorder edge, const QString& configName) { KConfigGroup config(m_config, "ElectricBorders"); QString lowerName = config.readEntry(configName, "None").toLower(); if (lowerName == "showdesktop") monitorChangeEdge(edge, int(ElectricActionShowDesktop)); else if (lowerName == "lockscreen") monitorChangeEdge(edge, int(ElectricActionLockScreen)); else if (lowerName == "krunner") monitorChangeEdge(edge, int(ElectricActionKRunner)); else if (lowerName == "activitymanager") monitorChangeEdge(edge, int(ElectricActionActivityManager)); else if (lowerName == "applicationlauncher") monitorChangeEdge(edge, int(ElectricActionApplicationLauncher)); } void KWinScreenEdgesConfig::monitorLoad() { // Load ElectricBorderActions monitorLoadAction(ElectricTop, "Top"); monitorLoadAction(ElectricTopRight, "TopRight"); monitorLoadAction(ElectricRight, "Right"); monitorLoadAction(ElectricBottomRight, "BottomRight"); monitorLoadAction(ElectricBottom, "Bottom"); monitorLoadAction(ElectricBottomLeft, "BottomLeft"); monitorLoadAction(ElectricLeft, "Left"); monitorLoadAction(ElectricTopLeft, "TopLeft"); // Load effect-specific actions: // Present Windows KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows"); QList list = QList(); // PresentWindows BorderActivateAll list.append(int(ElectricTopLeft)); list = presentWindowsConfig.readEntry("BorderActivateAll", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(PresentWindowsAll)); } // PresentWindows BorderActivate list.clear(); list.append(int(ElectricNone)); list = presentWindowsConfig.readEntry("BorderActivate", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(PresentWindowsCurrent)); } // PresentWindows BorderActivateClass list.clear(); list.append(int(ElectricNone)); list = presentWindowsConfig.readEntry("BorderActivateClass", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(PresentWindowsClass)); } // Desktop Grid KConfigGroup gridConfig(m_config, "Effect-DesktopGrid"); list.clear(); list.append(int(ElectricNone)); list = gridConfig.readEntry("BorderActivate", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(DesktopGrid)); } // Desktop Cube KConfigGroup cubeConfig(m_config, "Effect-Cube"); list.clear(); list.append(int(ElectricNone)); list = cubeConfig.readEntry("BorderActivate", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(Cube)); } list.clear(); list.append(int(ElectricNone)); list = cubeConfig.readEntry("BorderActivateCylinder", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(Cylinder)); } list.clear(); list.append(int(ElectricNone)); list = cubeConfig.readEntry("BorderActivateSphere", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(Sphere)); } // TabBox KConfigGroup tabBoxConfig(m_config, "TabBox"); list.clear(); // TabBox list.append(int(ElectricNone)); list = tabBoxConfig.readEntry("BorderActivate", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(TabBox)); } // Alternative TabBox list.clear(); list.append(int(ElectricNone)); list = tabBoxConfig.readEntry("BorderAlternativeActivate", list); foreach (int i, list) { monitorChangeEdge(ElectricBorder(i), int(TabBoxAlternative)); } + + for (int i=0; i < m_scripts.size(); i++) { + int index = EffectCount + i; + KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]); + list.append(int(ElectricNone)); + list = scriptConfig.readEntry("BorderActivate", list); + for (int i: list) { + monitorChangeEdge(ElectricBorder(i), index); + } + } } void KWinScreenEdgesConfig::monitorSaveAction(int edge, const QString& configName) { KConfigGroup config(m_config, "ElectricBorders"); int item = m_ui->monitor->selectedEdgeItem(edge); if (item == 1) config.writeEntry(configName, "ShowDesktop"); else if (item == 2) config.writeEntry(configName, "LockScreen"); else if (item == 3) config.writeEntry(configName, "KRunner"); else if (item == 4) config.writeEntry(configName, "ActivityManager"); else if (item == 5) config.writeEntry(configName, "ApplicationLauncher"); else // Anything else config.writeEntry(configName, "None"); } void KWinScreenEdgesConfig::monitorSave() { // Save ElectricBorderActions monitorSaveAction(int(Monitor::Top), "Top"); monitorSaveAction(int(Monitor::TopRight), "TopRight"); monitorSaveAction(int(Monitor::Right), "Right"); monitorSaveAction(int(Monitor::BottomRight), "BottomRight"); monitorSaveAction(int(Monitor::Bottom), "Bottom"); monitorSaveAction(int(Monitor::BottomLeft), "BottomLeft"); monitorSaveAction(int(Monitor::Left), "Left"); monitorSaveAction(int(Monitor::TopLeft), "TopLeft"); // Save effect-specific actions: // Present Windows KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows"); presentWindowsConfig.writeEntry("BorderActivateAll", monitorCheckEffectHasEdge(int(PresentWindowsAll))); presentWindowsConfig.writeEntry("BorderActivate", monitorCheckEffectHasEdge(int(PresentWindowsCurrent))); presentWindowsConfig.writeEntry("BorderActivateClass", monitorCheckEffectHasEdge(int(PresentWindowsClass))); // Desktop Grid KConfigGroup gridConfig(m_config, "Effect-DesktopGrid"); gridConfig.writeEntry("BorderActivate", monitorCheckEffectHasEdge(int(DesktopGrid))); // Desktop Cube KConfigGroup cubeConfig(m_config, "Effect-Cube"); cubeConfig.writeEntry("BorderActivate", monitorCheckEffectHasEdge(int(Cube))); cubeConfig.writeEntry("BorderActivateCylinder", monitorCheckEffectHasEdge(int(Cylinder))); cubeConfig.writeEntry("BorderActivateSphere", monitorCheckEffectHasEdge(int(Sphere))); // TabBox KConfigGroup tabBoxConfig(m_config, "TabBox"); tabBoxConfig.writeEntry("BorderActivate", monitorCheckEffectHasEdge(int(TabBox))); tabBoxConfig.writeEntry("BorderAlternativeActivate", monitorCheckEffectHasEdge(int(TabBoxAlternative))); + + for (int i=0; i < m_scripts.size(); i++) { + int index = EffectCount + i; + KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]); + scriptConfig.writeEntry("BorderActivate", + monitorCheckEffectHasEdge(index)); + } } void KWinScreenEdgesConfig::monitorDefaults() { // Clear all edges for (int i = 0; i < 8; i++) m_ui->monitor->selectEdgeItem(i, 0); // Present windows = Top-left m_ui->monitor->selectEdgeItem(int(Monitor::TopLeft), int(PresentWindowsAll)); } void KWinScreenEdgesConfig::monitorShowEvent() { // Check if they are enabled KConfigGroup config(m_config, "Plugins"); // Present Windows bool enabled = effectEnabled(BuiltInEffect::PresentWindows, config); monitorItemSetEnabled(int(PresentWindowsCurrent), enabled); monitorItemSetEnabled(int(PresentWindowsAll), enabled); // Desktop Grid enabled = effectEnabled(BuiltInEffect::DesktopGrid, config); monitorItemSetEnabled(int(DesktopGrid), enabled); // Desktop Cube enabled = effectEnabled(BuiltInEffect::Cube, config); monitorItemSetEnabled(int(Cube), enabled); monitorItemSetEnabled(int(Cylinder), enabled); monitorItemSetEnabled(int(Sphere), enabled); // tabbox, depends on reasonable focus policy. KConfigGroup config2(m_config, "Windows"); QString focusPolicy = config2.readEntry("FocusPolicy", QString()); bool reasonable = focusPolicy != "FocusStrictlyUnderMouse" && focusPolicy != "FocusUnderMouse"; monitorItemSetEnabled(int(TabBox), reasonable); monitorItemSetEnabled(int(TabBoxAlternative), reasonable); } void KWinScreenEdgesConfig::monitorChangeEdge(ElectricBorder border, int index) { switch(border) { case ElectricTop: m_ui->monitor->selectEdgeItem(int(Monitor::Top), index); break; case ElectricTopRight: m_ui->monitor->selectEdgeItem(int(Monitor::TopRight), index); break; case ElectricRight: m_ui->monitor->selectEdgeItem(int(Monitor::Right), index); break; case ElectricBottomRight: m_ui->monitor->selectEdgeItem(int(Monitor::BottomRight), index); break; case ElectricBottom: m_ui->monitor->selectEdgeItem(int(Monitor::Bottom), index); break; case ElectricBottomLeft: m_ui->monitor->selectEdgeItem(int(Monitor::BottomLeft), index); break; case ElectricLeft: m_ui->monitor->selectEdgeItem(int(Monitor::Left), index); break; case ElectricTopLeft: m_ui->monitor->selectEdgeItem(int(Monitor::TopLeft), index); break; default: // Nothing break; } } void KWinScreenEdgesConfig::monitorHideEdge(ElectricBorder border, bool hidden) { switch(border) { case ElectricTop: m_ui->monitor->setEdgeHidden(int(Monitor::Top), hidden); break; case ElectricTopRight: m_ui->monitor->setEdgeHidden(int(Monitor::TopRight), hidden); break; case ElectricRight: m_ui->monitor->setEdgeHidden(int(Monitor::Right), hidden); break; case ElectricBottomRight: m_ui->monitor->setEdgeHidden(int(Monitor::BottomRight), hidden); break; case ElectricBottom: m_ui->monitor->setEdgeHidden(int(Monitor::Bottom), hidden); break; case ElectricBottomLeft: m_ui->monitor->setEdgeHidden(int(Monitor::BottomLeft), hidden); break; case ElectricLeft: m_ui->monitor->setEdgeHidden(int(Monitor::Left), hidden); break; case ElectricTopLeft: m_ui->monitor->setEdgeHidden(int(Monitor::TopLeft), hidden); break; default: // Nothing break; } } QList KWinScreenEdgesConfig::monitorCheckEffectHasEdge(int index) const { QList list = QList(); if (m_ui->monitor->selectedEdgeItem(int(Monitor::Top)) == index) list.append(int(ElectricTop)); if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopRight)) == index) list.append(int(ElectricTopRight)); if (m_ui->monitor->selectedEdgeItem(int(Monitor::Right)) == index) list.append(int(ElectricRight)); if (m_ui->monitor->selectedEdgeItem(int(Monitor::BottomRight)) == index) list.append(int(ElectricBottomRight)); if (m_ui->monitor->selectedEdgeItem(int(Monitor::Bottom)) == index) list.append(int(ElectricBottom)); if (m_ui->monitor->selectedEdgeItem(int(Monitor::BottomLeft)) == index) list.append(int(ElectricBottomLeft)); if (m_ui->monitor->selectedEdgeItem(int(Monitor::Left)) == index) list.append(int(ElectricLeft)); if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopLeft)) == index) list.append(int(ElectricTopLeft)); if (list.isEmpty()) list.append(int(ElectricNone)); return list; } } // namespace #include "main.moc" diff --git a/kcmkwin/kwinscreenedges/main.h b/kcmkwin/kwinscreenedges/main.h index 16117eef5..4b7eb4fb5 100644 --- a/kcmkwin/kwinscreenedges/main.h +++ b/kcmkwin/kwinscreenedges/main.h @@ -1,96 +1,98 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 Lucas Murray This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #ifndef __MAIN_H__ #define __MAIN_H__ #include #include #include "kwinglobals.h" #include "ui_main.h" class QShowEvent; namespace KWin { enum class BuiltInEffect; class KWinScreenEdgesConfigForm : public QWidget, public Ui::KWinScreenEdgesConfigForm { Q_OBJECT public: explicit KWinScreenEdgesConfigForm(QWidget* parent); }; class KWinScreenEdgesConfig : public KCModule { Q_OBJECT public: explicit KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args); ~KWinScreenEdgesConfig(); public Q_SLOTS: virtual void groupChanged(); virtual void save(); virtual void load(); virtual void defaults(); protected: virtual void showEvent(QShowEvent* e); private Q_SLOTS: void sanitizeCooldown(); private: KWinScreenEdgesConfigForm* m_ui; KSharedConfigPtr m_config; + QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu enum EffectActions { PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions PresentWindowsCurrent, PresentWindowsClass, DesktopGrid, Cube, Cylinder, Sphere, TabBox, - TabBoxAlternative + TabBoxAlternative, + EffectCount }; bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const; void monitorAddItem(const QString& item); void monitorItemSetEnabled(int index, bool enabled); void monitorInit(); void monitorLoadAction(ElectricBorder edge, const QString& configName); void monitorLoad(); void monitorSaveAction(int edge, const QString& configName); void monitorSave(); void monitorDefaults(); void monitorShowEvent(); void monitorChangeEdge(ElectricBorder border, int index); void monitorHideEdge(ElectricBorder border, bool hidden); QList monitorCheckEffectHasEdge(int index) const; }; } // namespace #endif diff --git a/scripting/documentation-global.xml b/scripting/documentation-global.xml index af4d9a0d5..4bef7b35d 100644 --- a/scripting/documentation-global.xml +++ b/scripting/documentation-global.xml @@ -1,142 +1,144 @@ Global Methods and properties added to the global JavaScript object. KWin::Options options Global property to all configuration values of KWin core. KWin::Workspace workspace Global property to the core wrapper of KWin. object KWin Provides access to enums defined in KWin::WorkspaceWrapper Q_SCRIPTABLE void void KWin::Scripting::print (QVariant ... values) print Prints all provided values to kDebug and as a D-Bus signal Q_SCRIPTABLE QVariant QVariant KWin::Scripting::readConfig (QString key, QVariant defaultValue = QVariant()) readConfig Reads the config value for key in the Script's configuration with the optional default value. If not providing a default value and no value stored in the configuration an undefined value is returned. Q_SCRIPTABLE bool bool KWin::Scripting::registerScreenEdge (ElectricBorder border, QScriptValue callback) registerScreenEdge - Registers the callback for the screen edge. When the mouse gets pushed against the given edge the callback will be invoked. + Registers the callback for the screen edge. When the mouse gets pushed against the given edge the callback will be invoked. + Scripts can also add "X-KWin-Border-Activate" to their metadata file to have the effect listed in the screen edges KCM. This will write an entry BorderConfig= in the script configuration object with a list of ScreenEdges the user has selected. + Q_SCRIPTABLE bool bool KWin::Scripting::unregisterScreenEdge (ElectricBorder border) unregisterScreenEdge Unregisters the callback for the screen edge. This will disconnect all callbacks from this script to that edge. Q_SCRIPTABLE bool bool KWin::Scripting::registerShortcut (QString title, QString text, QString keySequence, QScriptValue callback) registerShortcut Registers keySequence as a global shortcut. When the shortcut is invoked the callback will be called. Title and text are used to name the shortcut and make it available to the global shortcut configuration module. Q_SCRIPTABLE bool bool KWin::Scripting::assert (bool value, QString message = QString()) assert Aborts the execution of the script if value does not evaluate to true. If message is provided an error is thrown with the given message, if not provided an error with default message is thrown. Q_SCRIPTABLE bool bool KWin::Scripting::assertTrue (bool value, QString message = QString()) assertTrue Aborts the execution of the script if value does not evaluate to true. If message is provided an error is thrown with the given message, if not provided an error with default message is thrown. Q_SCRIPTABLE bool bool KWin::Scripting::assertFalse (bool value, QString message = QString()) assertFalse Aborts the execution of the script if value does not evaluate to false. If message is provided an error is thrown with the given message, if not provided an error with default message is thrown. Q_SCRIPTABLE bool bool KWin::Scripting::assertEquals (QVariant expected, QVariant actual, QString message = QString()) assertEquals Aborts the execution of the script if the actual value is not equal to the expected value. If message is provided an error is thrown with the given message, if not provided an error with default message is thrown. Q_SCRIPTABLE bool bool KWin::Scripting::assertNull (QVariant value, QString message = QString()) assertNull Aborts the execution of the script if value is not null. If message is provided an error is thrown with the given message, if not provided an error with default message is thrown. Q_SCRIPTABLE bool bool KWin::Scripting::assertNotNull (QVariant value, QString message = QString()) assertNotNull Aborts the execution of the script if value is null. If message is provided an error is thrown with the given message, if not provided an error with default message is thrown. Q_SCRIPTABLE void void KWin::Scripting::callDBus (QString service, QString path, QString interface, QString method, QVariant arg..., QScriptValue callback = QScriptValue()) callDBus Call a D-Bus method at (service, path, interface and method). A variable number of arguments can be added to the method call. The D-Bus call is always performed in an async way invoking the callback provided as the last (optional) argument. The reply values of the D-Bus method call are passed to the callback. Q_SCRIPTABLE void void KWin::Scripting::registerUserActionsMenu (QScriptValue callback) registerUserActionsMenu Registers the passed in callback to be invoked whenever the User actions menu (Alt+F3 or right click on window decoration) is about to be shown. The callback is invoked with a reference to the Client for which the menu is shown. The callback can return either a single menu entry to be added to the menu or an own sub menu with multiple entries. The object for a menu entry should be {title: "My Menu entry", checkable: true, checked: false, triggered: function (action) { // callback with triggered QAction}}, for a menu it should be {title: "My menu", items: [{...}, {...}, ...] /*list with entries as described*/} diff --git a/scripting/kwinscript.desktop b/scripting/kwinscript.desktop index 0c20e8145..e0c0738b9 100644 --- a/scripting/kwinscript.desktop +++ b/scripting/kwinscript.desktop @@ -1,64 +1,67 @@ [Desktop Entry] Type=ServiceType X-KDE-ServiceType=KWin/Script Comment=KWin Script Comment[bs]=KWin skripta Comment[ca]=Script del KWin Comment[ca@valencia]=Script del KWin Comment[cs]=Skript KWinu Comment[da]=KWin-script Comment[de]=KWin-Skript Comment[el]=Σενάριο KWin Comment[en_GB]=KWin Script Comment[es]=Guion de KWin Comment[et]=KWini skript Comment[eu]=KWin scripta Comment[fi]=KWin-skripti Comment[fr]=Script KWin Comment[ga]=Script KWin Comment[gl]=Script do KWin Comment[he]=תוספים של KWin Comment[hu]=KWin parancsfájl Comment[ia]=Script de kwin Comment[id]=Skrip KWin Comment[it]=Script kwin Comment[ja]=KWin Script Comment[kk]=KWin скрипті Comment[km]=ស្គ្រីប KWin Comment[ko]=KWin 스크립트 Comment[lt]=KWin scenarijus Comment[mr]=के-विन स्क्रिप्ट Comment[nb]=KWin-skript Comment[nds]=KWin-Skript Comment[nl]=KWin-script Comment[nn]=KWin-skript Comment[pa]=KWin ਸਕ੍ਰਿਪਟ Comment[pl]=Skrypt KWin Comment[pt]=Programa do KWin Comment[pt_BR]=Script do KWin Comment[ro]=Script KWin Comment[ru]=Сценарий KWin Comment[sk]=KWin skript Comment[sl]=Skript KWin Comment[sr]=К‑винова скрипта Comment[sr@ijekavian]=К‑винова скрипта Comment[sr@ijekavianlatin]=KWinova skripta Comment[sr@latin]=KWinova skripta Comment[sv]=Kwin-skript Comment[tr]=KWin Betiği Comment[ug]=KWin قوليازما Comment[uk]=Скрипт KWin Comment[vi]=Tập lệnh KWin Comment[x-test]=xxKWin Scriptxx Comment[zh_CN]=KWin 脚本 Comment[zh_TW]=KWin 文稿 [PropertyDef::X-Plasma-API] Type=QString [PropertyDef::X-Plasma-MainScript] Type=QString [PropertyDef::X-KWin-Exclude-Listing] Type=bool + +[PropertyDef::X-KWin-Border-Activate] +Type=bool