Compare commits
2 Commits
64608d7bdf
...
b3a78b01ec
| Author | SHA1 | Date |
|---|---|---|
|
|
b3a78b01ec | |
|
|
07b31df088 |
|
|
@ -1,12 +1,11 @@
|
|||
hyprutils (0.8.2-1) unstable; urgency=medium
|
||||
hyprutils (0.8.3-1) unstable; urgency=medium
|
||||
|
||||
[ Carl Keinath ]
|
||||
* New upstream version 0.8.2.
|
||||
* New upstream version 0.8.3.
|
||||
* Breaking ABI changes: updated soversion to 7.
|
||||
* Added autopkgtests to run upstream tests.
|
||||
* Added upstream signing-key.
|
||||
|
||||
-- Alan M Varghese (NyxTrail) <alan@digistorm.in> Sun, 03 Aug 2025 09:42:26 +0200
|
||||
|
||||
-- Alan M Varghese (NyxTrail) <alan@digistorm.in> Sat, 23 Aug 2025 00:31:10 +0200
|
||||
|
||||
hyprutils (0.7.0-1) unstable; urgency=medium
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mDMEaAEKAhYJKwYBBAHaRw8BAQdA0jcIjjszUVXbYrI09s73NVDUJWpyy4FwIKah
|
||||
lo3R7VC0F1ZheHJ5IDx2YXhyeUB2YXhyeS5uZXQ+iJkEExYKAEEWIQTiakoquWdv
|
||||
VBSfjqpmWAY4CHHWQAUCaAEKAgIbAwUJAeEzgAULCQgHAgIiAgYVCgkICwIEFgID
|
||||
AQIeBwIXgAAKCRBmWAY4CHHWQNgzAQD0rfPNY85dp07PDQxA/Et9Tau5YfjUomMr
|
||||
hKrngxNr0AD/WFZNUQVK6OBfDSG8cXDyompOdu8s82SuwUXHQ6HyNgS4OARoAQoC
|
||||
EgorBgEEAZdVAQUBAQdA5nZLWUoLdG3Y5TCWxopWbveBREiefaK+co2bLCZUVAYD
|
||||
AQgHiH4EGBYKACYWIQTiakoquWdvVBSfjqpmWAY4CHHWQAUCaAEKAgIbDAUJAeEz
|
||||
gAAKCRBmWAY4CHHWQF13AQCddVwYoD7pnqaUUnx7lSck8YpPfJ/TS2DqFp8g1etV
|
||||
nwEA8CMv+uDMdIk4TaPQY2jAgKBH2kE9x8FYBZcQoqhK6gQ=
|
||||
=WUHf
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
version=4
|
||||
opts="mode=git, pgpmode=gittag" \
|
||||
opts="mode=git, pgpmode=none" \
|
||||
https://github.com/hyprwm/hyprutils.git \
|
||||
refs/tags/v@ANY_VERSION@
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#pragma once
|
||||
#include "hyprutils/memory/Casts.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Hyprutils::Math {
|
||||
|
|
@ -18,7 +20,7 @@ namespace Hyprutils::Math {
|
|||
|
||||
CEdges() = default;
|
||||
CEdges(eEdges edges) : m_edges(edges) {}
|
||||
CEdges(uint8_t edges) : m_edges(static_cast<eEdges>(edges)) {}
|
||||
CEdges(uint8_t edges) : m_edges(Memory::sc<eEdges>(edges)) {}
|
||||
|
||||
bool operator==(const CEdges& other) {
|
||||
return m_edges == other.m_edges;
|
||||
|
|
@ -80,28 +82,28 @@ namespace Hyprutils::Math {
|
|||
* @param top The state the top edge should be set to.
|
||||
*/
|
||||
void setTop(bool top) {
|
||||
m_edges = static_cast<eEdges>((m_edges & ~TOP) | (TOP * top));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~TOP) | (TOP * top));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param left The state the left edge should be set to.
|
||||
*/
|
||||
void setLeft(bool left) {
|
||||
m_edges = static_cast<eEdges>((m_edges & ~LEFT) | (LEFT * left));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~LEFT) | (LEFT * left));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bottom The state the bottom edge should be set to.
|
||||
*/
|
||||
void setBottom(bool bottom) {
|
||||
m_edges = static_cast<eEdges>((m_edges & ~BOTTOM) | (BOTTOM * bottom));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~BOTTOM) | (BOTTOM * bottom));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param right The state the right edge should be set to.
|
||||
*/
|
||||
void setRight(bool right) {
|
||||
m_edges = static_cast<eEdges>((m_edges & ~RIGHT) | (RIGHT * right));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~RIGHT) | (RIGHT * right));
|
||||
}
|
||||
|
||||
eEdges m_edges = NONE;
|
||||
|
|
|
|||
|
|
@ -83,9 +83,7 @@ namespace Hyprutils::Memory {
|
|||
std::swap(m_ptr, ref.m_ptr);
|
||||
}
|
||||
|
||||
CAtomicSharedPointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CAtomicSharedPointer() noexcept = default;
|
||||
|
||||
CAtomicSharedPointer(std::nullptr_t) noexcept {
|
||||
; // empty
|
||||
|
|
@ -143,7 +141,7 @@ namespace Hyprutils::Memory {
|
|||
// -> must unlock BEFORE reset
|
||||
// not last ref?
|
||||
// -> must unlock AFTER reset
|
||||
auto& mutex = ((Atomic_::impl<T>*)m_ptr.impl_)->getMutex();
|
||||
auto& mutex = sc<Atomic_::impl<T>*>(m_ptr.impl_)->getMutex();
|
||||
mutex.lock();
|
||||
|
||||
if (m_ptr.impl_->ref() > 1) {
|
||||
|
|
@ -208,7 +206,7 @@ namespace Hyprutils::Memory {
|
|||
|
||||
private:
|
||||
std::lock_guard<std::recursive_mutex> implLockGuard() const {
|
||||
return ((Atomic_::impl<T>*)m_ptr.impl_)->lockGuard();
|
||||
return sc<Atomic_::impl<T>*>(m_ptr.impl_)->lockGuard();
|
||||
}
|
||||
|
||||
CSharedPointer<T> m_ptr;
|
||||
|
|
@ -262,9 +260,7 @@ namespace Hyprutils::Memory {
|
|||
m_ptr = ref.m_ptr;
|
||||
}
|
||||
|
||||
CAtomicWeakPointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CAtomicWeakPointer() noexcept = default;
|
||||
|
||||
CAtomicWeakPointer(std::nullptr_t) noexcept {
|
||||
; // empty
|
||||
|
|
@ -316,7 +312,7 @@ namespace Hyprutils::Memory {
|
|||
// -> must unlock BEFORE reset
|
||||
// not last ref?
|
||||
// -> must unlock AFTER reset
|
||||
auto& mutex = ((Atomic_::impl<T>*)m_ptr.impl_)->getMutex();
|
||||
auto& mutex = sc<Atomic_::impl<T>*>(m_ptr.impl_)->getMutex();
|
||||
mutex.lock();
|
||||
if (m_ptr.impl_->ref() == 0 && m_ptr.impl_->wref() == 1) {
|
||||
mutex.unlock();
|
||||
|
|
@ -379,7 +375,7 @@ namespace Hyprutils::Memory {
|
|||
|
||||
private:
|
||||
std::lock_guard<std::recursive_mutex> implLockGuard() const {
|
||||
return ((Atomic_::impl<T>*)m_ptr.impl_)->lockGuard();
|
||||
return sc<Atomic_::impl<T>*>(m_ptr.impl_)->lockGuard();
|
||||
}
|
||||
|
||||
CWeakPointer<T> m_ptr;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
#include <bit>
|
||||
#include <utility>
|
||||
namespace Hyprutils::Memory {
|
||||
template <typename To, typename From>
|
||||
constexpr To sc(From&& from) noexcept {
|
||||
return static_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To cc(From&& from) noexcept {
|
||||
return const_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To rc(From&& from) noexcept {
|
||||
return reinterpret_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To dc(From&& from) {
|
||||
return dynamic_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To bc(const From& from) noexcept {
|
||||
return std::bit_cast<To>(from);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#include <cstdint>
|
||||
|
||||
#include "ImplBase.hpp"
|
||||
#include "Casts.hpp"
|
||||
|
||||
/*
|
||||
This is a custom impl of std::shared_ptr.
|
||||
|
|
@ -60,9 +61,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
/* creates an empty shared pointer with no implementation */
|
||||
CSharedPointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CSharedPointer() noexcept = default;
|
||||
|
||||
/* creates an empty shared pointer with no implementation */
|
||||
CSharedPointer(std::nullptr_t) noexcept {
|
||||
|
|
@ -114,11 +113,11 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
bool operator()(const CSharedPointer& lhs, const CSharedPointer& rhs) const {
|
||||
return reinterpret_cast<uintptr_t>(lhs.impl_) < reinterpret_cast<uintptr_t>(rhs.impl_);
|
||||
return rc<uintptr_t>(lhs.impl_) < rc<uintptr_t>(rhs.impl_);
|
||||
}
|
||||
|
||||
bool operator<(const CSharedPointer& rhs) const {
|
||||
return reinterpret_cast<uintptr_t>(impl_) < reinterpret_cast<uintptr_t>(rhs.impl_);
|
||||
return rc<uintptr_t>(impl_) < rc<uintptr_t>(rhs.impl_);
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
|
|
@ -135,7 +134,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
T* get() const {
|
||||
return impl_ ? static_cast<T*>(impl_->getData()) : nullptr;
|
||||
return impl_ ? sc<T*>(impl_->getData()) : nullptr;
|
||||
}
|
||||
|
||||
unsigned int strongRef() const {
|
||||
|
|
@ -183,7 +182,7 @@ namespace Hyprutils {
|
|||
};
|
||||
|
||||
template <typename U, typename... Args>
|
||||
static CSharedPointer<U> makeShared(Args&&... args) {
|
||||
[[nodiscard]] inline CSharedPointer<U> makeShared(Args&&... args) {
|
||||
return CSharedPointer<U>(new U(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "ImplBase.hpp"
|
||||
#include "Casts.hpp"
|
||||
|
||||
/*
|
||||
This is a custom impl of std::unique_ptr.
|
||||
|
|
@ -41,9 +42,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
/* creates an empty unique pointer with no implementation */
|
||||
CUniquePointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CUniquePointer() noexcept = default;
|
||||
|
||||
/* creates an empty unique pointer with no implementation */
|
||||
CUniquePointer(std::nullptr_t) noexcept {
|
||||
|
|
@ -74,7 +73,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
bool operator()(const CUniquePointer& lhs, const CUniquePointer& rhs) const {
|
||||
return reinterpret_cast<uintptr_t>(lhs.impl_) < reinterpret_cast<uintptr_t>(rhs.impl_);
|
||||
return rc<uintptr_t>(lhs.impl_) < rc<uintptr_t>(rhs.impl_);
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
|
|
@ -91,7 +90,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
T* get() const {
|
||||
return impl_ ? static_cast<T*>(impl_->getData()) : nullptr;
|
||||
return impl_ ? sc<T*>(impl_->getData()) : nullptr;
|
||||
}
|
||||
|
||||
Impl_::impl_base* impl_ = nullptr;
|
||||
|
|
@ -135,7 +134,7 @@ namespace Hyprutils {
|
|||
};
|
||||
|
||||
template <typename U, typename... Args>
|
||||
static CUniquePointer<U> makeUnique(Args&&... args) {
|
||||
[[nodiscard]] inline CUniquePointer<U> makeUnique(Args&&... args) {
|
||||
return CUniquePointer<U>(new U(std::forward<Args>(args)...));
|
||||
}
|
||||
}
|
||||
|
|
@ -146,4 +145,4 @@ struct std::hash<Hyprutils::Memory::CUniquePointer<T>> {
|
|||
std::size_t operator()(const Hyprutils::Memory::CUniquePointer<T>& p) const noexcept {
|
||||
return std::hash<void*>{}(p.impl_);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "./SharedPtr.hpp"
|
||||
#include "./UniquePtr.hpp"
|
||||
#include "./Casts.hpp"
|
||||
|
||||
/*
|
||||
This is a Hyprland implementation of std::weak_ptr.
|
||||
|
|
@ -91,7 +92,7 @@ namespace Hyprutils {
|
|||
/* create a weak ptr from a shared ptr with assignment */
|
||||
template <typename U>
|
||||
validHierarchy<const CWeakPointer<U>&> operator=(const CSharedPointer<U>& rhs) {
|
||||
if (reinterpret_cast<uintptr_t>(impl_) == reinterpret_cast<uintptr_t>(rhs.impl_))
|
||||
if (rc<uintptr_t>(impl_) == rc<uintptr_t>(rhs.impl_))
|
||||
return *this;
|
||||
|
||||
decrementWeak();
|
||||
|
|
@ -101,9 +102,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
/* create an empty weak ptr */
|
||||
CWeakPointer() {
|
||||
;
|
||||
}
|
||||
CWeakPointer() noexcept = default;
|
||||
|
||||
~CWeakPointer() {
|
||||
decrementWeak();
|
||||
|
|
@ -162,15 +161,15 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
bool operator()(const CWeakPointer& lhs, const CWeakPointer& rhs) const {
|
||||
return reinterpret_cast<uintptr_t>(lhs.impl_) < reinterpret_cast<uintptr_t>(rhs.impl_);
|
||||
return rc<uintptr_t>(lhs.impl_) < rc<uintptr_t>(rhs.impl_);
|
||||
}
|
||||
|
||||
bool operator<(const CWeakPointer& rhs) const {
|
||||
return reinterpret_cast<uintptr_t>(impl_) < reinterpret_cast<uintptr_t>(rhs.impl_);
|
||||
return rc<uintptr_t>(impl_) < rc<uintptr_t>(rhs.impl_);
|
||||
}
|
||||
|
||||
T* get() const {
|
||||
return impl_ ? static_cast<T*>(impl_->getData()) : nullptr;
|
||||
return impl_ ? sc<T*>(impl_->getData()) : nullptr;
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Hyprutils {
|
|||
|
||||
if constexpr (sizeof...(Args) == 1)
|
||||
// NOLINTNEXTLINE: const is reapplied by handler invocation if required
|
||||
emitInternal(const_cast<void*>(static_cast<const void*>(&std::get<0>(argsTuple))));
|
||||
emitInternal(Memory::cc<void*>(Memory::sc<const void*>(&std::get<0>(argsTuple))));
|
||||
else
|
||||
emitInternal(&argsTuple);
|
||||
}
|
||||
|
|
@ -94,9 +94,9 @@ namespace Hyprutils {
|
|||
if constexpr (sizeof...(Args) == 0)
|
||||
handler();
|
||||
else if constexpr (sizeof...(Args) == 1)
|
||||
handler(*static_cast<std::remove_reference_t<std::tuple_element_t<0, std::tuple<RefArg<Args>...>>>*>(args));
|
||||
handler(*Memory::sc<std::remove_reference_t<std::tuple_element_t<0, std::tuple<RefArg<Args>...>>>*>(args));
|
||||
else
|
||||
std::apply(handler, *static_cast<std::tuple<RefArg<Args>...>*>(args));
|
||||
std::apply(handler, *Memory::sc<std::tuple<RefArg<Args>...>*>(args));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
#include <hyprutils/animation/BezierCurve.hpp>
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Hyprutils::Animation;
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
void CBezierCurve::setup(const std::array<Vector2D, 2>& pVec) {
|
||||
// Avoid reallocations by reserving enough memory upfront
|
||||
|
|
@ -21,7 +23,7 @@ void CBezierCurve::setup(const std::array<Vector2D, 2>& pVec) {
|
|||
// bake BAKEDPOINTS points for faster lookups
|
||||
// T -> X ( / BAKEDPOINTS )
|
||||
for (int i = 0; i < BAKEDPOINTS; ++i) {
|
||||
float const t = (i + 1) / (float)BAKEDPOINTS;
|
||||
float const t = (i + 1) / sc<float>(BAKEDPOINTS);
|
||||
m_aPointsBaked[i] = Vector2D(getXForT(t), getYForT(t));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#include <hyprutils/math/Mat3x3.hpp>
|
||||
#include <hyprutils/math/Vector2D.hpp>
|
||||
#include <hyprutils/math/Box.hpp>
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
#include <cmath>
|
||||
#include <unordered_map>
|
||||
#include <format>
|
||||
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
static std::unordered_map<eTransform, Mat3x3> transforms = {
|
||||
{HYPRUTILS_TRANSFORM_NORMAL, std::array<float, 9>{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
|
|
@ -98,7 +100,7 @@ Mat3x3& Mat3x3::rotate(float rot) {
|
|||
}
|
||||
|
||||
Mat3x3& Mat3x3::scale(const Vector2D& scale_) {
|
||||
multiply(std::array<float, 9>{(float)scale_.x, 0.0f, 0.0f, 0.0f, (float)scale_.y, 0.0f, 0.0f, 0.0f, 1.0f});
|
||||
multiply(std::array<float, 9>{sc<float>(scale_.x), 0.0f, 0.0f, 0.0f, sc<float>(scale_.y), 0.0f, 0.0f, 0.0f, 1.0f});
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +109,7 @@ Mat3x3& Mat3x3::scale(const float scale_) {
|
|||
}
|
||||
|
||||
Mat3x3& Mat3x3::translate(const Vector2D& offset) {
|
||||
multiply(std::array<float, 9>{1.0f, 0.0f, (float)offset.x, 0.0f, 1.0f, (float)offset.y, 0.0f, 0.0f, 1.0f});
|
||||
multiply(std::array<float, 9>{1.0f, 0.0f, sc<float>(offset.x), 0.0f, 1.0f, sc<float>(offset.y), 0.0f, 0.0f, 1.0f});
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#include "hyprutils/memory/Casts.hpp"
|
||||
#include <hyprutils/math/Region.hpp>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
constexpr const int64_t MAX_REGION_SIDE = 10000000;
|
||||
|
||||
|
|
@ -86,7 +88,7 @@ CRegion& Hyprutils::Math::CRegion::invert(pixman_box32_t* box) {
|
|||
}
|
||||
|
||||
CRegion& Hyprutils::Math::CRegion::invert(const CBox& box) {
|
||||
pixman_box32 pixmanBox = {.x1 = (int32_t)box.x, .y1 = (int32_t)box.y, .x2 = (int32_t)box.w + (int32_t)box.x, .y2 = (int32_t)box.h + (int32_t)box.y};
|
||||
pixman_box32 pixmanBox = {.x1 = sc<int32_t>(box.x), .y1 = sc<int32_t>(box.y), .x2 = sc<int32_t>(box.w) + sc<int32_t>(box.x), .y2 = sc<int32_t>(box.h) + sc<int32_t>(box.y)};
|
||||
return this->invert(&pixmanBox);
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +106,7 @@ CRegion& Hyprutils::Math::CRegion::transform(const eTransform t, double w, doubl
|
|||
clear();
|
||||
|
||||
for (auto& r : rects) {
|
||||
CBox xfmd{(double)r.x1, (double)r.y1, (double)r.x2 - r.x1, (double)r.y2 - r.y1};
|
||||
CBox xfmd{r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1};
|
||||
xfmd.transform(t, w, h);
|
||||
add(xfmd);
|
||||
}
|
||||
|
|
@ -118,7 +120,7 @@ CRegion& Hyprutils::Math::CRegion::expand(double units) {
|
|||
clear();
|
||||
|
||||
for (auto& r : rects) {
|
||||
CBox b{(double)r.x1 - units, (double)r.y1 - units, (double)r.x2 - r.x1 + (units * 2), (double)r.y2 - r.y1 + (units * 2)};
|
||||
CBox b{sc<double>(r.x1) - units, sc<double>(r.y1) - units, sc<double>(r.x2) - r.x1 + (units * 2), sc<double>(r.y2) - r.y1 + (units * 2)};
|
||||
add(b);
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +173,7 @@ std::vector<pixman_box32_t> Hyprutils::Math::CRegion::getRects() const {
|
|||
|
||||
CBox Hyprutils::Math::CRegion::getExtents() {
|
||||
pixman_box32_t* box = pixman_region32_extents(&m_rRegion);
|
||||
return {(double)box->x1, (double)box->y1, (double)box->x2 - box->x1, (double)box->y2 - box->y1};
|
||||
return {sc<double>(box->x1), sc<double>(box->y1), sc<double>(box->x2) - box->x1, sc<double>(box->y2) - box->y1};
|
||||
}
|
||||
|
||||
bool Hyprutils::Math::CRegion::containsPoint(const Vector2D& vec) const {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
#include <hyprutils/math/Vector2D.hpp>
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
#include <hyprutils/math/Misc.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
Hyprutils::Math::Vector2D::Vector2D(double xx, double yy) : x(xx), y(yy) {
|
||||
;
|
||||
}
|
||||
|
||||
Hyprutils::Math::Vector2D::Vector2D(int xx, int yy) : x((double)xx), y((double)yy) {
|
||||
Hyprutils::Math::Vector2D::Vector2D(int xx, int yy) : x(sc<double>(xx)), y(sc<double>(yy)) {
|
||||
;
|
||||
}
|
||||
|
||||
|
|
@ -59,23 +61,14 @@ Vector2D Hyprutils::Math::Vector2D::getComponentMax(const Vector2D& other) const
|
|||
|
||||
Vector2D Hyprutils::Math::Vector2D::transform(eTransform transform, const Vector2D& monitorSize) const {
|
||||
switch (transform) {
|
||||
case HYPRUTILS_TRANSFORM_NORMAL:
|
||||
return *this;
|
||||
case HYPRUTILS_TRANSFORM_90:
|
||||
return Vector2D(y, monitorSize.y - x);
|
||||
case HYPRUTILS_TRANSFORM_180:
|
||||
return Vector2D(monitorSize.x - x, monitorSize.y - y);
|
||||
case HYPRUTILS_TRANSFORM_270:
|
||||
return Vector2D(monitorSize.x - y, x);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED:
|
||||
return Vector2D(monitorSize.x - x, y);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED_90:
|
||||
return Vector2D(y, x);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED_180:
|
||||
return Vector2D(x, monitorSize.y - y);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED_270:
|
||||
return Vector2D(monitorSize.x - y, monitorSize.y - x);
|
||||
default:
|
||||
return *this;
|
||||
case HYPRUTILS_TRANSFORM_NORMAL: return *this;
|
||||
case HYPRUTILS_TRANSFORM_90: return Vector2D(y, monitorSize.y - x);
|
||||
case HYPRUTILS_TRANSFORM_180: return Vector2D(monitorSize.x - x, monitorSize.y - y);
|
||||
case HYPRUTILS_TRANSFORM_270: return Vector2D(monitorSize.x - y, x);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED: return Vector2D(monitorSize.x - x, y);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED_90: return Vector2D(y, x);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED_180: return Vector2D(x, monitorSize.y - y);
|
||||
case HYPRUTILS_TRANSFORM_FLIPPED_270: return Vector2D(monitorSize.x - y, monitorSize.y - x);
|
||||
default: return *this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include <hyprutils/os/Process.hpp>
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
using namespace Hyprutils::OS;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
|
|
@ -61,7 +63,7 @@ bool Hyprutils::OS::CProcess::runSync() {
|
|||
dup2(errPipe[1], 2 /* stderr */);
|
||||
|
||||
// build argv
|
||||
std::vector<const char*> argsC;
|
||||
std::vector<char*> argsC;
|
||||
argsC.emplace_back(strdup(m_impl->binary.c_str()));
|
||||
for (auto& arg : m_impl->args) {
|
||||
// TODO: does this leak? Can we just pipe c_str() as the strings won't be realloc'd?
|
||||
|
|
@ -75,7 +77,7 @@ bool Hyprutils::OS::CProcess::runSync() {
|
|||
setenv(n.c_str(), v.c_str(), 1);
|
||||
}
|
||||
|
||||
execvp(m_impl->binary.c_str(), (char* const*)argsC.data());
|
||||
execvp(m_impl->binary.c_str(), argsC.data());
|
||||
exit(1);
|
||||
} else {
|
||||
// parent
|
||||
|
|
@ -129,7 +131,7 @@ bool Hyprutils::OS::CProcess::runSync() {
|
|||
|
||||
if (pollfds[0].revents & POLLIN) {
|
||||
while ((ret = read(outPipe[0], buf.data(), 1023)) > 0) {
|
||||
m_impl->out += std::string_view{(char*)buf.data(), (size_t)ret};
|
||||
m_impl->out += std::string_view{buf.data(), sc<size_t>(ret)};
|
||||
}
|
||||
|
||||
buf.fill(0);
|
||||
|
|
@ -137,7 +139,7 @@ bool Hyprutils::OS::CProcess::runSync() {
|
|||
|
||||
if (pollfds[1].revents & POLLIN) {
|
||||
while ((ret = read(errPipe[0], buf.data(), 1023)) > 0) {
|
||||
m_impl->err += std::string_view{(char*)buf.data(), (size_t)ret};
|
||||
m_impl->err += std::string_view{buf.data(), sc<size_t>(ret)};
|
||||
}
|
||||
|
||||
buf.fill(0);
|
||||
|
|
@ -146,13 +148,13 @@ bool Hyprutils::OS::CProcess::runSync() {
|
|||
|
||||
// Final reads. Nonblock, so its ok.
|
||||
while ((ret = read(outPipe[0], buf.data(), 1023)) > 0) {
|
||||
m_impl->out += std::string_view{(char*)buf.data(), (size_t)ret};
|
||||
m_impl->out += std::string_view{buf.data(), sc<size_t>(ret)};
|
||||
}
|
||||
|
||||
buf.fill(0);
|
||||
|
||||
while ((ret = read(errPipe[0], buf.data(), 1023)) > 0) {
|
||||
m_impl->err += std::string_view{(char*)buf.data(), (size_t)ret};
|
||||
m_impl->err += std::string_view{buf.data(), sc<size_t>(ret)};
|
||||
}
|
||||
|
||||
buf.fill(0);
|
||||
|
|
@ -198,7 +200,7 @@ bool Hyprutils::OS::CProcess::runAsync() {
|
|||
close(socket[0]);
|
||||
close(socket[1]);
|
||||
// build argv
|
||||
std::vector<const char*> argsC;
|
||||
std::vector<char*> argsC;
|
||||
argsC.emplace_back(strdup(m_impl->binary.c_str()));
|
||||
for (auto& arg : m_impl->args) {
|
||||
argsC.emplace_back(strdup(arg.c_str()));
|
||||
|
|
@ -216,7 +218,7 @@ bool Hyprutils::OS::CProcess::runAsync() {
|
|||
if (m_impl->stderrFD != -1)
|
||||
dup2(m_impl->stderrFD, 2);
|
||||
|
||||
execvp(m_impl->binary.c_str(), (char* const*)argsC.data());
|
||||
execvp(m_impl->binary.c_str(), argsC.data());
|
||||
_exit(0);
|
||||
}
|
||||
close(socket[0]);
|
||||
|
|
|
|||
|
|
@ -16,5 +16,5 @@ void Hyprutils::Signal::CSignalListener::emitInternal(void* data) {
|
|||
|
||||
void Hyprutils::Signal::CSignalListener::emit(std::any data) {
|
||||
auto dataTuple = std::tuple<std::any>(data);
|
||||
emitInternal(static_cast<void*>(&dataTuple));
|
||||
emitInternal(&dataTuple);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class CMyAnimationManager : public CAnimationManager {
|
|||
|
||||
switch (PAV->m_Type) {
|
||||
case eAVTypes::INT: {
|
||||
auto avInt = dynamic_cast<CAnimatedVariable<int>*>(PAV.get());
|
||||
auto avInt = dc<CAnimatedVariable<int>*>(PAV.get());
|
||||
if (!avInt)
|
||||
std::cout << Colors::RED << "Dynamic cast upcast failed" << Colors::RESET;
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ class CMyAnimationManager : public CAnimationManager {
|
|||
avInt->value() = avInt->begun() + (DELTA * POINTY);
|
||||
} break;
|
||||
case eAVTypes::TEST: {
|
||||
auto avCustom = dynamic_cast<CAnimatedVariable<SomeTestType>*>(PAV.get());
|
||||
auto avCustom = dc<CAnimatedVariable<SomeTestType>*>(PAV.get());
|
||||
if (!avCustom)
|
||||
std::cout << Colors::RED << "Dynamic cast upcast failed" << Colors::RESET;
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ class CMyAnimationManager : public CAnimationManager {
|
|||
constexpr const eAVTypes EAVTYPE = std::is_same_v<VarType, int> ? eAVTypes::INT : eAVTypes::TEST;
|
||||
const auto PAV = makeShared<CGenericAnimatedVariable<VarType, EmtpyContext>>();
|
||||
|
||||
PAV->create(EAVTYPE, static_cast<CAnimationManager*>(this), PAV, v);
|
||||
PAV->create(EAVTYPE, sc<CAnimationManager*>(this), PAV, v);
|
||||
PAV->setConfig(animationTree.getConfig(animationConfigName));
|
||||
av = std::move(PAV);
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
*s.m_iA = 5;
|
||||
s.m_iA->setCallbackOnEnd([&endCallbackRan](WP<CBaseAnimatedVariable> v) {
|
||||
endCallbackRan++;
|
||||
const auto PAV = dynamic_cast<CAnimatedVariable<int>*>(v.lock().get());
|
||||
const auto PAV = dc<CAnimatedVariable<int>*>(v.lock().get());
|
||||
|
||||
*PAV = 10;
|
||||
PAV->setCallbackOnEnd([&endCallbackRan](WP<CBaseAnimatedVariable> v) { endCallbackRan++; });
|
||||
|
|
|
|||
Loading…
Reference in New Issue