diff --git a/composite.cpp b/composite.cpp index 8c793ea823..6e5c27363b 100644 --- a/composite.cpp +++ b/composite.cpp @@ -232,8 +232,17 @@ void Workspace::finishCompositing() void Workspace::fallbackToXRenderCompositing() { finishCompositing(); - options->compositingMode = XRenderCompositing; - setupCompositing(); + KConfigGroup config(KSharedConfig::openConfig("kwinrc"), "Compositing"); + config.writeEntry("Backend", "XRender"); + config.writeEntry("GraphicsSystem", "native"); + config.sync(); + if (Extensions::nonNativePixmaps()) { // must restart to change the graphicssystem + restartKWin("automatic graphicssystem change for XRender backend"); + return; + } else { + options->compositingMode = XRenderCompositing; + setupCompositing(); + } } void Workspace::lostCMSelection() diff --git a/libkwineffects/kwinglobals.cpp b/libkwineffects/kwinglobals.cpp index 69fc99af1e..575813ee3f 100644 --- a/libkwineffects/kwinglobals.cpp +++ b/libkwineffects/kwinglobals.cpp @@ -134,7 +134,8 @@ void Extensions::init() kDebug(1212) << "Extensions: shape: 0x" << QString::number(shape_version, 16) << " composite: 0x" << QString::number(composite_version, 16) << " render: 0x" << QString::number(render_version, 16) - << " fixes: 0x" << QString::number(fixes_version, 16) << endl; + << " fixes: 0x" << QString::number(fixes_version, 16) + << " non_native_pixmaps: " << non_native_pixmaps << endl; } void Extensions::fillExtensionsData(const char**& extensions, int& nextensions, int*&opcodes, int*& error_bases) diff --git a/main.cpp b/main.cpp index 3773063da2..d61db714b9 100644 --- a/main.cpp +++ b/main.cpp @@ -409,6 +409,22 @@ KDE_EXPORT int kdemain(int argc, char * argv[]) KWorkSpace::trimMalloc(); + // the raster graphicssystem has a quite terrible performance on the XRender backend or when not + // compositing at all while some to many decorations suffer from bad performance of the native + // graphicssystem (lack of implementation, QGradient internally uses the raster system and + // XPutImage's the result because some graphics drivers have insufficient or bad performing + // implementations of XRenderCreate*Gradient) + // + // Therefore we allow configurationa and do some automagic selection to discourage + // ""known to be stupid" ideas ;-P + // The invalid system parameter "" will use the systems default graphicssystem + // "!= XRender" is intended since eg. pot. SW backends likely would profit from raster as well + KConfigGroup config(KSharedConfig::openConfig("kwinrc"), "Compositing"); + QString preferredSystem("native"); + if (config.readEntry("Enabled", true) && config.readEntry("Backend", "OpenGL") != "XRender") + preferredSystem = ""; + QApplication::setGraphicsSystem(config.readEntry("GraphicsSystem", preferredSystem)); + Display* dpy = XOpenDisplay(NULL); if (!dpy) { fprintf(stderr, "%s: FATAL ERROR while trying to open display %s\n", diff --git a/workspace.cpp b/workspace.cpp index 3c67ae6085..b4fd27746d 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1044,10 +1044,24 @@ void Workspace::slotReconfigure() } } +void Workspace::restartKWin(const QString &reason) +{ + kDebug(1212) << "restarting kwin for:" << reason; + char cmd[1024]; // copied from crashhandler - maybe not the best way to do? + sprintf(cmd, "%s --replace &", QFile::encodeName(QCoreApplication::applicationFilePath()).constData()); + system(cmd); +} + void Workspace::slotReinitCompositing() { // Reparse config. Config options will be reloaded by setupCompositing() KGlobal::config()->reparseConfiguration(); + const QString graphicsSystem = KConfigGroup(KSharedConfig::openConfig("kwinrc"), "Compositing").readEntry("GraphicsSystem", ""); + if ((Extensions::nonNativePixmaps() && graphicsSystem == "native") || + (!Extensions::nonNativePixmaps() && (graphicsSystem == "raster" || graphicsSystem == "raster")) ) { + restartKWin("explicitly reconfigured graphicsSystem change"); + return; + } // Update any settings that can be set in the compositing kcm. #ifdef KWIN_BUILD_SCREENEDGES diff --git a/workspace.h b/workspace.h index 60693243d4..9438f3ef03 100644 --- a/workspace.h +++ b/workspace.h @@ -702,6 +702,7 @@ private: void initShortcuts(); void initDesktopPopup(); void initActivityPopup(); + void restartKWin(const QString &reason); void discardPopup(); void setupWindowShortcut(Client* c); void checkCursorPos();