~ci-train-bot/qtmir/qtmir-ubuntu-zesty-2055

« back to all changes in this revision

Viewing changes to src/modules/Unity/Application/mirsurface.cpp

  • Committer: Bileto Bot
  • Author(s): Daniel van Vugt
  • Date: 2016-08-10 06:52:25 UTC
  • mfrom: (529.1.4 fix-1607240)
  • Revision ID: ci-train-bot@canonical.com-20160810065225-1pwwnzixc1vj5mso
Fix incorrect mouse wheel/touchpad scrolling scale (LP: #1607240)
and also add sufficient precision that high-resolution touchpad
scrolling now works! (LP: #1607223)

This fixes two mistakes:
 1. angleDelta is not in degrees but eighths of a degree, so the magic
    constant 15 should be 120 (QWheelEvent::DefaultDeltasPerStep)
    [http://doc.qt.io/qt-5/qwheelevent.html#angleDelta].
 2. When converting from Qt back into a Mir event we forgot completely
    to divide by the same factor to get back to the Mir scale of things. (LP: #1607223, #1607240)

Approved by: Lukáš Tinkl, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
    auto modifiers = getMirModifiersFromQt(qtEvent->modifiers());
110
110
    auto buttons = getMirButtonsFromQt(qtEvent->buttons());
111
111
 
 
112
    QPointF mirScroll(qtEvent->angleDelta());
 
113
    // QWheelEvent::DefaultDeltasPerStep = 120 but not defined on vivid
 
114
    mirScroll /= 120.0f;
 
115
 
112
116
    return mir::events::make_event(0 /*DeviceID */, timestamp, std::vector<uint8_t>{} /* cookie */, modifiers, mir_pointer_action_motion,
113
117
                                   buttons, qtEvent->x(), qtEvent->y(),
114
 
                                   qtEvent->angleDelta().x(), qtEvent->angleDelta().y(),
 
118
                                   mirScroll.x(), mirScroll.y(),
115
119
                                   0, 0);
116
120
}
117
121