Commit c7fe867e authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Use global static variables to store protocol version

s_version is used only to initialize a global so there is no point for
storing protocol version in a static member field and use funky syntax
in the cpp file to initialize it. This change also simplifies the code.
parent 94730634
......@@ -13,6 +13,9 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
class AppMenuManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_appmenu_manager
{
public:
......@@ -20,14 +23,11 @@ public:
QVector<AppMenuInterface*> appmenus;
AppMenuManagerInterface *q;
static const quint32 s_version;
protected:
void org_kde_kwin_appmenu_manager_create(Resource *resource, uint32_t id, wl_resource *surface) override;
};
const quint32 AppMenuManagerInterfacePrivate::s_version = 1;
void AppMenuManagerInterfacePrivate::org_kde_kwin_appmenu_manager_create(Resource *resource, uint32_t id, wl_resource *surface)
{
SurfaceInterface *s = SurfaceInterface::get(surface);
......
......@@ -17,23 +17,20 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
class BlurManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_blur_manager
{
public:
BlurManagerInterfacePrivate(BlurManagerInterface *q, Display *d);
private:
void createBlur(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface);
BlurManagerInterface *q;
static const quint32 s_version;
protected:
void org_kde_kwin_blur_manager_create(Resource *resource, uint32_t id, wl_resource *surface) override;
void org_kde_kwin_blur_manager_unset(Resource *resource, wl_resource *surface) override;
};
const quint32 BlurManagerInterfacePrivate::s_version = 1;
BlurManagerInterfacePrivate::BlurManagerInterfacePrivate(BlurManagerInterface *_q, Display *d)
: QtWaylandServer::org_kde_kwin_blur_manager(*d, s_version)
, q(_q)
......
......@@ -15,20 +15,18 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
class ContrastManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_contrast_manager
{
public:
ContrastManagerInterfacePrivate(Display *display);
private:
static const quint32 s_version;
protected:
void org_kde_kwin_contrast_manager_create(Resource *resource, uint32_t id, wl_resource *surface) override;
void org_kde_kwin_contrast_manager_unset(Resource *resource, wl_resource *surface) override;
};
const quint32 ContrastManagerInterfacePrivate::s_version = 1;
ContrastManagerInterfacePrivate::ContrastManagerInterfacePrivate(Display *display)
: QtWaylandServer::org_kde_kwin_contrast_manager(*display, s_version)
{
......
......@@ -10,7 +10,7 @@
namespace KWaylandServer
{
const quint32 DpmsManagerInterfacePrivate::s_version = 1;
static const quint32 s_version = 1;
DpmsManagerInterfacePrivate::DpmsManagerInterfacePrivate(DpmsManagerInterface *_q, Display *display)
: QtWaylandServer::org_kde_kwin_dpms_manager(*display, s_version)
......
......@@ -21,7 +21,6 @@ public:
DpmsManagerInterfacePrivate(DpmsManagerInterface *q, Display *d);
DpmsManagerInterface *q;
static const quint32 s_version;
protected:
void org_kde_kwin_dpms_manager_get(Resource *resource, uint32_t id, wl_resource *output) override;
......
......@@ -14,13 +14,13 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
class EglStreamControllerInterfacePrivate : public QtWaylandServer::wl_eglstream_controller
{
public:
EglStreamControllerInterfacePrivate(EglStreamControllerInterface *controller, Display *display);
private:
static const quint32 s_version;
EglStreamControllerInterface *q;
protected:
......@@ -29,8 +29,6 @@ protected:
};
const quint32 EglStreamControllerInterfacePrivate::s_version = 1;
void EglStreamControllerInterfacePrivate::eglstream_controller_attach_eglstream_consumer(Resource *resource, wl_resource *wl_surface, wl_resource *eglStream)
{
wl_array noAttribs = { 0, 0, nullptr };
......
......@@ -10,7 +10,7 @@
namespace KWaylandServer
{
const quint32 IdleInterfacePrivate::s_version = 1;
static const quint32 s_version = 1;
IdleInterfacePrivate::IdleInterfacePrivate(IdleInterface *_q, Display *display)
: QtWaylandServer::org_kde_kwin_idle(*display, s_version)
......
......@@ -29,7 +29,6 @@ public:
int inhibitCount = 0;
QVector<IdleTimeoutInterface *> idleTimeouts;
IdleInterface *q;
static const quint32 s_version;
protected:
void org_kde_kwin_idle_get_idle_timeout(Resource *resource, uint32_t id, wl_resource *seat, uint32_t timeout) override;
......
......@@ -10,7 +10,7 @@
namespace KWaylandServer
{
const quint32 IdleInhibitManagerV1InterfacePrivate::s_version = 1;
static const quint32 s_version = 1;
IdleInhibitManagerV1InterfacePrivate::IdleInhibitManagerV1InterfacePrivate(IdleInhibitManagerV1Interface *_q, Display *display)
: QtWaylandServer::zwp_idle_inhibit_manager_v1(*display, s_version)
......
......@@ -18,7 +18,6 @@ class IdleInhibitManagerV1InterfacePrivate : public QtWaylandServer::zwp_idle_in
public:
IdleInhibitManagerV1InterfacePrivate(IdleInhibitManagerV1Interface *_q, Display *display);
static const quint32 s_version;
IdleInhibitManagerV1Interface *q;
protected:
......
......@@ -15,6 +15,8 @@
namespace KWaylandServer
{
static const quint32 s_version = 2;
class PlasmaVirtualDesktopInterfacePrivate : public QtWaylandServer::org_kde_plasma_virtual_desktop
{
public:
......@@ -43,7 +45,6 @@ public:
quint32 rows = 0;
quint32 columns = 0;
PlasmaVirtualDesktopManagementInterface *q;
static const quint32 s_version;
inline QList<PlasmaVirtualDesktopInterface*>::const_iterator constFindDesktop(const QString &id);
inline QList<PlasmaVirtualDesktopInterface*>::iterator findDesktop(const QString &id);
......@@ -56,9 +57,6 @@ protected:
void org_kde_plasma_virtual_desktop_management_bind_resource(Resource *resource) override;
};
const quint32 PlasmaVirtualDesktopManagementInterfacePrivate::s_version = 2;
inline QList<PlasmaVirtualDesktopInterface*>::const_iterator PlasmaVirtualDesktopManagementInterfacePrivate::constFindDesktop(const QString &id)
{
return std::find_if( desktops.constBegin(),
......
......@@ -22,6 +22,8 @@
namespace KWaylandServer
{
static const quint32 s_version = 13;
class PlasmaWindowManagementInterfacePrivate : public QtWaylandServer::org_kde_plasma_window_management
{
public:
......@@ -38,7 +40,6 @@ public:
QVector<quint32> stackingOrder;
QVector<QString> stackingOrderUuids;
PlasmaWindowManagementInterface *q;
static const quint32 s_version;
protected:
void org_kde_plasma_window_management_bind_resource(Resource *resource) override;
......@@ -105,8 +106,6 @@ protected:
void org_kde_plasma_window_request_leave_virtual_desktop(Resource *resource, const QString &id) override;
};
const quint32 PlasmaWindowManagementInterfacePrivate::s_version = 13;
PlasmaWindowManagementInterfacePrivate::PlasmaWindowManagementInterfacePrivate(PlasmaWindowManagementInterface *_q, Display *display)
: QtWaylandServer::org_kde_plasma_window_management(*display, s_version)
, q(_q)
......
......@@ -15,6 +15,8 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
class ServerSideDecorationManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_server_decoration_manager
{
public:
......@@ -22,10 +24,7 @@ public:
void setDefaultMode(ServerSideDecorationManagerInterface::Mode mode);
ServerSideDecorationManagerInterface::Mode defaultMode = ServerSideDecorationManagerInterface::Mode::None;
private:
ServerSideDecorationManagerInterface *q;
static const quint32 s_version;
protected:
void org_kde_kwin_server_decoration_manager_bind_resource(Resource *resource) override;
......@@ -33,8 +32,6 @@ protected:
};
const quint32 ServerSideDecorationManagerInterfacePrivate::s_version = 1;
static uint32_t modeWayland(ServerSideDecorationManagerInterface::Mode mode)
{
switch (mode) {
......
......@@ -14,24 +14,22 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
class ServerSideDecorationPaletteManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_server_decoration_palette_manager
{
public:
ServerSideDecorationPaletteManagerInterfacePrivate(ServerSideDecorationPaletteManagerInterface *q, Display *display);
QVector<ServerSideDecorationPaletteInterface*> palettes;
private:
ServerSideDecorationPaletteManagerInterface *q;
static const quint32 s_version;
protected:
void org_kde_kwin_server_decoration_palette_manager_create(Resource *resource, uint32_t id, struct ::wl_resource *surface) override;
};
const quint32 ServerSideDecorationPaletteManagerInterfacePrivate::s_version = 1;
void ServerSideDecorationPaletteManagerInterfacePrivate::org_kde_kwin_server_decoration_palette_manager_create(Resource *resource, uint32_t id, wl_resource *surface)
{
SurfaceInterface *s = SurfaceInterface::get(surface);
......
......@@ -13,6 +13,8 @@
namespace KWaylandServer
{
static const quint32 s_version = 2;
class ShadowManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_shadow_manager
{
public:
......@@ -20,7 +22,6 @@ public:
ShadowManagerInterface *q;
Display *display;
static const quint32 s_version;
protected:
void org_kde_kwin_shadow_manager_create(Resource *resource, uint32_t id, wl_resource *surface) override;
......@@ -28,8 +29,6 @@ protected:
void org_kde_kwin_shadow_manager_destroy(Resource *resource) override;
};
const quint32 ShadowManagerInterfacePrivate::s_version = 2;
ShadowManagerInterfacePrivate::ShadowManagerInterfacePrivate(ShadowManagerInterface *_q, Display *display)
: QtWaylandServer::org_kde_kwin_shadow_manager(*display, s_version)
, q(_q)
......
......@@ -13,7 +13,7 @@
namespace KWaylandServer
{
const quint32 TextInputManagerV2InterfacePrivate::s_version = 1;
static const quint32 s_version = 1;
// helpers
static TextInputContentHints convertContentHint(uint32_t hint)
......
......@@ -23,7 +23,6 @@ public:
TextInputManagerV2InterfacePrivate(TextInputManagerV2Interface *_q, Display *display);
TextInputManagerV2Interface *q;
static const quint32 s_version;
protected:
void zwp_text_input_manager_v2_destroy(Resource *resource) override;
......
......@@ -13,6 +13,8 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
static TextInputContentHints convertContentHint(uint32_t hint)
{
const auto hints = zwp_text_input_v3_content_hint(hint);
......@@ -101,8 +103,6 @@ static TextInputChangeCause convertChangeCause(uint32_t cause)
}
}
const quint32 TextInputManagerV3InterfacePrivate::s_version = 1;
TextInputManagerV3InterfacePrivate::TextInputManagerV3InterfacePrivate(TextInputManagerV3Interface *_q, Display *display)
: QtWaylandServer::zwp_text_input_manager_v3(*display, s_version)
, q(_q)
......
......@@ -25,7 +25,6 @@ public:
TextInputManagerV3InterfacePrivate(TextInputManagerV3Interface *_q, Display *display);
TextInputManagerV3Interface *q;
static const quint32 s_version;
protected:
void zwp_text_input_manager_v3_destroy(Resource *resource) override;
......
......@@ -13,6 +13,9 @@
namespace KWaylandServer
{
static const quint32 s_exporterVersion = 1;
static const quint32 s_importerVersion = 1;
XdgForeignV2InterfacePrivate::XdgForeignV2InterfacePrivate(Display *display, XdgForeignV2Interface *_q)
: QObject(nullptr)
, q(_q)
......@@ -49,7 +52,6 @@ public:
XdgForeignV2Interface *foreignInterface;
QHash<QString, XdgExportedV2Interface *> exportedSurfaces;
XdgExporterV2Interface *q;
static const quint32 s_version;
protected:
void zxdg_exporter_v2_destroy(Resource *resource) override;
......@@ -57,8 +59,6 @@ protected:
};
const quint32 XdgExporterV2InterfacePrivate::s_version = 1;
XdgExporterV2Interface::XdgExporterV2Interface(Display *display, XdgForeignV2Interface *parent)
: QObject(parent)
, d(new XdgExporterV2InterfacePrivate(this, display, parent))
......@@ -122,7 +122,7 @@ void XdgExporterV2InterfacePrivate::zxdg_exporter_v2_export_toplevel(Resource *r
}
XdgExporterV2InterfacePrivate::XdgExporterV2InterfacePrivate(XdgExporterV2Interface *_q, Display *display, XdgForeignV2Interface *foreignInterface)
: QtWaylandServer::zxdg_exporter_v2(*display, s_version)
: QtWaylandServer::zxdg_exporter_v2(*display, s_exporterVersion)
, foreignInterface(foreignInterface)
, q(_q)
{
......@@ -141,15 +141,12 @@ public:
//parent->child hash
QHash<XdgImportedV2Interface *, SurfaceInterface *> children;
XdgImporterV2Interface *q;
static const quint32 s_version;
protected:
void zxdg_importer_v2_destroy(Resource *resource) override;
void zxdg_importer_v2_import_toplevel(Resource *resource, uint32_t id, const QString &handle) override;
};
const quint32 XdgImporterV2InterfacePrivate::s_version = 1;
XdgImporterV2Interface::XdgImporterV2Interface(Display *display, XdgForeignV2Interface *parent)
: QObject(parent)
, d(new XdgImporterV2InterfacePrivate(this, display, parent))
......@@ -264,7 +261,7 @@ void XdgImporterV2InterfacePrivate::zxdg_importer_v2_import_toplevel(Resource *r
}
XdgImporterV2InterfacePrivate::XdgImporterV2InterfacePrivate(XdgImporterV2Interface *_q, Display *display, XdgForeignV2Interface *foreignInterface)
: QtWaylandServer::zxdg_importer_v2(*display, s_version)
: QtWaylandServer::zxdg_importer_v2(*display, s_importerVersion)
, foreignInterface(foreignInterface)
, q(_q)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment