Commit 2b9adf27 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Cancel interactive desktop switching if desktop has not changed

If desktop wrapping is disabled and user swipes to left but there's no
desktop to left, the slide effect can get stuck active because there's
no desktopChanged() nor desktopChangingCancelled() signal emitted.

This change makes the VirtualDesktopManager explicitly cancel
interactive desktop switching session if the current desktop has not
changed.
parent 3c9d2093
Pipeline #170049 passed with stage
in 17 minutes and 12 seconds
......@@ -859,10 +859,18 @@ void VirtualDesktopManager::initShortcuts()
void VirtualDesktopManager::gestureReleasedY()
{
// Note that if desktop wrapping is disabled and there's no desktop above or below,
// above() and below() will return the current desktop.
VirtualDesktop *target = m_current;
if (m_currentDesktopOffset.y() <= -GESTURE_SWITCH_THRESHOLD) {
slotUp();
target = above(m_current, isNavigationWrappingAround());
} else if (m_currentDesktopOffset.y() >= GESTURE_SWITCH_THRESHOLD) {
slotDown();
target = below(m_current, isNavigationWrappingAround());
}
// If the current desktop has not changed, consider that the gesture has been canceled.
if (m_current != target) {
setCurrent(target);
} else {
Q_EMIT currentChangingCancelled();
}
......@@ -871,10 +879,18 @@ void VirtualDesktopManager::gestureReleasedY()
void VirtualDesktopManager::gestureReleasedX()
{
// Note that if desktop wrapping is disabled and there's no desktop to left or right,
// toLeft() and toRight() will return the current desktop.
VirtualDesktop *target = m_current;
if (m_currentDesktopOffset.x() <= -GESTURE_SWITCH_THRESHOLD) {
slotLeft();
target = toLeft(m_current, isNavigationWrappingAround());
} else if (m_currentDesktopOffset.x() >= GESTURE_SWITCH_THRESHOLD) {
slotRight();
target = toRight(m_current, isNavigationWrappingAround());
}
// If the current desktop has not changed, consider that the gesture has been canceled.
if (m_current != target) {
setCurrent(target);
} else {
Q_EMIT currentChangingCancelled();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment