From 6eb104b32a5cc7b29890cfd025b0fb3c0ecbe6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 25 Jun 2013 08:52:08 +0200 Subject: [PATCH] Introduce an OperationMode enum This enum describes how KWin is operating with the available windowing systems. By default KWin is using the OperationModeX11, but if the Wayland backend gets started KWin is using the OperationModeWaylandAndX11 This will be extended in future when XWayland and Wayland only become viable options. --- main.cpp | 11 +++++++++++ main.h | 25 +++++++++++++++++++++++++ wayland_backend.cpp | 2 ++ workspace.cpp | 9 +++++++++ 4 files changed, 47 insertions(+) diff --git a/main.cpp b/main.cpp index 9be12fa874..42aa9eb945 100644 --- a/main.cpp +++ b/main.cpp @@ -189,6 +189,7 @@ Application::Application(int &argc, char **argv) , m_eventFilter(new XcbEventFilter()) , m_replace(false) , m_configLock(false) + , m_operationMode(OperationModeWaylandAndX11) { } @@ -202,6 +203,16 @@ void Application::setReplace(bool replace) m_replace = replace; } +Application::OperationMode Application::operationMode() const +{ + return m_operationMode; +} + +void Application::setOperationMode(OperationMode mode) +{ + m_operationMode = mode; +} + void Application::start() { setQuitOnLastWindowClosed(false); diff --git a/main.h b/main.h index 22179babc9..fff5efe486 100644 --- a/main.h +++ b/main.h @@ -55,6 +55,23 @@ class Application : public QApplication { Q_OBJECT public: + /** + * @brief This enum provides the various operation modes of KWin depending on the available + * Windowing Systems at startup. For example whether KWin only talks to X11 or also to a Wayland + * Compositor. + * + */ + enum OperationMode { + /** + * @brief KWin uses only X11 for managing windows and compositing + */ + OperationModeX11, + /** + * @brief KWin uses X11 for managing windows, but renders to a Wayland compositor. + * Input is received from the Wayland compositor. + */ + OperationModeWaylandAndX11 + }; Application(int &argc, char **argv); ~Application(); @@ -62,6 +79,13 @@ public: void setConfigLock(bool lock); void start(); + /** + * @brief The operation mode used by KWin. + * + * @return OperationMode + */ + OperationMode operationMode() const; + void setOperationMode(OperationMode mode); static void setCrashCount(int count); static bool wasCrash(); @@ -80,6 +104,7 @@ private: QScopedPointer m_eventFilter; bool m_replace; bool m_configLock; + OperationMode m_operationMode; static int crashes; }; diff --git a/wayland_backend.cpp b/wayland_backend.cpp index 4cdef7649b..a24a839b22 100644 --- a/wayland_backend.cpp +++ b/wayland_backend.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . #include "wayland_backend.h" // KWin #include "cursor.h" +#include "main.h" // Qt #include #include @@ -645,6 +646,7 @@ WaylandBackend::WaylandBackend(QObject *parent) , m_shm() { qDebug() << "Created Wayland display"; + kwinApp()->setOperationMode(Application::OperationModeWaylandAndX11); // setup the registry wl_registry_add_listener(m_registry, &s_registryListener, this); wl_display_dispatch(m_display); diff --git a/workspace.cpp b/workspace.cpp index e4cd0c00b9..e616b6ef66 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1417,6 +1417,15 @@ QString Workspace::supportInformation() const support.append(QStringLiteral("Qt Version: ")); support.append(QString::fromUtf8(qVersion())); support.append(QStringLiteral("\n\n")); + support.append(QStringLiteral("Operation Mode: ")); + switch (kwinApp()->operationMode()) { + case Application::OperationModeX11: + support.append(QStringLiteral("X11 only")); + break; + case Application::OperationModeWaylandAndX11: + support.append(QStringLiteral("Wayland and X11")); + break; + } support.append(QStringLiteral("Options\n")); support.append(QStringLiteral("=======\n")); const QMetaObject *metaOptions = options->metaObject();