diff options
| author | Luke Barkess <57995669+Brumus14@users.noreply.github.com> | 2026-02-01 14:32:47 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-01 14:32:47 +0000 |
| commit | d9d9d9358fe61682fa402f30b18ec6076512417d (patch) | |
| tree | 167ce1d98edc4a9a13e805c705a92145626c16b5 /src/managers/input | |
| parent | 95c8f8b299e4ec84d79131196f0ca0942531e04f (diff) | |
gestures: add cursor zoom (#13033)
Diffstat (limited to 'src/managers/input')
| -rw-r--r-- | src/managers/input/trackpad/gestures/CursorZoomGesture.cpp | 33 | ||||
| -rw-r--r-- | src/managers/input/trackpad/gestures/CursorZoomGesture.hpp | 24 |
2 files changed, 57 insertions, 0 deletions
diff --git a/src/managers/input/trackpad/gestures/CursorZoomGesture.cpp b/src/managers/input/trackpad/gestures/CursorZoomGesture.cpp new file mode 100644 index 00000000..97dfe158 --- /dev/null +++ b/src/managers/input/trackpad/gestures/CursorZoomGesture.cpp @@ -0,0 +1,33 @@ +#include "CursorZoomGesture.hpp" + +#include "../../../../Compositor.hpp" +#include "../../../../helpers/Monitor.hpp" + +CCursorZoomTrackpadGesture::CCursorZoomTrackpadGesture(const std::string& first, const std::string& second) { + try { + m_zoomValue = std::stof(first); + } catch (...) { ; } + + if (second == "mult") + m_mode = MODE_MULT; +} + +void CCursorZoomTrackpadGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) { + ITrackpadGesture::begin(e); + + if (m_mode == MODE_TOGGLE) + m_zoomed = !m_zoomed; + + for (auto const& m : g_pCompositor->m_monitors) { + switch (m_mode) { + case MODE_TOGGLE: + static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor"); + *m->m_cursorZoom = m_zoomed ? m_zoomValue : *PZOOMFACTOR; + break; + case MODE_MULT: *m->m_cursorZoom = std::clamp(m->m_cursorZoom->goal() * m_zoomValue, 1.0F, 100.0F); break; + } + } +} + +void CCursorZoomTrackpadGesture::update(const ITrackpadGesture::STrackpadGestureUpdate& e) {} +void CCursorZoomTrackpadGesture::end(const ITrackpadGesture::STrackpadGestureEnd& e) {} diff --git a/src/managers/input/trackpad/gestures/CursorZoomGesture.hpp b/src/managers/input/trackpad/gestures/CursorZoomGesture.hpp new file mode 100644 index 00000000..b53c81e9 --- /dev/null +++ b/src/managers/input/trackpad/gestures/CursorZoomGesture.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "ITrackpadGesture.hpp" + +class CCursorZoomTrackpadGesture : public ITrackpadGesture { + public: + CCursorZoomTrackpadGesture(const std::string& zoomLevel, const std::string& mode); + virtual ~CCursorZoomTrackpadGesture() = default; + + virtual void begin(const ITrackpadGesture::STrackpadGestureBegin& e); + virtual void update(const ITrackpadGesture::STrackpadGestureUpdate& e); + virtual void end(const ITrackpadGesture::STrackpadGestureEnd& e); + + private: + float m_zoomValue = 1.0; + inline static bool m_zoomed = false; + + enum eMode : uint8_t { + MODE_TOGGLE = 0, + MODE_MULT, + }; + + eMode m_mode = MODE_TOGGLE; +}; |
