protocols: refactor class member vars (n-t) (#10273)
This commit is contained in:
parent
adbae0f74d
commit
2626f89ea6
41 changed files with 1507 additions and 1511 deletions
|
|
@ -11,7 +11,7 @@ CTearingControlProtocol::CTearingControlProtocol(const wl_interface* iface, cons
|
|||
}
|
||||
|
||||
void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CWpTearingControlManagerV1>(client, ver, id)).get();
|
||||
const auto RESOURCE = m_managers.emplace_back(makeUnique<CWpTearingControlManagerV1>(client, ver, id)).get();
|
||||
RESOURCE->setOnDestroy([this](CWpTearingControlManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
|
||||
RESOURCE->setDestroy([this](CWpTearingControlManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
||||
|
|
@ -21,58 +21,58 @@ void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_
|
|||
}
|
||||
|
||||
void CTearingControlProtocol::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 CTearingControlProtocol::onGetController(wl_client* client, CWpTearingControlManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surf) {
|
||||
const auto CONTROLLER = m_vTearingControllers.emplace_back(makeUnique<CTearingControl>(makeShared<CWpTearingControlV1>(client, pMgr->version(), id), surf)).get();
|
||||
const auto CONTROLLER = m_tearingControllers.emplace_back(makeUnique<CTearingControl>(makeShared<CWpTearingControlV1>(client, pMgr->version(), id), surf)).get();
|
||||
|
||||
if UNLIKELY (!CONTROLLER->good()) {
|
||||
pMgr->noMemory();
|
||||
m_vTearingControllers.pop_back();
|
||||
m_tearingControllers.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CTearingControlProtocol::onControllerDestroy(CTearingControl* control) {
|
||||
std::erase_if(m_vTearingControllers, [control](const auto& other) { return other.get() == control; });
|
||||
std::erase_if(m_tearingControllers, [control](const auto& other) { return other.get() == control; });
|
||||
}
|
||||
|
||||
void CTearingControlProtocol::onWindowDestroy(PHLWINDOW pWindow) {
|
||||
for (auto const& c : m_vTearingControllers) {
|
||||
if (c->pWindow.lock() == pWindow)
|
||||
c->pWindow.reset();
|
||||
for (auto const& c : m_tearingControllers) {
|
||||
if (c->m_window.lock() == pWindow)
|
||||
c->m_window.reset();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
CTearingControl::CTearingControl(SP<CWpTearingControlV1> resource_, SP<CWLSurfaceResource> surf_) : resource(resource_) {
|
||||
resource->setData(this);
|
||||
resource->setOnDestroy([this](CWpTearingControlV1* res) { PROTO::tearing->onControllerDestroy(this); });
|
||||
resource->setDestroy([this](CWpTearingControlV1* res) { PROTO::tearing->onControllerDestroy(this); });
|
||||
resource->setSetPresentationHint([this](CWpTearingControlV1* res, wpTearingControlV1PresentationHint hint) { this->onHint(hint); });
|
||||
CTearingControl::CTearingControl(SP<CWpTearingControlV1> resource_, SP<CWLSurfaceResource> surf_) : m_resource(resource_) {
|
||||
m_resource->setData(this);
|
||||
m_resource->setOnDestroy([this](CWpTearingControlV1* res) { PROTO::tearing->onControllerDestroy(this); });
|
||||
m_resource->setDestroy([this](CWpTearingControlV1* res) { PROTO::tearing->onControllerDestroy(this); });
|
||||
m_resource->setSetPresentationHint([this](CWpTearingControlV1* res, wpTearingControlV1PresentationHint hint) { this->onHint(hint); });
|
||||
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_wlSurface->resource() == surf_) {
|
||||
pWindow = w;
|
||||
m_window = w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTearingControl::onHint(wpTearingControlV1PresentationHint hint_) {
|
||||
hint = hint_;
|
||||
m_hint = hint_;
|
||||
updateWindow();
|
||||
}
|
||||
|
||||
void CTearingControl::updateWindow() {
|
||||
if UNLIKELY (pWindow.expired())
|
||||
if UNLIKELY (m_window.expired())
|
||||
return;
|
||||
|
||||
pWindow->m_tearingHint = hint == WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
|
||||
m_window->m_tearingHint = m_hint == WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
|
||||
}
|
||||
|
||||
bool CTearingControl::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue