Use xml interfaces to interact with KWin's DBus interfaces
It's a little bit more type safe. REVIEW: 116649
This commit is contained in:
parent
edc399a444
commit
05db7b9f7c
3 changed files with 27 additions and 6 deletions
|
@ -53,6 +53,13 @@ find_package(KF5 CONFIG REQUIRED COMPONENTS CoreAddons Config I18n Service XmlGu
|
|||
|
||||
find_package(KF5Declarative REQUIRED NO_MODULE)
|
||||
|
||||
# Required for KWin's DBus interfaces
|
||||
find_package(KDE4Workspace REQUIRED NO_MODULE)
|
||||
set_package_properties(KDE4Workspace PROPERTIES
|
||||
TYPE REQUIRED
|
||||
PURPOSE "Required for DBus interfaces to KWin"
|
||||
)
|
||||
|
||||
#########################################################################
|
||||
|
||||
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
||||
|
@ -74,6 +81,10 @@ set(kwincomposing_SRC
|
|||
compositing.cpp
|
||||
effectconfig.cpp)
|
||||
|
||||
qt5_add_dbus_interface( kwincomposing_SRC
|
||||
${KDE4WORKSPACE_DBUS_INTERFACES_DIR}/org.kde.kwin.Compositing.xml kwin_compositing_interface)
|
||||
qt5_add_dbus_interface( kwincomposing_SRC
|
||||
${KDE4WORKSPACE_DBUS_INTERFACES_DIR}/org.kde.kwin.Effects.xml kwin_effects_interface)
|
||||
|
||||
add_library(kwincompositing MODULE ${kwincomposing_SRC})
|
||||
|
||||
|
@ -99,6 +110,11 @@ set(modelTest_SRC
|
|||
test/effectmodeltest.cpp
|
||||
test/modeltest.cpp)
|
||||
|
||||
qt5_add_dbus_interface( modelTest_SRC
|
||||
${KDE4WORKSPACE_DBUS_INTERFACES_DIR}/org.kde.kwin.Compositing.xml kwin_compositing_interface)
|
||||
qt5_add_dbus_interface( modelTest_SRC
|
||||
${KDE4WORKSPACE_DBUS_INTERFACES_DIR}/org.kde.kwin.Effects.xml kwin_effects_interface)
|
||||
|
||||
add_executable(effectModelTest ${modelTest_SRC})
|
||||
|
||||
target_link_libraries(effectModelTest
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
**************************************************************************/
|
||||
|
||||
#include "compositing.h"
|
||||
#include <kwin_compositing_interface.h>
|
||||
|
||||
#include <KCModuleProxy>
|
||||
#include <KConfigGroup>
|
||||
|
@ -130,15 +131,16 @@ bool Compositing::OpenGLIsUnsafe() const
|
|||
|
||||
bool Compositing::OpenGLIsBroken()
|
||||
{
|
||||
QDBusInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Compositor"));
|
||||
OrgKdeKwinCompositingInterface interface(QStringLiteral("org.kde.KWin"),
|
||||
QStringLiteral("/Compositor"),
|
||||
QDBusConnection::sessionBus());
|
||||
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()) {
|
||||
if (interface.openGLIsBroken()) {
|
||||
kwinConfig.writeEntry("Backend", oldBackend);
|
||||
kwinConfig.sync();
|
||||
return true;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "model.h"
|
||||
#include "effectconfig.h"
|
||||
#include "compositing.h"
|
||||
#include <kwin_effects_interface.h>
|
||||
|
||||
#include <KPluginInfo>
|
||||
#include <KService>
|
||||
|
@ -235,13 +236,15 @@ int EffectModel::findRowByServiceName(const QString &serviceName)
|
|||
|
||||
void EffectModel::syncEffectsToKWin()
|
||||
{
|
||||
QDBusInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"));
|
||||
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
||||
QStringLiteral("/Effects"),
|
||||
QDBusConnection::sessionBus());
|
||||
for (int it = 0; it < m_effectsList.size(); it++) {
|
||||
if (m_effectsList.at(it).effectStatus != m_effectsChanged.at(it).effectStatus) {
|
||||
if (m_effectsList.at(it).effectStatus) {
|
||||
interface.asyncCall("loadEffect", m_effectsList.at(it).serviceName);
|
||||
interface.loadEffect(m_effectsList.at(it).serviceName);
|
||||
} else {
|
||||
interface.asyncCall("unloadEffect", m_effectsList.at(it).serviceName);
|
||||
interface.unloadEffect(m_effectsList.at(it).serviceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue