mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
internal: use an epsilon for scale calcs
This commit is contained in:
parent
9182de9ffc
commit
756fccfc53
4 changed files with 17 additions and 2 deletions
|
@ -201,7 +201,7 @@ void CHyprpaper::ensurePoolBuffersPresent() {
|
|||
|
||||
auto it = std::find_if(m_vBuffers.begin(), m_vBuffers.end(), [wt = &wt, &m](const std::unique_ptr<SPoolBuffer>& el) {
|
||||
auto scale = std::round((m->pCurrentLayerSurface && m->pCurrentLayerSurface->pFractionalScaleInfo ? m->pCurrentLayerSurface->fScale : m->scale) * 120.0) / 120.0;
|
||||
return el->target == wt->m_szPath && el->pixelSize == m->size * scale;
|
||||
return el->target == wt->m_szPath && vectorDeltaLessThan(el->pixelSize, m->size * scale, 1);
|
||||
});
|
||||
|
||||
if (it == m_vBuffers.end()) {
|
||||
|
@ -394,7 +394,7 @@ void CHyprpaper::destroyBuffer(SPoolBuffer* pBuffer) {
|
|||
SPoolBuffer* CHyprpaper::getPoolBuffer(SMonitor* pMonitor, CWallpaperTarget* pWallpaperTarget) {
|
||||
return std::find_if(m_vBuffers.begin(), m_vBuffers.end(), [&](const std::unique_ptr<SPoolBuffer>& el) {
|
||||
auto scale = std::round((pMonitor->pCurrentLayerSurface && pMonitor->pCurrentLayerSurface->pFractionalScaleInfo ? pMonitor->pCurrentLayerSurface->fScale : pMonitor->scale) * 120.0) / 120.0;
|
||||
return el->target == pWallpaperTarget->m_szPath && el->pixelSize == pMonitor->size * scale;
|
||||
return el->target == pWallpaperTarget->m_szPath && vectorDeltaLessThan(el->pixelSize, pMonitor->size * scale, 1);
|
||||
})->get();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "helpers/Monitor.hpp"
|
||||
#include "events/Events.hpp"
|
||||
#include "helpers/PoolBuffer.hpp"
|
||||
#include "helpers/MiscFunctions.hpp"
|
||||
#include "ipc/Socket.hpp"
|
||||
#include <mutex>
|
||||
|
||||
|
|
9
src/helpers/MiscFunctions.cpp
Normal file
9
src/helpers/MiscFunctions.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "MiscFunctions.hpp"
|
||||
|
||||
bool vectorDeltaLessThan(const Vector2D& a, const Vector2D& b, const float& delta) {
|
||||
return std::abs(a.x - b.x) < delta && std::abs(a.y - b.y) < delta;
|
||||
}
|
||||
|
||||
bool vectorDeltaLessThan(const Vector2D& a, const Vector2D& b, const Vector2D& delta) {
|
||||
return std::abs(a.x - b.x) < delta.x && std::abs(a.y - b.y) < delta.y;
|
||||
}
|
5
src/helpers/MiscFunctions.hpp
Normal file
5
src/helpers/MiscFunctions.hpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
#include "Vector2D.hpp"
|
||||
|
||||
bool vectorDeltaLessThan(const Vector2D& a, const Vector2D& b, const float& delta);
|
||||
bool vectorDeltaLessThan(const Vector2D& a, const Vector2D& b, const Vector2D& delta);
|
Loading…
Reference in a new issue