Martin,
I guess that this one is for you to test. Rather than draw a new line on
each cursor blink, I bitBlt cached pixmaps. It works (we still have a
blinking cursor, either 'normal' or 'foreign'), but I have no idea whether
it works as desired (zero traffic).
--
Angus
Index: src/frontends/qt2/qscreen.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/qscreen.C,v
retrieving revision 1.28
diff -u -p -r1.28 qscreen.C
--- src/frontends/qt2/qscreen.C 20 May 2004 09:36:28 -0000 1.28
+++ src/frontends/qt2/qscreen.C 4 May 2005 17:44:19 -0000
@@ -15,6 +15,7 @@
#include "debug.h"
#include "LColor.h"
+#include "lcolorcache.h"
#include <qapplication.h>
@@ -68,6 +69,9 @@ void QScreen::expose(int x, int y, int w
void QScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
{
+ if (!qApp->focusWidget())
+ return;
+
cursor_x_ = x;
cursor_y_ = y;
cursor_h_ = h;
@@ -85,34 +89,49 @@ void QScreen::showCursor(int x, int y, i
break;
}
- if (!nocursor_pixmap_.get()
- || cursor_w_ != nocursor_pixmap_->width()
- || cursor_h_ != nocursor_pixmap_->height()) {
- nocursor_pixmap_.reset(new QPixmap(cursor_w_, cursor_h_));
+ if (nocursor_pixmap_.isNull()
+ || cursor_w_ != nocursor_pixmap_.width()
+ || cursor_h_ != nocursor_pixmap_.height()) {
+ nocursor_pixmap_.resize(cursor_w_, cursor_h_);
}
- if (!qApp->focusWidget())
- return;
-
- // save old area
- bitBlt(nocursor_pixmap_.get(), 0, 0, owner_.getPixmap(),
- cursor_x_, cursor_y_, cursor_w_, cursor_h_);
-
- Painter & pain(owner_.getPainter());
- pain.start();
- pain.line(x, y, x, y + h - 1, LColor::cursor);
-
+ if (vcursor_pixmap_.isNull()
+ || cursor_h_ != vcursor_pixmap_.height()) {
+ vcursor_pixmap_.resize(1, cursor_h_);
+ vcursor_pixmap_.fill(lcolorcache.get(LColor::cursor));
+ }
+
switch (shape) {
case BAR_SHAPE:
break;
case REVERSED_L_SHAPE:
case L_SHAPE:
- pain.line(cursor_x_, y + h - 1, cursor_x_ + cursor_w_ - 1,
- y + h - 1, LColor::cursor);
+ if (hcursor_pixmap_.isNull()
+ || cursor_w_ != hcursor_pixmap_.width()) {
+ hcursor_pixmap_.resize(cursor_w_, 1);
+ hcursor_pixmap_.fill(lcolorcache.get(LColor::cursor));
+ }
break;
}
- pain.end();
+ // save old area
+ bitBlt(&nocursor_pixmap_, 0, 0, owner_.getPixmap(),
+ cursor_x_, cursor_y_, cursor_w_, cursor_h_);
+
+ bitBlt(owner_.getPixmap(), x, y,
+ &vcursor_pixmap_, 0, 0,
+ vcursor_pixmap_.width(), vcursor_pixmap_.height());
+
+ switch (shape) {
+ case BAR_SHAPE:
+ break;
+ case REVERSED_L_SHAPE:
+ case L_SHAPE:
+ bitBlt(owner_.getPixmap(), cursor_x_, y + h - 1,
+ &hcursor_pixmap_, 0, 0,
+ hcursor_pixmap_.width(), hcursor_pixmap_.height());
+ break;
+ }
owner_.getContent()->repaint(
cursor_x_, cursor_y_,
@@ -123,13 +142,12 @@ void QScreen::showCursor(int x, int y, i
void QScreen::removeCursor()
{
// before first showCursor
- if (!nocursor_pixmap_.get())
+ if (nocursor_pixmap_.isNull())
return;
bitBlt(owner_.getPixmap(), cursor_x_, cursor_y_,
- nocursor_pixmap_.get(), 0, 0, cursor_w_, cursor_h_);
+ &nocursor_pixmap_, 0, 0, cursor_w_, cursor_h_);
- owner_.getContent()->repaint(
- cursor_x_, cursor_y_,
- cursor_w_, cursor_h_);
+ owner_.getContent()
+ ->repaint(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
}
Index: src/frontends/qt2/qscreen.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/qscreen.h,v
retrieving revision 1.11
diff -u -p -r1.11 qscreen.h
--- src/frontends/qt2/qscreen.h 5 Sep 2003 15:06:13 -0000 1.11
+++ src/frontends/qt2/qscreen.h 4 May 2005 17:44:19 -0000
@@ -14,8 +14,7 @@
#include "screen.h"
-#include <qrect.h>
-#include <boost/scoped_ptr.hpp>
+#include <qpixmap.h>
class QWorkArea;
class WorkArea;
@@ -50,7 +49,9 @@ private:
/// our owning widget
QWorkArea & owner_;
- boost::scoped_ptr<QPixmap> nocursor_pixmap_;
+ QPixmap nocursor_pixmap_;
+ QPixmap hcursor_pixmap_;
+ QPixmap vcursor_pixmap_;
//@{ the cursor pixmap position/size
int cursor_x_;