summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/directfb/qdirectfbcursor.cpp
blob: f2c9f35968721705ba95ec8384378b4b2f58c271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "qdirectfbcursor.h"
#include "qdirectfbconvenience.h"


QDirectFBCursor::QDirectFBCursor(QPlatformScreen* screen) :
        QPlatformCursor(screen), surface(0)
{
    QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer);
    image = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
}

void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget)
{
    Q_UNUSED(widget);
    int xSpot;
    int ySpot;
    QPixmap map;

    if (cursor->shape() != Qt::BitmapCursor) {
        image->set(cursor->shape());
        xSpot = image->hotspot().x();
        ySpot = image->hotspot().y();
        QImage *i = image->image();
        map = QPixmap::fromImage(*i);
    } else {
        QPoint point = cursor->hotSpot();
        xSpot = point.x();
        ySpot = point.y();
        map = cursor->pixmap();
    }

    IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData());

    if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) {
        return;
    }
    m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot);
    m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED);
}