diff --git a/compositingprefs.cpp b/compositingprefs.cpp index c0b2963eca..631e4ce2bc 100644 --- a/compositingprefs.cpp +++ b/compositingprefs.cpp @@ -20,6 +20,7 @@ along with this program. If not, see . #include "compositingprefs.h" +#include "main.h" #include "xcbutils.h" #include "kwinglplatform.h" @@ -62,6 +63,11 @@ bool CompositingPrefs::compositingPossible() gl_workaround_group.readEntry(unsafeKey, false)) return false; + if (kwinApp()->shouldUseWaylandForCompositing()) { + // don't do X specific checks if we are not going to use X for compositing + return true; + } + if (!Xcb::Extensions::self()->isCompositeAvailable()) { qDebug() << "No composite extension available"; return false; diff --git a/main.cpp b/main.cpp index 42aa9eb945..cc36c13085 100644 --- a/main.cpp +++ b/main.cpp @@ -213,6 +213,11 @@ void Application::setOperationMode(OperationMode mode) m_operationMode = mode; } +bool Application::shouldUseWaylandForCompositing() const +{ + return m_operationMode == OperationModeWaylandAndX11; +} + void Application::start() { setQuitOnLastWindowClosed(false); diff --git a/main.h b/main.h index fff5efe486..4911c18bad 100644 --- a/main.h +++ b/main.h @@ -86,6 +86,7 @@ public: */ OperationMode operationMode() const; void setOperationMode(OperationMode mode); + bool shouldUseWaylandForCompositing() const; static void setCrashCount(int count); static bool wasCrash(); diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 09079cd921..c6b141c1ef 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -43,6 +43,7 @@ along with this program. If not, see . #include "deleted.h" #include "effects.h" #include "lanczosfilter.h" +#include "main.h" #include "overlaywindow.h" #include "paintredirector.h" #include "screens.h" @@ -198,8 +199,8 @@ SceneOpenGL *SceneOpenGL::createScene() OpenGLPlatformInterface platformInterface = NoOpenGLPlatformInterface; // should we use glx? #ifndef KWIN_HAVE_OPENGLES - // on OpenGL we default to glx - platformInterface = GlxPlatformInterface; + // on OpenGL we default to glx on X11 and to egl on Wayland + platformInterface = kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface; #endif const QByteArray envOpenGLInterface(qgetenv("KWIN_OPENGL_INTERFACE")); @@ -209,8 +210,7 @@ SceneOpenGL *SceneOpenGL::createScene() platformInterface = EglPlatformInterface; #else // check environment variable - if (qstrcmp(envOpenGLInterface, "egl") == 0 || - qstrcmp(envOpenGLInterface, "egl_wayland") == 0) { + if (qstrcmp(envOpenGLInterface, "egl") == 0) { qDebug() << "Forcing EGL native interface through environment variable"; platformInterface = EglPlatformInterface; } @@ -226,7 +226,7 @@ SceneOpenGL *SceneOpenGL::createScene() case EglPlatformInterface: #ifdef KWIN_HAVE_EGL #ifdef WAYLAND_FOUND - if (qstrcmp(envOpenGLInterface, "egl_wayland") == 0) { + if (kwinApp()->shouldUseWaylandForCompositing()) { backend = new EglWaylandBackend(); } else { backend = new EglOnXBackend(); diff --git a/scene_qpainter.cpp b/scene_qpainter.cpp index 35dae41748..e272474a92 100644 --- a/scene_qpainter.cpp +++ b/scene_qpainter.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include "composite.h" #include "deleted.h" #include "effects.h" +#include "main.h" #include "paintredirector.h" #include "toplevel.h" #ifdef WAYLAND_FOUND @@ -209,7 +210,7 @@ SceneQPainter *SceneQPainter::createScene() { QScopedPointer backend; #ifdef WAYLAND_FOUND - if (Wayland::WaylandBackend::self()) { + if (kwinApp()->shouldUseWaylandForCompositing()) { backend.reset(new WaylandQPainterBackend); if (backend->isFailed()) { return NULL; diff --git a/scene_xrender.cpp b/scene_xrender.cpp index 693af1dd72..13803117e5 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -29,6 +29,7 @@ along with this program. If not, see . #include "decorations.h" #include "deleted.h" #include "effects.h" +#include "main.h" #include "overlaywindow.h" #include "paintredirector.h" #include "workspace.h" @@ -367,7 +368,7 @@ SceneXrender* SceneXrender::createScene() { QScopedPointer backend; #ifdef WAYLAND_FOUND - if (Wayland::WaylandBackend::self()) { + if (kwinApp()->shouldUseWaylandForCompositing()) { backend.reset(new WaylandXRenderBackend); if (backend->isFailed()) { return NULL;