Check if OpenGLisBroken
This commit is contained in:
parent
52fd2c12a2
commit
16a066db78
6 changed files with 259 additions and 75 deletions
|
@ -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)
|
||||
|
||||
|
|
63
kcmkwin/kwincompositing/compositing.cpp
Normal file
63
kcmkwin/kwincompositing/compositing.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
/**************************************************************************
|
||||
* KWin - the KDE window manager *
|
||||
* This file is part of the KDE project. *
|
||||
* *
|
||||
* Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
**************************************************************************/
|
||||
|
||||
#include "compositing.h"
|
||||
|
||||
#include <KDE/KCModuleProxy>
|
||||
#include <KConfigGroup>
|
||||
#include <KDE/KSharedConfig>
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
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<bool> 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
|
41
kcmkwin/kwincompositing/compositing.h
Normal file
41
kcmkwin/kwincompositing/compositing.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**************************************************************************
|
||||
* KWin - the KDE window manager *
|
||||
* This file is part of the KDE project. *
|
||||
* *
|
||||
* Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef COMPOSITING_H
|
||||
#define COMPOSITING_H
|
||||
#include <QObject>
|
||||
|
||||
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
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "model.h"
|
||||
#include "effectconfig.h"
|
||||
#include "compositing.h"
|
||||
|
||||
#include <KDE/KPluginInfo>
|
||||
#include <KDE/KService>
|
||||
#include <KDE/KServiceTypeTrader>
|
||||
|
@ -276,6 +278,7 @@ EffectView::EffectView(QWindow *parent)
|
|||
qmlRegisterType<EffectModel>("org.kde.kwin.kwincompositing", 1, 0, "EffectModel");
|
||||
qmlRegisterType<EffectConfig>("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig");
|
||||
qmlRegisterType<EffectFilterModel>("org.kde.kwin.kwincompositing", 1, 0, "EffectFilterModel");
|
||||
qmlRegisterType<Compositing>("org.kde.kwin.kwincompositing", 1, 0, "Compositing");
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
110
kcmkwin/kwincompositing/qml/EffectView.qml
Normal file
110
kcmkwin/kwincompositing/qml/EffectView.qml
Normal file
|
@ -0,0 +1,110 @@
|
|||
/**************************************************************************
|
||||
* KWin - the KDE window manager *
|
||||
* This file is part of the KDE project. *
|
||||
* *
|
||||
* Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
**************************************************************************/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue