diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-05-05 22:18:10 +0100 |
|---|---|---|
| committer | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-05-09 13:37:39 +0100 |
| commit | ed411f53bdcf8d455f9e6ca769693aa84dc8372f (patch) | |
| tree | aacedb349acdd1022975d7b622dc7cfe11388223 /src/helpers/Box.cpp | |
| parent | e4e84064f2d07810e0c150bce1369a0a00503e9a (diff) | |
cursor: move to a hyprland impl
This moves wlr_cursor to a completely new impl mostly under
CPointerManager
Also adds beginSimple to OpenGL for simple render passes (e.g. cursor)
Diffstat (limited to 'src/helpers/Box.cpp')
| -rw-r--r-- | src/helpers/Box.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/helpers/Box.cpp b/src/helpers/Box.cpp index 8470b509..77406ecf 100644 --- a/src/helpers/Box.cpp +++ b/src/helpers/Box.cpp @@ -121,7 +121,7 @@ CBox& CBox::noNegativeSize() { return *this; } -CBox CBox::intersection(const CBox other) const { +CBox CBox::intersection(const CBox& other) const { const float newX = std::max(x, other.x); const float newY = std::max(y, other.y); const float newBottom = std::min(y + h, other.y + other.h); @@ -137,6 +137,14 @@ CBox CBox::intersection(const CBox other) const { return {newX, newY, newW, newH}; } +bool CBox::overlaps(const CBox& other) const { + return (other.x + other.w >= x) && (x + w >= other.x) && (other.y + other.h >= y) && (y + h >= other.y); +} + +bool CBox::inside(const CBox& bound) const { + return bound.x < x && bound.y < y && x + w < bound.x + bound.w && y + h < bound.y + bound.h; +} + CBox CBox::roundInternal() { float newW = x + w - std::floor(x); float newH = y + h - std::floor(y); @@ -156,6 +164,16 @@ Vector2D CBox::size() const { return {w, h}; } +Vector2D CBox::closestPoint(const Vector2D& vec) const { + if (containsPoint(vec)) + return vec; + + Vector2D nv = vec; + nv.x = std::clamp(nv.x, x, x + w); + nv.y = std::clamp(nv.y, y, y + h); + return nv; +} + SWindowDecorationExtents CBox::extentsFrom(const CBox& small) { return {{small.x - x, small.y - y}, {w - small.w - (small.x - x), h - small.h - (small.y - y)}}; } |
