~unity-2d-team/unity-2d/window-focus-fixes

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/hotmodifier.cpp

  • Committer: Tarmac
  • Author(s): Gerry Boland, Michał Sawicz
  • Date: 2012-02-28 11:30:52 UTC
  • mfrom: (915.1.61 hud-qml)
  • Revision ID: tarmac-20120228113052-ko3v4z076cq2aanr
Add HUD to Unity 2D

Known issue:
- on switching between Dash & Hud (tap Alt, then Super, then Alt...) blurred background image will contain Hud/Dash.. Fixes: https://bugs.launchpad.net/bugs/942045. Approved by Albert Astals Cid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
,   m_pressed(false)
32
32
,   m_held(false)
33
33
,   m_ignored(false)
 
34
,   m_otherModifierPressed(false)
34
35
{
35
36
    m_holdTimer.setSingleShot(true);
36
37
    m_holdTimer.setInterval(KEY_HOLD_THRESHOLD);
55
56
void
56
57
HotModifier::onModifiersChanged(Qt::KeyboardModifiers modifiers)
57
58
{
58
 
    /* FIXME this logic needs tweaking, as pressing one modifier and tapping
59
 
       another will result in a tap on the latter one. */
60
59
    bool pressed = m_modifiers & modifiers;
 
60
    bool otherModifierPressed = modifiers ^ m_modifiers;
 
61
 
 
62
    /* if a modifier other than m_modifier is pressed, we take note of it because when the
 
63
       other modifier is released, m_modifier is emitted again. If we don't ignore this
 
64
       event, we generate a tap, which is wrong */
 
65
    if (otherModifierPressed && pressed) {
 
66
        m_otherModifierPressed = true;
 
67
    }
 
68
 
61
69
    if (!m_ignored && m_pressed && !m_held && !pressed) {
62
70
        Q_EMIT tapped();
63
71
    } else if (m_pressed && m_held && !pressed) {
68
76
        m_ignored = false;
69
77
        m_holdTimer.start();
70
78
    }
 
79
    /* Case where "other modifier" is released while m_modifier still pressed. In this case
 
80
       we want to have the entire modifier press event ignored, to prevent generating a tap */
 
81
    if (m_otherModifierPressed && otherModifierPressed && pressed) {
 
82
        m_otherModifierPressed = false;
 
83
        m_ignored = true;
 
84
    }
71
85
    m_pressed = pressed;
72
86
}
73
87