~unity-team/qtmir/dpr

« back to all changes in this revision

Viewing changes to src/platforms/mirserver/cursor.cpp

  • Committer: Gerry Boland
  • Date: 2015-12-14 12:28:33 UTC
  • mfrom: (321.2.107 qtmir)
  • Revision ID: gerry.boland@canonical.com-20151214122833-gcdw2xaji4jd4027
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    m_shapeToCursorName[Qt::BlankCursor] = "blank";
41
41
    m_shapeToCursorName[Qt::SplitVCursor] = "split_v";
42
42
    m_shapeToCursorName[Qt::SplitHCursor] = "split_h";
43
 
    m_shapeToCursorName[Qt::PointingHandCursor] = "pointing_hand";
 
43
    m_shapeToCursorName[Qt::PointingHandCursor] = "hand";
44
44
    m_shapeToCursorName[Qt::ForbiddenCursor] = "forbidden";
45
45
    m_shapeToCursorName[Qt::WhatsThisCursor] = "whats_this";
46
46
    m_shapeToCursorName[Qt::BusyCursor] = "left_ptr_watch";
47
47
    m_shapeToCursorName[Qt::OpenHandCursor] = "openhand";
48
48
    m_shapeToCursorName[Qt::ClosedHandCursor] = "closedhand";
49
 
    m_shapeToCursorName[Qt::DragCopyCursor] = "copy";
50
 
    m_shapeToCursorName[Qt::DragMoveCursor] = "move";
51
 
    m_shapeToCursorName[Qt::DragLinkCursor] = "link";
 
49
    m_shapeToCursorName[Qt::DragCopyCursor] = "dnd-copy";
 
50
    m_shapeToCursorName[Qt::DragMoveCursor] = "dnd-move";
 
51
    m_shapeToCursorName[Qt::DragLinkCursor] = "dnd-link";
52
52
 
53
53
    connect(Mir::instance(), &Mir::cursorNameChanged, this, &Cursor::setMirCursorName);
54
54
}
60
60
    }
61
61
 
62
62
    if (windowCursor) {
63
 
        m_qtCursorName = m_shapeToCursorName.value(windowCursor->shape(), QString("left_ptr"));
 
63
        if (windowCursor->pixmap().isNull()) {
 
64
            m_qtCursorName = m_shapeToCursorName.value(windowCursor->shape(), QLatin1String("left_ptr"));
 
65
            m_mousePointer->setCustomCursor(QCursor());
 
66
        } else {
 
67
            m_qtCursorName = QLatin1String("custom");
 
68
            m_mousePointer->setCustomCursor(*windowCursor);
 
69
        }
64
70
    } else {
65
71
        m_qtCursorName.clear();
 
72
        m_mousePointer->setCustomCursor(QCursor());
66
73
    }
67
74
 
68
75
    updateMousePointerCursorName();
109
116
    return ok;
110
117
}
111
118
 
 
119
bool Cursor::handleWheelEvent(ulong timestamp, QPoint angleDelta, Qt::KeyboardModifiers modifiers)
 
120
{
 
121
    QMutexLocker locker(&m_mutex);
 
122
 
 
123
    if (!m_mousePointer || !m_mousePointer->isVisible()) {
 
124
        return false;
 
125
    }
 
126
 
 
127
    // Must not be called directly as we're most likely not in Qt's GUI (main) thread.
 
128
    bool ok = QMetaObject::invokeMethod(m_mousePointer, "handleWheelEvent", Qt::AutoConnection,
 
129
        Q_ARG(ulong, timestamp),
 
130
        Q_ARG(QPoint, angleDelta),
 
131
        Q_ARG(Qt::KeyboardModifiers, modifiers));
 
132
 
 
133
    if (!ok) {
 
134
        qCWarning(QTMIR_MIR_INPUT) << "Failed to invoke MousePointer::handleMouseEvent";
 
135
    }
 
136
 
 
137
    return ok;
 
138
}
 
139
 
112
140
void Cursor::setPos(const QPoint &pos)
113
141
{
114
142
    if (!m_mousePointer) {