[Containment Interface] Fix erratic high precision scrolling
This makes containment actions only trigger for one "wheel tick" rather than continuously when you scroll with a touchpad. REVIEW: 126433
This commit is contained in:
parent
54736e262f
commit
899f95d0cf
@ -58,7 +58,8 @@
|
|||||||
ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args)
|
ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args)
|
||||||
: AppletInterface(parent, args),
|
: AppletInterface(parent, args),
|
||||||
m_wallpaperInterface(0),
|
m_wallpaperInterface(0),
|
||||||
m_activityInfo(0)
|
m_activityInfo(0),
|
||||||
|
m_wheelDelta(0)
|
||||||
{
|
{
|
||||||
m_containment = static_cast<Plasma::Containment *>(appletScript()->applet()->containment());
|
m_containment = static_cast<Plasma::Containment *>(appletScript()->applet()->containment());
|
||||||
|
|
||||||
@ -962,14 +963,22 @@ void ContainmentInterface::wheelEvent(QWheelEvent *event)
|
|||||||
const QString trigger = Plasma::ContainmentActions::eventToString(event);
|
const QString trigger = Plasma::ContainmentActions::eventToString(event);
|
||||||
Plasma::ContainmentActions *plugin = m_containment->containmentActions().value(trigger);
|
Plasma::ContainmentActions *plugin = m_containment->containmentActions().value(trigger);
|
||||||
|
|
||||||
if (plugin) {
|
if (!plugin) {
|
||||||
if (event->delta() < 0) {
|
event->setAccepted(false);
|
||||||
plugin->performNextAction();
|
return;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
m_wheelDelta += event->delta();
|
||||||
|
|
||||||
|
// Angle delta 120 for common "one click"
|
||||||
|
// See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
|
||||||
|
while (m_wheelDelta >= 120) {
|
||||||
|
m_wheelDelta -= 120;
|
||||||
plugin->performPreviousAction();
|
plugin->performPreviousAction();
|
||||||
}
|
}
|
||||||
} else {
|
while (m_wheelDelta <= -120) {
|
||||||
event->setAccepted(false);
|
m_wheelDelta += 120;
|
||||||
|
plugin->performNextAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +218,7 @@ private:
|
|||||||
KActivities::Info *m_activityInfo;
|
KActivities::Info *m_activityInfo;
|
||||||
QPointer<Plasma::Containment> m_containment;
|
QPointer<Plasma::Containment> m_containment;
|
||||||
QWeakPointer<QMenu> m_contextMenu;
|
QWeakPointer<QMenu> m_contextMenu;
|
||||||
|
int m_wheelDelta;
|
||||||
friend class AppletInterface;
|
friend class AppletInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user