Introduce a method shouldUseWaylandForCompositing() in KWin::Application

Returns true if the OperationMode requires KWin to composite to a
Wayland surface. This replaces the checks for the WaylandBackend or env
variable used so far in the construction of the Scene.
icc-effect-5.14.5
Martin Gräßlin 2013-06-25 09:53:45 +02:00
parent 6eb104b32a
commit 1be3a7a9f0
6 changed files with 21 additions and 7 deletions

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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;

View File

@ -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);

1
main.h
View File

@ -86,6 +86,7 @@ public:
*/
OperationMode operationMode() const;
void setOperationMode(OperationMode mode);
bool shouldUseWaylandForCompositing() const;
static void setCrashCount(int count);
static bool wasCrash();

View File

@ -43,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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();

View File

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<QPainterBackend> backend;
#ifdef WAYLAND_FOUND
if (Wayland::WaylandBackend::self()) {
if (kwinApp()->shouldUseWaylandForCompositing()) {
backend.reset(new WaylandQPainterBackend);
if (backend->isFailed()) {
return NULL;

View File

@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<XRenderBackend> backend;
#ifdef WAYLAND_FOUND
if (Wayland::WaylandBackend::self()) {
if (kwinApp()->shouldUseWaylandForCompositing()) {
backend.reset(new WaylandXRenderBackend);
if (backend->isFailed()) {
return NULL;