Martin Vermeer wrote:
On Thu, 2006-11-02 at 10:45 +0100, Abdelrazak Younes wrote:
Martin Vermeer wrote:
Note that the job will be easier if stale caches are not covered up by
the current overzealous full-screen refresh behaviour. I suggest getting
rid of that first.
The full refresh thing is due to the cursor bug. I will work on it as soon as I find some free time.

Abdel.

Are you sure? That would be great.

Yes I'm sure. The attached patch fixes the full screen refresh on cursor blinking.

Unfortunately, there are some bad side effects. As I explained earlier, there is no backing pixmap any more as we draw directly on screen. This is the reason why I need to back-up the cursor area in order to restore it when the cursor is hidden (this is not yet working with this patch). Because of this also, when the widget loose the focus, the screen is not redrawn any more. This can be taken care of by caching the screen estate when we catch a "Focus Out" event. But at this point there is too much work to turn around the refresh problem. So the only pragmatic solution is to restore the backing pixmap.

Abdel.
Index: GuiWorkArea.C
===================================================================
--- GuiWorkArea.C       (revision 15685)
+++ GuiWorkArea.C       (working copy)
@@ -39,7 +39,6 @@
 #include <QMimeData>
 #include <QUrl>
 #include <QDragEnterEvent>
-#include <QPixmap>
 #include <QPainter>
 #include <QScrollBar>
 
@@ -50,8 +49,10 @@
 // On windows-XP the UserGuide PageDown scroll test is faster without event 
pruning (16 s)
 // than with it (23 s).
 #ifdef Q_WS_WIN
+int const CursorWidth = 2;
  #define USE_EVENT_PRUNING 0
 #else
+int const CursorWidth = 1;
  #define USE_EVENT_PRUNING 0
 #endif
 
@@ -181,7 +182,7 @@
 
 
 GuiWorkArea::GuiWorkArea(int w, int h, int id, LyXView & lyx_view)
-       : WorkArea(id, lyx_view)
+       : WorkArea(id, lyx_view), exposed_(false)
 {
        cursor_ = new frontend::CursorWidget(this);
        cursor_->hide();
@@ -596,7 +597,15 @@
        }
 
        //lyxerr << "real drawing" << endl;
-       paintText(*buffer_view_, pain);
+       if (!exposed_) {
+               paintText(*buffer_view_, pain);
+               exposed_ = true;
+       }
+
+       if (!cursor_->on_) {
+               const QRect & r = cursor_->geometry();
+               pain.drawPixmap(r.x(), r.y(), cursor_area_);
+       }
 }
 
 
@@ -604,14 +613,16 @@
 void GuiWorkArea::expose(int x, int y, int w, int h)
 {
        update(x, y, w, h);
+       exposed_ = false;
 }
 
 
 void GuiWorkArea::showCursor(int x, int y, int h, CursorShape shape)
 {
-       cursor_->setGeometry(x, y, 2, h);
+       cursor_->setGeometry(x, y, CursorWidth, h);
        cursor_->shape_ = shape;
        cursor_->on_ = true;
+       cursor_area_ = QPixmap::grabWidget(this, x, y, CursorWidth, h);
        cursor_->show();
 }
 
@@ -621,6 +632,7 @@
        if (!qApp->focusWidget())
                return;
        cursor_->hide();
+       cursor_->on_ = false;
 }
 
 
Index: GuiWorkArea.h
===================================================================
--- GuiWorkArea.h       (revision 15680)
+++ GuiWorkArea.h       (working copy)
@@ -23,6 +23,7 @@
 #include <QResizeEvent>
 #include <QKeyEvent>
 #include <QTimer>
+#include <QPixmap>
 
 #include <queue>
 
@@ -179,6 +180,10 @@
        CursorShape cursor_shape_;
        ///     
        CursorWidget * cursor_;
+       ///
+       bool exposed_;
+       ///
+       QPixmap cursor_area_;
 };
 
 } // namespace frontend

Reply via email to