summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremy Katz <jeremy.katz@nokia.com>2010-06-03 11:19:37 (GMT)
committerJeremy Katz <jeremy.katz@nokia.com>2010-06-03 11:19:37 (GMT)
commit28547949cc78d25884a76bf3c2112a6217ba5b66 (patch)
tree48f076d4f29aa215f85c106ab8ef012447eea50a /src
parent37ef97675aeb71a542ef179e98d5ee29f98d25c2 (diff)
downloadQt-28547949cc78d25884a76bf3c2112a6217ba5b66.zip
Qt-28547949cc78d25884a76bf3c2112a6217ba5b66.tar.gz
Qt-28547949cc78d25884a76bf3c2112a6217ba5b66.tar.bz2
software cursor cleanup
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/fb_base/fb_base.cpp24
-rw-r--r--src/plugins/platforms/fb_base/fb_base.h6
-rw-r--r--src/plugins/platforms/vnc/qvnccursor.cpp4
3 files changed, 21 insertions, 13 deletions
diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp
index f2009c1..cdcb608 100644
--- a/src/plugins/platforms/fb_base/fb_base.cpp
+++ b/src/plugins/platforms/fb_base/fb_base.cpp
@@ -26,25 +26,29 @@ void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e)
{
Q_UNUSED(e);
currentRect = getCurrentRect();
- screen->setDirty(currentRect);
+ setDirty();
}
QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter)
{
+ dirty = false;
if (currentRect.isNull())
return QRect();
+ if (!currentRect.intersects(screen->geometry()))
+ return QRect();
+
prevRect = currentRect;
painter.drawImage(prevRect, *graphic->image());
+ onScreen = true;
return prevRect;
}
QRect QGraphicsSystemSoftwareCursor::dirtyRect()
{
- if (!prevRect.isNull()) {
- QRect rect = prevRect;
- prevRect = QRect();
- return rect;
+ if (onScreen) {
+ onScreen = false;
+ return prevRect;
}
return QRect();
}
@@ -78,7 +82,7 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget
setCursor(shape);
}
currentRect = getCurrentRect();
- screen->setDirty(currentRect);
+ setDirty();
}
QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false)
@@ -126,8 +130,6 @@ QFbScreen::~QFbScreen()
void QFbScreen::setDirty(const QRect &rect)
{
-
-// qDebug() << "QFbScreen::setDirty" << rect;
repaintRegion += rect;
if (!redrawTimer.isActive()) {
redrawTimer.start();
@@ -165,9 +167,9 @@ void QFbScreen::generateRects()
QRegion QFbScreen::doRedraw()
{
QRegion touchedRegion;
- if (cursor)
+ if (cursor && cursor->isDirty() && cursor->isOnScreen())
repaintRegion += cursor->dirtyRect();
- if (repaintRegion.isEmpty())
+ if (repaintRegion.isEmpty() && !cursor->isDirty())
return touchedRegion;
QVector<QRect> rects = repaintRegion.rects();
@@ -223,7 +225,7 @@ QRegion QFbScreen::doRedraw()
}
QRect cursorRect;
- if (cursor) {
+ if (cursor && cursor->isDirty()) {
cursorRect = cursor->drawCursor(*compositePainter);
touchedRegion += cursorRect;
}
diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h
index 13638a0..d94462d 100644
--- a/src/plugins/platforms/fb_base/fb_base.h
+++ b/src/plugins/platforms/fb_base/fb_base.h
@@ -29,6 +29,10 @@ public:
virtual void pointerEvent(const QMouseEvent & event);
virtual void changeCursor(QCursor * widgetCursor, QWidget * widget);
+ virtual void setDirty() { dirty = true; screen->setDirty(QRect()); }
+ virtual bool isDirty() { return dirty; }
+ virtual bool isOnScreen() { return onScreen; }
+
protected:
QGraphicsSystemCursorImage * graphic;
@@ -39,6 +43,8 @@ private:
QRect currentRect; // next place to draw the cursor
QRect prevRect; // last place the cursor was drawn
QRect getCurrentRect();
+ bool dirty;
+ bool onScreen;
};
class QFbWindow;
diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp
index 8da06aa..72dcb25 100644
--- a/src/plugins/platforms/vnc/qvnccursor.cpp
+++ b/src/plugins/platforms/vnc/qvnccursor.cpp
@@ -64,14 +64,14 @@ void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
if (useVncCursor) {
server->setDirtyCursor();
} else {
- screen->setDirty(QRect(0,0,1,1));
+ setDirty();
}
}
void QVNCCursor::setCursorMode(bool vnc)
{
if (vnc) {
- screen->setDirty(dirtyRect());
+ setDirty();
server->setDirtyCursor();
} else {
server->setDirtyCursor();