summaryrefslogtreecommitdiff
path: root/src/protocols/TearingControl.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-04-27 12:43:12 +0100
committerGitHub <noreply@github.com>2024-04-27 12:43:12 +0100
commitbca7804bb6e1bf5ce5a99b9ae4806be25e36993c (patch)
treeebd3a578de1dfe11b54f9440cfc3a408ffa6a620 /src/protocols/TearingControl.cpp
parent25aec3ac8ce65ed224f025f8f6dfef73780577a4 (diff)
internal: Window storage rework - part 1 (#5762)
* Window storage rework - part 1 * format * remove useless include * fix pch * format * fix crash in dwindle * fix vram leak * prefer .expired() for bool checks
Diffstat (limited to 'src/protocols/TearingControl.cpp')
-rw-r--r--src/protocols/TearingControl.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/protocols/TearingControl.cpp b/src/protocols/TearingControl.cpp
index 72f92355..7f0fe744 100644
--- a/src/protocols/TearingControl.cpp
+++ b/src/protocols/TearingControl.cpp
@@ -4,7 +4,8 @@
#include "../Compositor.hpp"
CTearingControlProtocol::CTearingControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("destroyWindow", [this](void* self, SCallbackInfo& info, std::any param) { this->onWindowDestroy(std::any_cast<CWindow*>(param)); });
+ static auto P =
+ g_pHookSystem->hookDynamic("destroyWindow", [this](void* self, SCallbackInfo& info, std::any param) { this->onWindowDestroy(std::any_cast<PHLWINDOW>(param)); });
}
void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
@@ -36,10 +37,10 @@ void CTearingControlProtocol::onControllerDestroy(CTearingControl* control) {
std::erase_if(m_vTearingControllers, [control](const auto& other) { return other.get() == control; });
}
-void CTearingControlProtocol::onWindowDestroy(CWindow* pWindow) {
+void CTearingControlProtocol::onWindowDestroy(PHLWINDOW pWindow) {
for (auto& c : m_vTearingControllers) {
- if (c->pWindow == pWindow)
- c->pWindow = nullptr;
+ if (c->pWindow.lock() == pWindow)
+ c->pWindow.reset();
}
}
@@ -53,7 +54,7 @@ CTearingControl::CTearingControl(SP<CWpTearingControlV1> resource_, wlr_surface*
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_pWLSurface.wlr() == surf_) {
- pWindow = w.get();
+ pWindow = w;
break;
}
}
@@ -65,10 +66,10 @@ void CTearingControl::onHint(wpTearingControlV1PresentationHint hint_) {
}
void CTearingControl::updateWindow() {
- if (!pWindow)
+ if (pWindow.expired())
return;
- pWindow->m_bTearingHint = hint == WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
+ pWindow.lock()->m_bTearingHint = hint == WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
}
bool CTearingControl::good() {