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.
This commit is contained in:
parent
6eb104b32a
commit
1be3a7a9f0
6 changed files with 21 additions and 7 deletions
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "compositingprefs.h"
|
#include "compositingprefs.h"
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
#include "xcbutils.h"
|
#include "xcbutils.h"
|
||||||
#include "kwinglplatform.h"
|
#include "kwinglplatform.h"
|
||||||
|
|
||||||
|
@ -62,6 +63,11 @@ bool CompositingPrefs::compositingPossible()
|
||||||
gl_workaround_group.readEntry(unsafeKey, false))
|
gl_workaround_group.readEntry(unsafeKey, false))
|
||||||
return 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()) {
|
if (!Xcb::Extensions::self()->isCompositeAvailable()) {
|
||||||
qDebug() << "No composite extension available";
|
qDebug() << "No composite extension available";
|
||||||
return false;
|
return false;
|
||||||
|
|
5
main.cpp
5
main.cpp
|
@ -213,6 +213,11 @@ void Application::setOperationMode(OperationMode mode)
|
||||||
m_operationMode = mode;
|
m_operationMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::shouldUseWaylandForCompositing() const
|
||||||
|
{
|
||||||
|
return m_operationMode == OperationModeWaylandAndX11;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::start()
|
void Application::start()
|
||||||
{
|
{
|
||||||
setQuitOnLastWindowClosed(false);
|
setQuitOnLastWindowClosed(false);
|
||||||
|
|
1
main.h
1
main.h
|
@ -86,6 +86,7 @@ public:
|
||||||
*/
|
*/
|
||||||
OperationMode operationMode() const;
|
OperationMode operationMode() const;
|
||||||
void setOperationMode(OperationMode mode);
|
void setOperationMode(OperationMode mode);
|
||||||
|
bool shouldUseWaylandForCompositing() const;
|
||||||
|
|
||||||
static void setCrashCount(int count);
|
static void setCrashCount(int count);
|
||||||
static bool wasCrash();
|
static bool wasCrash();
|
||||||
|
|
|
@ -43,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "deleted.h"
|
#include "deleted.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
#include "lanczosfilter.h"
|
#include "lanczosfilter.h"
|
||||||
|
#include "main.h"
|
||||||
#include "overlaywindow.h"
|
#include "overlaywindow.h"
|
||||||
#include "paintredirector.h"
|
#include "paintredirector.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
|
@ -198,8 +199,8 @@ SceneOpenGL *SceneOpenGL::createScene()
|
||||||
OpenGLPlatformInterface platformInterface = NoOpenGLPlatformInterface;
|
OpenGLPlatformInterface platformInterface = NoOpenGLPlatformInterface;
|
||||||
// should we use glx?
|
// should we use glx?
|
||||||
#ifndef KWIN_HAVE_OPENGLES
|
#ifndef KWIN_HAVE_OPENGLES
|
||||||
// on OpenGL we default to glx
|
// on OpenGL we default to glx on X11 and to egl on Wayland
|
||||||
platformInterface = GlxPlatformInterface;
|
platformInterface = kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const QByteArray envOpenGLInterface(qgetenv("KWIN_OPENGL_INTERFACE"));
|
const QByteArray envOpenGLInterface(qgetenv("KWIN_OPENGL_INTERFACE"));
|
||||||
|
@ -209,8 +210,7 @@ SceneOpenGL *SceneOpenGL::createScene()
|
||||||
platformInterface = EglPlatformInterface;
|
platformInterface = EglPlatformInterface;
|
||||||
#else
|
#else
|
||||||
// check environment variable
|
// check environment variable
|
||||||
if (qstrcmp(envOpenGLInterface, "egl") == 0 ||
|
if (qstrcmp(envOpenGLInterface, "egl") == 0) {
|
||||||
qstrcmp(envOpenGLInterface, "egl_wayland") == 0) {
|
|
||||||
qDebug() << "Forcing EGL native interface through environment variable";
|
qDebug() << "Forcing EGL native interface through environment variable";
|
||||||
platformInterface = EglPlatformInterface;
|
platformInterface = EglPlatformInterface;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ SceneOpenGL *SceneOpenGL::createScene()
|
||||||
case EglPlatformInterface:
|
case EglPlatformInterface:
|
||||||
#ifdef KWIN_HAVE_EGL
|
#ifdef KWIN_HAVE_EGL
|
||||||
#ifdef WAYLAND_FOUND
|
#ifdef WAYLAND_FOUND
|
||||||
if (qstrcmp(envOpenGLInterface, "egl_wayland") == 0) {
|
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||||
backend = new EglWaylandBackend();
|
backend = new EglWaylandBackend();
|
||||||
} else {
|
} else {
|
||||||
backend = new EglOnXBackend();
|
backend = new EglOnXBackend();
|
||||||
|
|
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "composite.h"
|
#include "composite.h"
|
||||||
#include "deleted.h"
|
#include "deleted.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
|
#include "main.h"
|
||||||
#include "paintredirector.h"
|
#include "paintredirector.h"
|
||||||
#include "toplevel.h"
|
#include "toplevel.h"
|
||||||
#ifdef WAYLAND_FOUND
|
#ifdef WAYLAND_FOUND
|
||||||
|
@ -209,7 +210,7 @@ SceneQPainter *SceneQPainter::createScene()
|
||||||
{
|
{
|
||||||
QScopedPointer<QPainterBackend> backend;
|
QScopedPointer<QPainterBackend> backend;
|
||||||
#ifdef WAYLAND_FOUND
|
#ifdef WAYLAND_FOUND
|
||||||
if (Wayland::WaylandBackend::self()) {
|
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||||
backend.reset(new WaylandQPainterBackend);
|
backend.reset(new WaylandQPainterBackend);
|
||||||
if (backend->isFailed()) {
|
if (backend->isFailed()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "decorations.h"
|
#include "decorations.h"
|
||||||
#include "deleted.h"
|
#include "deleted.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
|
#include "main.h"
|
||||||
#include "overlaywindow.h"
|
#include "overlaywindow.h"
|
||||||
#include "paintredirector.h"
|
#include "paintredirector.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
@ -367,7 +368,7 @@ SceneXrender* SceneXrender::createScene()
|
||||||
{
|
{
|
||||||
QScopedPointer<XRenderBackend> backend;
|
QScopedPointer<XRenderBackend> backend;
|
||||||
#ifdef WAYLAND_FOUND
|
#ifdef WAYLAND_FOUND
|
||||||
if (Wayland::WaylandBackend::self()) {
|
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||||
backend.reset(new WaylandXRenderBackend);
|
backend.reset(new WaylandXRenderBackend);
|
||||||
if (backend->isFailed()) {
|
if (backend->isFailed()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue