mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2025-10-29 11:48:42 +00:00
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#include "ExpoGesture.hpp"
|
|
|
|
#include "overview.hpp"
|
|
|
|
#include <hyprland/src/Compositor.hpp>
|
|
#include <hyprland/src/helpers/Monitor.hpp>
|
|
|
|
void CExpoGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
|
|
ITrackpadGesture::begin(e);
|
|
|
|
m_lastDelta = 0.F;
|
|
m_firstUpdate = true;
|
|
|
|
if (!g_pOverview)
|
|
g_pOverview = std::make_unique<COverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
|
|
else {
|
|
g_pOverview->selectHoveredWorkspace();
|
|
g_pOverview->setClosing(true);
|
|
}
|
|
}
|
|
|
|
void CExpoGesture::update(const ITrackpadGesture::STrackpadGestureUpdate& e) {
|
|
if (m_firstUpdate) {
|
|
m_firstUpdate = false;
|
|
return;
|
|
}
|
|
|
|
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) {
|
|
g_pOverview->setClosing(false);
|
|
g_pOverview->onSwipeEnd();
|
|
g_pOverview->resetSwipe();
|
|
}
|