Commit 170b0e9a authored by Marco Martin's avatar Marco Martin Committed by Nate Graham
Browse files

effects/overview: Support touchpad realtime activation

Now it follows your fingers when you do a four-finger swipe up to activate it.

CCBUG: 401479
parent 08d18503
Pipeline #161321 passed with stage
in 25 minutes and 10 seconds
......@@ -30,6 +30,18 @@ OverviewEffect::OverviewEffect()
m_shutdownTimer->setSingleShot(true);
connect(m_shutdownTimer, &QTimer::timeout, this, &OverviewEffect::realDeactivate);
m_realtimeToggleAction = new QAction(this);
connect(m_realtimeToggleAction, &QAction::triggered, this, [this]() {
if (isRunning() && m_partialActivationFactor > 0.5) {
activate();
} else {
deactivate();
}
m_partialActivationFactor = 0;
Q_EMIT gestureInProgressChanged();
Q_EMIT partialActivationFactorChanged();
});
const QKeySequence defaultToggleShortcut = Qt::META | Qt::Key_W;
m_toggleAction = new QAction(this);
connect(m_toggleAction, &QAction::triggered, this, &OverviewEffect::toggle);
......@@ -39,10 +51,26 @@ OverviewEffect::OverviewEffect()
KGlobalAccel::self()->setShortcut(m_toggleAction, {defaultToggleShortcut});
m_toggleShortcut = KGlobalAccel::self()->shortcut(m_toggleAction);
effects->registerGlobalShortcut({defaultToggleShortcut}, m_toggleAction);
effects->registerTouchpadSwipeShortcut(SwipeDirection::Up, 4, m_toggleAction);
effects->registerTouchscreenSwipeShortcut(SwipeDirection::Up, 3, m_toggleAction);
effects->registerTouchscreenSwipeShortcut(SwipeDirection::Down, 3, m_toggleAction);
auto progressCallback = [this](qreal progress) {
if (m_status == Status::Active) {
return;
}
const bool wasInProgress = m_partialActivationFactor > 0;
m_partialActivationFactor = progress;
Q_EMIT partialActivationFactorChanged();
if (!wasInProgress) {
Q_EMIT gestureInProgressChanged();
}
if (!isRunning()) {
partialActivate();
}
};
effects->registerRealtimeTouchpadSwipeShortcut(SwipeDirection::Up, 4, m_realtimeToggleAction, progressCallback);
connect(effects, &EffectsHandler::screenAboutToLock, this, &OverviewEffect::realDeactivate);
initConfig<OverviewConfig>();
......@@ -90,7 +118,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags)
const QList<int> touchActivateBorders = OverviewConfig::touchBorderActivate();
for (const int &border : touchActivateBorders) {
m_touchBorderActivate.append(ElectricBorder(border));
effects->registerRealtimeTouchBorder(ElectricBorder(border), m_toggleAction, [this](ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) {
effects->registerRealtimeTouchBorder(ElectricBorder(border), m_realtimeToggleAction, [this](ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) {
Q_UNUSED(screen)
if (m_status == Status::Active) {
return;
......
......@@ -71,6 +71,7 @@ private:
QTimer *m_shutdownTimer;
QAction *m_toggleAction = nullptr;
QAction *m_realtimeToggleAction = nullptr;
QList<QKeySequence> m_toggleShortcut;
QList<ElectricBorder> m_borderActivate;
QList<ElectricBorder> m_touchBorderActivate;
......
......@@ -82,9 +82,17 @@ PresentWindowsEffect::PresentWindowsEffect()
KGlobalAccel::self()->setShortcut(exposeAllAction, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F10) << Qt::Key_LaunchC);
shortcutAll = KGlobalAccel::self()->shortcut(exposeAllAction);
effects->registerGlobalShortcut(Qt::CTRL + Qt::Key_F10, exposeAllAction);
effects->registerTouchpadSwipeShortcut(SwipeDirection::Down, 4, exposeAllAction);
connect(exposeAllAction, &QAction::triggered, this, &PresentWindowsEffect::toggleActiveAllDesktops);
effects->registerRealtimeTouchpadSwipeShortcut(SwipeDirection::Down, 4, new QAction(this), [this](qreal progress) {
m_mode = ModeAllDesktops;
if (progress > .2 && !m_activated) {
setActive(true);
} else if (progress <= .2 && m_activated) {
setActive(false);
}
});
QAction *exposeClassAction = m_exposeClassAction;
exposeClassAction->setObjectName(QStringLiteral("ExposeClass"));
exposeClassAction->setText(i18n("Toggle Present Windows (Window class)"));
......
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