summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2009-04-28 22:44:01 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2009-04-29 00:09:18 (GMT)
commitd7be4d1cd394c04f85647b6de823a33aa7b2d900 (patch)
treea58c37e01140187e678ab826aeabf0bda13cafa9 /src/plugins
parent69051b4e49f16ea0d25db99ba42c557095a61a99 (diff)
downloadQt-d7be4d1cd394c04f85647b6de823a33aa7b2d900.zip
Qt-d7be4d1cd394c04f85647b6de823a33aa7b2d900.tar.gz
Qt-d7be4d1cd394c04f85647b6de823a33aa7b2d900.tar.bz2
Fixed cursors with QT_NO_DIRECTFB_PREALLOCATED
Refactor cursor management code to do. No need to change the cooperative level four times for each show/hide. Simplify code a little. Also we used to disable the cursor when we wanted to hide it which meant that we no longer received mouse events. Reviewed-by: Donald <qt-info@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 4b8af41..0374e58 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -538,16 +538,12 @@ class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor
{
public:
QDirectFBScreenCursor();
- ~QDirectFBScreenCursor();
-
- void set(const QImage &image, int hotx, int hoty);
- void move(int x, int y);
- void show();
- void hide();
-
+ virtual void set(const QImage &image, int hotx, int hoty);
+ virtual void move(int x, int y);
+ virtual void show();
+ virtual void hide();
private:
IDirectFBDisplayLayer *layer;
- bool implicitHide;
};
QDirectFBScreenCursor::QDirectFBScreenCursor()
@@ -557,116 +553,120 @@ QDirectFBScreenCursor::QDirectFBScreenCursor()
qFatal("QDirectFBScreenCursor: DirectFB not initialized");
layer = QDirectFBScreen::instance()->dfbDisplayLayer();
-
- if (layer)
- layer->SetCooperativeLevel(layer, DLSCL_SHARED); // XXX: hw: remove?
- else
- qFatal("QDirectFBScreenCursor: Unable to get primary display layer!");
-
- enable = true;
- hwaccel = true;
- implicitHide = false;
- supportsAlpha = true;
-
- set(QImage(), 0, 0);
-}
-
-QDirectFBScreenCursor::~QDirectFBScreenCursor()
-{
-}
-
-void QDirectFBScreenCursor::show()
-{
+ Q_ASSERT(layer);
DFBResult result;
result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
+ DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
"Unable to set cooperative level", result);
}
result = layer->EnableCursor(layer, 1);
if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
+ DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
"Unable to enable cursor", result);
}
+
result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
if (result != DFB_OK) {
DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to reset cooperative level", result);
+ "Unable to set cooperative level", result);
}
- implicitHide = false;
+
+ layer->SetCooperativeLevel(layer, DLSCL_SHARED);
+
+ enable = false;
+ hwaccel = true;
+ supportsAlpha = true;
+}
+
+void QDirectFBScreenCursor::move(int x, int y)
+{
+ layer->WarpCursor(layer, x, y);
}
void QDirectFBScreenCursor::hide()
{
- DFBResult result;
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
- result = layer->EnableCursor(layer, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to disable cursor", result);
- }
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to reset cooperative level", result);
+ if (enable) {
+ QScreenCursor::hide();
+ DFBResult result;
+ result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::hide: "
+ "Unable to set cooperative level", result);
+ }
+ result = layer->SetCursorOpacity(layer, 0);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::hide: "
+ "Unable to set cursor opacity", result);
+ }
+ result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::hide: "
+ "Unable to set cooperative level", result);
+ }
}
- implicitHide = true;
}
-void QDirectFBScreenCursor::move(int x, int y)
+void QDirectFBScreenCursor::show()
{
- layer->WarpCursor(layer, x, y);
+ if (!enable) {
+ QScreenCursor::show();
+ DFBResult result;
+ result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::show: "
+ "Unable to set cooperative level", result);
+ }
+ result = layer->SetCursorOpacity(layer, 255);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::show: "
+ "Unable to set cursor shape", result);
+ }
+ result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::show: "
+ "Unable to set cooperative level", result);
+ }
+ }
}
void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty)
{
- if (image.isNull() && isVisible()) {
- hide();
- implicitHide = true;
- } else if (!image.isNull() && implicitHide) {
- show();
- }
- cursor = image.convertToFormat(QDirectFBScreen::instance()->alphaPixmapFormat());
+ QDirectFBScreen *screen = QDirectFBScreen::instance();
+ if (!screen)
+ return;
- if (!image.isNull()) {
- Q_ASSERT(cursor.numColors() == 0);
+ if (image.isNull()) {
+ cursor = QImage();
+ hide();
+ } else {
+ cursor = image.convertToFormat(screen->alphaPixmapFormat());
size = cursor.size();
hotspot = QPoint(hotx, hoty);
-
- DFBSurfaceDescription description;
- description = QDirectFBScreen::getSurfaceDescription(cursor);
-
- IDirectFBSurface *surface;
- surface = QDirectFBScreen::instance()->createDFBSurface(&description,
- QDirectFBScreen::TrackSurface);
+ IDirectFBSurface *surface = screen->createDFBSurface(cursor, QDirectFBScreen::DontTrackSurface);
if (!surface) {
qWarning("QDirectFBScreenCursor::set: Unable to create surface");
return;
}
DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: "
+ DirectFBError("QDirectFBScreenCursor::show: "
"Unable to set cooperative level", result);
}
result = layer->SetCursorShape(layer, surface, hotx, hoty);
if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to set cursor shape",
- result);
+ DirectFBError("QDirectFBScreenCursor::show: "
+ "Unable to set cursor shape", result);
}
-
+ surface->Release(surface);
result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: "
- "Unable to reset cooperative level", result);
+ DirectFBError("QDirectFBScreenCursor::show: "
+ "Unable to set cooperative level", result);
}
-
- if (surface)
- QDirectFBScreen::instance()->releaseDFBSurface(surface);
+ show();
}
+
}
#endif // QT_NO_DIRECTFB_LAYER