hyprland-plugins/hyprexpo/ExpoGesture.cpp

42 lines
1.1 KiB
C++
Raw Permalink Normal View History

2025-09-11 21:13:16 +01:00
#include "ExpoGesture.hpp"
#include "overview.hpp"
2025-09-11 21:27:43 +01:00
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/state/FocusState.hpp>
2025-09-11 21:27:43 +01:00
#include <hyprland/src/helpers/Monitor.hpp>
2025-09-11 21:13:16 +01:00
void CExpoGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
ITrackpadGesture::begin(e);
m_lastDelta = 0.F;
m_firstUpdate = true;
2025-09-11 21:27:43 +01:00
if (!g_pOverview)
g_pOverview = std::make_unique<COverview>(Desktop::focusState()->monitor()->m_activeWorkspace);
2025-09-13 00:59:41 +01:00
else {
g_pOverview->selectHoveredWorkspace();
g_pOverview->setClosing(true);
}
2025-09-11 21:13:16 +01:00
}
void CExpoGesture::update(const ITrackpadGesture::STrackpadGestureUpdate& e) {
if (m_firstUpdate) {
m_firstUpdate = false;
return;
}
2025-09-11 21:13:16 +01:00
m_lastDelta += distance(e);
if (m_lastDelta <= 0.01) // plugin will crash if swipe ends at <= 0
m_lastDelta = 0.01;
g_pOverview->onSwipeUpdate(m_lastDelta);
}
void CExpoGesture::end(const ITrackpadGesture::STrackpadGestureEnd& e) {
2025-09-13 00:59:41 +01:00
g_pOverview->setClosing(false);
2025-09-11 21:13:16 +01:00
g_pOverview->onSwipeEnd();
2025-09-13 00:59:41 +01:00
g_pOverview->resetSwipe();
2025-09-11 21:13:16 +01:00
}