Address code formatting

This commit is contained in:
Aleix Pol 2021-04-06 13:39:27 +02:00
parent 1bf7276d53
commit cd9b1a6fd3
12 changed files with 80 additions and 90 deletions

View file

@ -23,11 +23,11 @@ include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMSetupVersion) include(ECMSetupVersion)
include(ECMGenerateHeaders) include(ECMGenerateHeaders)
include(CheckIncludeFiles)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(FeatureSummary) include(FeatureSummary)
include(GenerateExportHeader) include(GenerateExportHeader)
include(KDEClangFormat) include(KDEClangFormat)
include(ECMQtDeclareLoggingCategory)
find_package(WaylandScanner) find_package(WaylandScanner)
find_package(QtWaylandScanner) find_package(QtWaylandScanner)
@ -36,7 +36,6 @@ find_package(WaylandProtocols)
set_package_properties(Wayland PROPERTIES set_package_properties(Wayland PROPERTIES
TYPE REQUIRED) TYPE REQUIRED)
# adjusting CMAKE_C_FLAGS to get wayland protocols to compile
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90")
ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX LAYERSHELLQT 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" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LayerShellQtConfigVersion.cmake"
SOVERSION 5) 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(src)
add_subdirectory(tests) add_subdirectory(tests)

View file

@ -5,8 +5,8 @@
*/ */
#include "shell.h" #include "shell.h"
#include <qglobal.h>
#include <QByteArray> #include <QByteArray>
#include <qglobal.h>
using namespace LayerShellQt; using namespace LayerShellQt;

View file

@ -11,11 +11,11 @@
namespace LayerShellQt namespace LayerShellQt
{ {
/** /**
* Sets the right environment so the shells created from now on use wlr-layer-shell. * Sets the right environment so the shells created from now on use wlr-layer-shell.
*/ */
class LAYERSHELLQT_EXPORT Shell { class LAYERSHELLQT_EXPORT Shell
{
public: public:
static void useLayerShell(); static void useLayerShell();
}; };

View file

@ -5,10 +5,10 @@
*/ */
#include "window.h" #include "window.h"
#include <private/qwaylandwindow_p.h>
#include <private/qwaylandshellsurface_p.h>
#include <layershellqt_logging.h>
#include "../qwaylandlayersurface_p.h" #include "../qwaylandlayersurface_p.h"
#include <layershellqt_logging.h>
#include <private/qwaylandshellsurface_p.h>
#include <private/qwaylandwindow_p.h>
using namespace LayerShellQt; using namespace LayerShellQt;
@ -47,7 +47,8 @@ void Window::setKeyboardInteractivity(bool enabled)
Window::Window(WindowPrivate *d) Window::Window(WindowPrivate *d)
: d(d) : d(d)
{} {
}
Window *Window::get(QWindow *window) Window *Window::get(QWindow *window)
{ {

View file

@ -10,8 +10,8 @@
#include <qwayland-wlr-layer-shell-unstable-v1.h> #include <qwayland-wlr-layer-shell-unstable-v1.h>
namespace LayerShellQt { namespace LayerShellQt
{
QWaylandLayerShell::QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell) QWaylandLayerShell::QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell)
: QtWayland::zwlr_layer_shell_v1(shell->object()) : QtWayland::zwlr_layer_shell_v1(shell->object())
{ {
@ -22,8 +22,7 @@ QWaylandLayerShell::~QWaylandLayerShell()
zwlr_layer_shell_v1_destroy(object()); zwlr_layer_shell_v1_destroy(object());
} }
QWaylandLayerSurface *QWaylandLayerShell::createLayerSurface( QWaylandLayerSurface *QWaylandLayerShell::createLayerSurface(QtWaylandClient::QWaylandWindow *window)
QtWaylandClient::QWaylandWindow *window)
{ {
return new QWaylandLayerSurface(this, window); return new QWaylandLayerSurface(this, window);
} }

View file

@ -10,21 +10,20 @@
#include <wayland-client.h> #include <wayland-client.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>
#include <QtWaylandClient/private/qwaylandshellintegration_p.h> #include <QtWaylandClient/private/qwaylandshellintegration_p.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>
#include "qwaylandlayersurface_p.h" #include "qwaylandlayersurface_p.h"
namespace LayerShellQt { namespace LayerShellQt
{
class LAYERSHELLQT_EXPORT QWaylandLayerShell : public QtWayland::zwlr_layer_shell_v1 class LAYERSHELLQT_EXPORT QWaylandLayerShell : public QtWayland::zwlr_layer_shell_v1
{ {
public: public:
QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell); QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell);
virtual ~QWaylandLayerShell(); virtual ~QWaylandLayerShell();
QWaylandLayerSurface *createLayerSurface( QWaylandLayerSurface *createLayerSurface(QtWaylandClient::QWaylandWindow *window);
QtWaylandClient::QWaylandWindow *window);
// TODO: Popups // TODO: Popups
}; };

View file

@ -5,17 +5,17 @@
* SPDX-License-Identifier: LGPL-3.0-or-later * SPDX-License-Identifier: LGPL-3.0-or-later
*/ */
#include "qwaylandlayershellintegration_p.h"
#include "qwaylandlayershell_p.h" #include "qwaylandlayershell_p.h"
#include "qwaylandlayershellintegration_p.h"
#include <qwayland-wlr-layer-shell-unstable-v1.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h> #include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>
namespace LayerShellQt { namespace LayerShellQt
{
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() : QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
m_layerShell(Q_NULLPTR) : m_layerShell(Q_NULLPTR)
{ {
} }
@ -26,22 +26,17 @@ bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay
return m_layerShell != nullptr; return m_layerShell != nullptr;
} }
QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration:: QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow *window)
createShellSurface(QtWaylandClient::QWaylandWindow *window)
{ {
return m_layerShell->createLayerSurface(window); return m_layerShell->createLayerSurface(window);
} }
void QWaylandLayerShellIntegration::registryLayer(void *data, void QWaylandLayerShellIntegration::registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
struct wl_registry *registry, uint32_t id,
const QString &interface, uint32_t version)
{ {
QWaylandLayerShellIntegration *shell = QWaylandLayerShellIntegration *shell = static_cast<QWaylandLayerShellIntegration *>(data);
static_cast<QWaylandLayerShellIntegration *>(data);
if (interface == QStringLiteral("zwlr_layer_shell_v1")) if (interface == QStringLiteral("zwlr_layer_shell_v1"))
shell->m_layerShell = new QWaylandLayerShell( shell->m_layerShell = new QWaylandLayerShell(new QtWayland::zwlr_layer_shell_v1(registry, id, version));
new QtWayland::zwlr_layer_shell_v1(registry, id, version));
} }
} }

View file

@ -10,11 +10,11 @@
#include <wayland-client.h> #include <wayland-client.h>
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
#include "layershellqt_export.h" #include "layershellqt_export.h"
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
namespace LayerShellQt { namespace LayerShellQt
{
class QWaylandLayerShell; class QWaylandLayerShell;
class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegration class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegration
@ -23,12 +23,10 @@ public:
QWaylandLayerShellIntegration(); QWaylandLayerShellIntegration();
bool initialize(QtWaylandClient::QWaylandDisplay *display) override; bool initialize(QtWaylandClient::QWaylandDisplay *display) override;
QtWaylandClient::QWaylandShellSurface *createShellSurface( QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
QtWaylandClient::QWaylandWindow *window) override;
private: private:
static void registryLayer(void *data, struct wl_registry *registry, static void registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
uint32_t id, const QString &interface, uint32_t version);
QWaylandLayerShell *m_layerShell; QWaylandLayerShell *m_layerShell;
}; };

View file

@ -5,24 +5,23 @@
* SPDX-License-Identifier: LGPL-3.0-or-later * SPDX-License-Identifier: LGPL-3.0-or-later
*/ */
#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
#include "qwaylandlayershellintegration_p.h" #include "qwaylandlayershellintegration_p.h"
#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
using namespace LayerShellQt; using namespace LayerShellQt;
class QWaylandLayerShellIntegrationPlugin : class QWaylandLayerShellIntegrationPlugin : public QtWaylandClient::QWaylandShellIntegrationPlugin
public QtWaylandClient::QWaylandShellIntegrationPlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA( Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "layer-shell.json")
IID QWaylandShellIntegrationFactoryInterface_iid
FILE "layer-shell.json")
public: public:
QWaylandLayerShellIntegrationPlugin() {} QWaylandLayerShellIntegrationPlugin()
{
}
QtWaylandClient::QWaylandShellIntegration *create( QtWaylandClient::QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override
const QString &key, const QStringList &paramList) override { {
Q_UNUSED(key); Q_UNUSED(key);
Q_UNUSED(paramList); Q_UNUSED(paramList);
return new QWaylandLayerShellIntegration(); return new QWaylandLayerShellIntegration();

View file

@ -8,13 +8,13 @@
#include "qwaylandlayershell_p.h" #include "qwaylandlayershell_p.h"
#include "qwaylandlayersurface_p.h" #include "qwaylandlayersurface_p.h"
#include <qwayland-wlr-layer-shell-unstable-v1.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylandsurface_p.h>
#include <QtWaylandClient/private/qwaylandscreen_p.h> #include <QtWaylandClient/private/qwaylandscreen_p.h>
#include <QtWaylandClient/private/qwaylandsurface_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>
namespace LayerShellQt { namespace LayerShellQt
{
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandClient::QWaylandWindow *window) QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandClient::QWaylandWindow *window)
: QtWaylandClient::QWaylandShellSurface(window) : QtWaylandClient::QWaylandShellSurface(window)
, QtWayland::zwlr_layer_surface_v1( , QtWayland::zwlr_layer_surface_v1(
@ -37,8 +37,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_closed()
window()->window()->close(); window()->window()->close();
} }
void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height)
uint32_t width, uint32_t height)
{ {
ack_configure(serial); ack_configure(serial);
m_pendingSize = QSize(width, height); m_pendingSize = QSize(width, height);

View file

@ -10,24 +10,23 @@
#include <wayland-client.h> #include <wayland-client.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
#include "layershellqt_export.h" #include "layershellqt_export.h"
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>
namespace LayerShellQt { namespace LayerShellQt
{
class QWaylandLayerShell; class QWaylandLayerShell;
class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylandShellSurface, class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylandShellSurface, public QtWayland::zwlr_layer_surface_v1
public QtWayland::zwlr_layer_surface_v1
{ {
Q_OBJECT Q_OBJECT
public: public:
QWaylandLayerSurface(QWaylandLayerShell *shell, QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandClient::QWaylandWindow *window);
QtWaylandClient::QWaylandWindow *window);
virtual ~QWaylandLayerSurface(); virtual ~QWaylandLayerSurface();
bool isExposed() const override { bool isExposed() const override
{
return m_configured; return m_configured;
} }
@ -39,8 +38,7 @@ public:
void applyConfigure() override; void applyConfigure() override;
private: private:
void zwlr_layer_surface_v1_configure(uint32_t serial, void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
uint32_t width, uint32_t height) override;
void zwlr_layer_surface_v1_closed() override; void zwlr_layer_surface_v1_closed() override;
QSize m_pendingSize; QSize m_pendingSize;

View file

@ -15,7 +15,8 @@ int main(int argc, char** argv)
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
engine.loadData("import QtQuick.Controls 2.10\n" engine.loadData(
"import QtQuick.Controls 2.10\n"
"import QtQuick 2.10\n" "import QtQuick 2.10\n"
"\n" "\n"
"ApplicationWindow {" "ApplicationWindow {"
@ -24,7 +25,8 @@ int main(int argc, char** argv)
" Rectangle { color: 'red'; anchors.fill: parent }" " 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<QWindow *>(object)); auto layerWindow = LayerShellQt::Window::get(qobject_cast<QWindow *>(object));