diff --git a/CMakeLists.txt b/CMakeLists.txt index f2c28f7..1a9fcba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,11 +23,11 @@ include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMSetupVersion) include(ECMGenerateHeaders) -include(CheckIncludeFiles) include(CMakePackageConfigHelpers) include(FeatureSummary) include(GenerateExportHeader) include(KDEClangFormat) +include(ECMQtDeclareLoggingCategory) find_package(WaylandScanner) find_package(QtWaylandScanner) @@ -36,7 +36,6 @@ find_package(WaylandProtocols) set_package_properties(Wayland PROPERTIES TYPE REQUIRED) -# adjusting CMAKE_C_FLAGS to get wayland protocols to compile set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX LAYERSHELLQT @@ -44,7 +43,8 @@ ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX LAYERSHELLQT PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LayerShellQtConfigVersion.cmake" SOVERSION 5) -include(ECMQtDeclareLoggingCategory) +file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) +kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) add_subdirectory(src) add_subdirectory(tests) diff --git a/src/interfaces/shell.cpp b/src/interfaces/shell.cpp index 19d8269..d9595e2 100644 --- a/src/interfaces/shell.cpp +++ b/src/interfaces/shell.cpp @@ -5,8 +5,8 @@ */ #include "shell.h" -#include #include +#include using namespace LayerShellQt; diff --git a/src/interfaces/shell.h b/src/interfaces/shell.h index 5160d78..cccae17 100644 --- a/src/interfaces/shell.h +++ b/src/interfaces/shell.h @@ -11,11 +11,11 @@ namespace LayerShellQt { - /** * Sets the right environment so the shells created from now on use wlr-layer-shell. */ -class LAYERSHELLQT_EXPORT Shell { +class LAYERSHELLQT_EXPORT Shell +{ public: static void useLayerShell(); }; diff --git a/src/interfaces/window.cpp b/src/interfaces/window.cpp index 2e90eb6..9239981 100644 --- a/src/interfaces/window.cpp +++ b/src/interfaces/window.cpp @@ -5,10 +5,10 @@ */ #include "window.h" -#include -#include -#include #include "../qwaylandlayersurface_p.h" +#include +#include +#include using namespace LayerShellQt; @@ -47,7 +47,8 @@ void Window::setKeyboardInteractivity(bool enabled) Window::Window(WindowPrivate *d) : d(d) -{} +{ +} Window *Window::get(QWindow *window) { @@ -56,7 +57,7 @@ Window *Window::get(QWindow *window) qCDebug(LAYERSHELLQT) << "window not a wayland window" << window; return nullptr; } - QWaylandLayerSurface* s = qobject_cast(ww->shellSurface()); + QWaylandLayerSurface *s = qobject_cast(ww->shellSurface()); if (!s) { qCDebug(LAYERSHELLQT) << "window not using wlr-layer-shell" << window << ww->shellSurface(); return nullptr; diff --git a/src/qwaylandlayershell.cpp b/src/qwaylandlayershell.cpp index 2df469d..7c87370 100644 --- a/src/qwaylandlayershell.cpp +++ b/src/qwaylandlayershell.cpp @@ -10,8 +10,8 @@ #include -namespace LayerShellQt { - +namespace LayerShellQt +{ QWaylandLayerShell::QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell) : QtWayland::zwlr_layer_shell_v1(shell->object()) { @@ -22,8 +22,7 @@ QWaylandLayerShell::~QWaylandLayerShell() zwlr_layer_shell_v1_destroy(object()); } -QWaylandLayerSurface *QWaylandLayerShell::createLayerSurface( - QtWaylandClient::QWaylandWindow *window) +QWaylandLayerSurface *QWaylandLayerShell::createLayerSurface(QtWaylandClient::QWaylandWindow *window) { return new QWaylandLayerSurface(this, window); } diff --git a/src/qwaylandlayershell_p.h b/src/qwaylandlayershell_p.h index 25fae6a..4a5810f 100644 --- a/src/qwaylandlayershell_p.h +++ b/src/qwaylandlayershell_p.h @@ -10,21 +10,20 @@ #include -#include #include +#include #include "qwaylandlayersurface_p.h" -namespace LayerShellQt { - +namespace LayerShellQt +{ class LAYERSHELLQT_EXPORT QWaylandLayerShell : public QtWayland::zwlr_layer_shell_v1 { public: QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell); virtual ~QWaylandLayerShell(); - QWaylandLayerSurface *createLayerSurface( - QtWaylandClient::QWaylandWindow *window); + QWaylandLayerSurface *createLayerSurface(QtWaylandClient::QWaylandWindow *window); // TODO: Popups }; diff --git a/src/qwaylandlayershellintegration.cpp b/src/qwaylandlayershellintegration.cpp index eb14d3d..3c68f0d 100644 --- a/src/qwaylandlayershellintegration.cpp +++ b/src/qwaylandlayershellintegration.cpp @@ -5,17 +5,17 @@ * SPDX-License-Identifier: LGPL-3.0-or-later */ -#include "qwaylandlayershellintegration_p.h" #include "qwaylandlayershell_p.h" +#include "qwaylandlayershellintegration_p.h" -#include -#include #include +#include +#include -namespace LayerShellQt { - -QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() : - m_layerShell(Q_NULLPTR) +namespace LayerShellQt +{ +QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() + : m_layerShell(Q_NULLPTR) { } @@ -26,22 +26,17 @@ bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay return m_layerShell != nullptr; } -QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration:: - createShellSurface(QtWaylandClient::QWaylandWindow *window) +QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow *window) { return m_layerShell->createLayerSurface(window); } -void QWaylandLayerShellIntegration::registryLayer(void *data, - struct wl_registry *registry, uint32_t id, - const QString &interface, uint32_t version) +void QWaylandLayerShellIntegration::registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) { - QWaylandLayerShellIntegration *shell = - static_cast(data); + QWaylandLayerShellIntegration *shell = static_cast(data); if (interface == QStringLiteral("zwlr_layer_shell_v1")) - shell->m_layerShell = new QWaylandLayerShell( - new QtWayland::zwlr_layer_shell_v1(registry, id, version)); + shell->m_layerShell = new QWaylandLayerShell(new QtWayland::zwlr_layer_shell_v1(registry, id, version)); } } diff --git a/src/qwaylandlayershellintegration_p.h b/src/qwaylandlayershellintegration_p.h index 04743cc..c22fad0 100644 --- a/src/qwaylandlayershellintegration_p.h +++ b/src/qwaylandlayershellintegration_p.h @@ -10,11 +10,11 @@ #include -#include #include "layershellqt_export.h" +#include -namespace LayerShellQt { - +namespace LayerShellQt +{ class QWaylandLayerShell; class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegration @@ -23,12 +23,10 @@ public: QWaylandLayerShellIntegration(); bool initialize(QtWaylandClient::QWaylandDisplay *display) override; - QtWaylandClient::QWaylandShellSurface *createShellSurface( - QtWaylandClient::QWaylandWindow *window) override; + QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override; private: - static void registryLayer(void *data, struct wl_registry *registry, - uint32_t id, const QString &interface, uint32_t version); + static void registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version); QWaylandLayerShell *m_layerShell; }; diff --git a/src/qwaylandlayershellintegrationplugin.cpp b/src/qwaylandlayershellintegrationplugin.cpp index b3152a2..7b61935 100644 --- a/src/qwaylandlayershellintegrationplugin.cpp +++ b/src/qwaylandlayershellintegrationplugin.cpp @@ -5,27 +5,26 @@ * SPDX-License-Identifier: LGPL-3.0-or-later */ -#include #include "qwaylandlayershellintegration_p.h" +#include using namespace LayerShellQt; -class QWaylandLayerShellIntegrationPlugin : - public QtWaylandClient::QWaylandShellIntegrationPlugin +class QWaylandLayerShellIntegrationPlugin : public QtWaylandClient::QWaylandShellIntegrationPlugin { - Q_OBJECT - Q_PLUGIN_METADATA( - IID QWaylandShellIntegrationFactoryInterface_iid - FILE "layer-shell.json") + Q_OBJECT + Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "layer-shell.json") public: - QWaylandLayerShellIntegrationPlugin() {} + QWaylandLayerShellIntegrationPlugin() + { + } - QtWaylandClient::QWaylandShellIntegration *create( - const QString &key, const QStringList ¶mList) override { - Q_UNUSED(key); - Q_UNUSED(paramList); - return new QWaylandLayerShellIntegration(); + QtWaylandClient::QWaylandShellIntegration *create(const QString &key, const QStringList ¶mList) override + { + Q_UNUSED(key); + Q_UNUSED(paramList); + return new QWaylandLayerShellIntegration(); } }; diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index d544a79..b9abc46 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -8,21 +8,21 @@ #include "qwaylandlayershell_p.h" #include "qwaylandlayersurface_p.h" -#include -#include -#include #include +#include +#include +#include -namespace LayerShellQt { - +namespace LayerShellQt +{ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandClient::QWaylandWindow *window) : QtWaylandClient::QWaylandShellSurface(window) , QtWayland::zwlr_layer_surface_v1( - // TODO: Specify namespace - shell->get_layer_surface(window->waylandSurface()->object(), - window->waylandScreen()->output(), - QtWayland::zwlr_layer_shell_v1::layer_top, - QStringLiteral("qt"))) + // TODO: Specify namespace + shell->get_layer_surface(window->waylandSurface()->object(), + window->waylandScreen()->output(), + QtWayland::zwlr_layer_shell_v1::layer_top, + QStringLiteral("qt"))) { set_anchor(anchor_top | anchor_bottom | anchor_left | anchor_right); } @@ -37,8 +37,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_closed() window()->window()->close(); } -void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, - uint32_t width, uint32_t height) +void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) { ack_configure(serial); m_pendingSize = QSize(width, height); diff --git a/src/qwaylandlayersurface_p.h b/src/qwaylandlayersurface_p.h index 3115267..bd062d9 100644 --- a/src/qwaylandlayersurface_p.h +++ b/src/qwaylandlayersurface_p.h @@ -10,24 +10,23 @@ #include -#include -#include #include "layershellqt_export.h" +#include +#include -namespace LayerShellQt { - +namespace LayerShellQt +{ class QWaylandLayerShell; -class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylandShellSurface, - public QtWayland::zwlr_layer_surface_v1 +class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylandShellSurface, public QtWayland::zwlr_layer_surface_v1 { Q_OBJECT public: - QWaylandLayerSurface(QWaylandLayerShell *shell, - QtWaylandClient::QWaylandWindow *window); + QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandClient::QWaylandWindow *window); virtual ~QWaylandLayerSurface(); - bool isExposed() const override { + bool isExposed() const override + { return m_configured; } @@ -39,8 +38,7 @@ public: void applyConfigure() override; private: - void zwlr_layer_surface_v1_configure(uint32_t serial, - uint32_t width, uint32_t height) override; + void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override; void zwlr_layer_surface_v1_closed() override; QSize m_pendingSize; diff --git a/tests/main.cpp b/tests/main.cpp index 9557335..c3d4d3d 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -9,24 +9,26 @@ #include #include -int main(int argc, char** argv) +int main(int argc, char **argv) { LayerShellQt::Shell::useLayerShell(); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.loadData("import QtQuick.Controls 2.10\n" - "import QtQuick 2.10\n" - "\n" - "ApplicationWindow {" - " width: 100; height: 100\n" - " visible: true\n" - " Rectangle { color: 'red'; anchors.fill: parent }" - "}" + engine.loadData( + "import QtQuick.Controls 2.10\n" + "import QtQuick 2.10\n" + "\n" + "ApplicationWindow {" + " width: 100; height: 100\n" + " visible: true\n" + " Rectangle { color: 'red'; anchors.fill: parent }" + "}" - , QStringLiteral("bananaland:/potato.qml")); + , + QStringLiteral("bananaland:/potato.qml")); - QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [] (QObject *object) { + QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [](QObject *object) { auto layerWindow = LayerShellQt::Window::get(qobject_cast(object)); Q_ASSERT(layerWindow); layerWindow->setMargins({50, 50, 50, 50});