diff --git a/scripting/scripting.cpp b/scripting/scripting.cpp
index 3069bd04ba..14434d3fa3 100644
--- a/scripting/scripting.cpp
+++ b/scripting/scripting.cpp
@@ -50,6 +50,7 @@ along with this program. If not, see .
#include
#include
#include
+#include
QScriptValue kwinScriptPrint(QScriptContext *context, QScriptEngine *engine)
{
@@ -556,6 +557,7 @@ void KWin::DeclarativeScript::run()
qmlRegisterType("org.kde.kwin", 2, 0, "ClientModelByScreenAndDesktop");
qmlRegisterType("org.kde.kwin", 2, 0, "ClientFilterModel");
qmlRegisterType();
+ qmlRegisterType();
m_engine->rootContext()->setContextProperty(QStringLiteral("workspace"), AbstractScript::workspace());
m_engine->rootContext()->setContextProperty(QStringLiteral("options"), options);
@@ -594,6 +596,15 @@ QVariant KWin::JSEngineGlobalMethodsWrapper::readConfig(const QString &key, QVar
return m_script->config().readEntry(key, defaultValue);
}
+void KWin::JSEngineGlobalMethodsWrapper::registerWindow(QQuickWindow *window)
+{
+ connect(window, &QWindow::visibilityChanged, [window](QWindow::Visibility visibility) {
+ if (visibility == QWindow::Hidden) {
+ window->destroy();
+ }
+ });
+}
+
KWin::Scripting *KWin::Scripting::s_self = NULL;
KWin::Scripting *KWin::Scripting::create(QObject *parent)
diff --git a/scripting/scripting.h b/scripting/scripting.h
index 3a0f89a6ef..a7f991d88c 100644
--- a/scripting/scripting.h
+++ b/scripting/scripting.h
@@ -39,6 +39,7 @@ class QMenu;
class QMutex;
class QScriptEngine;
class QScriptValue;
+class QQuickWindow;
class KConfigGroup;
/// @c true == javascript, @c false == qml
@@ -315,6 +316,7 @@ public:
public Q_SLOTS:
QVariant readConfig(const QString &key, QVariant defaultValue = QVariant());
+ void registerWindow(QQuickWindow *window);
private:
DeclarativeScript *m_script;
diff --git a/scripts/desktopchangeosd/contents/ui/osd.qml b/scripts/desktopchangeosd/contents/ui/osd.qml
index 44032f3fba..dc038d39ed 100644
--- a/scripts/desktopchangeosd/contents/ui/osd.qml
+++ b/scripts/desktopchangeosd/contents/ui/osd.qml
@@ -294,4 +294,8 @@ PlasmaCore.Dialog {
dialogItem.show();
}
}
+
+ Component.onCompleted: {
+ KWin.registerWindow(dialog);
+ }
}