summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <jeremy.katz@nokia.com>2009-11-26 13:39:06 +0100
committerJeremy Katz <jeremy.katz@nokia.com>2009-11-26 14:27:45 +0100
commitc290785d0f8e1ef7af4bdff683aab40b8ff33681 (patch)
treeed3ff2635d237ef9853cd940b39650fd41718661
parent19039afd151f2c2401659904b89968d302149493 (diff)
move software cursor from QGraphicsSystemCursor into QGraphicsSystemSoftwareCursor
-rw-r--r--src/gui/painting/qgraphicssystemcursor.cpp72
-rw-r--r--src/gui/painting/qgraphicssystemcursor.h24
-rw-r--r--src/plugins/graphicssystems/fb_base/fb_base.cpp74
-rw-r--r--src/plugins/graphicssystems/fb_base/fb_base.h26
-rw-r--r--src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp2
-rw-r--r--src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp8
-rw-r--r--src/plugins/graphicssystems/vnc/qvnccursor.cpp12
-rw-r--r--src/plugins/graphicssystems/vnc/qvnccursor.h5
8 files changed, 111 insertions, 112 deletions
diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp
index 3afaf4bfbc..022dc64c70 100644
--- a/src/gui/painting/qgraphicssystemcursor.cpp
+++ b/src/gui/painting/qgraphicssystemcursor.cpp
@@ -53,79 +53,9 @@ QT_BEGIN_NAMESPACE
QPointer<QGraphicsSystemCursor> QGraphicsSystemCursor::instance = 0;
QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr )
- :currentRect(QRect()), prevRect(QRect()), screen(scr)
+ : screen(scr)
{
- graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0);
instance = this;
- setCursor(Qt::ArrowCursor);
-}
-
-QGraphicsSystemCursor::~QGraphicsSystemCursor()
-{
-}
-
-void QGraphicsSystemCursor::setCursor(Qt::CursorShape shape)
-{
- graphic->set(shape);
-}
-
-void QGraphicsSystemCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
-{
- graphic->set(data, mask, width, height, hotX, hotY);
-}
-
-QRect QGraphicsSystemCursor::dirtyRect()
-{
- if (!prevRect.isNull()) {
- QRect rect = prevRect;
- prevRect = QRect();
- return rect;
- }
- return QRect();
-}
-
-QRect QGraphicsSystemCursor::drawCursor(QPainter & painter)
-{
- if (currentRect.isNull())
- return QRect();
-
- prevRect = currentRect;
- painter.drawImage(prevRect, *graphic->image());
- return prevRect;
-}
-
-QRect QGraphicsSystemCursor::getCurrentRect()
-{
- QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(),
- -graphic->hotspot().y());
- rect.translate(QCursor::pos());
- return rect;
-}
-
-void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & e)
-{
- Q_UNUSED(e);
- currentRect = getCurrentRect();
- screen->setDirty(currentRect);
-}
-
-void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
-{
- Q_UNUSED(widget);
- Qt::CursorShape shape = widgetCursor->shape();
-
- if (shape == Qt::BitmapCursor) {
- // application supplied cursor
- const QBitmap * map = widgetCursor->bitmap();
- const QBitmap * mask = widgetCursor->mask();
- QPoint spot = widgetCursor->hotSpot();
- setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y());
- } else {
- // system cursor
- setCursor(shape);
- }
- currentRect = getCurrentRect();
- screen->setDirty(currentRect);
}
// End of display and pointer event handling code
diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h
index d385ac0f64..42727a828a 100644
--- a/src/gui/painting/qgraphicssystemcursor.h
+++ b/src/gui/painting/qgraphicssystemcursor.h
@@ -51,7 +51,7 @@
QT_BEGIN_NAMESPACE
// Cursor graphics management
-class QGraphicsSystemCursorImage {
+class Q_GUI_EXPORT QGraphicsSystemCursorImage {
public:
QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
{ set(data, mask, width, height, hotX, hotY); }
@@ -68,33 +68,17 @@ private:
class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject {
public:
QGraphicsSystemCursor(QGraphicsSystemScreen *);
- virtual ~QGraphicsSystemCursor();
// input methods
- virtual void pointerEvent(const QMouseEvent & event);
- virtual void changeCursor(QCursor * widgetCursor, QWidget * widget);
-
- // output methods
- virtual QRect drawCursor(QPainter &);
- virtual QRect dirtyRect();
+ virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); }
+ virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0;
static QPointer<QGraphicsSystemCursor> getInstance() { return instance; }
protected:
- static QPointer<QGraphicsSystemCursor> instance;
-
- QRect currentRect; // next place to draw the cursor
- QRect prevRect; // last place the cursor was drawn
+ static QPointer<QGraphicsSystemCursor> instance; // limit 1 cursor at a time
QGraphicsSystemScreen * screen; // Where to request an update
-
- QGraphicsSystemCursorImage * graphic;
-
-private:
-
- void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
- void setCursor(Qt::CursorShape shape);
- QRect getCurrentRect();
};
QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp
index 6ecfd1b2ec..27cb8a44e6 100644
--- a/src/plugins/graphicssystems/fb_base/fb_base.cpp
+++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp
@@ -3,9 +3,81 @@
#include <qpainter.h>
#include <private/qapplication_p.h>
#include <qdebug.h>
-
+#include <qbitmap.h>
#include <qgraphicssystemcursor.h>
+QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr)
+ : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect())
+{
+ graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0);
+ setCursor(Qt::ArrowCursor);
+}
+
+QRect QGraphicsSystemSoftwareCursor::getCurrentRect()
+{
+ QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(),
+ -graphic->hotspot().y());
+ rect.translate(QCursor::pos());
+ return rect;
+}
+
+
+void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e)
+{
+ Q_UNUSED(e);
+ currentRect = getCurrentRect();
+ screen->setDirty(currentRect);
+}
+
+QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter)
+{
+ if (currentRect.isNull())
+ return QRect();
+
+ prevRect = currentRect;
+ painter.drawImage(prevRect, *graphic->image());
+ return prevRect;
+}
+
+QRect QGraphicsSystemSoftwareCursor::dirtyRect()
+{
+ if (!prevRect.isNull()) {
+ QRect rect = prevRect;
+ prevRect = QRect();
+ return rect;
+ }
+ return QRect();
+}
+
+void QGraphicsSystemSoftwareCursor::setCursor(Qt::CursorShape shape)
+{
+ graphic->set(shape);
+}
+
+void QGraphicsSystemSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+{
+ graphic->set(data, mask, width, height, hotX, hotY);
+}
+
+void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
+{
+ Q_UNUSED(widget);
+ Qt::CursorShape shape = widgetCursor->shape();
+
+ if (shape == Qt::BitmapCursor) {
+ // application supplied cursor
+ const QBitmap * map = widgetCursor->bitmap();
+ const QBitmap * mask = widgetCursor->mask();
+ QPoint spot = widgetCursor->hotSpot();
+ setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y());
+ } else {
+ // system cursor
+ setCursor(shape);
+ }
+ currentRect = getCurrentRect();
+ screen->setDirty(currentRect);
+}
+
QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0)
{
mScreenImage = new QImage(mGeometry.size(), mFormat);
diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h
index 8e54f476f5..9abd5d07f8 100644
--- a/src/plugins/graphicssystems/fb_base/fb_base.h
+++ b/src/plugins/graphicssystems/fb_base/fb_base.h
@@ -15,6 +15,30 @@ class QPainter;
class QGraphicsSystemFbWindowSurface;
class QGraphicsSystemFbScreen;
+class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor
+{
+public:
+ QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr);
+
+ // output methods
+ QRect dirtyRect();
+ virtual QRect drawCursor(QPainter & painter);
+
+ // input methods
+ virtual void pointerEvent(const QMouseEvent & event);
+ virtual void changeCursor(QCursor * widgetCursor, QWidget * widget);
+
+protected:
+ QGraphicsSystemCursorImage * graphic;
+
+private:
+ void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
+ void setCursor(Qt::CursorShape shape);
+ QRect currentRect; // next place to draw the cursor
+ QRect prevRect; // last place the cursor was drawn
+ QRect getCurrentRect();
+};
+
class QGraphicsSystemFbWindowSurface : public QWindowSurface
{
public:
@@ -74,7 +98,7 @@ public:
protected:
QList<QGraphicsSystemFbWindowSurface *> windowStack;
QRegion repaintRegion;
- QGraphicsSystemCursor * cursor;
+ QGraphicsSystemSoftwareCursor * cursor;
QTimer redrawTimer;
protected slots:
diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp
index 2a0007b169..f5ca6e73d4 100644
--- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp
+++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp
@@ -807,7 +807,7 @@ QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w,
mFormat);
mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(),
bytesPerLine, mFormat);
- cursor = new QGraphicsSystemCursor(this);
+ cursor = new QGraphicsSystemSoftwareCursor(this);
}
void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect)
diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp
index 450905c298..bdcac37a62 100644
--- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp
+++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp
@@ -72,14 +72,6 @@ public:
ws->setCursor(cursor->shape());
}
-
- //#### remove this
- void pointerEvent(const QMouseEvent & event) {
- Q_UNUSED(event);
-#if 0
- qDebug() << "pointerEvent" << event.globalPos();
-#endif
- }
};
diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp
index 55d1c614c3..fb214d80af 100644
--- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp
+++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp
@@ -54,13 +54,13 @@
QT_BEGIN_NAMESPACE
QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr )
- :QGraphicsSystemCursor::QGraphicsSystemCursor(scr), useVncCursor(false), server(srvr)
+ :QGraphicsSystemSoftwareCursor(scr), useVncCursor(false), server(srvr)
{
}
void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
{
- QGraphicsSystemCursor::changeCursor(widgetCursor, widget);
+ QGraphicsSystemSoftwareCursor::changeCursor(widgetCursor, widget);
if (useVncCursor) {
server->setDirtyCursor();
} else {
@@ -71,8 +71,7 @@ void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
void QVNCCursor::setCursorMode(bool vnc)
{
if (vnc) {
- screen->setDirty(prevRect);
- prevRect = QRect();
+ screen->setDirty(dirtyRect());
server->setDirtyCursor();
} else {
server->setDirtyCursor();
@@ -85,10 +84,7 @@ QRect QVNCCursor::drawCursor(QPainter & painter)
if (useVncCursor)
return QRect();
- if (currentRect.isNull())
- return QRect();
-
- return QGraphicsSystemCursor::drawCursor(painter);
+ return QGraphicsSystemSoftwareCursor::drawCursor(painter);
}
void QVNCCursor::clearClientCursor()
diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.h b/src/plugins/graphicssystems/vnc/qvnccursor.h
index a90b7e2cbb..8ea0f45e64 100644
--- a/src/plugins/graphicssystems/vnc/qvnccursor.h
+++ b/src/plugins/graphicssystems/vnc/qvnccursor.h
@@ -41,7 +41,7 @@
#ifndef QVNCCURSOR_H
#define QVNCCURSOR_H
-#include "qgraphicssystemcursor.h"
+#include "../fb_base/fb_base.h"
#include <QList>
#include <QImage>
#include <QMouseEvent>
@@ -51,13 +51,14 @@ QT_BEGIN_NAMESPACE
class QVNCGraphicsSystemScreen;
class QVNCServer;
-class QVNCCursor : public QGraphicsSystemCursor {
+class QVNCCursor : public QGraphicsSystemSoftwareCursor {
public:
QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *);
// input methods
void setCursorMode(bool vnc);
void changeCursor(QCursor * widgetCursor, QWidget * widget);
+
// output methods
QRect drawCursor(QPainter &);