diff --git a/kcmkwin/kwincompositing/CMakeLists.txt b/kcmkwin/kwincompositing/CMakeLists.txt index 4916a90340..f0ef5dc956 100644 --- a/kcmkwin/kwincompositing/CMakeLists.txt +++ b/kcmkwin/kwincompositing/CMakeLists.txt @@ -77,6 +77,7 @@ set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") set(kwincomposing_SRC model.cpp main.cpp + compositing.cpp effectconfig.cpp) @@ -97,6 +98,7 @@ target_link_libraries(kwincompositing set(modelTest_SRC model.cpp effectconfig.cpp + compositing.cpp test/effectmodeltest.cpp test/modeltest.cpp) diff --git a/kcmkwin/kwincompositing/compositing.cpp b/kcmkwin/kwincompositing/compositing.cpp new file mode 100644 index 0000000000..fd374e977b --- /dev/null +++ b/kcmkwin/kwincompositing/compositing.cpp @@ -0,0 +1,63 @@ +/************************************************************************** +* KWin - the KDE window manager * +* This file is part of the KDE project. * +* * +* Copyright (C) 2013 Antonis Tsiapaliokas * +* * +* 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 "compositing.h" + +#include +#include +#include + +#include +#include +namespace KWin { +namespace Compositing { + +Compositing::Compositing(QObject *parent) + : QObject(parent) +{ +} + +bool Compositing::OpenGLIsUnsafe() { + KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing"); + return kwinConfig.readEntry("OpenGLIsUnsafe", true); +} + +bool Compositing::OpenGLIsBroken() { + QDBusInterface interface(QStringLiteral("org.kde.kwin"), QStringLiteral("/Compositing")); + KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing"); + + QString oldBackend = kwinConfig.readEntry("Backend", "OpenGL"); + kwinConfig.writeEntry("Backend", "OpenGL"); + kwinConfig.sync(); + QDBusReply OpenGLIsBrokenReply = interface.call("OpenGLIsBroken"); + + if (OpenGLIsBrokenReply.value()) { + kwinConfig.writeEntry("Backend", oldBackend); + kwinConfig.sync(); + return true; + } + + kwinConfig.writeEntry("OpenGLIsUnsafe", false); + kwinConfig.sync(); + return false; +} + +}//end namespace Compositing +}//end namespace KWin diff --git a/kcmkwin/kwincompositing/compositing.h b/kcmkwin/kwincompositing/compositing.h new file mode 100644 index 0000000000..c1c85958d2 --- /dev/null +++ b/kcmkwin/kwincompositing/compositing.h @@ -0,0 +1,41 @@ +/************************************************************************** + * KWin - the KDE window manager * + * This file is part of the KDE project. * + * * + * Copyright (C) 2013 Antonis Tsiapaliokas * + * * + * 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 COMPOSITING_H +#define COMPOSITING_H +#include + +namespace KWin { +namespace Compositing { + +class Compositing : public QObject { + + Q_OBJECT + +public: + explicit Compositing(QObject *parent = 0); + + Q_INVOKABLE bool OpenGLIsUnsafe(); + Q_INVOKABLE bool OpenGLIsBroken(); +}; +}//end namespace Compositing +}//end namespace KWin +#endif diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index d61aef09c0..b49158aa95 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -20,6 +20,8 @@ #include "model.h" #include "effectconfig.h" +#include "compositing.h" + #include #include #include @@ -276,6 +278,7 @@ EffectView::EffectView(QWindow *parent) qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectModel"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectFilterModel"); + qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "Compositing"); init(); } diff --git a/kcmkwin/kwincompositing/qml/EffectView.qml b/kcmkwin/kwincompositing/qml/EffectView.qml new file mode 100644 index 0000000000..9217b1c3c7 --- /dev/null +++ b/kcmkwin/kwincompositing/qml/EffectView.qml @@ -0,0 +1,110 @@ +/************************************************************************** +* KWin - the KDE window manager * +* This file is part of the KDE project. * +* * +* Copyright (C) 2013 Antonis Tsiapaliokas * +* * +* 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 . * +**************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 +import org.kde.kwin.kwincompositing 1.0 + +Item { + + Component { + id: sectionHeading + Rectangle { + width: parent.width + height:25 + color: "white" + + Text { + text: section + font.bold: true + font.pointSize: 16 + color: "gray" + } + } + } + + ColumnLayout { + id: col + height: parent.height + anchors { + top: parent.top + left: parent.left + right: parent.right + } + TextField { + id: searchField + Layout.fillWidth: true + height: 20 + anchors { + top: parent.top + } + focus: true + } + + EffectFilterModel { + id:searchModel + filter: searchField.text + effectModel: EffectModel { + id: effectModel + } + } + + + ScrollView { + id: scroll + highlightOnFocus: true + Layout.fillWidth: true + anchors { + top: searchField.bottom + left: parent.left + right: parent.right + bottom: apply.top + } + ListView { + id: effectView + Layout.fillWidth: true + anchors.fill: parent + model: VisualDataModel{ + model: searchModel + delegate: Effect{} + } + + section.property: "CategoryRole" + section.delegate: sectionHeading + } + } + + Button { + id: apply + text: "Apply" + enabled: false + anchors { + bottom: parent.bottom + } + + onClicked: { + effectModel.syncConfig(); + effectModel.reload(); + apply.enabled = false; + } + } + } +} diff --git a/kcmkwin/kwincompositing/qml/main.qml b/kcmkwin/kwincompositing/qml/main.qml index aad371fb75..e7f01f6fa8 100644 --- a/kcmkwin/kwincompositing/qml/main.qml +++ b/kcmkwin/kwincompositing/qml/main.qml @@ -23,91 +23,56 @@ import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import org.kde.kwin.kwincompositing 1.0 + Item { id: window width: 640 height: 480 + property bool openGLBrokeState: true - Component { - id: sectionHeading - Rectangle { - width: parent.width - height:25 - color: "white" - - Text { - text: section - font.bold: true - font.pointSize: 16 - color: "gray" - } - } - } - - ColumnLayout { - id: col - height: parent.height - anchors { - top: parent.top - left: parent.left - right: parent.right - } - TextField { - id: searchField - Layout.fillWidth: true - height: 20 - anchors { - top: parent.top - } - focus: true - } - - EffectFilterModel { - id:searchModel - filter: searchField.text - effectModel: EffectModel { - id: effectModel - } - } - - - ScrollView { - id: scroll - highlightOnFocus: true - Layout.fillWidth: true - anchors { - top: searchField.bottom - left: parent.left - right: parent.right - bottom: apply.top - } - ListView { - id: effectView - Layout.fillWidth: true - anchors.fill: parent - model: VisualDataModel{ - model: searchModel - delegate: Effect{} - } - - section.property: "CategoryRole" - section.delegate: sectionHeading - } + Item { + id: openGLError + visible: false + anchors.fill: parent + anchors.leftMargin: parent.width/2 - 100 + Text { + id: openGLErrorText + text: "OpenGL compositing (the default) has crashed KWin in the past.\n" + + "This was most likely due to a driver bug.\n" + + "If you think that you have meanwhile upgraded to a stable driver,\n" + + "you can reset this protection but be aware that this might result in an immediate crash!\n" + + "Alternatively, you might want to use the XRender backend instead." } Button { - id: apply - text: "Apply" - enabled: false - anchors { - bottom: parent.bottom - } - + id: openGLButton + text: "Re-enable OpenGL detection" + anchors.top: openGLErrorText.bottom onClicked: { - effectModel.syncConfig(); - effectModel.reload(); - apply.enabled = false; + openGLBrokeState = compositing.OpenGLIsBroken(); + view.visible = !openGLBrokeState; + openGLError.visible = openGLBrokeState; } } } + + EffectView{ + id: view + anchors.fill: parent + visible: false + } + + Compositing { + id: compositing + } + + Component.onCompleted: { + if (compositing.OpenGLIsUnsafe()) { + openGLError.visible = true; + } else { + openGLError.visible = false; + console.log("mesa") + view.visible = true; + } + } }