mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 07:29:48 +01:00
gestures: Swipe direction lock (#3052)
This commit is contained in:
parent
4d14edd8a5
commit
17ea7db23a
3 changed files with 31 additions and 18 deletions
|
@ -226,6 +226,8 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["gestures:workspace_swipe_min_speed_to_force"].intValue = 30;
|
configValues["gestures:workspace_swipe_min_speed_to_force"].intValue = 30;
|
||||||
configValues["gestures:workspace_swipe_cancel_ratio"].floatValue = 0.5f;
|
configValues["gestures:workspace_swipe_cancel_ratio"].floatValue = 0.5f;
|
||||||
configValues["gestures:workspace_swipe_create_new"].intValue = 1;
|
configValues["gestures:workspace_swipe_create_new"].intValue = 1;
|
||||||
|
configValues["gestures:workspace_swipe_direction_lock"].intValue = 1;
|
||||||
|
configValues["gestures:workspace_swipe_direction_lock_threshold"].intValue = 10;
|
||||||
configValues["gestures:workspace_swipe_forever"].intValue = 0;
|
configValues["gestures:workspace_swipe_forever"].intValue = 0;
|
||||||
configValues["gestures:workspace_swipe_numbered"].intValue = 0;
|
configValues["gestures:workspace_swipe_numbered"].intValue = 0;
|
||||||
configValues["gestures:workspace_swipe_use_r"].intValue = 0;
|
configValues["gestures:workspace_swipe_use_r"].intValue = 0;
|
||||||
|
|
|
@ -309,6 +309,7 @@ struct SSwipeGesture {
|
||||||
|
|
||||||
double delta = 0;
|
double delta = 0;
|
||||||
|
|
||||||
|
int initialDirection = 0;
|
||||||
float avgSpeed = 0;
|
float avgSpeed = 0;
|
||||||
int speedPoints = 0;
|
int speedPoints = 0;
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false;
|
m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false;
|
||||||
|
|
||||||
m_sActiveSwipe.pWorkspaceBegin = nullptr;
|
m_sActiveSwipe.pWorkspaceBegin = nullptr;
|
||||||
|
m_sActiveSwipe.initialDirection = 0;
|
||||||
|
|
||||||
g_pInputManager->refocus();
|
g_pInputManager->refocus();
|
||||||
|
|
||||||
|
@ -191,6 +192,8 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
static auto* const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
|
static auto* const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
|
||||||
static auto* const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue;
|
static auto* const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue;
|
||||||
static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
||||||
|
static auto* const PSWIPEDIRLOCK = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_direction_lock")->intValue;
|
||||||
|
static auto* const PSWIPEDIRLOCKTHRESHOLD = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_direction_lock_threshold")->intValue;
|
||||||
static auto* const PSWIPEFOREVER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_forever")->intValue;
|
static auto* const PSWIPEFOREVER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_forever")->intValue;
|
||||||
static auto* const PSWIPENUMBER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_numbered")->intValue;
|
static auto* const PSWIPENUMBER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_numbered")->intValue;
|
||||||
static auto* const PSWIPEUSER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_use_r")->intValue;
|
static auto* const PSWIPEUSER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_use_r")->intValue;
|
||||||
|
@ -225,6 +228,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*PSWIPEDIRLOCK) {
|
||||||
|
if (m_sActiveSwipe.initialDirection != 0 && m_sActiveSwipe.initialDirection != (m_sActiveSwipe.delta < 0 ? -1 : 1))
|
||||||
|
m_sActiveSwipe.delta = 0;
|
||||||
|
else if (m_sActiveSwipe.initialDirection == 0 && abs(m_sActiveSwipe.delta) > *PSWIPEDIRLOCKTHRESHOLD)
|
||||||
|
m_sActiveSwipe.initialDirection = m_sActiveSwipe.delta < 0 ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_sActiveSwipe.delta < 0) {
|
if (m_sActiveSwipe.delta < 0) {
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue