forked from yayuuu/hyprland-scroll-overview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverviewGesture.cpp
More file actions
44 lines (33 loc) · 1.21 KB
/
Copy pathOverviewGesture.cpp
File metadata and controls
44 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "OverviewGesture.hpp"
#include "scrollOverview.hpp"
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/state/FocusState.hpp>
#include <hyprland/src/helpers/Monitor.hpp>
void COverviewGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
ITrackpadGesture::begin(e);
m_lastDelta = 0.F;
m_firstUpdate = true;
if (!g_pScrollOverview) {
if (!ensureScrollOverviewHooks())
return;
g_pScrollOverview = makeShared<CScrollOverview>(Desktop::focusState()->monitor()->m_activeWorkspace);
} else {
g_pScrollOverview->selectHoveredWorkspace();
g_pScrollOverview->setClosing(true);
}
}
void COverviewGesture::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_pScrollOverview->onSwipeUpdate(m_lastDelta);
}
void COverviewGesture::end(const ITrackpadGesture::STrackpadGestureEnd& e) {
g_pScrollOverview->setClosing(false);
g_pScrollOverview->onSwipeEnd();
g_pScrollOverview->resetSwipe();
}