~mterry/unity8/session-lightdm

« back to all changes in this revision

Viewing changes to src/MouseTouchAdaptor.cpp

  • Committer: Bileto Bot
  • Author(s): Michael Zanetti
  • Date: 2017-01-24 07:44:03 UTC
  • mfrom: (2748.5.1 appdrawer-four-finger)
  • Revision ID: ci-train-bot@canonical.com-20170124074403-2xrnkv6q411xv83c
allow 4 finger simulation with mousetouchadaptor

Approved by: Lukáš Tinkl, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
MouseTouchAdaptor *g_instance = nullptr;
73
73
 
74
74
const Qt::KeyboardModifiers TRI_PRESS_MODIFIER = Qt::ShiftModifier|Qt::ControlModifier|Qt::AltModifier;
 
75
const Qt::KeyboardModifiers QUAD_PRESS_MODIFIER = TRI_PRESS_MODIFIER|Qt::MetaModifier;
75
76
 
76
77
Qt::MouseButton translateMouseButton(xcb_button_t detail)
77
78
{
91
92
    if (mod & 0x01) qtMod |= Qt::ShiftModifier;
92
93
    if (mod & 0x04) qtMod |= Qt::ControlModifier;
93
94
    if (mod & 0x08) qtMod |= Qt::AltModifier;
94
 
    if (mod & 0x80) qtMod |= Qt::MetaModifier;
 
95
    if (mod & 0x40) qtMod |= Qt::MetaModifier;
95
96
 
96
97
    return qtMod;
97
98
}
101
102
    : QObject(nullptr)
102
103
    , m_leftButtonIsPressed(false)
103
104
    , m_triPressModifier(false)
 
105
    , m_quadPressModifier(false)
104
106
    , m_enabled(true)
105
107
{
106
108
    QCoreApplication::instance()->installNativeEventFilter(this);
297
299
        touchEvent.press(2, windowPos);
298
300
        m_triPressModifier = true;
299
301
    }
 
302
    if (qtMod == QUAD_PRESS_MODIFIER) {
 
303
        touchEvent.press(1, windowPos);
 
304
        touchEvent.press(2, windowPos);
 
305
        touchEvent.press(3, windowPos);
 
306
        m_quadPressModifier = true;
 
307
    }
 
308
 
300
309
    touchEvent.commit(false /* processEvents */);
301
310
 
302
311
    m_leftButtonIsPressed = true;
322
331
        touchEvent.release(1, windowPos);
323
332
        touchEvent.release(2, windowPos);
324
333
    }
 
334
    if (m_quadPressModifier) {
 
335
        touchEvent.release(1, windowPos);
 
336
        touchEvent.release(2, windowPos);
 
337
        touchEvent.release(3, windowPos);
 
338
    }
325
339
    touchEvent.commit(false /* processEvents */);
326
340
 
327
341
    m_leftButtonIsPressed = false;
328
342
    m_triPressModifier = false;
 
343
    m_quadPressModifier = false;
329
344
    return true;
330
345
}
331
346
 
354
369
            m_triPressModifier = false;
355
370
        }
356
371
    }
 
372
    if (m_quadPressModifier) {
 
373
        if (qtMod == QUAD_PRESS_MODIFIER) {
 
374
            touchEvent.move(1, windowPos);
 
375
            touchEvent.move(2, windowPos);
 
376
            touchEvent.move(3, windowPos);
 
377
        } else {
 
378
            touchEvent.release(1, windowPos);
 
379
            touchEvent.release(2, windowPos);
 
380
            touchEvent.release(3, windowPos);
 
381
            m_quadPressModifier = false;
 
382
        }
 
383
    }
357
384
    touchEvent.commit(false /* processEvents */);
358
385
 
359
386
    return true;