input: don't trigger titlebar actions on every event with a touchpad
Instead, accumulate the values and only trigger an action when the user has scrolled far enough BUG: 444737
This commit is contained in:
parent
b89009f9e1
commit
52b4ee3338
1 changed files with 27 additions and 3 deletions
|
@ -1345,6 +1345,28 @@ private:
|
||||||
QPointF m_lastLocalTouchPos;
|
QPointF m_lastLocalTouchPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MouseWheelAccumulator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float accumulate(WheelEvent *event)
|
||||||
|
{
|
||||||
|
m_scrollV120 += event->deltaV120();
|
||||||
|
m_scrollDistance += event->delta();
|
||||||
|
if (std::abs(m_scrollV120) >= 120 || (!event->deltaV120() && std::abs(m_scrollDistance) >= 15)) {
|
||||||
|
float ret = m_scrollDistance;
|
||||||
|
m_scrollV120 = 0;
|
||||||
|
m_scrollDistance = 0;
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
float m_scrollDistance = 0;
|
||||||
|
int m_scrollV120 = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class DecorationEventFilter : public InputEventFilter
|
class DecorationEventFilter : public InputEventFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1400,7 +1422,6 @@ public:
|
||||||
}
|
}
|
||||||
const QPointF localPos = event->globalPosition() - decoration->window()->pos();
|
const QPointF localPos = event->globalPosition() - decoration->window()->pos();
|
||||||
const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical;
|
const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical;
|
||||||
const int delta = event->angleDelta().x() != 0 ? event->angleDelta().x() : event->angleDelta().y();
|
|
||||||
QWheelEvent e(localPos, event->globalPosition(), QPoint(),
|
QWheelEvent e(localPos, event->globalPosition(), QPoint(),
|
||||||
event->angleDelta(),
|
event->angleDelta(),
|
||||||
event->buttons(),
|
event->buttons(),
|
||||||
|
@ -1413,9 +1434,11 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((orientation == Qt::Vertical) && decoration->window()->titlebarPositionUnderMouse()) {
|
if ((orientation == Qt::Vertical) && decoration->window()->titlebarPositionUnderMouse()) {
|
||||||
|
if (float delta = m_accumulator.accumulate(event)) {
|
||||||
decoration->window()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1),
|
decoration->window()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1),
|
||||||
event->globalPosition());
|
event->globalPosition());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override
|
bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override
|
||||||
|
@ -1554,6 +1577,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QPointF m_lastGlobalTouchPos;
|
QPointF m_lastGlobalTouchPos;
|
||||||
QPointF m_lastLocalTouchPos;
|
QPointF m_lastLocalTouchPos;
|
||||||
|
MouseWheelAccumulator m_accumulator;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if KWIN_BUILD_TABBOX
|
#if KWIN_BUILD_TABBOX
|
||||||
|
|
Loading…
Reference in a new issue