From 55f1f3fedfc6dc5da7f304bdfc8296a0a056f781 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 21 Apr 2024 19:29:45 +0100 Subject: [PATCH] protocols: minor style improvements to new impls --- src/protocols/CursorShape.cpp | 1 + src/protocols/CursorShape.hpp | 18 +++++++++--------- src/protocols/FractionalScale.hpp | 15 ++++++++------- src/protocols/IdleInhibit.hpp | 13 ++++++++----- src/protocols/TearingControl.cpp | 1 + src/protocols/TearingControl.hpp | 12 +++++++----- src/protocols/XDGOutput.hpp | 12 +++++++----- 7 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/protocols/CursorShape.cpp b/src/protocols/CursorShape.cpp index da27dbda..e94dda60 100644 --- a/src/protocols/CursorShape.cpp +++ b/src/protocols/CursorShape.cpp @@ -1,4 +1,5 @@ #include "CursorShape.hpp" +#include // clang-format off constexpr const char* SHAPE_NAMES[] = { diff --git a/src/protocols/CursorShape.hpp b/src/protocols/CursorShape.hpp index f410bf5b..9a527f85 100644 --- a/src/protocols/CursorShape.hpp +++ b/src/protocols/CursorShape.hpp @@ -12,14 +12,6 @@ class CCursorShapeProtocol : public IWaylandProtocol { virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); - void onManagerResourceDestroy(wl_resource* res); - void onDeviceResourceDestroy(wl_resource* res); - - void onGetPointer(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* pointer); - void onGetTabletToolV2(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* tablet); - - void onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t serial, wpCursorShapeDeviceV1Shape shape); - struct SSetShapeEvent { CWpCursorShapeDeviceV1* pMgr = nullptr; wpCursorShapeDeviceV1Shape shape; @@ -31,8 +23,16 @@ class CCursorShapeProtocol : public IWaylandProtocol { } events; private: - void createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource); + void onManagerResourceDestroy(wl_resource* res); + void onDeviceResourceDestroy(wl_resource* res); + void onGetPointer(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* pointer); + void onGetTabletToolV2(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* tablet); + + void onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t serial, wpCursorShapeDeviceV1Shape shape); + void createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource); + + // std::unordered_map> m_mDevices; std::vector> m_vManagers; }; diff --git a/src/protocols/FractionalScale.hpp b/src/protocols/FractionalScale.hpp index b800124f..10ebf49a 100644 --- a/src/protocols/FractionalScale.hpp +++ b/src/protocols/FractionalScale.hpp @@ -45,22 +45,23 @@ class CFractionalScaleProtocol : public IWaylandProtocol { virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); - void onManagerResourceDestroy(wl_resource* res); - void onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, wlr_surface* surface); - - void sendScale(wlr_surface* surf, const float& scale); void onSurfaceDestroy(wlr_surface* surf); - - void removeAddon(CFractionalScaleAddon*); + void sendScale(wlr_surface* surf, const float& scale); private: - void registerSurface(wlr_surface*); + void removeAddon(CFractionalScaleAddon*); + void registerSurface(wlr_surface*); + void onManagerResourceDestroy(wl_resource* res); + void onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, wlr_surface* surface); + // std::unordered_map m_mSurfaceDestroyListeners; std::unordered_map m_mSurfaceScales; std::unordered_map> m_mAddons; std::vector> m_vManagers; + + friend class CFractionalScaleAddon; }; namespace PROTO { diff --git a/src/protocols/IdleInhibit.hpp b/src/protocols/IdleInhibit.hpp index 3283333f..3ea8f691 100644 --- a/src/protocols/IdleInhibit.hpp +++ b/src/protocols/IdleInhibit.hpp @@ -44,18 +44,21 @@ class CIdleInhibitProtocol : public IWaylandProtocol { virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); - void onManagerResourceDestroy(wl_resource* res); - void onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wlr_surface* surface); - - void removeInhibitor(CIdleInhibitorResource*); - struct { CSignal newIdleInhibitor; // data: SP } events; private: + void onManagerResourceDestroy(wl_resource* res); + void onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wlr_surface* surface); + + void removeInhibitor(CIdleInhibitorResource*); + + // std::vector> m_vManagers; std::vector> m_vInhibitors; + + friend class CIdleInhibitorResource; }; namespace PROTO { diff --git a/src/protocols/TearingControl.cpp b/src/protocols/TearingControl.cpp index 21d37e3c..40167766 100644 --- a/src/protocols/TearingControl.cpp +++ b/src/protocols/TearingControl.cpp @@ -26,6 +26,7 @@ void CTearingControlProtocol::onGetController(wl_client* client, wl_resource* re m_vTearingControllers.emplace_back(std::make_unique(std::make_shared(client, wl_resource_get_version(resource), id), surf)).get(); if (!CONTROLLER->good()) { + wl_resource_post_no_memory(resource); m_vTearingControllers.pop_back(); return; } diff --git a/src/protocols/TearingControl.hpp b/src/protocols/TearingControl.hpp index fbd0e1fc..b13bbb82 100644 --- a/src/protocols/TearingControl.hpp +++ b/src/protocols/TearingControl.hpp @@ -39,15 +39,17 @@ class CTearingControlProtocol : public IWaylandProtocol { virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); - void onManagerResourceDestroy(wl_resource* res); - void onControllerDestroy(CTearingControl* control); - void onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf); - private: - void onWindowDestroy(CWindow* pWindow); + void onManagerResourceDestroy(wl_resource* res); + void onControllerDestroy(CTearingControl* control); + void onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf); + void onWindowDestroy(CWindow* pWindow); + // std::vector> m_vManagers; std::vector> m_vTearingControllers; + + friend class CTearingControl; }; namespace PROTO { diff --git a/src/protocols/XDGOutput.hpp b/src/protocols/XDGOutput.hpp index d2314b7b..73e7d53e 100644 --- a/src/protocols/XDGOutput.hpp +++ b/src/protocols/XDGOutput.hpp @@ -31,15 +31,17 @@ class CXDGOutputProtocol : public IWaylandProtocol { virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); - void onManagerResourceDestroy(wl_resource* res); - void onOutputResourceDestroy(wl_resource* res); - void onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource); - private: - void updateAllOutputs(); + void onManagerResourceDestroy(wl_resource* res); + void onOutputResourceDestroy(wl_resource* res); + void onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource); + void updateAllOutputs(); + // std::vector> m_vManagerResources; std::vector> m_vXDGOutputs; + + friend class CXDGOutput; }; namespace PROTO {