Work around problem of restored QQuickWindows not being visible
A declarative KWin script needs to register the QQuickWindows it is using in the KWin object. This method ensures that the QQuickWindow will destroy the platfrom window once it gets hidden. So the next time the QQuickWindow is shown a new platform window is created. As can be seen in the OSD this is not really nice, therefore a KWin.Dialog should be created which takes care of these steps.
This commit is contained in:
parent
d7a3a497d1
commit
17553e5a1f
3 changed files with 17 additions and 0 deletions
|
@ -50,6 +50,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptValue>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <QQuickWindow>
|
||||
|
||||
QScriptValue kwinScriptPrint(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
|
@ -556,6 +557,7 @@ void KWin::DeclarativeScript::run()
|
|||
qmlRegisterType<KWin::ScriptingClientModel::ClientModelByScreenAndDesktop>("org.kde.kwin", 2, 0, "ClientModelByScreenAndDesktop");
|
||||
qmlRegisterType<KWin::ScriptingClientModel::ClientFilterModel>("org.kde.kwin", 2, 0, "ClientFilterModel");
|
||||
qmlRegisterType<KWin::Client>();
|
||||
qmlRegisterType<QQuickWindow>();
|
||||
|
||||
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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -294,4 +294,8 @@ PlasmaCore.Dialog {
|
|||
dialogItem.show();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
KWin.registerWindow(dialog);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue