mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-07-25 17:21:54 -07:00
alphamodifier: move to unique ptrs
less refcounting, move by rvalue.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "alpha-modifier-v1.hpp"
|
||||
#include "core/Compositor.hpp"
|
||||
|
||||
CAlphaModifier::CAlphaModifier(SP<CWpAlphaModifierSurfaceV1> resource, SP<CWLSurfaceResource> surface) : m_surface(surface) {
|
||||
CAlphaModifier::CAlphaModifier(UP<CWpAlphaModifierSurfaceV1>&& resource, SP<CWLSurfaceResource> surface) : m_surface(surface) {
|
||||
setResource(std::move(resource));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ bool CAlphaModifier::good() {
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
void CAlphaModifier::setResource(SP<CWpAlphaModifierSurfaceV1> resource) {
|
||||
void CAlphaModifier::setResource(UP<CWpAlphaModifierSurfaceV1>&& resource) {
|
||||
m_resource = std::move(resource);
|
||||
|
||||
if UNLIKELY (!m_resource->resource())
|
||||
@@ -89,11 +89,11 @@ void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id
|
||||
manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present");
|
||||
return;
|
||||
} else {
|
||||
iter->second->setResource(makeShared<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id));
|
||||
iter->second->setResource(makeUnique<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id));
|
||||
alphaModifier = iter->second.get();
|
||||
}
|
||||
} else {
|
||||
alphaModifier = m_alphaModifiers.emplace(surface, makeUnique<CAlphaModifier>(makeShared<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id), surface))
|
||||
alphaModifier = m_alphaModifiers.emplace(surface, makeUnique<CAlphaModifier>(makeUnique<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id), surface))
|
||||
.first->second.get();
|
||||
}
|
||||
|
||||
|
@@ -11,13 +11,13 @@ class CAlphaModifierProtocol;
|
||||
|
||||
class CAlphaModifier {
|
||||
public:
|
||||
CAlphaModifier(SP<CWpAlphaModifierSurfaceV1> resource_, SP<CWLSurfaceResource> surface);
|
||||
CAlphaModifier(UP<CWpAlphaModifierSurfaceV1>&& resource_, SP<CWLSurfaceResource> surface);
|
||||
|
||||
bool good();
|
||||
void setResource(SP<CWpAlphaModifierSurfaceV1> resource);
|
||||
void setResource(UP<CWpAlphaModifierSurfaceV1>&& resource);
|
||||
|
||||
private:
|
||||
SP<CWpAlphaModifierSurfaceV1> m_resource;
|
||||
UP<CWpAlphaModifierSurfaceV1> m_resource;
|
||||
WP<CWLSurfaceResource> m_surface;
|
||||
float m_alpha = 1.0;
|
||||
|
||||
|
Reference in New Issue
Block a user