hyprland-plugins/hyprexpo/ExpoGesture.cpp
nnra 84659a2502
all: chase hyprland for 40d8fa8 (#549)
* hyprexpo: Fixes for 40d8fa8

* csgo-vulkan-fix: Fixes for 40d8fa8

* hyprbars: Fixes for 40d8fa8

I am not entirely sure whether I was supposed to use fullWindowFocus()
or rawWindowFocus() in hyprbars/barDeco.cpp at line 220

* xtra-dispatchers: Fixes for 40d8fa8

I am not entirely sure whether I was supposed to use fullWindowFocus()
or rawWindowFocus() in xtra-dispatchers/main.cpp at lines 47 and 106

* hyprscrolling: Fixes for 40d8fa8

A lot of repeated code can be removed if it's safe to store
`Desktop::focusState()`, `Desktop::focusState()->monitor()` and
`Desktop::focusState()->window()` at the top of the
`CScrollingLayout::findBestNeighbor` function.
This change requires further review as I don't know if any of those
change during this function so I didn't wanna introduce any unexpected
issues.
I am not entirely sure whether I was supposed to use fullWindowFocus()
or rawWindowFocus() in xtra-dispatchers/main.cpp at lines 786, 789 and
1344
2025-11-26 22:10:33 +00:00

41 lines
1.1 KiB
C++

#include "ExpoGesture.hpp"
#include "overview.hpp"
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/state/FocusState.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>(Desktop::focusState()->monitor()->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();
}