diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-06-19 16:20:06 +0200 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-06-19 16:20:15 +0200 |
| commit | fb15b7aa2a9bba0f0693f84d0c65d386942583f8 (patch) | |
| tree | d4403944b5d6a3e03d2262f03a7d0b3ed6ffae24 /src/protocols | |
| parent | 6e5804b53de753f24953d9d647940df66bc68f6d (diff) | |
core: Move to hyprutils for Math
Moves CRegion, CBox and Vector2D over to hyprutils.
Requires hyprutils>=0.1.4
Diffstat (limited to 'src/protocols')
| -rw-r--r-- | src/protocols/LayerShell.cpp | 2 | ||||
| -rw-r--r-- | src/protocols/LayerShell.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/PointerConstraints.hpp | 4 | ||||
| -rw-r--r-- | src/protocols/PointerGestures.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/RelativePointer.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/Screencopy.cpp | 9 | ||||
| -rw-r--r-- | src/protocols/Tablet.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/TextInputV3.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/ToplevelExport.cpp | 2 | ||||
| -rw-r--r-- | src/protocols/XDGShell.cpp | 20 | ||||
| -rw-r--r-- | src/protocols/XDGShell.hpp | 4 | ||||
| -rw-r--r-- | src/protocols/core/Compositor.cpp | 2 | ||||
| -rw-r--r-- | src/protocols/core/Compositor.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/core/DataDevice.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/core/Seat.hpp | 2 | ||||
| -rw-r--r-- | src/protocols/core/Shm.hpp | 2 |
16 files changed, 31 insertions, 30 deletions
diff --git a/src/protocols/LayerShell.cpp b/src/protocols/LayerShell.cpp index d4b105cb..fd66ba5e 100644 --- a/src/protocols/LayerShell.cpp +++ b/src/protocols/LayerShell.cpp @@ -82,7 +82,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) { pending.committed |= STATE_SIZE; - pending.desiredSize = {x, y}; + pending.desiredSize = {(int)x, (int)y}; }); resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { diff --git a/src/protocols/LayerShell.hpp b/src/protocols/LayerShell.hpp index 7fa14447..6d29248a 100644 --- a/src/protocols/LayerShell.hpp +++ b/src/protocols/LayerShell.hpp @@ -6,7 +6,7 @@ #include <tuple> #include "WaylandProtocol.hpp" #include "wlr-layer-shell-unstable-v1.hpp" -#include "../helpers/Vector2D.hpp" +#include "../helpers/math/Math.hpp" #include "../helpers/signal/Signal.hpp" #include "types/SurfaceRole.hpp" diff --git a/src/protocols/PointerConstraints.hpp b/src/protocols/PointerConstraints.hpp index 8a78de99..faf28b32 100644 --- a/src/protocols/PointerConstraints.hpp +++ b/src/protocols/PointerConstraints.hpp @@ -7,8 +7,8 @@ #include <cstdint> #include "WaylandProtocol.hpp" #include "pointer-constraints-unstable-v1.hpp" -#include "../helpers/Vector2D.hpp" -#include "../helpers/Region.hpp" +#include "../helpers/math/Math.hpp" +#include "../helpers/math/Math.hpp" #include "../helpers/signal/Signal.hpp" class CWLSurface; diff --git a/src/protocols/PointerGestures.hpp b/src/protocols/PointerGestures.hpp index 33c2bace..f907a49f 100644 --- a/src/protocols/PointerGestures.hpp +++ b/src/protocols/PointerGestures.hpp @@ -4,7 +4,7 @@ #include <vector> #include "WaylandProtocol.hpp" #include "pointer-gestures-unstable-v1.hpp" -#include "../helpers/Vector2D.hpp" +#include "../helpers/math/Math.hpp" class CPointerGestureSwipe { public: diff --git a/src/protocols/RelativePointer.hpp b/src/protocols/RelativePointer.hpp index 93446e85..453ce157 100644 --- a/src/protocols/RelativePointer.hpp +++ b/src/protocols/RelativePointer.hpp @@ -5,7 +5,7 @@ #include <cstdint> #include "WaylandProtocol.hpp" #include "relative-pointer-unstable-v1.hpp" -#include "../helpers/Vector2D.hpp" +#include "../helpers/math/Math.hpp" class CRelativePointer { public: diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 0c4eac86..8a6285a1 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -279,7 +279,7 @@ void CScreencopyProtocolManager::captureOutput(wl_client* client, wl_resource* r } int ow, oh; wlr_output_effective_resolution(PFRAME->pMonitor->output, &ow, &oh); - PFRAME->box.transform(PFRAME->pMonitor->transform, ow, oh).scale(PFRAME->pMonitor->scale).round(); + PFRAME->box.transform(wlTransformToHyprutils(PFRAME->pMonitor->transform), ow, oh).scale(PFRAME->pMonitor->scale).round(); PFRAME->shmStride = FormatUtils::minStride(PSHMINFO, PFRAME->box.w); @@ -556,9 +556,10 @@ bool CScreencopyProtocolManager::copyFrameDmabuf(SScreencopyFrame* frame) { if (!g_pHyprRenderer->beginRender(frame->pMonitor, fakeDamage, RENDER_MODE_TO_BUFFER, frame->buffer.lock(), nullptr, true)) return false; - CBox monbox = CBox{0, 0, frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y} - .translate({-frame->box.x, -frame->box.y}) // vvvv kinda ass-backwards but that's how I designed the renderer... sigh. - .transform(wlr_output_transform_invert(frame->pMonitor->output->transform), frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y); + CBox monbox = + CBox{0, 0, frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y} + .translate({-frame->box.x, -frame->box.y}) // vvvv kinda ass-backwards but that's how I designed the renderer... sigh. + .transform(wlTransformToHyprutils(wlr_output_transform_invert(frame->pMonitor->output->transform)), frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y); g_pHyprOpenGL->setMonitorTransformEnabled(true); g_pHyprOpenGL->setRenderModifEnabled(false); g_pHyprOpenGL->renderTexture(TEXTURE, &monbox, 1); diff --git a/src/protocols/Tablet.hpp b/src/protocols/Tablet.hpp index c61395c9..58f13c1a 100644 --- a/src/protocols/Tablet.hpp +++ b/src/protocols/Tablet.hpp @@ -5,7 +5,7 @@ #include <cstdint> #include "WaylandProtocol.hpp" #include "tablet-v2.hpp" -#include "../helpers/Vector2D.hpp" +#include "../helpers/math/Math.hpp" class CTablet; class CTabletTool; diff --git a/src/protocols/TextInputV3.hpp b/src/protocols/TextInputV3.hpp index 3959e72b..9f6284dc 100644 --- a/src/protocols/TextInputV3.hpp +++ b/src/protocols/TextInputV3.hpp @@ -7,7 +7,7 @@ #include "WaylandProtocol.hpp" #include "text-input-unstable-v3.hpp" #include "../helpers/signal/Signal.hpp" -#include "../helpers/Box.hpp" +#include "../helpers/math/Math.hpp" class CWLSurfaceResource; diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index 80f9defa..287538b5 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -202,7 +202,7 @@ void CToplevelExportProtocolManager::captureToplevel(wl_client* client, wl_resou PFRAME->box = {0, 0, (int)(pWindow->m_vRealSize.value().x * PMONITOR->scale), (int)(pWindow->m_vRealSize.value().y * PMONITOR->scale)}; int ow, oh; wlr_output_effective_resolution(PMONITOR->output, &ow, &oh); - PFRAME->box.transform(PMONITOR->transform, ow, oh).round(); + PFRAME->box.transform(wlTransformToHyprutils(PMONITOR->transform), ow, oh).round(); PFRAME->shmStride = FormatUtils::minStride(PSHMINFO, PFRAME->box.w); diff --git a/src/protocols/XDGShell.cpp b/src/protocols/XDGShell.cpp index c16ebb9d..9c56df93 100644 --- a/src/protocols/XDGShell.cpp +++ b/src/protocols/XDGShell.cpp @@ -514,13 +514,13 @@ CXDGPositionerRules::CXDGPositionerRules(SP<CXDGPositionerResource> positioner) static Vector2D pointForAnchor(const CBox& box, const Vector2D& predictionSize, xdgPositionerAnchor anchor) { switch (anchor) { - case XDG_POSITIONER_ANCHOR_TOP: return box.pos() + Vector2D{box.size().x / 2.F - predictionSize.x / 2.F, 0}; - case XDG_POSITIONER_ANCHOR_BOTTOM: return box.pos() + Vector2D{box.size().x / 2.F - predictionSize.x / 2.F, box.size().y}; - case XDG_POSITIONER_ANCHOR_LEFT: return box.pos() + Vector2D{0, box.size().y / 2.F - predictionSize.y / 2.F}; - case XDG_POSITIONER_ANCHOR_RIGHT: return box.pos() + Vector2D{box.size().x, box.size().y / 2.F - predictionSize.y / 2.F}; + case XDG_POSITIONER_ANCHOR_TOP: return box.pos() + Vector2D{box.size().x / 2.0 - predictionSize.x / 2.0, 0.0}; + case XDG_POSITIONER_ANCHOR_BOTTOM: return box.pos() + Vector2D{box.size().x / 2.0 - predictionSize.x / 2.0, box.size().y}; + case XDG_POSITIONER_ANCHOR_LEFT: return box.pos() + Vector2D{0.0, box.size().y / 2.0 - predictionSize.y / 2.0}; + case XDG_POSITIONER_ANCHOR_RIGHT: return box.pos() + Vector2D{box.size().x, box.size().y / 2.F - predictionSize.y / 2.0}; case XDG_POSITIONER_ANCHOR_TOP_LEFT: return box.pos(); - case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT: return box.pos() + Vector2D{0, box.size().y}; - case XDG_POSITIONER_ANCHOR_TOP_RIGHT: return box.pos() + Vector2D{box.size().x, 0}; + case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT: return box.pos() + Vector2D{0.0, box.size().y}; + case XDG_POSITIONER_ANCHOR_TOP_RIGHT: return box.pos() + Vector2D{box.size().x, 0.0}; case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT: return box.pos() + Vector2D{box.size().x, box.size().y}; default: return box.pos(); } @@ -555,10 +555,10 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa }; int edgeCount = countEdges(test); - if (flipX && edgeCount > countEdges(test.copy().translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0}))) - test.translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0}); - if (flipY && edgeCount > countEdges(test.copy().translate(Vector2D{0, -predictedBox.h - state.anchorRect.h}))) - test.translate(Vector2D{0, -predictedBox.h - state.anchorRect.h}); + if (flipX && edgeCount > countEdges(test.copy().translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0.0}))) + test.translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0.0}); + if (flipY && edgeCount > countEdges(test.copy().translate(Vector2D{0.0, -predictedBox.h - state.anchorRect.h}))) + test.translate(Vector2D{0.0, -predictedBox.h - state.anchorRect.h}); success = test.copy().expand(-1).inside(constraint); diff --git a/src/protocols/XDGShell.hpp b/src/protocols/XDGShell.hpp index d60db86a..da551718 100644 --- a/src/protocols/XDGShell.hpp +++ b/src/protocols/XDGShell.hpp @@ -6,8 +6,8 @@ #include <optional> #include "WaylandProtocol.hpp" #include "xdg-shell.hpp" -#include "../helpers/Vector2D.hpp" -#include "../helpers/Box.hpp" +#include "../helpers/math/Math.hpp" +#include "../helpers/math/Math.hpp" #include "../helpers/signal/Signal.hpp" #include "types/SurfaceRole.hpp" diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 165da6ee..4bce3f58 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -421,7 +421,7 @@ CRegion CWLSurfaceResource::accumulateCurrentBufferDamage() { Vector2D trc = current.transform % 2 == 1 ? Vector2D{current.buffer->size.y, current.buffer->size.x} : current.buffer->size; - return surfaceDamage.scale(current.scale).transform(wlr_output_transform_invert(current.transform), trc.x, trc.y).add(current.bufferDamage); + return surfaceDamage.scale(current.scale).transform(wlTransformToHyprutils(wlr_output_transform_invert(current.transform)), trc.x, trc.y).add(current.bufferDamage); } CWLCompositorResource::CWLCompositorResource(SP<CWlCompositor> resource_) : resource(resource_) { diff --git a/src/protocols/core/Compositor.hpp b/src/protocols/core/Compositor.hpp index f50144bf..2f276719 100644 --- a/src/protocols/core/Compositor.hpp +++ b/src/protocols/core/Compositor.hpp @@ -14,7 +14,7 @@ #include "../WaylandProtocol.hpp" #include "wayland.hpp" #include "../../helpers/signal/Signal.hpp" -#include "../../helpers/Region.hpp" +#include "../../helpers/math/Math.hpp" #include "../types/Buffer.hpp" #include "../types/SurfaceRole.hpp" diff --git a/src/protocols/core/DataDevice.hpp b/src/protocols/core/DataDevice.hpp index 5b31559f..22bb9376 100644 --- a/src/protocols/core/DataDevice.hpp +++ b/src/protocols/core/DataDevice.hpp @@ -15,7 +15,7 @@ #include <wayland-server-protocol.h> #include "wayland.hpp" #include "../../helpers/signal/Signal.hpp" -#include "../../helpers/Vector2D.hpp" +#include "../../helpers/math/Math.hpp" #include "../types/DataDevice.hpp" class CWLDataDeviceResource; diff --git a/src/protocols/core/Seat.hpp b/src/protocols/core/Seat.hpp index 0b563b8f..09b36056 100644 --- a/src/protocols/core/Seat.hpp +++ b/src/protocols/core/Seat.hpp @@ -15,7 +15,7 @@ #include <wayland-server-protocol.h> #include "wayland.hpp" #include "../../helpers/signal/Signal.hpp" -#include "../../helpers/Vector2D.hpp" +#include "../../helpers/math/Math.hpp" constexpr const char* HL_SEAT_NAME = "Hyprland"; diff --git a/src/protocols/core/Shm.hpp b/src/protocols/core/Shm.hpp index 687e2031..70a8b208 100644 --- a/src/protocols/core/Shm.hpp +++ b/src/protocols/core/Shm.hpp @@ -13,7 +13,7 @@ #include "../WaylandProtocol.hpp" #include "wayland.hpp" #include "../types/Buffer.hpp" -#include "../../helpers/Vector2D.hpp" +#include "../../helpers/math/Math.hpp" class CWLSHMPoolResource; |
