diff options
| author | davc0n <dconti.dev@gmail.com> | 2025-05-04 23:39:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-04 23:39:00 +0200 |
| commit | 9cd5b257459a6b4c5d5d4d1026df85f0ecbe5a93 (patch) | |
| tree | c1ec209a122a10ab637ba62da5eabb0fea0d1568 /src/protocols | |
| parent | 78ff20ddf03166c7fa769419b7c2861db89f412b (diff) | |
protocols: refactor class member vars (u-z) (#10282)
* protocols: refactor class member vars (u-z)
* protocols: fix clang format
Diffstat (limited to 'src/protocols')
27 files changed, 869 insertions, 867 deletions
diff --git a/src/protocols/LayerShell.cpp b/src/protocols/LayerShell.cpp index 1f37f622..4cb37ff4 100644 --- a/src/protocols/LayerShell.cpp +++ b/src/protocols/LayerShell.cpp @@ -120,12 +120,12 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C m_resource->setGetPopup([this](CZwlrLayerSurfaceV1* r, wl_resource* popup_) { auto popup = CXDGPopupResource::fromResource(popup_); - if (popup->taken) { + if (popup->m_taken) { r->error(-1, "Parent already exists!"); return; } - popup->taken = true; + popup->m_taken = true; m_events.newPopup.emit(popup); }); diff --git a/src/protocols/Viewporter.cpp b/src/protocols/Viewporter.cpp index 0b82603f..b7144814 100644 --- a/src/protocols/Viewporter.cpp +++ b/src/protocols/Viewporter.cpp @@ -2,23 +2,23 @@ #include "core/Compositor.hpp" #include <algorithm> -CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) { +CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); }); - resource->setOnDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); }); + m_resource->setDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); }); - resource->setSetDestination([this](CWpViewport* r, int32_t x, int32_t y) { - if UNLIKELY (!surface) { + m_resource->setSetDestination([this](CWpViewport* r, int32_t x, int32_t y) { + if UNLIKELY (!m_surface) { r->error(WP_VIEWPORT_ERROR_NO_SURFACE, "Surface is gone"); return; } - surface->m_pending.updated.viewport = true; + m_surface->m_pending.updated.viewport = true; if (x == -1 && y == -1) { - surface->m_pending.viewport.hasDestination = false; + m_surface->m_pending.viewport.hasDestination = false; return; } @@ -27,22 +27,22 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes return; } - surface->m_pending.viewport.hasDestination = true; - surface->m_pending.viewport.destination = {x, y}; + m_surface->m_pending.viewport.hasDestination = true; + m_surface->m_pending.viewport.destination = {x, y}; }); - resource->setSetSource([this](CWpViewport* r, wl_fixed_t fx, wl_fixed_t fy, wl_fixed_t fw, wl_fixed_t fh) { - if UNLIKELY (!surface) { + m_resource->setSetSource([this](CWpViewport* r, wl_fixed_t fx, wl_fixed_t fy, wl_fixed_t fw, wl_fixed_t fh) { + if UNLIKELY (!m_surface) { r->error(WP_VIEWPORT_ERROR_NO_SURFACE, "Surface is gone"); return; } - surface->m_pending.updated.viewport = true; + m_surface->m_pending.updated.viewport = true; double x = wl_fixed_to_double(fx), y = wl_fixed_to_double(fy), w = wl_fixed_to_double(fw), h = wl_fixed_to_double(fh); if (x == -1 && y == -1 && w == -1 && h == -1) { - surface->m_pending.viewport.hasSource = false; + m_surface->m_pending.viewport.hasSource = false; return; } @@ -51,20 +51,20 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes return; } - surface->m_pending.viewport.hasSource = true; - surface->m_pending.viewport.source = {x, y, w, h}; + m_surface->m_pending.viewport.hasSource = true; + m_surface->m_pending.viewport.source = {x, y, w, h}; }); - listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) { - if (!surface || !surface->m_pending.buffer) + m_listeners.surfacePrecommit = m_surface->m_events.precommit.registerListener([this](std::any d) { + if (!m_surface || !m_surface->m_pending.buffer) return; - if (surface->m_pending.viewport.hasSource) { - auto& src = surface->m_pending.viewport.source; + if (m_surface->m_pending.viewport.hasSource) { + auto& src = m_surface->m_pending.viewport.source; - if (src.w + src.x > surface->m_pending.bufferSize.x || src.h + src.y > surface->m_pending.bufferSize.y) { - resource->error(WP_VIEWPORT_ERROR_BAD_VALUE, "Box doesn't fit"); - surface->m_pending.rejected = true; + if (src.w + src.x > m_surface->m_pending.bufferSize.x || src.h + src.y > m_surface->m_pending.bufferSize.y) { + m_resource->error(WP_VIEWPORT_ERROR_BAD_VALUE, "Box doesn't fit"); + m_surface->m_pending.rejected = true; return; } } @@ -72,38 +72,38 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes } CViewportResource::~CViewportResource() { - if (!surface) + if (!m_surface) return; - surface->m_pending.viewport.hasDestination = false; - surface->m_pending.viewport.hasSource = false; + m_surface->m_pending.viewport.hasDestination = false; + m_surface->m_pending.viewport.hasSource = false; } bool CViewportResource::good() { - return resource->resource(); + return m_resource->resource(); } -CViewporterResource::CViewporterResource(SP<CWpViewporter> resource_) : resource(resource_) { +CViewporterResource::CViewporterResource(SP<CWpViewporter> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); }); - resource->setOnDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); }); + m_resource->setDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); }); - resource->setGetViewport([](CWpViewporter* r, uint32_t id, wl_resource* surf) { - const auto RESOURCE = PROTO::viewport->m_vViewports.emplace_back( + m_resource->setGetViewport([](CWpViewporter* r, uint32_t id, wl_resource* surf) { + const auto RESOURCE = PROTO::viewport->m_viewports.emplace_back( makeShared<CViewportResource>(makeShared<CWpViewport>(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surf))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::viewport->m_vViewports.pop_back(); + PROTO::viewport->m_viewports.pop_back(); return; } }); } bool CViewporterResource::good() { - return resource->resource(); + return m_resource->resource(); } CViewporterProtocol::CViewporterProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -111,19 +111,19 @@ CViewporterProtocol::CViewporterProtocol(const wl_interface* iface, const int& v } void CViewporterProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared<CViewporterResource>(makeShared<CWpViewporter>(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared<CViewporterResource>(makeShared<CWpViewporter>(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CViewporterProtocol::destroyResource(CViewporterResource* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CViewporterProtocol::destroyResource(CViewportResource* resource) { - std::erase_if(m_vViewports, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_viewports, [&](const auto& other) { return other.get() == resource; }); } diff --git a/src/protocols/Viewporter.hpp b/src/protocols/Viewporter.hpp index 6824f2ae..d967da74 100644 --- a/src/protocols/Viewporter.hpp +++ b/src/protocols/Viewporter.hpp @@ -14,14 +14,14 @@ class CViewportResource { ~CViewportResource(); bool good(); - WP<CWLSurfaceResource> surface; + WP<CWLSurfaceResource> m_surface; private: - SP<CWpViewport> resource; + SP<CWpViewport> m_resource; struct { CHyprSignalListener surfacePrecommit; - } listeners; + } m_listeners; }; class CViewporterResource { @@ -31,7 +31,7 @@ class CViewporterResource { bool good(); private: - SP<CWpViewporter> resource; + SP<CWpViewporter> m_resource; }; class CViewporterProtocol : public IWaylandProtocol { @@ -45,8 +45,8 @@ class CViewporterProtocol : public IWaylandProtocol { void destroyResource(CViewportResource* resource); // - std::vector<SP<CViewporterResource>> m_vManagers; - std::vector<SP<CViewportResource>> m_vViewports; + std::vector<SP<CViewporterResource>> m_managers; + std::vector<SP<CViewportResource>> m_viewports; friend class CViewporterResource; friend class CViewportResource; diff --git a/src/protocols/VirtualKeyboard.cpp b/src/protocols/VirtualKeyboard.cpp index e57d66c8..48ed7eeb 100644 --- a/src/protocols/VirtualKeyboard.cpp +++ b/src/protocols/VirtualKeyboard.cpp @@ -4,47 +4,47 @@ #include "../helpers/time/Time.hpp" using namespace Hyprutils::OS; -CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1> resource_) : resource(resource_) { +CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CZwpVirtualKeyboardV1* r) { + m_resource->setDestroy([this](CZwpVirtualKeyboardV1* r) { releasePressed(); - events.destroy.emit(); + m_events.destroy.emit(); PROTO::virtualKeyboard->destroyResource(this); }); - resource->setOnDestroy([this](CZwpVirtualKeyboardV1* r) { + m_resource->setOnDestroy([this](CZwpVirtualKeyboardV1* r) { releasePressed(); - events.destroy.emit(); + m_events.destroy.emit(); PROTO::virtualKeyboard->destroyResource(this); }); - resource->setKey([this](CZwpVirtualKeyboardV1* r, uint32_t timeMs, uint32_t key, uint32_t state) { - if UNLIKELY (!hasKeymap) { + m_resource->setKey([this](CZwpVirtualKeyboardV1* r, uint32_t timeMs, uint32_t key, uint32_t state) { + if UNLIKELY (!m_hasKeymap) { r->error(ZWP_VIRTUAL_KEYBOARD_V1_ERROR_NO_KEYMAP, "Key event received before a keymap was set"); return; } - events.key.emit(IKeyboard::SKeyEvent{ + m_events.key.emit(IKeyboard::SKeyEvent{ .timeMs = timeMs, .keycode = key, .state = (wl_keyboard_key_state)state, }); - const bool CONTAINS = std::find(pressed.begin(), pressed.end(), key) != pressed.end(); + const bool CONTAINS = std::find(m_pressed.begin(), m_pressed.end(), key) != m_pressed.end(); if (state && !CONTAINS) - pressed.emplace_back(key); + m_pressed.emplace_back(key); else if (!state && CONTAINS) - std::erase(pressed, key); + std::erase(m_pressed, key); }); - resource->setModifiers([this](CZwpVirtualKeyboardV1* r, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { - if UNLIKELY (!hasKeymap) { + m_resource->setModifiers([this](CZwpVirtualKeyboardV1* r, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { + if UNLIKELY (!m_hasKeymap) { r->error(ZWP_VIRTUAL_KEYBOARD_V1_ERROR_NO_KEYMAP, "Mods event received before a keymap was set"); return; } - events.modifiers.emit(IKeyboard::SModifiersEvent{ + m_events.modifiers.emit(IKeyboard::SModifiersEvent{ .depressed = depressed, .latched = latched, .locked = locked, @@ -52,7 +52,7 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1> }); }); - resource->setKeymap([this](CZwpVirtualKeyboardV1* r, uint32_t fmt, int32_t fd, uint32_t len) { + m_resource->setKeymap([this](CZwpVirtualKeyboardV1* r, uint32_t fmt, int32_t fd, uint32_t len) { auto xkbContext = xkb_context_new(XKB_CONTEXT_NO_FLAGS); CFileDescriptor keymapFd{fd}; if UNLIKELY (!xkbContext) { @@ -79,40 +79,40 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1> return; } - events.keymap.emit(IKeyboard::SKeymapEvent{ + m_events.keymap.emit(IKeyboard::SKeymapEvent{ .keymap = xkbKeymap, }); - hasKeymap = true; + m_hasKeymap = true; xkb_keymap_unref(xkbKeymap); xkb_context_unref(xkbContext); }); - name = "hl-virtual-keyboard"; + m_name = "hl-virtual-keyboard"; } CVirtualKeyboardV1Resource::~CVirtualKeyboardV1Resource() { - events.destroy.emit(); + m_events.destroy.emit(); } bool CVirtualKeyboardV1Resource::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CVirtualKeyboardV1Resource::client() { - return resource->resource() ? resource->client() : nullptr; + return m_resource->resource() ? m_resource->client() : nullptr; } void CVirtualKeyboardV1Resource::releasePressed() { - for (auto const& p : pressed) { - events.key.emit(IKeyboard::SKeyEvent{ + for (auto const& p : m_pressed) { + m_events.key.emit(IKeyboard::SKeyEvent{ .timeMs = Time::millis(Time::steadyNow()), .keycode = p, .state = WL_KEYBOARD_KEY_STATE_RELEASED, }); } - pressed.clear(); + m_pressed.clear(); } CVirtualKeyboardProtocol::CVirtualKeyboardProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -120,31 +120,31 @@ CVirtualKeyboardProtocol::CVirtualKeyboardProtocol(const wl_interface* iface, co } void CVirtualKeyboardProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwpVirtualKeyboardManagerV1>(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwpVirtualKeyboardManagerV1>(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CZwpVirtualKeyboardManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setCreateVirtualKeyboard([this](CZwpVirtualKeyboardManagerV1* pMgr, wl_resource* seat, uint32_t id) { this->onCreateKeeb(pMgr, seat, id); }); } void CVirtualKeyboardProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CVirtualKeyboardProtocol::destroyResource(CVirtualKeyboardV1Resource* keeb) { - std::erase_if(m_vKeyboards, [&](const auto& other) { return other.get() == keeb; }); + std::erase_if(m_keyboards, [&](const auto& other) { return other.get() == keeb; }); } void CVirtualKeyboardProtocol::onCreateKeeb(CZwpVirtualKeyboardManagerV1* pMgr, wl_resource* seat, uint32_t id) { - const auto RESOURCE = m_vKeyboards.emplace_back(makeShared<CVirtualKeyboardV1Resource>(makeShared<CZwpVirtualKeyboardV1>(pMgr->client(), pMgr->version(), id))); + const auto RESOURCE = m_keyboards.emplace_back(makeShared<CVirtualKeyboardV1Resource>(makeShared<CZwpVirtualKeyboardV1>(pMgr->client(), pMgr->version(), id))); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_vKeyboards.pop_back(); + m_keyboards.pop_back(); return; } LOGM(LOG, "New VKeyboard at id {}", id); - events.newKeyboard.emit(RESOURCE); + m_events.newKeyboard.emit(RESOURCE); } diff --git a/src/protocols/VirtualKeyboard.hpp b/src/protocols/VirtualKeyboard.hpp index 0a13003b..ad2eccfa 100644 --- a/src/protocols/VirtualKeyboard.hpp +++ b/src/protocols/VirtualKeyboard.hpp @@ -17,21 +17,21 @@ class CVirtualKeyboardV1Resource { CSignal key; CSignal modifiers; CSignal keymap; - } events; + } m_events; bool good(); wl_client* client(); - std::string name = ""; + std::string m_name = ""; private: - SP<CZwpVirtualKeyboardV1> resource; + SP<CZwpVirtualKeyboardV1> m_resource; void releasePressed(); - bool hasKeymap = false; + bool m_hasKeymap = false; - std::vector<uint32_t> pressed; + std::vector<uint32_t> m_pressed; }; class CVirtualKeyboardProtocol : public IWaylandProtocol { @@ -42,7 +42,7 @@ class CVirtualKeyboardProtocol : public IWaylandProtocol { struct { CSignal newKeyboard; // SP<CVirtualKeyboard> - } events; + } m_events; private: void onManagerResourceDestroy(wl_resource* res); @@ -50,8 +50,8 @@ class CVirtualKeyboardProtocol : public IWaylandProtocol { void onCreateKeeb(CZwpVirtualKeyboardManagerV1* pMgr, wl_resource* seat, uint32_t id); // - std::vector<UP<CZwpVirtualKeyboardManagerV1>> m_vManagers; - std::vector<SP<CVirtualKeyboardV1Resource>> m_vKeyboards; + std::vector<UP<CZwpVirtualKeyboardManagerV1>> m_managers; + std::vector<SP<CVirtualKeyboardV1Resource>> m_keyboards; friend class CVirtualKeyboardV1Resource; }; diff --git a/src/protocols/VirtualPointer.cpp b/src/protocols/VirtualPointer.cpp index ce64e1e5..e40d35f2 100644 --- a/src/protocols/VirtualPointer.cpp +++ b/src/protocols/VirtualPointer.cpp @@ -1,21 +1,21 @@ #include "VirtualPointer.hpp" #include "core/Output.hpp" -CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_, PHLMONITORREF boundOutput_) : boundOutput(boundOutput_), resource(resource_) { +CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_, PHLMONITORREF boundOutput_) : m_boundOutput(boundOutput_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CZwlrVirtualPointerV1* r) { - events.destroy.emit(); + m_resource->setDestroy([this](CZwlrVirtualPointerV1* r) { + m_events.destroy.emit(); PROTO::virtualPointer->destroyResource(this); }); - resource->setOnDestroy([this](CZwlrVirtualPointerV1* r) { - events.destroy.emit(); + m_resource->setOnDestroy([this](CZwlrVirtualPointerV1* r) { + m_events.destroy.emit(); PROTO::virtualPointer->destroyResource(this); }); - resource->setMotion([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, wl_fixed_t dx, wl_fixed_t dy) { - events.move.emit(IPointer::SMotionEvent{ + m_resource->setMotion([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, wl_fixed_t dx, wl_fixed_t dy) { + m_events.move.emit(IPointer::SMotionEvent{ .timeMs = timeMs, .delta = {wl_fixed_to_double(dx), wl_fixed_to_double(dy)}, .unaccel = {wl_fixed_to_double(dx), wl_fixed_to_double(dy)}, @@ -23,84 +23,84 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r }); }); - resource->setMotionAbsolute([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t x, uint32_t y, uint32_t xExtent, uint32_t yExtent) { + m_resource->setMotionAbsolute([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t x, uint32_t y, uint32_t xExtent, uint32_t yExtent) { if (!xExtent || !yExtent) return; - events.warp.emit(IPointer::SMotionAbsoluteEvent{ + m_events.warp.emit(IPointer::SMotionAbsoluteEvent{ .timeMs = timeMs, .absolute = {(double)x / xExtent, (double)y / yExtent}, }); }); - resource->setButton([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t button, uint32_t state) { - events.button.emit(IPointer::SButtonEvent{ + m_resource->setButton([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t button, uint32_t state) { + m_events.button.emit(IPointer::SButtonEvent{ .timeMs = timeMs, .button = button, .state = (wl_pointer_button_state)state, }); }); - resource->setAxis([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value) { - if UNLIKELY (axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) { + m_resource->setAxis([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value) { + if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) { r->error(ZWLR_VIRTUAL_POINTER_V1_ERROR_INVALID_AXIS, "Invalid axis"); return; } - axis = axis_; - axisEvents[axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = (wl_pointer_axis)axis, .delta = wl_fixed_to_double(value)}; + m_axis = axis_; + m_axisEvents[m_axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = (wl_pointer_axis)m_axis, .delta = wl_fixed_to_double(value)}; }); - resource->setFrame([this](CZwlrVirtualPointerV1* r) { - for (auto& e : axisEvents) { + m_resource->setFrame([this](CZwlrVirtualPointerV1* r) { + for (auto& e : m_axisEvents) { if (!e.timeMs) continue; - events.axis.emit(e); + m_events.axis.emit(e); e.timeMs = 0; } - events.frame.emit(); + m_events.frame.emit(); }); - resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { axisEvents[axis].source = (wl_pointer_axis_source)source; }); + m_resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { m_axisEvents[m_axis].source = (wl_pointer_axis_source)source; }); - resource->setAxisStop([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_) { - if UNLIKELY (axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) { + m_resource->setAxisStop([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_) { + if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) { r->error(ZWLR_VIRTUAL_POINTER_V1_ERROR_INVALID_AXIS, "Invalid axis"); return; } - axis = axis_; - axisEvents[axis].timeMs = timeMs; - axisEvents[axis].axis = (wl_pointer_axis)axis; - axisEvents[axis].delta = 0; - axisEvents[axis].deltaDiscrete = 0; + m_axis = axis_; + m_axisEvents[m_axis].timeMs = timeMs; + m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis; + m_axisEvents[m_axis].delta = 0; + m_axisEvents[m_axis].deltaDiscrete = 0; }); - resource->setAxisDiscrete([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value, int32_t discrete) { - if UNLIKELY (axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) { + m_resource->setAxisDiscrete([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value, int32_t discrete) { + if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) { r->error(ZWLR_VIRTUAL_POINTER_V1_ERROR_INVALID_AXIS, "Invalid axis"); return; } - axis = axis_; - axisEvents[axis].timeMs = timeMs; - axisEvents[axis].axis = (wl_pointer_axis)axis; - axisEvents[axis].delta = wl_fixed_to_double(value); - axisEvents[axis].deltaDiscrete = discrete * 120; + m_axis = axis_; + m_axisEvents[m_axis].timeMs = timeMs; + m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis; + m_axisEvents[m_axis].delta = wl_fixed_to_double(value); + m_axisEvents[m_axis].deltaDiscrete = discrete * 120; }); } CVirtualPointerV1Resource::~CVirtualPointerV1Resource() { - events.destroy.emit(); + m_events.destroy.emit(); } bool CVirtualPointerV1Resource::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CVirtualPointerV1Resource::client() { - return resource->client(); + return m_resource->client(); } CVirtualPointerProtocol::CVirtualPointerProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -108,7 +108,7 @@ CVirtualPointerProtocol::CVirtualPointerProtocol(const wl_interface* iface, cons } void CVirtualPointerProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwlrVirtualPointerManagerV1>(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwlrVirtualPointerManagerV1>(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); @@ -128,24 +128,24 @@ void CVirtualPointerProtocol::bindManager(wl_client* client, void* data, uint32_ } void CVirtualPointerProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CVirtualPointerProtocol::destroyResource(CVirtualPointerV1Resource* pointer) { - std::erase_if(m_vPointers, [&](const auto& other) { return other.get() == pointer; }); + std::erase_if(m_pointers, [&](const auto& other) { return other.get() == pointer; }); } void CVirtualPointerProtocol::onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id, PHLMONITORREF output) { - const auto RESOURCE = m_vPointers.emplace_back(makeShared<CVirtualPointerV1Resource>(makeShared<CZwlrVirtualPointerV1>(pMgr->client(), pMgr->version(), id), output)); + const auto RESOURCE = m_pointers.emplace_back(makeShared<CVirtualPointerV1Resource>(makeShared<CZwlrVirtualPointerV1>(pMgr->client(), pMgr->version(), id), output)); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_vPointers.pop_back(); + m_pointers.pop_back(); return; } LOGM(LOG, "New VPointer at id {}", id); - events.newPointer.emit(RESOURCE); + m_events.newPointer.emit(RESOURCE); }
\ No newline at end of file diff --git a/src/protocols/VirtualPointer.hpp b/src/protocols/VirtualPointer.hpp index ac8bcae2..a608086a 100644 --- a/src/protocols/VirtualPointer.hpp +++ b/src/protocols/VirtualPointer.hpp @@ -32,21 +32,21 @@ class CVirtualPointerV1Resource { CSignal holdBegin; CSignal holdEnd; - } events; + } m_events; bool good(); wl_client* client(); - std::string name; + std::string m_name; - PHLMONITORREF boundOutput; + PHLMONITORREF m_boundOutput; private: - SP<CZwlrVirtualPointerV1> resource; + SP<CZwlrVirtualPointerV1> m_resource; - uint32_t axis = 0; + uint32_t m_axis = 0; - std::array<IPointer::SAxisEvent, 2> axisEvents; + std::array<IPointer::SAxisEvent, 2> m_axisEvents; }; class CVirtualPointerProtocol : public IWaylandProtocol { @@ -57,7 +57,7 @@ class CVirtualPointerProtocol : public IWaylandProtocol { struct { CSignal newPointer; // SP<CVirtualPointerV1Resource> - } events; + } m_events; private: void onManagerResourceDestroy(wl_resource* res); @@ -65,8 +65,8 @@ class CVirtualPointerProtocol : public IWaylandProtocol { void onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id, PHLMONITORREF output); // - std::vector<UP<CZwlrVirtualPointerManagerV1>> m_vManagers; - std::vector<SP<CVirtualPointerV1Resource>> m_vPointers; + std::vector<UP<CZwlrVirtualPointerManagerV1>> m_managers; + std::vector<SP<CVirtualPointerV1Resource>> m_pointers; friend class CVirtualPointerV1Resource; }; diff --git a/src/protocols/WaylandProtocol.cpp b/src/protocols/WaylandProtocol.cpp index 8eff80b0..8aa2c896 100644 --- a/src/protocols/WaylandProtocol.cpp +++ b/src/protocols/WaylandProtocol.cpp @@ -14,17 +14,17 @@ static void displayDestroyInternal(struct wl_listener* listener, void* data) { void IWaylandProtocol::onDisplayDestroy() { wl_list_remove(&m_liDisplayDestroy.listener.link); wl_list_init(&m_liDisplayDestroy.listener.link); - if (m_pGlobal) { - wl_global_destroy(m_pGlobal); - m_pGlobal = nullptr; + if (m_global) { + wl_global_destroy(m_global); + m_global = nullptr; } } IWaylandProtocol::IWaylandProtocol(const wl_interface* iface, const int& ver, const std::string& name) : - m_szName(name), m_pGlobal(wl_global_create(g_pCompositor->m_wlDisplay, iface, ver, this, &bindManagerInternal)) { + m_name(name), m_global(wl_global_create(g_pCompositor->m_wlDisplay, iface, ver, this, &bindManagerInternal)) { - if UNLIKELY (!m_pGlobal) { - LOGM(ERR, "could not create a global [{}]", m_szName); + if UNLIKELY (!m_global) { + LOGM(ERR, "could not create a global [{}]", m_name); return; } @@ -33,7 +33,7 @@ IWaylandProtocol::IWaylandProtocol(const wl_interface* iface, const int& ver, co m_liDisplayDestroy.parent = this; wl_display_add_destroy_listener(g_pCompositor->m_wlDisplay, &m_liDisplayDestroy.listener); - LOGM(LOG, "Registered global [{}]", m_szName); + LOGM(LOG, "Registered global [{}]", m_name); } IWaylandProtocol::~IWaylandProtocol() { @@ -41,10 +41,10 @@ IWaylandProtocol::~IWaylandProtocol() { } void IWaylandProtocol::removeGlobal() { - if (m_pGlobal) - wl_global_remove(m_pGlobal); + if (m_global) + wl_global_remove(m_global); } wl_global* IWaylandProtocol::getGlobal() { - return m_pGlobal; + return m_global; } diff --git a/src/protocols/WaylandProtocol.hpp b/src/protocols/WaylandProtocol.hpp index 918ac70f..d46d6aaf 100644 --- a/src/protocols/WaylandProtocol.hpp +++ b/src/protocols/WaylandProtocol.hpp @@ -61,6 +61,6 @@ class IWaylandProtocol { SIWaylandProtocolDestroyWrapper m_liDisplayDestroy; private: - std::string m_szName; - wl_global* m_pGlobal = nullptr; + std::string m_name; + wl_global* m_global = nullptr; }; diff --git a/src/protocols/XDGActivation.cpp b/src/protocols/XDGActivation.cpp index 4062847b..bae3acc3 100644 --- a/src/protocols/XDGActivation.cpp +++ b/src/protocols/XDGActivation.cpp @@ -4,43 +4,43 @@ #include "core/Compositor.hpp" #include <algorithm> -CXDGActivationToken::CXDGActivationToken(SP<CXdgActivationTokenV1> resource_) : resource(resource_) { +CXDGActivationToken::CXDGActivationToken(SP<CXdgActivationTokenV1> resource_) : m_resource(resource_) { if UNLIKELY (!resource_->resource()) return; - resource->setDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); }); - resource->setOnDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); }); + m_resource->setDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); }); + m_resource->setOnDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); }); - resource->setSetSerial([this](CXdgActivationTokenV1* r, uint32_t serial_, wl_resource* seat) { serial = serial_; }); + m_resource->setSetSerial([this](CXdgActivationTokenV1* r, uint32_t serial_, wl_resource* seat) { m_serial = serial_; }); - resource->setSetAppId([this](CXdgActivationTokenV1* r, const char* appid) { appID = appid; }); + m_resource->setSetAppId([this](CXdgActivationTokenV1* r, const char* appid) { m_appID = appid; }); - resource->setCommit([this](CXdgActivationTokenV1* r) { + m_resource->setCommit([this](CXdgActivationTokenV1* r) { // TODO: should we send a protocol error of already_used here // if it was used? the protocol spec doesn't say _when_ it should be sent... - if UNLIKELY (committed) { + if UNLIKELY (m_committed) { LOGM(WARN, "possible protocol error, two commits from one token. Ignoring."); return; } - committed = true; + m_committed = true; // send done with a new token - token = g_pTokenManager->registerNewToken({}, std::chrono::months{12}); + m_token = g_pTokenManager->registerNewToken({}, std::chrono::months{12}); - LOGM(LOG, "assigned new xdg-activation token {}", token); + LOGM(LOG, "assigned new xdg-activation token {}", m_token); - resource->sendDone(token.c_str()); + m_resource->sendDone(m_token.c_str()); - PROTO::activation->m_vSentTokens.push_back({token, resource->client()}); + PROTO::activation->m_sentTokens.push_back({m_token, m_resource->client()}); - auto count = std::count_if(PROTO::activation->m_vSentTokens.begin(), PROTO::activation->m_vSentTokens.end(), - [this](const auto& other) { return other.client == resource->client(); }); + auto count = std::count_if(PROTO::activation->m_sentTokens.begin(), PROTO::activation->m_sentTokens.end(), + [this](const auto& other) { return other.client == m_resource->client(); }); if UNLIKELY (count > 10) { // remove first token. Too many, dear app. - for (auto i = PROTO::activation->m_vSentTokens.begin(); i != PROTO::activation->m_vSentTokens.end(); ++i) { - if (i->client == resource->client()) { - PROTO::activation->m_vSentTokens.erase(i); + for (auto i = PROTO::activation->m_sentTokens.begin(); i != PROTO::activation->m_sentTokens.end(); ++i) { + if (i->client == m_resource->client()) { + PROTO::activation->m_sentTokens.erase(i); break; } } @@ -49,12 +49,12 @@ CXDGActivationToken::CXDGActivationToken(SP<CXdgActivationTokenV1> resource_) : } CXDGActivationToken::~CXDGActivationToken() { - if (committed) - g_pTokenManager->removeToken(g_pTokenManager->getToken(token)); + if (m_committed) + g_pTokenManager->removeToken(g_pTokenManager->getToken(m_token)); } bool CXDGActivationToken::good() { - return resource->resource(); + return m_resource->resource(); } CXDGActivationProtocol::CXDGActivationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -62,21 +62,21 @@ CXDGActivationProtocol::CXDGActivationProtocol(const wl_interface* iface, const } void CXDGActivationProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CXdgActivationV1>(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique<CXdgActivationV1>(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CXdgActivationV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CXdgActivationV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setGetActivationToken([this](CXdgActivationV1* pMgr, uint32_t id) { this->onGetToken(pMgr, id); }); RESOURCE->setActivate([this](CXdgActivationV1* pMgr, const char* token, wl_resource* surface) { - auto TOKEN = std::find_if(m_vSentTokens.begin(), m_vSentTokens.end(), [token](const auto& t) { return t.token == token; }); + auto TOKEN = std::find_if(m_sentTokens.begin(), m_sentTokens.end(), [token](const auto& t) { return t.token == token; }); - if UNLIKELY (TOKEN == m_vSentTokens.end()) { + if UNLIKELY (TOKEN == m_sentTokens.end()) { LOGM(WARN, "activate event for non-existent token {}??", token); return; } // remove token. It's been now spent. - m_vSentTokens.erase(TOKEN); + m_sentTokens.erase(TOKEN); SP<CWLSurfaceResource> surf = CWLSurfaceResource::fromResource(surface); const auto PWINDOW = g_pCompositor->getWindowFromSurface(surf); @@ -91,20 +91,20 @@ void CXDGActivationProtocol::bindManager(wl_client* client, void* data, uint32_t } void CXDGActivationProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CXDGActivationProtocol::destroyToken(CXDGActivationToken* token) { - std::erase_if(m_vTokens, [&](const auto& other) { return other.get() == token; }); + std::erase_if(m_tokens, [&](const auto& other) { return other.get() == token; }); } void CXDGActivationProtocol::onGetToken(CXdgActivationV1* pMgr, uint32_t id) { const auto CLIENT = pMgr->client(); - const auto RESOURCE = m_vTokens.emplace_back(makeUnique<CXDGActivationToken>(makeShared<CXdgActivationTokenV1>(CLIENT, pMgr->version(), id))).get(); + const auto RESOURCE = m_tokens.emplace_back(makeUnique<CXDGActivationToken>(makeShared<CXdgActivationTokenV1>(CLIENT, pMgr->version(), id))).get(); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_vTokens.pop_back(); + m_tokens.pop_back(); return; } }
\ No newline at end of file diff --git a/src/protocols/XDGActivation.hpp b/src/protocols/XDGActivation.hpp index acc6fdb3..ae1bc07a 100644 --- a/src/protocols/XDGActivation.hpp +++ b/src/protocols/XDGActivation.hpp @@ -13,13 +13,13 @@ class CXDGActivationToken { bool good(); private: - SP<CXdgActivationTokenV1> resource; + SP<CXdgActivationTokenV1> m_resource; - uint32_t serial = 0; - std::string appID = ""; - bool committed = false; + uint32_t m_serial = 0; + std::string m_appID = ""; + bool m_committed = false; - std::string token = ""; + std::string m_token = ""; friend class CXDGActivationProtocol; }; @@ -39,11 +39,11 @@ class CXDGActivationProtocol : public IWaylandProtocol { std::string token; wl_client* client = nullptr; // READ-ONLY: can be dead }; - std::vector<SSentToken> m_vSentTokens; + std::vector<SSentToken> m_sentTokens; // - std::vector<UP<CXdgActivationV1>> m_vManagers; - std::vector<UP<CXDGActivationToken>> m_vTokens; + std::vector<UP<CXdgActivationV1>> m_managers; + std::vector<UP<CXDGActivationToken>> m_tokens; friend class CXDGActivationToken; }; diff --git a/src/protocols/XDGBell.cpp b/src/protocols/XDGBell.cpp index f2cedf66..bf46d3eb 100644 --- a/src/protocols/XDGBell.cpp +++ b/src/protocols/XDGBell.cpp @@ -59,7 +59,7 @@ CXDGSystemBellProtocol::CXDGSystemBellProtocol(const wl_interface* iface, const } void CXDGSystemBellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = WP<CXDGSystemBellManagerResource>{m_vManagers.emplace_back(makeUnique<CXDGSystemBellManagerResource>(makeUnique<CXdgSystemBellV1>(client, ver, id)))}; + const auto RESOURCE = WP<CXDGSystemBellManagerResource>{m_managers.emplace_back(makeUnique<CXDGSystemBellManagerResource>(makeUnique<CXdgSystemBellV1>(client, ver, id)))}; if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); @@ -68,5 +68,5 @@ void CXDGSystemBellProtocol::bindManager(wl_client* client, void* data, uint32_t } void CXDGSystemBellProtocol::destroyResource(CXDGSystemBellManagerResource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; }); } diff --git a/src/protocols/XDGBell.hpp b/src/protocols/XDGBell.hpp index ff385059..f36315bd 100644 --- a/src/protocols/XDGBell.hpp +++ b/src/protocols/XDGBell.hpp @@ -24,7 +24,7 @@ class CXDGSystemBellProtocol : public IWaylandProtocol { void destroyResource(CXDGSystemBellManagerResource* res); // - std::vector<UP<CXDGSystemBellManagerResource>> m_vManagers; + std::vector<UP<CXDGSystemBellManagerResource>> m_managers; friend class CXDGSystemBellManagerResource; }; diff --git a/src/protocols/XDGDecoration.cpp b/src/protocols/XDGDecoration.cpp index f9dbf411..b093fbb8 100644 --- a/src/protocols/XDGDecoration.cpp +++ b/src/protocols/XDGDecoration.cpp @@ -1,14 +1,14 @@ #include "XDGDecoration.hpp" #include <algorithm> -CXDGDecoration::CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resource* toplevel) : resource(resource_), pToplevelResource(toplevel) { - if UNLIKELY (!resource->resource()) +CXDGDecoration::CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resource* toplevel) : m_resource(resource_), m_toplevelResource(toplevel) { + if UNLIKELY (!m_resource->resource()) return; - resource->setDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); }); - resource->setOnDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); }); + m_resource->setDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); }); + m_resource->setOnDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); }); - resource->setSetMode([this](CZxdgToplevelDecorationV1*, zxdgToplevelDecorationV1Mode mode) { + m_resource->setSetMode([this](CZxdgToplevelDecorationV1*, zxdgToplevelDecorationV1Mode mode) { std::string modeString; switch (mode) { case ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE: modeString = "MODE_CLIENT_SIDE"; break; @@ -17,23 +17,23 @@ CXDGDecoration::CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resou } LOGM(LOG, "setMode: {}. {} MODE_SERVER_SIDE as reply.", modeString, (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE ? "Sending" : "Ignoring and sending")); - resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); }); - resource->setUnsetMode([this](CZxdgToplevelDecorationV1*) { + m_resource->setUnsetMode([this](CZxdgToplevelDecorationV1*) { LOGM(LOG, "unsetMode. Sending MODE_SERVER_SIDE."); - resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); }); - resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); } bool CXDGDecoration::good() { - return resource->resource(); + return m_resource->resource(); } wl_resource* CXDGDecoration::toplevelResource() { - return pToplevelResource; + return m_toplevelResource; } CXDGDecorationProtocol::CXDGDecorationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -41,7 +41,7 @@ CXDGDecorationProtocol::CXDGDecorationProtocol(const wl_interface* iface, const } void CXDGDecorationProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZxdgDecorationManagerV1>(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique<CZxdgDecorationManagerV1>(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CZxdgDecorationManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CZxdgDecorationManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -49,26 +49,26 @@ void CXDGDecorationProtocol::bindManager(wl_client* client, void* data, uint32_t } void CXDGDecorationProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CXDGDecorationProtocol::destroyDecoration(CXDGDecoration* decoration) { - m_mDecorations.erase(decoration->toplevelResource()); + m_decorations.erase(decoration->toplevelResource()); } void CXDGDecorationProtocol::onGetDecoration(CZxdgDecorationManagerV1* pMgr, uint32_t id, wl_resource* xdgToplevel) { - if UNLIKELY (m_mDecorations.contains(xdgToplevel)) { + if UNLIKELY (m_decorations.contains(xdgToplevel)) { pMgr->error(ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED, "Decoration object already exists"); return; } const auto CLIENT = pMgr->client(); const auto RESOURCE = - m_mDecorations.emplace(xdgToplevel, makeUnique<CXDGDecoration>(makeShared<CZxdgToplevelDecorationV1>(CLIENT, pMgr->version(), id), xdgToplevel)).first->second.get(); + m_decorations.emplace(xdgToplevel, makeUnique<CXDGDecoration>(makeShared<CZxdgToplevelDecorationV1>(CLIENT, pMgr->version(), id), xdgToplevel)).first->second.get(); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_mDecorations.erase(xdgToplevel); + m_decorations.erase(xdgToplevel); return; } }
\ No newline at end of file diff --git a/src/protocols/XDGDecoration.hpp b/src/protocols/XDGDecoration.hpp index 33a9b663..2bbf4bfb 100644 --- a/src/protocols/XDGDecoration.hpp +++ b/src/protocols/XDGDecoration.hpp @@ -13,8 +13,8 @@ class CXDGDecoration { wl_resource* toplevelResource(); private: - SP<CZxdgToplevelDecorationV1> resource; - wl_resource* pToplevelResource = nullptr; // READ-ONLY. + SP<CZxdgToplevelDecorationV1> m_resource; + wl_resource* m_toplevelResource = nullptr; // READ-ONLY. }; class CXDGDecorationProtocol : public IWaylandProtocol { @@ -29,8 +29,8 @@ class CXDGDecorationProtocol : public IWaylandProtocol { void onGetDecoration(CZxdgDecorationManagerV1* pMgr, uint32_t id, wl_resource* xdgToplevel); // - std::vector<UP<CZxdgDecorationManagerV1>> m_vManagers; - std::unordered_map<wl_resource*, UP<CXDGDecoration>> m_mDecorations; // xdg_toplevel -> deco + std::vector<UP<CZxdgDecorationManagerV1>> m_managers; + std::unordered_map<wl_resource*, UP<CXDGDecoration>> m_decorations; // xdg_toplevel -> deco friend class CXDGDecoration; }; diff --git a/src/protocols/XDGDialog.cpp b/src/protocols/XDGDialog.cpp index 675d4e78..c38a1077 100644 --- a/src/protocols/XDGDialog.cpp +++ b/src/protocols/XDGDialog.cpp @@ -4,29 +4,29 @@ #include "../Compositor.hpp" #include <algorithm> -CXDGDialogV1Resource::CXDGDialogV1Resource(SP<CXdgDialogV1> resource_, SP<CXDGToplevelResource> toplevel_) : resource(resource_), toplevel(toplevel_) { +CXDGDialogV1Resource::CXDGDialogV1Resource(SP<CXdgDialogV1> resource_, SP<CXDGToplevelResource> toplevel_) : m_resource(resource_), m_toplevel(toplevel_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); - resource->setOnDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); + m_resource->setDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); + m_resource->setOnDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); - resource->setSetModal([this](CXdgDialogV1* r) { + m_resource->setSetModal([this](CXdgDialogV1* r) { modal = true; updateWindow(); }); - resource->setUnsetModal([this](CXdgDialogV1* r) { + m_resource->setUnsetModal([this](CXdgDialogV1* r) { modal = false; updateWindow(); }); } void CXDGDialogV1Resource::updateWindow() { - if UNLIKELY (!toplevel || !toplevel->parent || !toplevel->parent->owner) + if UNLIKELY (!m_toplevel || !m_toplevel->m_parent || !m_toplevel->m_parent->m_owner) return; - auto HLSurface = CWLSurface::fromResource(toplevel->parent->owner->surface.lock()); + auto HLSurface = CWLSurface::fromResource(m_toplevel->m_parent->m_owner->m_surface.lock()); if UNLIKELY (!HLSurface || !HLSurface->getWindow()) return; @@ -34,36 +34,36 @@ void CXDGDialogV1Resource::updateWindow() { } bool CXDGDialogV1Resource::good() { - return resource->resource(); + return m_resource->resource(); } -CXDGWmDialogManagerResource::CXDGWmDialogManagerResource(SP<CXdgWmDialogV1> resource_) : resource(resource_) { +CXDGWmDialogManagerResource::CXDGWmDialogManagerResource(SP<CXdgWmDialogV1> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); - resource->setOnDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); + m_resource->setDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); + m_resource->setOnDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); }); - resource->setGetXdgDialog([](CXdgWmDialogV1* r, uint32_t id, wl_resource* toplevel) { + m_resource->setGetXdgDialog([](CXdgWmDialogV1* r, uint32_t id, wl_resource* toplevel) { auto tl = CXDGToplevelResource::fromResource(toplevel); if UNLIKELY (!tl) { r->error(-1, "Toplevel inert"); return; } - const auto RESOURCE = PROTO::xdgDialog->m_vDialogs.emplace_back(makeShared<CXDGDialogV1Resource>(makeShared<CXdgDialogV1>(r->client(), r->version(), id), tl)); + const auto RESOURCE = PROTO::xdgDialog->m_dialogs.emplace_back(makeShared<CXDGDialogV1Resource>(makeShared<CXdgDialogV1>(r->client(), r->version(), id), tl)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); return; } - tl->dialog = RESOURCE; + tl->m_dialog = RESOURCE; }); } bool CXDGWmDialogManagerResource::good() { - return resource->resource(); + return m_resource->resource(); } CXDGDialogProtocol::CXDGDialogProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -71,7 +71,7 @@ CXDGDialogProtocol::CXDGDialogProtocol(const wl_interface* iface, const int& ver } void CXDGDialogProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXDGWmDialogManagerResource>(makeShared<CXdgWmDialogV1>(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared<CXDGWmDialogManagerResource>(makeShared<CXdgWmDialogV1>(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); @@ -80,9 +80,9 @@ void CXDGDialogProtocol::bindManager(wl_client* client, void* data, uint32_t ver } void CXDGDialogProtocol::destroyResource(CXDGWmDialogManagerResource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; }); } void CXDGDialogProtocol::destroyResource(CXDGDialogV1Resource* res) { - std::erase_if(m_vDialogs, [&](const auto& other) { return other.get() == res; }); + std::erase_if(m_dialogs, [&](const auto& other) { return other.get() == res; }); } diff --git a/src/protocols/XDGDialog.hpp b/src/protocols/XDGDialog.hpp index 1b29e692..316f1687 100644 --- a/src/protocols/XDGDialog.hpp +++ b/src/protocols/XDGDialog.hpp @@ -16,8 +16,8 @@ class CXDGDialogV1Resource { bool modal = false; private: - SP<CXdgDialogV1> resource; - WP<CXDGToplevelResource> toplevel; + SP<CXdgDialogV1> m_resource; + WP<CXDGToplevelResource> m_toplevel; void updateWindow(); }; @@ -29,7 +29,7 @@ class CXDGWmDialogManagerResource { bool good(); private: - SP<CXdgWmDialogV1> resource; + SP<CXdgWmDialogV1> m_resource; }; class CXDGDialogProtocol : public IWaylandProtocol { @@ -44,8 +44,8 @@ class CXDGDialogProtocol : public IWaylandProtocol { void destroyResource(CXDGDialogV1Resource* res); // - std::vector<SP<CXDGWmDialogManagerResource>> m_vManagers; - std::vector<SP<CXDGDialogV1Resource>> m_vDialogs; + std::vector<SP<CXDGWmDialogManagerResource>> m_managers; + std::vector<SP<CXDGDialogV1Resource>> m_dialogs; friend class CXDGWmDialogManagerResource; friend class CXDGDialogV1Resource; diff --git a/src/protocols/XDGOutput.cpp b/src/protocols/XDGOutput.cpp index 92aaefc9..93ac1c37 100644 --- a/src/protocols/XDGOutput.cpp +++ b/src/protocols/XDGOutput.cpp @@ -14,15 +14,15 @@ // void CXDGOutputProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagerResources, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managerResources, [&](const auto& other) { return other->resource() == res; }); } void CXDGOutputProtocol::onOutputResourceDestroy(wl_resource* res) { - std::erase_if(m_vXDGOutputs, [&](const auto& other) { return other->resource->resource() == res; }); + std::erase_if(m_xdgOutputs, [&](const auto& other) { return other->m_resource->resource() == res; }); } void CXDGOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagerResources.emplace_back(makeUnique<CZxdgOutputManagerV1>(client, ver, id)).get(); + const auto RESOURCE = m_managerResources.emplace_back(makeUnique<CZxdgOutputManagerV1>(client, ver, id)).get(); if UNLIKELY (!RESOURCE->resource()) { LOGM(LOG, "Couldn't bind XDGOutputMgr"); @@ -45,34 +45,34 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32 const auto PMONITOR = OUTPUT->m_monitor.lock(); const auto CLIENT = mgr->client(); - CXDGOutput* pXDGOutput = m_vXDGOutputs.emplace_back(makeUnique<CXDGOutput>(makeShared<CZxdgOutputV1>(CLIENT, mgr->version(), id), PMONITOR)).get(); + CXDGOutput* pXDGOutput = m_xdgOutputs.emplace_back(makeUnique<CXDGOutput>(makeShared<CZxdgOutputV1>(CLIENT, mgr->version(), id), PMONITOR)).get(); #ifndef NO_XWAYLAND if (g_pXWayland && g_pXWayland->pServer && g_pXWayland->pServer->xwaylandClient == CLIENT) - pXDGOutput->isXWayland = true; + pXDGOutput->m_isXWayland = true; #endif - pXDGOutput->client = CLIENT; + pXDGOutput->m_client = CLIENT; - pXDGOutput->outputProto = OUTPUT->m_owner; + pXDGOutput->m_outputProto = OUTPUT->m_owner; - if UNLIKELY (!pXDGOutput->resource->resource()) { - m_vXDGOutputs.pop_back(); + if UNLIKELY (!pXDGOutput->m_resource->resource()) { + m_xdgOutputs.pop_back(); mgr->noMemory(); return; } if UNLIKELY (!PMONITOR) { - LOGM(ERR, "New xdg_output from client {:x} ({}) has no CMonitor?!", (uintptr_t)CLIENT, pXDGOutput->isXWayland ? "xwayland" : "not xwayland"); + LOGM(ERR, "New xdg_output from client {:x} ({}) has no CMonitor?!", (uintptr_t)CLIENT, pXDGOutput->m_isXWayland ? "xwayland" : "not xwayland"); return; } - LOGM(LOG, "New xdg_output for {}: client {:x} ({})", PMONITOR->m_name, (uintptr_t)CLIENT, pXDGOutput->isXWayland ? "xwayland" : "not xwayland"); + LOGM(LOG, "New xdg_output for {}: client {:x} ({})", PMONITOR->m_name, (uintptr_t)CLIENT, pXDGOutput->m_isXWayland ? "xwayland" : "not xwayland"); - const auto XDGVER = pXDGOutput->resource->version(); + const auto XDGVER = pXDGOutput->m_resource->version(); if (XDGVER >= OUTPUT_NAME_SINCE_VERSION) - pXDGOutput->resource->sendName(PMONITOR->m_name.c_str()); + pXDGOutput->m_resource->sendName(PMONITOR->m_name.c_str()); if (XDGVER >= OUTPUT_DESCRIPTION_SINCE_VERSION && !PMONITOR->m_output->description.empty()) - pXDGOutput->resource->sendDescription(PMONITOR->m_output->description.c_str()); + pXDGOutput->m_resource->sendDescription(PMONITOR->m_output->description.c_str()); pXDGOutput->sendDetails(); @@ -84,40 +84,40 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32 void CXDGOutputProtocol::updateAllOutputs() { LOGM(LOG, "updating all xdg_output heads"); - for (auto const& o : m_vXDGOutputs) { - if (!o->monitor) + for (auto const& o : m_xdgOutputs) { + if (!o->m_monitor) continue; o->sendDetails(); - o->monitor->scheduleDone(); + o->m_monitor->scheduleDone(); } } // -CXDGOutput::CXDGOutput(SP<CZxdgOutputV1> resource_, PHLMONITOR monitor_) : monitor(monitor_), resource(resource_) { - if UNLIKELY (!resource->resource()) +CXDGOutput::CXDGOutput(SP<CZxdgOutputV1> resource_, PHLMONITOR monitor_) : m_monitor(monitor_), m_resource(resource_) { + if UNLIKELY (!m_resource->resource()) return; - resource->setDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); }); - resource->setOnDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); }); + m_resource->setDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); }); + m_resource->setOnDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); }); } void CXDGOutput::sendDetails() { static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); - if UNLIKELY (!monitor || !outputProto || outputProto->isDefunct()) + if UNLIKELY (!m_monitor || !m_outputProto || m_outputProto->isDefunct()) return; - const auto POS = isXWayland ? monitor->m_xwaylandPosition : monitor->m_position; - resource->sendLogicalPosition(POS.x, POS.y); + const auto POS = m_isXWayland ? m_monitor->m_xwaylandPosition : m_monitor->m_position; + m_resource->sendLogicalPosition(POS.x, POS.y); - if (*PXWLFORCESCALEZERO && isXWayland) - resource->sendLogicalSize(monitor->m_transformedSize.x, monitor->m_transformedSize.y); + if (*PXWLFORCESCALEZERO && m_isXWayland) + m_resource->sendLogicalSize(m_monitor->m_transformedSize.x, m_monitor->m_transformedSize.y); else - resource->sendLogicalSize(monitor->m_size.x, monitor->m_size.y); + m_resource->sendLogicalSize(m_monitor->m_size.x, m_monitor->m_size.y); - if (resource->version() < OUTPUT_DONE_DEPRECATED_SINCE_VERSION) - resource->sendDone(); + if (m_resource->version() < OUTPUT_DONE_DEPRECATED_SINCE_VERSION) + m_resource->sendDone(); } diff --git a/src/protocols/XDGOutput.hpp b/src/protocols/XDGOutput.hpp index 6a5be284..eccce837 100644 --- a/src/protocols/XDGOutput.hpp +++ b/src/protocols/XDGOutput.hpp @@ -15,14 +15,12 @@ class CXDGOutput { void sendDetails(); private: - PHLMONITORREF monitor; - SP<CZxdgOutputV1> resource; - WP<CWLOutputProtocol> outputProto; + PHLMONITORREF m_monitor; + SP<CZxdgOutputV1> m_resource; + WP<CWLOutputProtocol> m_outputProto; - std::optional<Vector2D> overridePosition; - - wl_client* client = nullptr; - bool isXWayland = false; + wl_client* m_client = nullptr; + bool m_isXWayland = false; friend class CXDGOutputProtocol; }; @@ -40,8 +38,8 @@ class CXDGOutputProtocol : public IWaylandProtocol { void onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource); // - std::vector<UP<CZxdgOutputManagerV1>> m_vManagerResources; - std::vector<UP<CXDGOutput>> m_vXDGOutputs; + std::vector<UP<CZxdgOutputManagerV1>> m_managerResources; + std::vector<UP<CXDGOutput>> m_xdgOutputs; friend class CXDGOutput; }; diff --git a/src/protocols/XDGShell.cpp b/src/protocols/XDGShell.cpp index 6f58ef64..d3d5c18e 100644 --- a/src/protocols/XDGShell.cpp +++ b/src/protocols/XDGShell.cpp @@ -26,72 +26,72 @@ void SXDGPositionerState::setGravity(xdgPositionerGravity edges) { } CXDGPopupResource::CXDGPopupResource(SP<CXdgPopup> resource_, SP<CXDGSurfaceResource> owner_, SP<CXDGSurfaceResource> surface_, SP<CXDGPositionerResource> positioner) : - surface(surface_), parent(owner_), resource(resource_), positionerRules(positioner) { + m_surface(surface_), m_parent(owner_), m_resource(resource_), m_positionerRules(positioner) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setDestroy([this](CXdgPopup* r) { - if (surface && surface->mapped) - surface->events.unmap.emit(); - PROTO::xdgShell->onPopupDestroy(self); - events.destroy.emit(); + m_resource->setDestroy([this](CXdgPopup* r) { + if (m_surface && m_surface->m_mapped) + m_surface->m_events.unmap.emit(); + PROTO::xdgShell->onPopupDestroy(m_self); + m_events.destroy.emit(); PROTO::xdgShell->destroyResource(this); }); - resource->setOnDestroy([this](CXdgPopup* r) { - if (surface && surface->mapped) - surface->events.unmap.emit(); - PROTO::xdgShell->onPopupDestroy(self); - events.destroy.emit(); + m_resource->setOnDestroy([this](CXdgPopup* r) { + if (m_surface && m_surface->m_mapped) + m_surface->m_events.unmap.emit(); + PROTO::xdgShell->onPopupDestroy(m_self); + m_events.destroy.emit(); PROTO::xdgShell->destroyResource(this); }); - resource->setReposition([this](CXdgPopup* r, wl_resource* positionerRes, uint32_t token) { + m_resource->setReposition([this](CXdgPopup* r, wl_resource* positionerRes, uint32_t token) { LOGM(LOG, "Popup {:x} asks for reposition", (uintptr_t)this); - lastRepositionToken = token; - auto pos = CXDGPositionerResource::fromResource(positionerRes); + m_lastRepositionToken = token; + auto pos = CXDGPositionerResource::fromResource(positionerRes); if (!pos) return; - positionerRules = CXDGPositionerRules{pos}; - events.reposition.emit(); + m_positionerRules = CXDGPositionerRules{pos}; + m_events.reposition.emit(); }); - resource->setGrab([this](CXdgPopup* r, wl_resource* seat, uint32_t serial) { + m_resource->setGrab([this](CXdgPopup* r, wl_resource* seat, uint32_t serial) { LOGM(LOG, "xdg_popup {:x} requests grab", (uintptr_t)this); - PROTO::xdgShell->addOrStartGrab(self.lock()); + PROTO::xdgShell->addOrStartGrab(m_self.lock()); }); - if (parent) - taken = true; + if (m_parent) + m_taken = true; } CXDGPopupResource::~CXDGPopupResource() { - PROTO::xdgShell->onPopupDestroy(self); - events.destroy.emit(); + PROTO::xdgShell->onPopupDestroy(m_self); + m_events.destroy.emit(); } void CXDGPopupResource::applyPositioning(const CBox& box, const Vector2D& t1coord) { - CBox constraint = box.copy().translate(surface->pending.geometry.pos()); + CBox constraint = box.copy().translate(m_surface->m_pending.geometry.pos()); - geometry = positionerRules.getPosition(constraint, accumulateParentOffset() + t1coord); + m_geometry = m_positionerRules.getPosition(constraint, accumulateParentOffset() + t1coord); - LOGM(LOG, "Popup {:x} gets unconstrained to {} {}", (uintptr_t)this, geometry.pos(), geometry.size()); + LOGM(LOG, "Popup {:x} gets unconstrained to {} {}", (uintptr_t)this, m_geometry.pos(), m_geometry.size()); - configure(geometry); + configure(m_geometry); - if UNLIKELY (lastRepositionToken) + if UNLIKELY (m_lastRepositionToken) repositioned(); } Vector2D CXDGPopupResource::accumulateParentOffset() { - SP<CXDGSurfaceResource> current = parent.lock(); + SP<CXDGSurfaceResource> current = m_parent.lock(); Vector2D off; while (current) { - off += current->current.geometry.pos(); - if (current->popup) { - off += current->popup->geometry.pos(); - current = current->popup->parent.lock(); + off += current->m_current.geometry.pos(); + if (current->m_popup) { + off += current->m_popup->m_geometry.pos(); + current = current->m_popup->m_parent.lock(); } else break; } @@ -100,399 +100,399 @@ Vector2D CXDGPopupResource::accumulateParentOffset() { SP<CXDGPopupResource> CXDGPopupResource::fromResource(wl_resource* res) { auto data = (CXDGPopupResource*)(((CXdgPopup*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } bool CXDGPopupResource::good() { - return resource->resource(); + return m_resource->resource(); } void CXDGPopupResource::configure(const CBox& box) { - resource->sendConfigure(box.x, box.y, box.w, box.h); - if (surface) - surface->scheduleConfigure(); + m_resource->sendConfigure(box.x, box.y, box.w, box.h); + if (m_surface) + m_surface->scheduleConfigure(); } void CXDGPopupResource::done() { - events.dismissed.emit(); - resource->sendPopupDone(); + m_events.dismissed.emit(); + m_resource->sendPopupDone(); } void CXDGPopupResource::repositioned() { - if LIKELY (!lastRepositionToken) + if LIKELY (!m_lastRepositionToken) return; - LOGM(LOG, "repositioned: sending reposition token {}", lastRepositionToken); + LOGM(LOG, "repositioned: sending reposition token {}", m_lastRepositionToken); - resource->sendRepositioned(lastRepositionToken); - lastRepositionToken = 0; + m_resource->sendRepositioned(m_lastRepositionToken); + m_lastRepositionToken = 0; } -CXDGToplevelResource::CXDGToplevelResource(SP<CXdgToplevel> resource_, SP<CXDGSurfaceResource> owner_) : owner(owner_), resource(resource_) { +CXDGToplevelResource::CXDGToplevelResource(SP<CXdgToplevel> resource_, SP<CXDGSurfaceResource> owner_) : m_owner(owner_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setDestroy([this](CXdgToplevel* r) { - events.destroy.emit(); + m_resource->setDestroy([this](CXdgToplevel* r) { + m_events.destroy.emit(); PROTO::xdgShell->destroyResource(this); }); - resource->setOnDestroy([this](CXdgToplevel* r) { - events.destroy.emit(); + m_resource->setOnDestroy([this](CXdgToplevel* r) { + m_events.destroy.emit(); PROTO::xdgShell->destroyResource(this); }); - if (resource->version() >= 5) { + if (m_resource->version() >= 5) { wl_array arr; wl_array_init(&arr); auto p = (uint32_t*)wl_array_add(&arr, sizeof(uint32_t)); *p = XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN; p = (uint32_t*)wl_array_add(&arr, sizeof(uint32_t)); *p = XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE; - resource->sendWmCapabilities(&arr); + m_resource->sendWmCapabilities(&arr); wl_array_release(&arr); } - if (resource->version() >= 2) { - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_LEFT); - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_RIGHT); - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_TOP); - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_BOTTOM); + if (m_resource->version() >= 2) { + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_LEFT); + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_RIGHT); + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_TOP); + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_TILED_BOTTOM); } - resource->setSetTitle([this](CXdgToplevel* r, const char* t) { - state.title = t; - events.metadataChanged.emit(); + m_resource->setSetTitle([this](CXdgToplevel* r, const char* t) { + m_state.title = t; + m_events.metadataChanged.emit(); }); - resource->setSetAppId([this](CXdgToplevel* r, const char* id) { - state.appid = id; - events.metadataChanged.emit(); + m_resource->setSetAppId([this](CXdgToplevel* r, const char* id) { + m_state.appid = id; + m_events.metadataChanged.emit(); }); - resource->setSetMaxSize([this](CXdgToplevel* r, int32_t x, int32_t y) { - pending.maxSize = {x, y}; - events.sizeLimitsChanged.emit(); + m_resource->setSetMaxSize([this](CXdgToplevel* r, int32_t x, int32_t y) { + m_pending.maxSize = {x, y}; + m_events.sizeLimitsChanged.emit(); }); - resource->setSetMinSize([this](CXdgToplevel* r, int32_t x, int32_t y) { - pending.minSize = {x, y}; - events.sizeLimitsChanged.emit(); + m_resource->setSetMinSize([this](CXdgToplevel* r, int32_t x, int32_t y) { + m_pending.minSize = {x, y}; + m_events.sizeLimitsChanged.emit(); }); - resource->setSetMaximized([this](CXdgToplevel* r) { - state.requestsMaximize = true; - events.stateChanged.emit(); - state.requestsMaximize.reset(); + m_resource->setSetMaximized([this](CXdgToplevel* r) { + m_state.requestsMaximize = true; + m_events.stateChanged.emit(); + m_state.requestsMaximize.reset(); }); - resource->setUnsetMaximized([this](CXdgToplevel* r) { - state.requestsMaximize = false; - events.stateChanged.emit(); - state.requestsMaximize.reset(); + m_resource->setUnsetMaximized([this](CXdgToplevel* r) { + m_state.requestsMaximize = false; + m_events.stateChanged.emit(); + m_state.requestsMaximize.reset(); }); - resource->setSetFullscreen([this](CXdgToplevel* r, wl_resource* output) { + m_resource->setSetFullscreen([this](CXdgToplevel* r, wl_resource* output) { if (output) if (const auto PM = CWLOutputResource::fromResource(output)->m_monitor; PM) - state.requestsFullscreenMonitor = PM->m_id; + m_state.requestsFullscreenMonitor = PM->m_id; - state.requestsFullscreen = true; - events.stateChanged.emit(); - state.requestsFullscreen.reset(); - state.requestsFullscreenMonitor.reset(); + m_state.requestsFullscreen = true; + m_events.stateChanged.emit(); + m_state.requestsFullscreen.reset(); + m_state.requestsFullscreenMonitor.reset(); }); - resource->setUnsetFullscreen([this](CXdgToplevel* r) { - state.requestsFullscreen = false; - events.stateChanged.emit(); - state.requestsFullscreen.reset(); + m_resource->setUnsetFullscreen([this](CXdgToplevel* r) { + m_state.requestsFullscreen = false; + m_events.stateChanged.emit(); + m_state.requestsFullscreen.reset(); }); - resource->setSetMinimized([this](CXdgToplevel* r) { - state.requestsMinimize = true; - events.stateChanged.emit(); - state.requestsMinimize.reset(); + m_resource->setSetMinimized([this](CXdgToplevel* r) { + m_state.requestsMinimize = true; + m_events.stateChanged.emit(); + m_state.requestsMinimize.reset(); }); - resource->setSetParent([this](CXdgToplevel* r, wl_resource* parentR) { - auto oldParent = parent; + m_resource->setSetParent([this](CXdgToplevel* r, wl_resource* parentR) { + auto oldParent = m_parent; - if (parent) - std::erase(parent->children, self); + if (m_parent) + std::erase(m_parent->m_children, m_self); auto newp = parentR ? CXDGToplevelResource::fromResource(parentR) : nullptr; - parent = newp; + m_parent = newp; - if (parent) - parent->children.emplace_back(self); + if (m_parent) + m_parent->m_children.emplace_back(m_self); LOGM(LOG, "Toplevel {:x} sets parent to {:x}{}", (uintptr_t)this, (uintptr_t)newp.get(), (oldParent ? std::format(" (was {:x})", (uintptr_t)oldParent.get()) : "")); }); } CXDGToplevelResource::~CXDGToplevelResource() { - events.destroy.emit(); - if (parent) - std::erase_if(parent->children, [this](const auto& other) { return !other || other.get() == this; }); + m_events.destroy.emit(); + if (m_parent) + std::erase_if(m_parent->m_children, [this](const auto& other) { return !other || other.get() == this; }); } SP<CXDGToplevelResource> CXDGToplevelResource::fromResource(wl_resource* res) { auto data = (CXDGToplevelResource*)(((CXdgToplevel*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } bool CXDGToplevelResource::good() { - return resource->resource(); + return m_resource->resource(); } bool CXDGToplevelResource::anyChildModal() { - return std::ranges::any_of(children, [](const auto& child) { return child && child->dialog && child->dialog->modal; }); + return std::ranges::any_of(m_children, [](const auto& child) { return child && child->m_dialog && child->m_dialog->modal; }); } uint32_t CXDGToplevelResource::setSize(const Vector2D& size) { - pendingApply.size = size; + m_pendingApply.size = size; applyState(); - return owner->scheduleConfigure(); + return m_owner->scheduleConfigure(); } uint32_t CXDGToplevelResource::setMaximized(bool maximized) { - bool set = std::find(pendingApply.states.begin(), pendingApply.states.end(), XDG_TOPLEVEL_STATE_MAXIMIZED) != pendingApply.states.end(); + bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_MAXIMIZED) != m_pendingApply.states.end(); if (maximized == set) - return owner->scheduledSerial; + return m_owner->m_scheduledSerial; if (maximized && !set) - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_MAXIMIZED); + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_MAXIMIZED); else if (!maximized && set) - std::erase(pendingApply.states, XDG_TOPLEVEL_STATE_MAXIMIZED); + std::erase(m_pendingApply.states, XDG_TOPLEVEL_STATE_MAXIMIZED); applyState(); - return owner->scheduleConfigure(); + return m_owner->scheduleConfigure(); } uint32_t CXDGToplevelResource::setFullscreen(bool fullscreen) { - bool set = std::find(pendingApply.states.begin(), pendingApply.states.end(), XDG_TOPLEVEL_STATE_FULLSCREEN) != pendingApply.states.end(); + bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_FULLSCREEN) != m_pendingApply.states.end(); if (fullscreen == set) - return owner->scheduledSerial; + return m_owner->m_scheduledSerial; if (fullscreen && !set) - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_FULLSCREEN); + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_FULLSCREEN); else if (!fullscreen && set) - std::erase(pendingApply.states, XDG_TOPLEVEL_STATE_FULLSCREEN); + std::erase(m_pendingApply.states, XDG_TOPLEVEL_STATE_FULLSCREEN); applyState(); - return owner->scheduleConfigure(); + return m_owner->scheduleConfigure(); } uint32_t CXDGToplevelResource::setActive(bool active) { - bool set = std::find(pendingApply.states.begin(), pendingApply.states.end(), XDG_TOPLEVEL_STATE_ACTIVATED) != pendingApply.states.end(); + bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_ACTIVATED) != m_pendingApply.states.end(); if (active == set) - return owner->scheduledSerial; + return m_owner->m_scheduledSerial; if (active && !set) - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_ACTIVATED); + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_ACTIVATED); else if (!active && set) - std::erase(pendingApply.states, XDG_TOPLEVEL_STATE_ACTIVATED); + std::erase(m_pendingApply.states, XDG_TOPLEVEL_STATE_ACTIVATED); applyState(); - return owner->scheduleConfigure(); + return m_owner->scheduleConfigure(); } uint32_t CXDGToplevelResource::setSuspeneded(bool sus) { - if (resource->version() < 6) - return owner->scheduleConfigure(); // SUSPENDED is since 6 + if (m_resource->version() < 6) + return m_owner->scheduleConfigure(); // SUSPENDED is since 6 - bool set = std::find(pendingApply.states.begin(), pendingApply.states.end(), XDG_TOPLEVEL_STATE_SUSPENDED) != pendingApply.states.end(); + bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_SUSPENDED) != m_pendingApply.states.end(); if (sus == set) - return owner->scheduledSerial; + return m_owner->m_scheduledSerial; if (sus && !set) - pendingApply.states.push_back(XDG_TOPLEVEL_STATE_SUSPENDED); + m_pendingApply.states.push_back(XDG_TOPLEVEL_STATE_SUSPENDED); else if (!sus && set) - std::erase(pendingApply.states, XDG_TOPLEVEL_STATE_SUSPENDED); + std::erase(m_pendingApply.states, XDG_TOPLEVEL_STATE_SUSPENDED); applyState(); - return owner->scheduleConfigure(); + return m_owner->scheduleConfigure(); } void CXDGToplevelResource::applyState() { wl_array arr; wl_array_init(&arr); - if (!pendingApply.states.empty()) { - wl_array_add(&arr, pendingApply.states.size() * sizeof(int)); - memcpy(arr.data, pendingApply.states.data(), pendingApply.states.size() * sizeof(int)); + if (!m_pendingApply.states.empty()) { + wl_array_add(&arr, m_pendingApply.states.size() * sizeof(int)); + memcpy(arr.data, m_pendingApply.states.data(), m_pendingApply.states.size() * sizeof(int)); } - resource->sendConfigure(pendingApply.size.x, pendingApply.size.y, &arr); + m_resource->sendConfigure(m_pendingApply.size.x, m_pendingApply.size.y, &arr); wl_array_release(&arr); } void CXDGToplevelResource::close() { - resource->sendClose(); + m_resource->sendClose(); } Vector2D CXDGToplevelResource::layoutMinSize() { Vector2D minSize; - if (current.minSize.x > 1) - minSize.x = owner ? current.minSize.x + owner->current.geometry.pos().x : current.minSize.x; - if (current.minSize.y > 1) - minSize.y = owner ? current.minSize.y + owner->current.geometry.pos().y : current.minSize.y; + if (m_current.minSize.x > 1) + minSize.x = m_owner ? m_current.minSize.x + m_owner->m_current.geometry.pos().x : m_current.minSize.x; + if (m_current.minSize.y > 1) + minSize.y = m_owner ? m_current.minSize.y + m_owner->m_current.geometry.pos().y : m_current.minSize.y; return minSize; } Vector2D CXDGToplevelResource::layoutMaxSize() { Vector2D maxSize; - if (current.maxSize.x > 1) - maxSize.x = owner ? current.maxSize.x + owner->current.geometry.pos().x : current.maxSize.x; - if (current.maxSize.y > 1) - maxSize.y = owner ? current.maxSize.y + owner->current.geometry.pos().y : current.maxSize.y; + if (m_current.maxSize.x > 1) + maxSize.x = m_owner ? m_current.maxSize.x + m_owner->m_current.geometry.pos().x : m_current.maxSize.x; + if (m_current.maxSize.y > 1) + maxSize.y = m_owner ? m_current.maxSize.y + m_owner->m_current.geometry.pos().y : m_current.maxSize.y; return maxSize; } CXDGSurfaceResource::CXDGSurfaceResource(SP<CXdgSurface> resource_, SP<CXDGWMBase> owner_, SP<CWLSurfaceResource> surface_) : - owner(owner_), surface(surface_), resource(resource_) { + m_owner(owner_), m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setDestroy([this](CXdgSurface* r) { - if (mapped) - events.unmap.emit(); - events.destroy.emit(); + m_resource->setDestroy([this](CXdgSurface* r) { + if (m_mapped) + m_events.unmap.emit(); + m_events.destroy.emit(); PROTO::xdgShell->destroyResource(this); }); - resource->setOnDestroy([this](CXdgSurface* r) { - if (mapped) - events.unmap.emit(); - events.destroy.emit(); + m_resource->setOnDestroy([this](CXdgSurface* r) { + if (m_mapped) + m_events.unmap.emit(); + m_events.destroy.emit(); PROTO::xdgShell->destroyResource(this); }); - listeners.surfaceDestroy = surface->m_events.destroy.registerListener([this](std::any d) { + m_listeners.surfaceDestroy = m_surface->m_events.destroy.registerListener([this](std::any d) { LOGM(WARN, "wl_surface destroyed before its xdg_surface role object"); - listeners.surfaceDestroy.reset(); - listeners.surfaceCommit.reset(); + m_listeners.surfaceDestroy.reset(); + m_listeners.surfaceCommit.reset(); - if (mapped) - events.unmap.emit(); + if (m_mapped) + m_events.unmap.emit(); - mapped = false; - surface.reset(); - events.destroy.emit(); + m_mapped = false; + m_surface.reset(); + m_events.destroy.emit(); }); - listeners.surfaceCommit = surface->m_events.commit.registerListener([this](std::any d) { - current = pending; - if (toplevel) - toplevel->current = toplevel->pending; + m_listeners.surfaceCommit = m_surface->m_events.commit.registerListener([this](std::any d) { + m_current = m_pending; + if (m_toplevel) + m_toplevel->m_current = m_toplevel->m_pending; - if UNLIKELY (initialCommit && surface->m_pending.buffer) { - resource->error(-1, "Buffer attached before initial commit"); + if UNLIKELY (m_initialCommit && m_surface->m_pending.buffer) { + m_resource->error(-1, "Buffer attached before initial commit"); return; } - if (surface->m_current.texture && !mapped) { + if (m_surface->m_current.texture && !m_mapped) { // this forces apps to not draw CSD. - if (toplevel) - toplevel->setMaximized(true); + if (m_toplevel) + m_toplevel->setMaximized(true); - mapped = true; - surface->map(); - events.map.emit(); + m_mapped = true; + m_surface->map(); + m_events.map.emit(); return; } - if (!surface->m_current.texture && mapped) { - mapped = false; - events.unmap.emit(); - surface->unmap(); + if (!m_surface->m_current.texture && m_mapped) { + m_mapped = false; + m_events.unmap.emit(); + m_surface->unmap(); return; } - events.commit.emit(); - initialCommit = false; + m_events.commit.emit(); + m_initialCommit = false; }); - resource->setGetToplevel([this](CXdgSurface* r, uint32_t id) { - const auto RESOURCE = PROTO::xdgShell->m_vToplevels.emplace_back(makeShared<CXDGToplevelResource>(makeShared<CXdgToplevel>(r->client(), r->version(), id), self.lock())); + m_resource->setGetToplevel([this](CXdgSurface* r, uint32_t id) { + const auto RESOURCE = PROTO::xdgShell->m_toplevels.emplace_back(makeShared<CXDGToplevelResource>(makeShared<CXdgToplevel>(r->client(), r->version(), id), m_self.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xdgShell->m_vToplevels.pop_back(); + PROTO::xdgShell->m_toplevels.pop_back(); return; } - toplevel = RESOURCE; - toplevel->self = RESOURCE; + m_toplevel = RESOURCE; + m_toplevel->m_self = RESOURCE; - LOGM(LOG, "xdg_surface {:x} gets a toplevel {:x}", (uintptr_t)owner.get(), (uintptr_t)RESOURCE.get()); + LOGM(LOG, "xdg_surface {:x} gets a toplevel {:x}", (uintptr_t)m_owner.get(), (uintptr_t)RESOURCE.get()); - g_pCompositor->m_windows.emplace_back(CWindow::create(self.lock())); + g_pCompositor->m_windows.emplace_back(CWindow::create(m_self.lock())); - for (auto const& p : popups) { + for (auto const& p : m_popups) { if (!p) continue; - events.newPopup.emit(p); + m_events.newPopup.emit(p); } }); - resource->setGetPopup([this](CXdgSurface* r, uint32_t id, wl_resource* parentXDG, wl_resource* positionerRes) { + m_resource->setGetPopup([this](CXdgSurface* r, uint32_t id, wl_resource* parentXDG, wl_resource* positionerRes) { auto parent = parentXDG ? CXDGSurfaceResource::fromResource(parentXDG) : nullptr; auto positioner = CXDGPositionerResource::fromResource(positionerRes); const auto RESOURCE = - PROTO::xdgShell->m_vPopups.emplace_back(makeShared<CXDGPopupResource>(makeShared<CXdgPopup>(r->client(), r->version(), id), parent, self.lock(), positioner)); + PROTO::xdgShell->m_popups.emplace_back(makeShared<CXDGPopupResource>(makeShared<CXdgPopup>(r->client(), r->version(), id), parent, m_self.lock(), positioner)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xdgShell->m_vPopups.pop_back(); + PROTO::xdgShell->m_popups.pop_back(); return; } - popup = RESOURCE; - RESOURCE->self = RESOURCE; + m_popup = RESOURCE; + RESOURCE->m_self = RESOURCE; - LOGM(LOG, "xdg_surface {:x} gets a popup {:x} owner {:x}", (uintptr_t)self.get(), (uintptr_t)RESOURCE.get(), (uintptr_t)parent.get()); + LOGM(LOG, "xdg_surface {:x} gets a popup {:x} owner {:x}", (uintptr_t)m_self.get(), (uintptr_t)RESOURCE.get(), (uintptr_t)parent.get()); if (!parent) return; - parent->popups.emplace_back(RESOURCE); - if (parent->mapped) - parent->events.newPopup.emit(RESOURCE); + parent->m_popups.emplace_back(RESOURCE); + if (parent->m_mapped) + parent->m_events.newPopup.emit(RESOURCE); }); - resource->setAckConfigure([this](CXdgSurface* r, uint32_t serial) { - if (serial < lastConfigureSerial) + m_resource->setAckConfigure([this](CXdgSurface* r, uint32_t serial) { + if (serial < m_lastConfigureSerial) return; - lastConfigureSerial = serial; - events.ack.emit(serial); + m_lastConfigureSerial = serial; + m_events.ack.emit(serial); }); - resource->setSetWindowGeometry([this](CXdgSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { + m_resource->setSetWindowGeometry([this](CXdgSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { LOGM(LOG, "xdg_surface {:x} requests geometry {}x{} {}x{}", (uintptr_t)this, x, y, w, h); - pending.geometry = {x, y, w, h}; + m_pending.geometry = {x, y, w, h}; }); } CXDGSurfaceResource::~CXDGSurfaceResource() { - events.destroy.emit(); - if (configureSource) - wl_event_source_remove(configureSource); - if (surface) - surface->resetRole(); + m_events.destroy.emit(); + if (m_configureSource) + wl_event_source_remove(m_configureSource); + if (m_surface) + m_surface->resetRole(); } bool CXDGSurfaceResource::good() { - return resource->resource(); + return m_resource->resource(); } SP<CXDGSurfaceResource> CXDGSurfaceResource::fromResource(wl_resource* res) { auto data = (CXDGSurfaceResource*)(((CXdgSurface*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } static void onConfigure(void* data) { @@ -500,54 +500,54 @@ static void onConfigure(void* data) { } uint32_t CXDGSurfaceResource::scheduleConfigure() { - if (configureSource) - return scheduledSerial; + if (m_configureSource) + return m_scheduledSerial; - configureSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, onConfigure, this); - scheduledSerial = wl_display_next_serial(g_pCompositor->m_wlDisplay); + m_configureSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, onConfigure, this); + m_scheduledSerial = wl_display_next_serial(g_pCompositor->m_wlDisplay); - return scheduledSerial; + return m_scheduledSerial; } void CXDGSurfaceResource::configure() { - configureSource = nullptr; - resource->sendConfigure(scheduledSerial); + m_configureSource = nullptr; + m_resource->sendConfigure(m_scheduledSerial); } -CXDGPositionerResource::CXDGPositionerResource(SP<CXdgPositioner> resource_, SP<CXDGWMBase> owner_) : owner(owner_), resource(resource_) { +CXDGPositionerResource::CXDGPositionerResource(SP<CXdgPositioner> resource_, SP<CXDGWMBase> owner_) : m_owner(owner_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setDestroy([this](CXdgPositioner* r) { PROTO::xdgShell->destroyResource(this); }); - resource->setOnDestroy([this](CXdgPositioner* r) { PROTO::xdgShell->destroyResource(this); }); + m_resource->setDestroy([this](CXdgPositioner* r) { PROTO::xdgShell->destroyResource(this); }); + m_resource->setOnDestroy([this](CXdgPositioner* r) { PROTO::xdgShell->destroyResource(this); }); - resource->setSetSize([this](CXdgPositioner* r, int32_t x, int32_t y) { + m_resource->setSetSize([this](CXdgPositioner* r, int32_t x, int32_t y) { if UNLIKELY (x <= 0 || y <= 0) { r->error(XDG_POSITIONER_ERROR_INVALID_INPUT, "Invalid size"); return; } - state.requestedSize = {x, y}; + m_state.requestedSize = {x, y}; }); - resource->setSetAnchorRect([this](CXdgPositioner* r, int32_t x, int32_t y, int32_t w, int32_t h) { + m_resource->setSetAnchorRect([this](CXdgPositioner* r, int32_t x, int32_t y, int32_t w, int32_t h) { if UNLIKELY (w <= 0 || h <= 0) { r->error(XDG_POSITIONER_ERROR_INVALID_INPUT, "Invalid box"); return; } - state.anchorRect = {x, y, w, h}; + m_state.anchorRect = {x, y, w, h}; }); - resource->setSetOffset([this](CXdgPositioner* r, int32_t x, int32_t y) { state.offset = {x, y}; }); + m_resource->setSetOffset([this](CXdgPositioner* r, int32_t x, int32_t y) { m_state.offset = {x, y}; }); - resource->setSetAnchor([this](CXdgPositioner* r, xdgPositionerAnchor a) { state.setAnchor(a); }); + m_resource->setSetAnchor([this](CXdgPositioner* r, xdgPositionerAnchor a) { m_state.setAnchor(a); }); - resource->setSetGravity([this](CXdgPositioner* r, xdgPositionerGravity g) { state.setGravity(g); }); + m_resource->setSetGravity([this](CXdgPositioner* r, xdgPositionerGravity g) { m_state.setGravity(g); }); - resource->setSetConstraintAdjustment([this](CXdgPositioner* r, xdgPositionerConstraintAdjustment a) { state.constraintAdjustment = (uint32_t)a; }); + m_resource->setSetConstraintAdjustment([this](CXdgPositioner* r, xdgPositionerConstraintAdjustment a) { m_state.constraintAdjustment = (uint32_t)a; }); // TODO: support this shit better. The current impl _works_, but is lacking and could be wrong in a few cases. // doesn't matter _that_ much for now, though. @@ -555,14 +555,14 @@ CXDGPositionerResource::CXDGPositionerResource(SP<CXdgPositioner> resource_, SP< SP<CXDGPositionerResource> CXDGPositionerResource::fromResource(wl_resource* res) { auto data = (CXDGPositionerResource*)(((CXdgPositioner*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } bool CXDGPositionerResource::good() { - return resource->resource(); + return m_resource->resource(); } -CXDGPositionerRules::CXDGPositionerRules(SP<CXDGPositionerResource> positioner) : state(positioner->state) { +CXDGPositionerRules::CXDGPositionerRules(SP<CXDGPositionerResource> positioner) : m_state(positioner->m_state) { ; } @@ -572,20 +572,20 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo // padding constraint.expand(-4); - auto anchorRect = state.anchorRect.copy().translate(parentCoord); + auto anchorRect = m_state.anchorRect.copy().translate(parentCoord); - auto width = state.requestedSize.x; - auto height = state.requestedSize.y; - auto gravity = state.gravity; + auto width = m_state.requestedSize.x; + auto height = m_state.requestedSize.y; + auto gravity = m_state.gravity; - auto anchorX = state.anchor.left() ? anchorRect.x : state.anchor.right() ? anchorRect.extent().x : anchorRect.middle().x; - auto anchorY = state.anchor.top() ? anchorRect.y : state.anchor.bottom() ? anchorRect.extent().y : anchorRect.middle().y; + auto anchorX = m_state.anchor.left() ? anchorRect.x : m_state.anchor.right() ? anchorRect.extent().x : anchorRect.middle().x; + auto anchorY = m_state.anchor.top() ? anchorRect.y : m_state.anchor.bottom() ? anchorRect.extent().y : anchorRect.middle().y; auto calcEffectiveX = [&](CEdges anchorGravity, double anchorX) { return anchorGravity.left() ? anchorX - width : anchorGravity.right() ? anchorX : anchorX - width / 2; }; auto calcEffectiveY = [&](CEdges anchorGravity, double anchorY) { return anchorGravity.top() ? anchorY - height : anchorGravity.bottom() ? anchorY : anchorY - height / 2; }; auto calcRemainingWidth = [&](double effectiveX) { - auto width = state.requestedSize.x; + auto width = m_state.requestedSize.x; if (effectiveX < constraint.x) { auto diff = constraint.x - effectiveX; effectiveX = constraint.x; @@ -600,7 +600,7 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo }; auto calcRemainingHeight = [&](double effectiveY) { - auto height = state.requestedSize.y; + auto height = m_state.requestedSize.y; if (effectiveY < constraint.y) { auto diff = constraint.y - effectiveY; effectiveY = constraint.y; @@ -621,12 +621,12 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo // It considers the offset when deciding whether or not to flip but does not actually flip the offset, instead // applying it after the flip step. - if (state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X) { - auto flip = (gravity.left() && effectiveX + state.offset.x < constraint.x) || (gravity.right() && effectiveX + state.offset.x + width > constraint.extent().x); + if (m_state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X) { + auto flip = (gravity.left() && effectiveX + m_state.offset.x < constraint.x) || (gravity.right() && effectiveX + m_state.offset.x + width > constraint.extent().x); if (flip) { auto newGravity = gravity ^ (CEdges::LEFT | CEdges::RIGHT); - auto newAnchorX = state.anchor.left() ? anchorRect.extent().x : state.anchor.right() ? anchorRect.x : anchorX; + auto newAnchorX = m_state.anchor.left() ? anchorRect.extent().x : m_state.anchor.right() ? anchorRect.x : anchorX; auto newEffectiveX = calcEffectiveX(newGravity, newAnchorX); if (calcRemainingWidth(newEffectiveX).second > calcRemainingWidth(effectiveX).second) { @@ -637,12 +637,13 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo } } - if (state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y) { - auto flip = (state.gravity.top() && effectiveY + state.offset.y < constraint.y) || (state.gravity.bottom() && effectiveY + state.offset.y + height > constraint.extent().y); + if (m_state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y) { + auto flip = + (m_state.gravity.top() && effectiveY + m_state.offset.y < constraint.y) || (m_state.gravity.bottom() && effectiveY + m_state.offset.y + height > constraint.extent().y); if (flip) { auto newGravity = gravity ^ (CEdges::TOP | CEdges::BOTTOM); - auto newAnchorY = state.anchor.top() ? anchorRect.extent().y : state.anchor.bottom() ? anchorRect.y : anchorY; + auto newAnchorY = m_state.anchor.top() ? anchorRect.extent().y : m_state.anchor.bottom() ? anchorRect.y : anchorY; auto newEffectiveY = calcEffectiveY(newGravity, newAnchorY); if (calcRemainingHeight(newEffectiveY).second > calcRemainingHeight(effectiveY).second) { @@ -653,12 +654,12 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo } } - effectiveX += state.offset.x; - effectiveY += state.offset.y; + effectiveX += m_state.offset.x; + effectiveY += m_state.offset.y; // Slide order is important for the case where the window is too large to fit on screen. - if (state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X) { + if (m_state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X) { if (effectiveX + width > constraint.extent().x) effectiveX = constraint.extent().x - width; @@ -666,7 +667,7 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo effectiveX = constraint.x; } - if (state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y) { + if (m_state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y) { if (effectiveY + height > constraint.extent().y) effectiveY = constraint.extent().y - height; @@ -674,13 +675,13 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo effectiveY = constraint.y; } - if (state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X) { + if (m_state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X) { auto [newX, newWidth] = calcRemainingWidth(effectiveX); effectiveX = newX; width = newWidth; } - if (state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y) { + if (m_state.constraintAdjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y) { auto [newY, newHeight] = calcRemainingHeight(effectiveY); effectiveY = newY; height = newHeight; @@ -689,33 +690,33 @@ CBox CXDGPositionerRules::getPosition(CBox constraint, const Vector2D& parentCoo return {effectiveX - parentCoord.x, effectiveY - parentCoord.y, width, height}; } -CXDGWMBase::CXDGWMBase(SP<CXdgWmBase> resource_) : resource(resource_) { +CXDGWMBase::CXDGWMBase(SP<CXdgWmBase> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CXdgWmBase* r) { PROTO::xdgShell->destroyResource(this); }); - resource->setOnDestroy([this](CXdgWmBase* r) { PROTO::xdgShell->destroyResource(this); }); + m_resource->setDestroy([this](CXdgWmBase* r) { PROTO::xdgShell->destroyResource(this); }); + m_resource->setOnDestroy([this](CXdgWmBase* r) { PROTO::xdgShell->destroyResource(this); }); - pClient = resource->client(); + m_client = m_resource->client(); - resource->setCreatePositioner([this](CXdgWmBase* r, uint32_t id) { + m_resource->setCreatePositioner([this](CXdgWmBase* r, uint32_t id) { const auto RESOURCE = - PROTO::xdgShell->m_vPositioners.emplace_back(makeShared<CXDGPositionerResource>(makeShared<CXdgPositioner>(r->client(), r->version(), id), self.lock())); + PROTO::xdgShell->m_positioners.emplace_back(makeShared<CXDGPositionerResource>(makeShared<CXdgPositioner>(r->client(), r->version(), id), m_self.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xdgShell->m_vPositioners.pop_back(); + PROTO::xdgShell->m_positioners.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; - positioners.emplace_back(RESOURCE); + m_positioners.emplace_back(RESOURCE); LOGM(LOG, "New xdg_positioner at {:x}", (uintptr_t)RESOURCE.get()); }); - resource->setGetXdgSurface([this](CXdgWmBase* r, uint32_t id, wl_resource* surf) { + m_resource->setGetXdgSurface([this](CXdgWmBase* r, uint32_t id, wl_resource* surf) { auto SURF = CWLSurfaceResource::fromResource(surf); if UNLIKELY (!SURF) { @@ -728,123 +729,124 @@ CXDGWMBase::CXDGWMBase(SP<CXdgWmBase> resource_) : resource(resource_) { return; } - const auto RESOURCE = PROTO::xdgShell->m_vSurfaces.emplace_back(makeShared<CXDGSurfaceResource>(makeShared<CXdgSurface>(r->client(), r->version(), id), self.lock(), SURF)); + const auto RESOURCE = + PROTO::xdgShell->m_surfaces.emplace_back(makeShared<CXDGSurfaceResource>(makeShared<CXdgSurface>(r->client(), r->version(), id), m_self.lock(), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xdgShell->m_vSurfaces.pop_back(); + PROTO::xdgShell->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; - RESOURCE->surface = SURF; - SURF->m_role = makeShared<CXDGSurfaceRole>(RESOURCE); + RESOURCE->m_self = RESOURCE; + RESOURCE->m_surface = SURF; + SURF->m_role = makeShared<CXDGSurfaceRole>(RESOURCE); - surfaces.emplace_back(RESOURCE); + m_surfaces.emplace_back(RESOURCE); LOGM(LOG, "New xdg_surface at {:x}", (uintptr_t)RESOURCE.get()); }); - resource->setPong([this](CXdgWmBase* r, uint32_t serial) { - g_pANRManager->onResponse(self.lock()); - events.pong.emit(); + m_resource->setPong([this](CXdgWmBase* r, uint32_t serial) { + g_pANRManager->onResponse(m_self.lock()); + m_events.pong.emit(); }); } bool CXDGWMBase::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXDGWMBase::client() { - return pClient; + return m_client; } void CXDGWMBase::ping() { - resource->sendPing(1337); + m_resource->sendPing(1337); } CXDGShellProtocol::CXDGShellProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { - grab = makeShared<CSeatGrab>(); - grab->m_keyboard = true; - grab->m_pointer = true; - grab->setCallback([this]() { - for (auto const& g : grabbed) { + m_grab = makeShared<CSeatGrab>(); + m_grab->m_keyboard = true; + m_grab->m_pointer = true; + m_grab->setCallback([this]() { + for (auto const& g : m_grabbed) { g->done(); } - grabbed.clear(); + m_grabbed.clear(); }); } void CXDGShellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vWMBases.emplace_back(makeShared<CXDGWMBase>(makeShared<CXdgWmBase>(client, ver, id))); + const auto RESOURCE = m_wmBases.emplace_back(makeShared<CXDGWMBase>(makeShared<CXdgWmBase>(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vWMBases.pop_back(); + m_wmBases.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; LOGM(LOG, "New xdg_wm_base at {:x}", (uintptr_t)RESOURCE.get()); } void CXDGShellProtocol::destroyResource(CXDGWMBase* resource) { - std::erase_if(m_vWMBases, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_wmBases, [&](const auto& other) { return other.get() == resource; }); } void CXDGShellProtocol::destroyResource(CXDGPositionerResource* resource) { - std::erase_if(m_vPositioners, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_positioners, [&](const auto& other) { return other.get() == resource; }); } void CXDGShellProtocol::destroyResource(CXDGSurfaceResource* resource) { - std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; }); } void CXDGShellProtocol::destroyResource(CXDGToplevelResource* resource) { - std::erase_if(m_vToplevels, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_toplevels, [&](const auto& other) { return other.get() == resource; }); } void CXDGShellProtocol::destroyResource(CXDGPopupResource* resource) { - std::erase_if(m_vPopups, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_popups, [&](const auto& other) { return other.get() == resource; }); } void CXDGShellProtocol::addOrStartGrab(SP<CXDGPopupResource> popup) { - if (!grabOwner) { - grabOwner = popup; - grabbed.clear(); - grab->clear(); - grab->add(popup->surface->surface.lock()); - if (popup->parent) - grab->add(popup->parent->surface.lock()); - g_pSeatManager->setGrab(grab); - grabbed.emplace_back(popup); + if (!m_grabOwner) { + m_grabOwner = popup; + m_grabbed.clear(); + m_grab->clear(); + m_grab->add(popup->m_surface->m_surface.lock()); + if (popup->m_parent) + m_grab->add(popup->m_parent->m_surface.lock()); + g_pSeatManager->setGrab(m_grab); + m_grabbed.emplace_back(popup); return; } - grabbed.emplace_back(popup); + m_grabbed.emplace_back(popup); - grab->add(popup->surface->surface.lock()); + m_grab->add(popup->m_surface->m_surface.lock()); - if (popup->parent) - grab->add(popup->parent->surface.lock()); + if (popup->m_parent) + m_grab->add(popup->m_parent->m_surface.lock()); } void CXDGShellProtocol::onPopupDestroy(WP<CXDGPopupResource> popup) { - if (popup == grabOwner) { + if (popup == m_grabOwner) { g_pSeatManager->setGrab(nullptr); - for (auto const& g : grabbed) { + for (auto const& g : m_grabbed) { g->done(); } - grabbed.clear(); + m_grabbed.clear(); return; } - std::erase(grabbed, popup); - if (popup->surface) - grab->remove(popup->surface->surface.lock()); + std::erase(m_grabbed, popup); + if (popup->m_surface) + m_grab->remove(popup->m_surface->m_surface.lock()); } -CXDGSurfaceRole::CXDGSurfaceRole(SP<CXDGSurfaceResource> xdg) : xdgSurface(xdg) { +CXDGSurfaceRole::CXDGSurfaceRole(SP<CXDGSurfaceResource> xdg) : m_xdgSurface(xdg) { ; } diff --git a/src/protocols/XDGShell.hpp b/src/protocols/XDGShell.hpp index 12f76774..632467ec 100644 --- a/src/protocols/XDGShell.hpp +++ b/src/protocols/XDGShell.hpp @@ -40,7 +40,7 @@ class CXDGPositionerRules { CBox getPosition(CBox constraint, const Vector2D& parentPos); private: - SXDGPositionerState state; + SXDGPositionerState m_state; }; class CXDGPopupResource { @@ -54,19 +54,19 @@ class CXDGPopupResource { void applyPositioning(const CBox& availableBox, const Vector2D& t1coord /* relative to box */); - WP<CXDGSurfaceResource> surface; - WP<CXDGSurfaceResource> parent; - WP<CXDGPopupResource> self; + WP<CXDGSurfaceResource> m_surface; + WP<CXDGSurfaceResource> m_parent; + WP<CXDGPopupResource> m_self; - bool taken = false; + bool m_taken = false; - CBox geometry; + CBox m_geometry; struct { CSignal reposition; CSignal dismissed; CSignal destroy; // only the role - } events; + } m_events; // schedules a configure event void configure(const CBox& box); @@ -75,13 +75,13 @@ class CXDGPopupResource { void repositioned(); private: - SP<CXdgPopup> resource; + SP<CXdgPopup> m_resource; - uint32_t lastRepositionToken = 0; + uint32_t m_lastRepositionToken = 0; Vector2D accumulateParentOffset(); - CXDGPositionerRules positionerRules; + CXDGPositionerRules m_positionerRules; }; class CXDGToplevelResource { @@ -91,10 +91,10 @@ class CXDGToplevelResource { static SP<CXDGToplevelResource> fromResource(wl_resource*); - WP<CXDGSurfaceResource> owner; - WP<CXDGToplevelResource> self; + WP<CXDGSurfaceResource> m_owner; + WP<CXDGToplevelResource> m_self; - PHLWINDOWREF window; + PHLWINDOWREF m_window; bool good(); @@ -115,7 +115,7 @@ class CXDGToplevelResource { CSignal stateChanged; // maximized, fs, minimized, etc. CSignal metadataChanged; // title, appid CSignal destroy; // only the role - } events; + } m_events; struct { std::string title; @@ -126,29 +126,30 @@ class CXDGToplevelResource { std::optional<bool> requestsFullscreen; std::optional<MONITORID> requestsFullscreenMonitor; std::optional<bool> requestsMinimize; - } state; + } m_state; struct { Vector2D size; std::vector<xdgToplevelState> states; - } pendingApply; + } m_pendingApply; struct { Vector2D minSize = {1, 1}; Vector2D maxSize = {1337420, 694200}; - } pending, current; + } m_pending, m_current; - WP<CXDGToplevelResource> parent; - WP<CXDGDialogV1Resource> dialog; + WP<CXDGToplevelResource> m_parent; + WP<CXDGDialogV1Resource> m_dialog; - std::optional<std::string> m_toplevelTag, m_toplevelDescription; + std::optional<std::string> m_toplevelTag; + std::optional<std::string> m_toplevelDescription; bool anyChildModal(); - std::vector<WP<CXDGToplevelResource>> children; + std::vector<WP<CXDGToplevelResource>> m_children; private: - SP<CXdgToplevel> resource; + SP<CXdgToplevel> m_resource; void applyState(); }; @@ -160,7 +161,7 @@ class CXDGSurfaceRole : public ISurfaceRole { return SURFACE_ROLE_XDG_SHELL; } - WP<CXDGSurfaceResource> xdgSurface; + WP<CXDGSurfaceResource> m_xdgSurface; }; class CXDGSurfaceResource { @@ -172,17 +173,17 @@ class CXDGSurfaceResource { bool good(); - WP<CXDGWMBase> owner; - WP<CWLSurfaceResource> surface; + WP<CXDGWMBase> m_owner; + WP<CWLSurfaceResource> m_surface; - WP<CXDGToplevelResource> toplevel; - WP<CXDGPopupResource> popup; + WP<CXDGToplevelResource> m_toplevel; + WP<CXDGPopupResource> m_popup; - WP<CXDGSurfaceResource> self; + WP<CXDGSurfaceResource> m_self; struct { CBox geometry; - } pending, current; + } m_pending, m_current; struct { CSignal ack; @@ -191,30 +192,30 @@ class CXDGSurfaceResource { CSignal unmap; CSignal destroy; CSignal newPopup; // SP<CXDGPopupResource> - } events; + } m_events; - bool initialCommit = true; - bool mapped = false; + bool m_initialCommit = true; + bool m_mapped = false; uint32_t scheduleConfigure(); // do not call directly void configure(); private: - SP<CXdgSurface> resource; + SP<CXdgSurface> m_resource; - uint32_t lastConfigureSerial = 0; - uint32_t scheduledSerial = 0; + uint32_t m_lastConfigureSerial = 0; + uint32_t m_scheduledSerial = 0; - wl_event_source* configureSource = nullptr; + wl_event_source* m_configureSource = nullptr; // - std::vector<WP<CXDGPopupResource>> popups; + std::vector<WP<CXDGPopupResource>> m_popups; struct { CHyprSignalListener surfaceDestroy; CHyprSignalListener surfaceCommit; - } listeners; + } m_listeners; friend class CXDGPopupResource; friend class CXDGToplevelResource; @@ -228,13 +229,13 @@ class CXDGPositionerResource { bool good(); - SXDGPositionerState state; + SXDGPositionerState m_state; - WP<CXDGWMBase> owner; - WP<CXDGPositionerResource> self; + WP<CXDGWMBase> m_owner; + WP<CXDGPositionerResource> m_self; private: - SP<CXdgPositioner> resource; + SP<CXdgPositioner> m_resource; }; class CXDGWMBase { @@ -245,18 +246,18 @@ class CXDGWMBase { wl_client* client(); void ping(); - std::vector<WP<CXDGPositionerResource>> positioners; - std::vector<WP<CXDGSurfaceResource>> surfaces; + std::vector<WP<CXDGPositionerResource>> m_positioners; + std::vector<WP<CXDGSurfaceResource>> m_surfaces; - WP<CXDGWMBase> self; + WP<CXDGWMBase> m_self; struct { CSignal pong; - } events; + } m_events; private: - SP<CXdgWmBase> resource; - wl_client* pClient = nullptr; + SP<CXdgWmBase> m_resource; + wl_client* m_client = nullptr; }; class CXDGShellProtocol : public IWaylandProtocol { @@ -273,16 +274,16 @@ class CXDGShellProtocol : public IWaylandProtocol { void destroyResource(CXDGPopupResource* resource); // - std::vector<SP<CXDGWMBase>> m_vWMBases; - std::vector<SP<CXDGPositionerResource>> m_vPositioners; - std::vector<SP<CXDGSurfaceResource>> m_vSurfaces; - std::vector<SP<CXDGToplevelResource>> m_vToplevels; - std::vector<SP<CXDGPopupResource>> m_vPopups; + std::vector<SP<CXDGWMBase>> m_wmBases; + std::vector<SP<CXDGPositionerResource>> m_positioners; + std::vector<SP<CXDGSurfaceResource>> m_surfaces; + std::vector<SP<CXDGToplevelResource>> m_toplevels; + std::vector<SP<CXDGPopupResource>> m_popups; // current popup grab - WP<CXDGPopupResource> grabOwner; - SP<CSeatGrab> grab; - std::vector<WP<CXDGPopupResource>> grabbed; + WP<CXDGPopupResource> m_grabOwner; + SP<CSeatGrab> m_grab; + std::vector<WP<CXDGPopupResource>> m_grabbed; void addOrStartGrab(SP<CXDGPopupResource> popup); void onPopupDestroy(WP<CXDGPopupResource> popup); diff --git a/src/protocols/XDGTag.cpp b/src/protocols/XDGTag.cpp index 1b62918d..2966ac90 100644 --- a/src/protocols/XDGTag.cpp +++ b/src/protocols/XDGTag.cpp @@ -41,7 +41,7 @@ CXDGToplevelTagProtocol::CXDGToplevelTagProtocol(const wl_interface* iface, cons void CXDGToplevelTagProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { const auto RESOURCE = - WP<CXDGToplevelTagManagerResource>{m_vManagers.emplace_back(makeUnique<CXDGToplevelTagManagerResource>(makeUnique<CXdgToplevelTagManagerV1>(client, ver, id)))}; + WP<CXDGToplevelTagManagerResource>{m_managers.emplace_back(makeUnique<CXDGToplevelTagManagerResource>(makeUnique<CXdgToplevelTagManagerV1>(client, ver, id)))}; if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); @@ -50,5 +50,5 @@ void CXDGToplevelTagProtocol::bindManager(wl_client* client, void* data, uint32_ } void CXDGToplevelTagProtocol::destroyResource(CXDGToplevelTagManagerResource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; }); } diff --git a/src/protocols/XDGTag.hpp b/src/protocols/XDGTag.hpp index cff4da03..920d5030 100644 --- a/src/protocols/XDGTag.hpp +++ b/src/protocols/XDGTag.hpp @@ -26,7 +26,7 @@ class CXDGToplevelTagProtocol : public IWaylandProtocol { void destroyResource(CXDGToplevelTagManagerResource* res); // - std::vector<UP<CXDGToplevelTagManagerResource>> m_vManagers; + std::vector<UP<CXDGToplevelTagManagerResource>> m_managers; friend class CXDGToplevelTagManagerResource; }; diff --git a/src/protocols/XWaylandShell.cpp b/src/protocols/XWaylandShell.cpp index b4615e19..9bb75a3e 100644 --- a/src/protocols/XWaylandShell.cpp +++ b/src/protocols/XWaylandShell.cpp @@ -2,24 +2,24 @@ #include "core/Compositor.hpp" #include <algorithm> -CXWaylandSurfaceResource::CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) { +CXWaylandSurfaceResource::CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CXwaylandSurfaceV1* r) { + m_resource->setDestroy([this](CXwaylandSurfaceV1* r) { events.destroy.emit(); PROTO::xwaylandShell->destroyResource(this); }); - resource->setOnDestroy([this](CXwaylandSurfaceV1* r) { + m_resource->setOnDestroy([this](CXwaylandSurfaceV1* r) { events.destroy.emit(); PROTO::xwaylandShell->destroyResource(this); }); - pClient = resource->client(); + m_client = m_resource->client(); - resource->setSetSerial([this](CXwaylandSurfaceV1* r, uint32_t lo, uint32_t hi) { - serial = (((uint64_t)hi) << 32) + lo; - PROTO::xwaylandShell->events.newSurface.emit(self.lock()); + m_resource->setSetSerial([this](CXwaylandSurfaceV1* r, uint32_t lo, uint32_t hi) { + m_serial = (((uint64_t)hi) << 32) + lo; + PROTO::xwaylandShell->m_events.newSurface.emit(m_self.lock()); }); } @@ -28,36 +28,36 @@ CXWaylandSurfaceResource::~CXWaylandSurfaceResource() { } bool CXWaylandSurfaceResource::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXWaylandSurfaceResource::client() { - return pClient; + return m_client; } -CXWaylandShellResource::CXWaylandShellResource(SP<CXwaylandShellV1> resource_) : resource(resource_) { +CXWaylandShellResource::CXWaylandShellResource(SP<CXwaylandShellV1> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); }); - resource->setOnDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); }); + m_resource->setDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); }); + m_resource->setOnDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); }); - resource->setGetXwaylandSurface([](CXwaylandShellV1* r, uint32_t id, wl_resource* surface) { - const auto RESOURCE = PROTO::xwaylandShell->m_vSurfaces.emplace_back( + m_resource->setGetXwaylandSurface([](CXwaylandShellV1* r, uint32_t id, wl_resource* surface) { + const auto RESOURCE = PROTO::xwaylandShell->m_surfaces.emplace_back( makeShared<CXWaylandSurfaceResource>(makeShared<CXwaylandSurfaceV1>(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surface))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xwaylandShell->m_vSurfaces.pop_back(); + PROTO::xwaylandShell->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); } bool CXWaylandShellResource::good() { - return resource->resource(); + return m_resource->resource(); } CXWaylandShellProtocol::CXWaylandShellProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -65,19 +65,19 @@ CXWaylandShellProtocol::CXWaylandShellProtocol(const wl_interface* iface, const } void CXWaylandShellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXWaylandShellResource>(makeShared<CXwaylandShellV1>(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared<CXWaylandShellResource>(makeShared<CXwaylandShellV1>(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CXWaylandShellProtocol::destroyResource(CXWaylandShellResource* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CXWaylandShellProtocol::destroyResource(CXWaylandSurfaceResource* resource) { - std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; }); } diff --git a/src/protocols/XWaylandShell.hpp b/src/protocols/XWaylandShell.hpp index f6f91c49..a83f258e 100644 --- a/src/protocols/XWaylandShell.hpp +++ b/src/protocols/XWaylandShell.hpp @@ -20,14 +20,14 @@ class CXWaylandSurfaceResource { CSignal destroy; } events; - uint64_t serial = 0; - WP<CWLSurfaceResource> surface; + uint64_t m_serial = 0; + WP<CWLSurfaceResource> m_surface; - WP<CXWaylandSurfaceResource> self; + WP<CXWaylandSurfaceResource> m_self; private: - SP<CXwaylandSurfaceV1> resource; - wl_client* pClient = nullptr; + SP<CXwaylandSurfaceV1> m_resource; + wl_client* m_client = nullptr; }; class CXWaylandShellResource { @@ -37,7 +37,7 @@ class CXWaylandShellResource { bool good(); private: - SP<CXwaylandShellV1> resource; + SP<CXwaylandShellV1> m_resource; }; class CXWaylandShellProtocol : public IWaylandProtocol { @@ -48,15 +48,15 @@ class CXWaylandShellProtocol : public IWaylandProtocol { struct { CSignal newSurface; // SP<CXWaylandSurfaceResource>. Fired when it sets a serial, otherwise it's useless - } events; + } m_events; private: void destroyResource(CXWaylandSurfaceResource* resource); void destroyResource(CXWaylandShellResource* resource); // - std::vector<SP<CXWaylandShellResource>> m_vManagers; - std::vector<SP<CXWaylandSurfaceResource>> m_vSurfaces; + std::vector<SP<CXWaylandShellResource>> m_managers; + std::vector<SP<CXWaylandSurfaceResource>> m_surfaces; friend class CXWaylandSurfaceResource; friend class CXWaylandShellResource; diff --git a/src/protocols/XXColorManagement.cpp b/src/protocols/XXColorManagement.cpp index e0a9b61d..5a345f40 100644 --- a/src/protocols/XXColorManagement.cpp +++ b/src/protocols/XXColorManagement.cpp @@ -31,54 +31,54 @@ static wpColorManagerV1Primaries getWPPrimaries(xxColorManagerV4Primaries primar return (wpColorManagerV1Primaries)(primaries + 1); } -CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(resource_) { +CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES); - - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_NTSC); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_BT2020); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES); + + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_NTSC); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_BT2020); // resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_CIE1931_XYZ); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB); - - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR); - - resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB); + + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR); + + m_resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL); // resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE); // resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_ABSOLUTE); // resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE_BPC); - resource->setDestroy([](CXxColorManagerV4* r) { LOGM(TRACE, "Destroy xx_color_manager at {:x} (generated default)", (uintptr_t)r); }); - resource->setGetOutput([](CXxColorManagerV4* r, uint32_t id, wl_resource* output) { + m_resource->setDestroy([](CXxColorManagerV4* r) { LOGM(TRACE, "Destroy xx_color_manager at {:x} (generated default)", (uintptr_t)r); }); + m_resource->setGetOutput([](CXxColorManagerV4* r, uint32_t id, wl_resource* output) { LOGM(TRACE, "Get output for id={}, output={}", id, (uintptr_t)output); const auto RESOURCE = - PROTO::xxColorManagement->m_vOutputs.emplace_back(makeShared<CXXColorManagementOutput>(makeShared<CXxColorManagementOutputV4>(r->client(), r->version(), id))); + PROTO::xxColorManagement->m_outputs.emplace_back(makeShared<CXXColorManagementOutput>(makeShared<CXxColorManagementOutputV4>(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vOutputs.pop_back(); + PROTO::xxColorManagement->m_outputs.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setGetSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { + m_resource->setGetSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); auto SURF = CWLSurfaceResource::fromResource(surface); @@ -94,16 +94,16 @@ CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(res } const auto RESOURCE = - PROTO::xxColorManagement->m_vSurfaces.emplace_back(makeShared<CXXColorManagementSurface>(makeShared<CXxColorManagementSurfaceV4>(r->client(), r->version(), id), SURF)); + PROTO::xxColorManagement->m_surfaces.emplace_back(makeShared<CXXColorManagementSurface>(makeShared<CXxColorManagementSurfaceV4>(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vSurfaces.pop_back(); + PROTO::xxColorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setGetFeedbackSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { + m_resource->setGetFeedbackSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { LOGM(TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface); auto SURF = CWLSurfaceResource::fromResource(surface); @@ -113,118 +113,118 @@ CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(res return; } - const auto RESOURCE = PROTO::xxColorManagement->m_vFeedbackSurfaces.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_feedbackSurfaces.emplace_back( makeShared<CXXColorManagementFeedbackSurface>(makeShared<CXxColorManagementFeedbackSurfaceV4>(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vFeedbackSurfaces.pop_back(); + PROTO::xxColorManagement->m_feedbackSurfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setNewIccCreator([](CXxColorManagerV4* r, uint32_t id) { + m_resource->setNewIccCreator([](CXxColorManagerV4* r, uint32_t id) { LOGM(WARN, "New ICC creator for id={} (unsupported)", id); r->error(XX_COLOR_MANAGER_V4_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported"); }); - resource->setNewParametricCreator([](CXxColorManagerV4* r, uint32_t id) { + m_resource->setNewParametricCreator([](CXxColorManagerV4* r, uint32_t id) { LOGM(TRACE, "New parametric creator for id={}", id); - const auto RESOURCE = PROTO::xxColorManagement->m_vParametricCreators.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_parametricCreators.emplace_back( makeShared<CXXColorManagementParametricCreator>(makeShared<CXxImageDescriptionCreatorParamsV4>(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vParametricCreators.pop_back(); + PROTO::xxColorManagement->m_parametricCreators.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setOnDestroy([this](CXxColorManagerV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setOnDestroy([this](CXxColorManagerV4* r) { PROTO::xxColorManagement->destroyResource(this); }); } bool CXXColorManager::good() { - return resource->resource(); + return m_resource->resource(); } -CXXColorManagementOutput::CXXColorManagementOutput(SP<CXxColorManagementOutputV4> resource_) : resource(resource_) { +CXXColorManagementOutput::CXXColorManagementOutput(SP<CXxColorManagementOutputV4> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - resource->setDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); - resource->setOnDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setOnDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); - resource->setGetImageDescription([this](CXxColorManagementOutputV4* r, uint32_t id) { + m_resource->setGetImageDescription([this](CXxColorManagementOutputV4* r, uint32_t id) { LOGM(TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id); - if (imageDescription.valid()) - PROTO::xxColorManagement->destroyResource(imageDescription.get()); + if (m_imageDescription.valid()) + PROTO::xxColorManagement->destroyResource(m_imageDescription.get()); - const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back( makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), true)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vImageDescriptions.pop_back(); + PROTO::xxColorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); } bool CXXColorManagementOutput::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXXColorManagementOutput::client() { - return pClient; + return m_client; } -CXXColorManagementSurface::CXXColorManagementSurface(SP<CWLSurfaceResource> surface_) : surface(surface_) { +CXXColorManagementSurface::CXXColorManagementSurface(SP<CWLSurfaceResource> surface_) : m_surface(surface_) { // only for frog cm untill wayland cm is adopted } -CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) { +CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - if (!surface->m_colorManagement.valid()) { + if (!m_surface->m_colorManagement.valid()) { const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared<CColorManagementSurface>(surface_)); if UNLIKELY (!RESOURCE) { - resource->noMemory(); + m_resource->noMemory(); PROTO::colorManagement->m_surfaces.pop_back(); return; } RESOURCE->m_self = RESOURCE; - surface->m_colorManagement = RESOURCE; + m_surface->m_colorManagement = RESOURCE; - resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { - LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)surface); - if (surface.valid()) - PROTO::colorManagement->destroyResource(surface->m_colorManagement.get()); + m_resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { + LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)m_surface); + if (m_surface.valid()) + PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get()); PROTO::xxColorManagement->destroyResource(this); }); } else - resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); + m_resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); PROTO::xxColorManagement->destroyResource(this); }); - resource->setDestroy([this](CXxColorManagementSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); + m_resource->setDestroy([this](CXxColorManagementSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); PROTO::xxColorManagement->destroyResource(this); }); - resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) { + m_resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) { LOGM(TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent); const auto PO = (CXxImageDescriptionV4*)wl_resource_get_user_data(image_description); @@ -237,35 +237,35 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac return; } - const auto imageDescription = std::find_if(PROTO::xxColorManagement->m_vImageDescriptions.begin(), PROTO::xxColorManagement->m_vImageDescriptions.end(), + const auto imageDescription = std::find_if(PROTO::xxColorManagement->m_imageDescriptions.begin(), PROTO::xxColorManagement->m_imageDescriptions.end(), [&](const auto& other) { return other->resource()->resource() == image_description; }); - if (imageDescription == PROTO::xxColorManagement->m_vImageDescriptions.end()) { + if (imageDescription == PROTO::xxColorManagement->m_imageDescriptions.end()) { r->error(XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, "Image description not found"); return; } - if (surface.valid()) { - surface->m_colorManagement->m_imageDescription = imageDescription->get()->settings; - surface->m_colorManagement->setHasImageDescription(true); + if (m_surface.valid()) { + m_surface->m_colorManagement->m_imageDescription = imageDescription->get()->m_settings; + m_surface->m_colorManagement->setHasImageDescription(true); } else LOGM(ERR, "Set image description for invalid surface"); }); - resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) { + m_resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) { LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r); - if (surface.valid()) { - surface->m_colorManagement->m_imageDescription = SImageDescription{}; - surface->m_colorManagement->setHasImageDescription(false); + if (m_surface.valid()) { + m_surface->m_colorManagement->m_imageDescription = SImageDescription{}; + m_surface->m_colorManagement->setHasImageDescription(false); } else LOGM(ERR, "Unset image description for invalid surface"); }); } bool CXXColorManagementSurface::good() { - return resource && resource->resource(); + return m_resource && m_resource->resource(); } wl_client* CXXColorManagementSurface::client() { - return pClient; + return m_client; } const SImageDescription& CXXColorManagementSurface::imageDescription() { @@ -297,104 +297,104 @@ bool CXXColorManagementSurface::needsHdrMetadataUpdate() { } CXXColorManagementFeedbackSurface::CXXColorManagementFeedbackSurface(SP<CXxColorManagementFeedbackSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : - surface(surface_), resource(resource_) { + m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - resource->setDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); + m_resource->setDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::xxColorManagement->destroyResource(m_currentPreferred.get()); PROTO::xxColorManagement->destroyResource(this); }); - resource->setOnDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); + m_resource->setOnDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::xxColorManagement->destroyResource(m_currentPreferred.get()); PROTO::xxColorManagement->destroyResource(this); }); - resource->setGetPreferred([this](CXxColorManagementFeedbackSurfaceV4* r, uint32_t id) { + m_resource->setGetPreferred([this](CXxColorManagementFeedbackSurfaceV4* r, uint32_t id) { LOGM(TRACE, "Get preferred for id {}", id); if (m_currentPreferred.valid()) PROTO::xxColorManagement->destroyResource(m_currentPreferred.get()); - const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back( makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), true)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vImageDescriptions.pop_back(); + PROTO::xxColorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; m_currentPreferred = RESOURCE; - m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription(); + m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription(); RESOURCE->resource()->sendReady(id); }); } bool CXXColorManagementFeedbackSurface::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXXColorManagementFeedbackSurface::client() { - return pClient; + return m_client; } -CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxImageDescriptionCreatorParamsV4> resource_) : resource(resource_) { +CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxImageDescriptionCreatorParamsV4> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; // - pClient = resource->client(); + m_client = m_resource->client(); - resource->setOnDestroy([this](CXxImageDescriptionCreatorParamsV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setOnDestroy([this](CXxImageDescriptionCreatorParamsV4* r) { PROTO::xxColorManagement->destroyResource(this); }); - resource->setCreate([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t id) { + m_resource->setCreate([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t id) { LOGM(TRACE, "Create image description from params for id {}", id); // FIXME actually check completeness - if (!valuesSet) { + if (!m_valuesSet) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INCOMPLETE_SET, "Missing required settings"); return; } // FIXME actually check consistency - if (!valuesSet) { + if (!m_valuesSet) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INCONSISTENT_SET, "Set is not consistent"); return; } - const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back( makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), false)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vImageDescriptions.pop_back(); + PROTO::xxColorManagement->m_imageDescriptions.pop_back(); return; } // FIXME actually check support - if (!valuesSet) { + if (!m_valuesSet) { RESOURCE->resource()->sendFailed(XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, "unsupported"); return; } - RESOURCE->self = RESOURCE; - RESOURCE->settings = settings; + RESOURCE->m_self = RESOURCE; + RESOURCE->m_settings = m_settings; RESOURCE->resource()->sendReady(id); PROTO::xxColorManagement->destroyResource(this); }); - resource->setSetTfNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t tf) { + m_resource->setSetTfNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t tf) { LOGM(TRACE, "Set image description transfer function to {}", tf); - if (valuesSet & PC_TF) { + if (m_valuesSet & PC_TF) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Transfer function already set"); return; } @@ -409,21 +409,21 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, "Unsupported transfer function"); return; } - settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf)); - valuesSet |= PC_TF; + m_settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf)); + m_valuesSet |= PC_TF; }); - resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) { + m_resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) { LOGM(TRACE, "Set image description tf power to {}", eexp); - if (valuesSet & PC_TF_POWER) { + if (m_valuesSet & PC_TF_POWER) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Transfer function power already set"); return; } - settings.transferFunctionPower = eexp / 10000.0f; - valuesSet |= PC_TF_POWER; + m_settings.transferFunctionPower = eexp / 10000.0f; + m_valuesSet |= PC_TF_POWER; }); - resource->setSetPrimariesNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t primaries) { + m_resource->setSetPrimariesNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t primaries) { LOGM(TRACE, "Set image description primaries by name {}", primaries); - if (valuesSet & PC_PRIMARIES) { + if (m_valuesSet & PC_PRIMARIES) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Primaries already set"); return; } @@ -438,29 +438,29 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI case XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3: case XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3: case XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB: - settings.primariesNameSet = true; - settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries)); - settings.primaries = getPrimaries(settings.primariesNamed); - valuesSet |= PC_PRIMARIES; + m_settings.primariesNameSet = true; + m_settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries)); + m_settings.primaries = getPrimaries(m_settings.primariesNamed); + m_valuesSet |= PC_PRIMARIES; break; default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_PRIMARIES, "Unsupported primaries"); } }); - resource->setSetPrimaries( + m_resource->setSetPrimaries( [this](CXxImageDescriptionCreatorParamsV4* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { LOGM(TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); - if (valuesSet & PC_PRIMARIES) { + if (m_valuesSet & PC_PRIMARIES) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Primaries already set"); return; } - settings.primariesNameSet = false; - settings.primaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; - valuesSet |= PC_PRIMARIES; + m_settings.primariesNameSet = false; + m_settings.primaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; + m_valuesSet |= PC_PRIMARIES; }); - resource->setSetLuminances([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { + m_resource->setSetLuminances([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { auto min = min_lum / 10000.0f; LOGM(TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum); - if (valuesSet & PC_LUMINANCES) { + if (m_valuesSet & PC_LUMINANCES) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Luminances already set"); return; } @@ -468,20 +468,20 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, "Invalid luminances"); return; } - settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum}; - valuesSet |= PC_LUMINANCES; + m_settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum}; + m_valuesSet |= PC_LUMINANCES; }); - resource->setSetMasteringDisplayPrimaries( + m_resource->setSetMasteringDisplayPrimaries( [this](CXxImageDescriptionCreatorParamsV4* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { LOGM(TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); // if (valuesSet & PC_MASTERING_PRIMARIES) { // r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Mastering primaries already set"); // return; // } - settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; - valuesSet |= PC_MASTERING_PRIMARIES; + m_settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; + m_valuesSet |= PC_MASTERING_PRIMARIES; }); - resource->setSetMasteringLuminance([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum) { + m_resource->setSetMasteringLuminance([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum) { auto min = min_lum / 10000.0f; LOGM(TRACE, "Set image description mastering luminances to {} - {}", min, max_lum); // if (valuesSet & PC_MASTERING_LUMINANCES) { @@ -492,35 +492,35 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, "Invalid luminances"); return; } - settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum}; - valuesSet |= PC_MASTERING_LUMINANCES; + m_settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum}; + m_valuesSet |= PC_MASTERING_LUMINANCES; }); - resource->setSetMaxCll([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_cll) { + m_resource->setSetMaxCll([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_cll) { LOGM(TRACE, "Set image description max content light level to {}", max_cll); // if (valuesSet & PC_CLL) { // r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Max CLL already set"); // return; // } - settings.maxCLL = max_cll; - valuesSet |= PC_CLL; + m_settings.maxCLL = max_cll; + m_valuesSet |= PC_CLL; }); - resource->setSetMaxFall([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_fall) { + m_resource->setSetMaxFall([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_fall) { LOGM(TRACE, "Set image description max frame-average light level to {}", max_fall); // if (valuesSet & PC_FALL) { // r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Max FALL already set"); // return; // } - settings.maxFALL = max_fall; - valuesSet |= PC_FALL; + m_settings.maxFALL = max_fall; + m_valuesSet |= PC_FALL; }); } bool CXXColorManagementParametricCreator::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXXColorManagementParametricCreator::client() { - return pClient; + return m_client; } CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxImageDescriptionV4> resource_, bool allowGetInformation) : @@ -528,7 +528,7 @@ CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxIma if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); m_resource->setDestroy([this](CXxImageDescriptionV4* r) { PROTO::xxColorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CXxImageDescriptionV4* r) { PROTO::xxColorManagement->destroyResource(this); }); @@ -540,7 +540,7 @@ CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxIma return; } - auto RESOURCE = makeShared<CXXColorManagementImageDescriptionInfo>(makeShared<CXxImageDescriptionInfoV4>(r->client(), r->version(), id), settings); + auto RESOURCE = makeShared<CXXColorManagementImageDescriptionInfo>(makeShared<CXxImageDescriptionInfoV4>(r->client(), r->version(), id), m_settings); if UNLIKELY (!RESOURCE->good()) r->noMemory(); @@ -555,7 +555,7 @@ bool CXXColorManagementImageDescription::good() { } wl_client* CXXColorManagementImageDescription::client() { - return pClient; + return m_client; } SP<CXxImageDescriptionV4> CXXColorManagementImageDescription::resource() { @@ -563,33 +563,34 @@ SP<CXxImageDescriptionV4> CXXColorManagementImageDescription::resource() { } CXXColorManagementImageDescriptionInfo::CXXColorManagementImageDescriptionInfo(SP<CXxImageDescriptionInfoV4> resource_, const SImageDescription& settings_) : - m_resource(resource_), settings(settings_) { + m_resource(resource_), m_settings(settings_) { if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); }; - if (settings.icc.fd >= 0) - m_resource->sendIccFile(settings.icc.fd, settings.icc.length); + if (m_settings.icc.fd >= 0) + m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length); // send preferred client paramateres - m_resource->sendPrimaries(toProto(settings.primaries.red.x), toProto(settings.primaries.red.y), toProto(settings.primaries.green.x), toProto(settings.primaries.green.y), - toProto(settings.primaries.blue.x), toProto(settings.primaries.blue.y), toProto(settings.primaries.white.x), toProto(settings.primaries.white.y)); - if (settings.primariesNameSet) - m_resource->sendPrimariesNamed(settings.primariesNamed); - m_resource->sendTfPower(std::round(settings.transferFunctionPower * 10000)); - m_resource->sendTfNamed(settings.transferFunction); - m_resource->sendLuminances(std::round(settings.luminances.min * 10000), settings.luminances.max, settings.luminances.reference); + m_resource->sendPrimaries(toProto(m_settings.primaries.red.x), toProto(m_settings.primaries.red.y), toProto(m_settings.primaries.green.x), + toProto(m_settings.primaries.green.y), toProto(m_settings.primaries.blue.x), toProto(m_settings.primaries.blue.y), + toProto(m_settings.primaries.white.x), toProto(m_settings.primaries.white.y)); + if (m_settings.primariesNameSet) + m_resource->sendPrimariesNamed(m_settings.primariesNamed); + m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000)); + m_resource->sendTfNamed(m_settings.transferFunction); + m_resource->sendLuminances(std::round(m_settings.luminances.min * 10000), m_settings.luminances.max, m_settings.luminances.reference); // send expexted display paramateres - m_resource->sendTargetPrimaries(toProto(settings.masteringPrimaries.red.x), toProto(settings.masteringPrimaries.red.y), toProto(settings.masteringPrimaries.green.x), - toProto(settings.masteringPrimaries.green.y), toProto(settings.masteringPrimaries.blue.x), toProto(settings.masteringPrimaries.blue.y), - toProto(settings.masteringPrimaries.white.x), toProto(settings.masteringPrimaries.white.y)); - m_resource->sendTargetLuminance(std::round(settings.masteringLuminances.min * 10000), settings.masteringLuminances.max); - m_resource->sendTargetMaxCll(settings.maxCLL); - m_resource->sendTargetMaxFall(settings.maxFALL); + m_resource->sendTargetPrimaries(toProto(m_settings.masteringPrimaries.red.x), toProto(m_settings.masteringPrimaries.red.y), toProto(m_settings.masteringPrimaries.green.x), + toProto(m_settings.masteringPrimaries.green.y), toProto(m_settings.masteringPrimaries.blue.x), toProto(m_settings.masteringPrimaries.blue.y), + toProto(m_settings.masteringPrimaries.white.x), toProto(m_settings.masteringPrimaries.white.y)); + m_resource->sendTargetLuminance(std::round(m_settings.masteringLuminances.min * 10000), m_settings.masteringLuminances.max); + m_resource->sendTargetMaxCll(m_settings.maxCLL); + m_resource->sendTargetMaxFall(m_settings.maxFALL); m_resource->sendDone(); } @@ -599,7 +600,7 @@ bool CXXColorManagementImageDescriptionInfo::good() { } wl_client* CXXColorManagementImageDescriptionInfo::client() { - return pClient; + return m_client; } CXXColorManagementProtocol::CXXColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -607,11 +608,11 @@ CXXColorManagementProtocol::CXXColorManagementProtocol(const wl_interface* iface } void CXXColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXXColorManager>(makeShared<CXxColorManagerV4>(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared<CXXColorManager>(makeShared<CXxColorManagerV4>(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } @@ -619,31 +620,31 @@ void CXXColorManagementProtocol::bindManager(wl_client* client, void* data, uint } void CXXColorManagementProtocol::onImagePreferredChanged() { - for (auto const& feedback : m_vFeedbackSurfaces) { - feedback->resource->sendPreferredChanged(); + for (auto const& feedback : m_feedbackSurfaces) { + feedback->m_resource->sendPreferredChanged(); } } void CXXColorManagementProtocol::destroyResource(CXXColorManager* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementOutput* resource) { - std::erase_if(m_vOutputs, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_outputs, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementSurface* resource) { - std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementFeedbackSurface* resource) { - std::erase_if(m_vFeedbackSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_feedbackSurfaces, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementParametricCreator* resource) { - std::erase_if(m_vParametricCreators, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_parametricCreators, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementImageDescription* resource) { - std::erase_if(m_vImageDescriptions, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_imageDescriptions, [&](const auto& other) { return other.get() == resource; }); } diff --git a/src/protocols/XXColorManagement.hpp b/src/protocols/XXColorManagement.hpp index 96e99752..0407730a 100644 --- a/src/protocols/XXColorManagement.hpp +++ b/src/protocols/XXColorManagement.hpp @@ -20,7 +20,7 @@ class CXXColorManager { bool good(); private: - SP<CXxColorManagerV4> resource; + SP<CXxColorManagerV4> m_resource; }; class CXXColorManagementOutput { @@ -30,12 +30,12 @@ class CXXColorManagementOutput { bool good(); wl_client* client(); - WP<CXXColorManagementOutput> self; - WP<CXXColorManagementImageDescription> imageDescription; + WP<CXXColorManagementOutput> m_self; + WP<CXXColorManagementImageDescription> m_imageDescription; private: - SP<CXxColorManagementOutputV4> resource; - wl_client* pClient = nullptr; + SP<CXxColorManagementOutputV4> m_resource; + wl_client* m_client = nullptr; friend class CXXColorManagementProtocol; friend class CXXColorManagementImageDescription; @@ -49,8 +49,8 @@ class CXXColorManagementSurface { bool good(); wl_client* client(); - WP<CXXColorManagementSurface> self; - WP<CWLSurfaceResource> surface; + WP<CXXColorManagementSurface> m_self; + WP<CWLSurfaceResource> m_surface; const NColorManagement::SImageDescription& imageDescription(); bool hasImageDescription(); @@ -60,8 +60,8 @@ class CXXColorManagementSurface { bool needsHdrMetadataUpdate(); private: - SP<CXxColorManagementSurfaceV4> resource; - wl_client* pClient = nullptr; + SP<CXxColorManagementSurfaceV4> m_resource; + wl_client* m_client = nullptr; NColorManagement::SImageDescription m_imageDescription; bool m_hasImageDescription = false; bool m_needsNewMetadata = false; @@ -77,12 +77,12 @@ class CXXColorManagementFeedbackSurface { bool good(); wl_client* client(); - WP<CXXColorManagementFeedbackSurface> self; - WP<CWLSurfaceResource> surface; + WP<CXXColorManagementFeedbackSurface> m_self; + WP<CWLSurfaceResource> m_surface; private: - SP<CXxColorManagementFeedbackSurfaceV4> resource; - wl_client* pClient = nullptr; + SP<CXxColorManagementFeedbackSurfaceV4> m_resource; + wl_client* m_client = nullptr; WP<CXXColorManagementImageDescription> m_currentPreferred; @@ -96,9 +96,9 @@ class CXXColorManagementParametricCreator { bool good(); wl_client* client(); - WP<CXXColorManagementParametricCreator> self; + WP<CXXColorManagementParametricCreator> m_self; - NColorManagement::SImageDescription settings; + NColorManagement::SImageDescription m_settings; private: enum eValuesSet : uint32_t { // NOLINT @@ -112,9 +112,9 @@ class CXXColorManagementParametricCreator { PC_FALL = (1 << 7), }; - SP<CXxImageDescriptionCreatorParamsV4> resource; - wl_client* pClient = nullptr; - uint32_t valuesSet = 0; // enum eValuesSet + SP<CXxImageDescriptionCreatorParamsV4> m_resource; + wl_client* m_client = nullptr; + uint32_t m_valuesSet = 0; // enum eValuesSet }; class CXXColorManagementImageDescription { @@ -125,13 +125,13 @@ class CXXColorManagementImageDescription { wl_client* client(); SP<CXxImageDescriptionV4> resource(); - WP<CXXColorManagementImageDescription> self; + WP<CXXColorManagementImageDescription> m_self; - NColorManagement::SImageDescription settings; + NColorManagement::SImageDescription m_settings; private: SP<CXxImageDescriptionV4> m_resource; - wl_client* pClient = nullptr; + wl_client* m_client = nullptr; bool m_allowGetInformation = false; friend class CXXColorManagementOutput; @@ -146,8 +146,8 @@ class CXXColorManagementImageDescriptionInfo { private: SP<CXxImageDescriptionInfoV4> m_resource; - wl_client* pClient = nullptr; - NColorManagement::SImageDescription settings; + wl_client* m_client = nullptr; + NColorManagement::SImageDescription m_settings; }; class CXXColorManagementProtocol : public IWaylandProtocol { @@ -166,12 +166,12 @@ class CXXColorManagementProtocol : public IWaylandProtocol { void destroyResource(CXXColorManagementParametricCreator* resource); void destroyResource(CXXColorManagementImageDescription* resource); - std::vector<SP<CXXColorManager>> m_vManagers; - std::vector<SP<CXXColorManagementOutput>> m_vOutputs; - std::vector<SP<CXXColorManagementSurface>> m_vSurfaces; - std::vector<SP<CXXColorManagementFeedbackSurface>> m_vFeedbackSurfaces; - std::vector<SP<CXXColorManagementParametricCreator>> m_vParametricCreators; - std::vector<SP<CXXColorManagementImageDescription>> m_vImageDescriptions; + std::vector<SP<CXXColorManager>> m_managers; + std::vector<SP<CXXColorManagementOutput>> m_outputs; + std::vector<SP<CXXColorManagementSurface>> m_surfaces; + std::vector<SP<CXXColorManagementFeedbackSurface>> m_feedbackSurfaces; + std::vector<SP<CXXColorManagementParametricCreator>> m_parametricCreators; + std::vector<SP<CXXColorManagementImageDescription>> m_imageDescriptions; friend class CXXColorManager; friend class CXXColorManagementOutput; |
