protocols: refactor class member vars (u-z) (#10282)

* protocols: refactor class member vars (u-z)

* protocols: fix clang format
This commit is contained in:
davc0n 2025-05-04 23:39:00 +02:00 committed by GitHub
parent 78ff20ddf0
commit 9cd5b25745
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 985 additions and 981 deletions

View file

@ -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; });
}