Hello,

This patch cleans up a lot of thing. It removes the work_area_ member from BufferView and all the cursor handling. The next thing to cleanup on the list is LyXView but that's another story.

Qt4 and qt3 have been tested. I would like to commit that instead of going through a branch. Any objection?

I have a question to LyX kernel expert:

If you launch LyX with "-dbg debug" you will noticed that BufferView::pimpl::update() is called twice within the same workAreaKeyPress(). I haven't been update to locate the origin of the second call, it seems that it is the result of a boost signal/slot connection but I don't know which. The second update() is called immediately after the first update() call. Because of that I have to call LyXView::redrawWorkArea() within the update and I would _really_ like to avoid that.

Help please.

Abdel.

PS: Angus, the patch summary is in the log ;-)


Log:

* BufferView:
  - painter(): this was used only by rowpainter::paintText(), we now
    pass the painter directly.
  - hideCursor(): deleted
  - viewMetricsInfo(), needsRedraw(): new methods for WorkArea::redraw()

* CoordCache:
  - startUpdating(), doneUpdating(): deleted because the screen drawing
    is now done at one place (WorkArea::redraw()) and cannot be called
    for within itself. Those debug methods are then not useful.

* frontends/GuiCursor:
  - deleted. Functionality transfered to WorkArea.

* frontends/Gui:
  - guiCursor() method: deleted.

* frontends/Timeout:
  - emit() renamed to emitSignal() to avoid compiler confusion with Qt
    emit() function (change propagated to all frontend).

* frontends/WorkArea:
  - now each instance handles its blinking cursor independently.
  - the redraw() method now check if the the attached bufferView needs
    a screen redraw().
  - processKeySym(): new method that should be used by all frontends
    instead of buffer_view_->workAreaKeyPress(). This enable the cursor
    to be shown as soon as a key is pressed. Only Qt4 takes advantage of
    this for now.
  - bufferView(): new access methods.
  - hideCursor(), howCursor(), toggleCursor(): new methods transfered
    from GuiCursor.


* frontends/LyXView:
  - now contains a pointer reference to the current WorkArea instead of
    the BufferView.
  - redrawWorkArea(): new temporary method called from within
    BufferView::pimpl::update() that calls WorkArea::redra() in order to
    do the actual screen redrawing.

* frontends/qt4/GuiWorkArea:
  - keyPressEvent(): call WorkArea::processKeySym() instead of
    buffer_view_->workAreaKeyPress().
Index: src/BufferView.C
===================================================================
--- src/BufferView.C    (revision 14265)
+++ src/BufferView.C    (working copy)
@@ -43,7 +43,6 @@
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
 #include "frontends/Gui.h"
-#include "frontends/WorkArea.h"
 
 #include "insets/insetcommand.h" // ChangeRefs
 #include "insets/insettext.h"
@@ -62,8 +61,8 @@
 extern BufferList bufferlist;
 
 
-BufferView::BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea)
-       : pimpl_(new Pimpl(*this, owner, workArea))
+BufferView::BufferView(LyXView * owner)
+       : pimpl_(new Pimpl(*this, owner))
 {}
 
 
@@ -91,12 +90,6 @@
 }
 
 
-lyx::frontend::Painter & BufferView::painter() const
-{
-       return pimpl_->painter();
-}
-
-
 void BufferView::setBuffer(Buffer * b)
 {
        pimpl_->setBuffer(b);
@@ -317,11 +310,6 @@
 }
 
 
-void BufferView::hideCursor()
-{
-       pimpl_->gui().guiCursor().hide();
-}
-
 LyXText * BufferView::getLyXText()
 {
        LyXText * text = cursor().innerText();
@@ -438,3 +426,17 @@
 {
        return pimpl_->offset_ref_;
 }
+
+
+ViewMetricsInfo const & BufferView::viewMetricsInfo()
+{
+       return pimpl_->viewMetricsInfo();
+}
+
+
+bool & BufferView::needsRedraw()
+{
+       return pimpl_->needsRedraw();
+}
+
+
Index: src/BufferView.h
===================================================================
--- src/BufferView.h    (revision 14265)
+++ src/BufferView.h    (working copy)
@@ -15,6 +15,8 @@
 #ifndef BUFFER_VIEW_H
 #define BUFFER_VIEW_H
 
+#include "metricsinfo.h"
+
 #include "frontends/LyXKeySym.h"
 
 #include "support/types.h"
@@ -35,13 +37,6 @@
 class LyXView;
 class ParIterator;
 
-namespace lyx {
-namespace frontend {
-class Painter;
-class WorkArea;
-}
-}
-
 namespace Update {
        enum flags {
                FitCursor = 1,
@@ -94,7 +89,7 @@
         * Create a view with the given owner main window,
         * of the given dimensions.
         */
-       BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea);
+       BufferView(LyXView * owner);
 
        ~BufferView();
 
@@ -103,9 +98,6 @@
        /// return the buffer being viewed
        Buffer * buffer() const;
 
-       /// return the painter object for drawing onto the view
-       lyx::frontend::Painter & painter() const;
-
        /// return the owning main view
        LyXView * owner() const;
 
@@ -169,9 +161,6 @@
        /// set the cursor based on the given TeX source row
        void setCursorFromRow(int row);
 
-       /// hide the cursor if it is visible
-       void hideCursor();
-
        /// center the document view around the cursor
        void center();
        /// scroll document by the given number of lines of default height
@@ -243,7 +232,18 @@
        bool const repaintAll() const;
        ///
        void const repaintAll(bool r) const;
+       ///
+       ViewMetricsInfo const & viewMetricsInfo();
 
+       /// needs_redraw_ accessor
+       /**
+       This accessor is there for the WorkArea class use. The WorkArea
+       must set needsRedraw to false once screen redrawing is done!
+       \retval true is a redraw is needed
+       \retval fasle otherwise
+       */
+       bool & needsRedraw();
+
 private:
        ///
        class Pimpl;
Index: src/BufferView_pimpl.C
===================================================================
--- src/BufferView_pimpl.C      (revision 14265)
+++ src/BufferView_pimpl.C      (working copy)
@@ -48,7 +48,6 @@
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
 #include "pariterator.h"
-#include "rowpainter.h"
 #include "toc.h"
 #include "undo.h"
 #include "vspace.h"
@@ -64,15 +63,13 @@
 #include "frontends/font_metrics.h"
 #include "frontends/Gui.h"
 #include "frontends/LyXView.h"
-#include "frontends/Painter.h"
-#include "frontends/WorkArea.h"
 
 #include "graphics/Previews.h"
 
 #include "support/convert.h"
 #include "support/filefilterlist.h"
 #include "support/filetools.h"
-#include "support/forkedcontr.h"
+//#include "support/forkedcontr.h"
 #include "support/package.h"
 #include "support/types.h"
 
@@ -82,7 +79,6 @@
 #include <functional>
 #include <vector>
 
-using lyx::frontend::WorkArea;
 using lyx::frontend::Clipboard;
 using lyx::frontend::Gui;
 
@@ -92,7 +88,6 @@
 using lyx::support::bformat;
 using lyx::support::FileFilterList;
 using lyx::support::fileSearch;
-using lyx::support::ForkedcallsController;
 using lyx::support::isDirWriteable;
 using lyx::support::makeDisplayPath;
 using lyx::support::makeAbsPath;
@@ -114,13 +109,7 @@
 
 unsigned int const saved_positions_num = 20;
 
-// All the below connection objects are needed because of a bug in some
-// versions of GCC (<=2.96 are on the suspects list.) By having and assigning
-// to these connections we avoid a segfault upon startup, and also at exit.
-// (Lgb)
 
-boost::signals::connection timecon;
-
 /// Return an inset of this class if it exists at the current cursor position
 template <class T>
 T * getInsetByCode(LCursor & cur, InsetBase::Code code)
@@ -137,19 +126,13 @@
 } // anon namespace
 
 
-BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner, WorkArea * workArea)
-       : bv_(&bv), owner_(owner), buffer_(0), wh_(0), cursor_timeout(400), 
-         using_xterm_cursor(false), workArea_(workArea), cursor_(bv), 
+BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner)
+       : bv_(&bv), owner_(owner), buffer_(0), wh_(0),
+         using_xterm_cursor(false), cursor_(bv),
          multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0)
 {
        xsel_cache_.set = false;
 
-       // Setup the signals
-       timecon = cursor_timeout.timeout
-               .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
-
-       cursor_timeout.start();
-       
        saved_positions.resize(saved_positions_num);
        // load saved bookmarks
        lyx::Session::BookmarkList & bmList = 
LyX::ref().session().loadBookmarks();
@@ -319,12 +302,6 @@
 }
 
 
-lyx::frontend::Painter & BufferView::Pimpl::painter() const
-{
-       return workArea_->getPainter();
-}
-
-
 int BufferView::Pimpl::width() const
 {
        return width_;
@@ -519,8 +496,6 @@
        if (!buffer_)
                return;
 
-       owner_->gui().guiCursor().hide();
-
        LyXText & t = *bv_->text();
 
        float const bar = value / float(wh_ * t.paragraphs().size());
@@ -590,16 +565,7 @@
                                         key_modifier::state state)
 {
        owner_->getLyXFunc().processKeySym(key, state);
-
-       /* This is perhaps a bit of a hack. When we move
-        * around, or type, it's nice to be able to see
-        * the cursor immediately after the keypress. So
-        * we reset the toggle timeout and force the visibility
-        * of the cursor. Note we cannot do this inside
-        * dispatch() itself, because that's called recursively.
-        */
-       if (available())
-               owner_->gui().guiCursor().show(*bv_);
+       //update();
 }
 
 
@@ -634,7 +600,6 @@
 void BufferView::Pimpl::selectionLost()
 {
        if (available()) {
-               owner_->gui().guiCursor().hide();
                cursor_.clearSelection();
                xsel_cache_.set = false;
        }
@@ -688,6 +653,12 @@
 }
 
 
+ViewMetricsInfo const & BufferView::Pimpl::viewMetricsInfo()
+{
+       return metrics_info_;
+}
+
+
 void BufferView::Pimpl::update(Update::flags flags)
 {
        lyxerr[Debug::DEBUG]
@@ -702,55 +673,29 @@
                // Update macro store
                buffer_->buildMacros();
 
-               CoordCache backup;
-               std::swap(theCoords, backup);
-
-               // This, together with doneUpdating(), verifies (using
-               // asserts) that screen redraw is not called from
-               // within itself.
-               theCoords.startUpdating();
-
                // First drawing step
-               ViewMetricsInfo vi = metrics(flags & Update::SinglePar);
-               bool forceupdate(flags & (Update::Force | Update::SinglePar));
+               updateMetrics(flags & Update::SinglePar);
+               needs_redraw_ = (flags & (Update::Force | Update::SinglePar));
 
                if ((flags & Update::FitCursor) && fitCursor()) {
-                       forceupdate = true;
-                       vi = metrics();
+                       updateMetrics();
+                       needs_redraw_ = true;
                }
+
                if ((flags & Update::MultiParSel) && multiParSel()) {
-                       forceupdate = true;
-                       vi = metrics();
+                       updateMetrics();
+                       needs_redraw_ = true;
                }
-               if (forceupdate) {
-                       // Second drawing step
-                       workArea_->redraw(*bv_, vi);
-               } else {
-                       // Abort updating of the coord
-                       // cache - just restore the old one
-                       std::swap(theCoords, backup);
-               }
-       } else
-               workArea_->greyOut();
+       }
 
+       owner_->redrawWorkArea();
        owner_->view_state_changed();
 }
 
 
-// Callback for cursor timer
-void BufferView::Pimpl::cursorToggle()
+bool & BufferView::Pimpl::needsRedraw()
 {
-       if (buffer_) {
-               owner_->gui().guiCursor().toggle(*bv_);
-
-               // Use this opportunity to deal with any child processes that
-               // have finished but are waiting to communicate this fact
-               // to the rest of LyX.
-               ForkedcallsController & fcc = ForkedcallsController::get();
-               fcc.handleCompletedProcesses();
-       }
-
-       cursor_timeout.restart();
+       return needs_redraw_;
 }
 
 
@@ -999,8 +944,6 @@
        if (!available())
                return false;
 
-       owner_->gui().guiCursor().hide();
-
        // Either the inset under the cursor or the
        // surrounding LyXText will handle this event.
 
@@ -1035,10 +978,6 @@
                        update(Update::FitCursor | Update::MultiParSel);
        }
 
-       // See workAreaKeyPress
-       cursor_timeout.restart();
-       owner_->gui().guiCursor().show(*bv_);
-
        // Skip these when selecting
        if (cmd.action != LFUN_MOUSE_MOTION) {
                owner_->updateLayoutChoice();
@@ -1416,7 +1355,7 @@
 }
 
 
-ViewMetricsInfo BufferView::Pimpl::metrics(bool singlepar)
+void BufferView::Pimpl::updateMetrics(bool singlepar)
 {
        // Remove old position cache
        theCoords.clear();
@@ -1513,5 +1452,5 @@
                << "size: " << size
                << endl;
 
-       return ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size);
+       metrics_info_ = ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size);
 }
Index: src/BufferView_pimpl.h
===================================================================
--- src/BufferView_pimpl.h      (revision 14265)
+++ src/BufferView_pimpl.h      (working copy)
@@ -21,9 +21,9 @@
 #include "BufferView.h"
 #include "cursor.h"
 #include "errorlist.h"
+#include "metricsinfo.h"
 
 #include "frontends/LyXKeySym.h"
-#include "frontends/Timeout.h"
 
 #include "support/types.h"
 
@@ -34,13 +34,10 @@
 
 class FuncRequest;
 class FuncStatus;
-class ViewMetricsInfo;
 
 namespace lyx {
 namespace frontend {
 class Gui;
-class WorkArea;
-class Painter;
 }
 }
 
@@ -49,10 +46,8 @@
 class BufferView::Pimpl : public boost::signals::trackable {
 public:
        ///
-       Pimpl(BufferView & bv, LyXView * owner, lyx::frontend::WorkArea * 
workArea);
+       Pimpl(BufferView & bv, LyXView * owner);
        ///
-       lyx::frontend::Painter & painter() const;
-       ///
        void setBuffer(Buffer * buf);
        ///
        void resizeCurrentBuffer();
@@ -83,7 +78,7 @@
        ///
        void selectionLost();
        ///
-       void cursorToggle();
+//     void cursorToggle();
        ///
        bool available() const;
        /// get the change at the cursor position
@@ -125,6 +120,18 @@
        */
        int height() const;
 
+       ///
+       ViewMetricsInfo const & viewMetricsInfo();
+       
+       /// needs_redraw_ accessor
+       /**
+       This accessor is there for the WorkArea class use. The WorkArea
+       must set needsRedraw to false once screen redrawing is done!
+       \retval true is a redraw is needed
+       \retval fasle otherwise
+       */
+       bool & needsRedraw();
+
 private:
        ///
        int width_;
@@ -132,6 +139,8 @@
        int height_;
        ///
        ScrollbarParameters scrollbarParameters_;
+       ///
+       bool needs_redraw_;
 
        /// An error list (replaces the error insets)
        ErrorList errorlist_;
@@ -160,6 +169,10 @@
        /// notify readonly status
        void showReadonly(bool);
 
+       ///
+       ViewMetricsInfo metrics_info_;
+       ///
+       void updateMetrics(bool singlepar = false);
 
        ///
        friend class BufferView;
@@ -174,8 +187,6 @@
        /// Estimated average par height for scrollbar
        int wh_;
        ///
-       Timeout cursor_timeout;
-       ///
        void stuffClipboard(std::string const &) const;
        ///
        bool using_xterm_cursor;
@@ -199,8 +210,6 @@
        ///
        void menuInsertLyXFile(std::string const & filen);
 
-       lyx::frontend::WorkArea * workArea_;
-
        /// this is used to handle XSelection events in the right manner
        struct {
                CursorSlice cursor;
@@ -215,8 +224,6 @@
        lyx::pit_type anchor_ref_;
        ///
        int offset_ref_;
-       ///
-       ViewMetricsInfo metrics(bool singlepar = false);
        /// Working variable indicating a full screen refresh
        mutable bool refresh_inside_;
 
Index: src/coordcache.C
===================================================================
--- src/coordcache.C    (revision 14265)
+++ src/coordcache.C    (working copy)
@@ -33,7 +33,6 @@
 
 void CoordCache::clear()
 {
-       BOOST_ASSERT(updating);
        arrays_.clear();
        insets_.clear();
        pars_.clear();
@@ -42,20 +41,6 @@
 }
 
 
-void CoordCache::startUpdating()
-{
-       BOOST_ASSERT(!updating);
-       updating = true;
-}
-
-
-void CoordCache::doneUpdating()
-{
-       BOOST_ASSERT(updating);
-       updating = false;
-}
-
-
 Point CoordCache::get(LyXText const * text, lyx::pit_type pit)
 {
        ParPosCache::iterator const it = pars_.find(text);
Index: src/coordcache.h
===================================================================
--- src/coordcache.h    (revision 14265)
+++ src/coordcache.h    (working copy)
@@ -108,12 +108,9 @@
  */
 class CoordCache {
 public:
-       CoordCache() : updating(false) { }
-       /// In order to find bugs, we record when we start updating the cache
-       void startUpdating();
-       /// When we are done, we record that to help find bugs
-       void doneUpdating();
+       CoordCache() { }
 
+       ///
        void clear();
        Point get(LyXText const *, lyx::pit_type);
 
@@ -125,18 +122,17 @@
        typedef std::map<LyXText const *, InnerParPosCache> SliceCache;
 
        /// A map from MathArray to position on the screen
-       CoordCacheBase<MathArray> & arrays() { BOOST_ASSERT(updating); return 
arrays_; }
+       CoordCacheBase<MathArray> & arrays() { return arrays_; }
        CoordCacheBase<MathArray> const & getArrays() const { return arrays_; }
        /// A map from insets to positions on the screen
-       CoordCacheBase<InsetBase> & insets() { BOOST_ASSERT(updating); return 
insets_; }
+       CoordCacheBase<InsetBase> & insets() { return insets_; }
        CoordCacheBase<InsetBase> const & getInsets() const { return insets_; }
        /// A map from (LyXText, paragraph) pair to screen positions
-       ParPosCache & parPos() { BOOST_ASSERT(updating); return pars_; }
+       ParPosCache & parPos() { return pars_; }
        ParPosCache const & getParPos() const { return pars_; }
        ///
        SliceCache & slice(bool boundary)
        {
-               BOOST_ASSERT(updating);
                return boundary ? slices1_ : slices0_;
        }
        SliceCache const & getSlice(bool boundary) const
@@ -155,12 +151,6 @@
        SliceCache slices0_;
        /// Used with boundary == 1
        SliceCache slices1_;
-
-       /**
-        * Debugging flag only: Set to true while the cache is being built.
-        * No changes to the structure are allowed unless we are updating.
-        */
-       bool updating;
 };
 
 extern CoordCache theCoords;
Index: src/frontends/gtk/GScreen.C
===================================================================
--- src/frontends/gtk/GScreen.C (revision 14265)
+++ src/frontends/gtk/GScreen.C (working copy)
@@ -32,7 +32,7 @@
 
 #include "frontends/font_metrics.h"
 #include "frontends/Painter.h"
-#include "frontends/GuiCursor.h"
+#include "frontends/WorkArea.h"
 
 #include "insets/insettext.h"
 
Index: src/frontends/gtk/GScreen.h
===================================================================
--- src/frontends/gtk/GScreen.h (revision 14265)
+++ src/frontends/gtk/GScreen.h (working copy)
@@ -12,7 +12,7 @@
 #ifndef GSCREEN_H
 #define GSCREEN_H
 
-#include "frontends/GuiCursor.h"
+#include "frontends/WorkArea.h"
 
 #include <gtkmm.h>
 
Index: src/frontends/gtk/GTimeout.C
===================================================================
--- src/frontends/gtk/GTimeout.C        (revision 14265)
+++ src/frontends/gtk/GTimeout.C        (working copy)
@@ -76,7 +76,7 @@
 
 bool GTimeout::timeoutEvent()
 {
-       emit();
+       emitSignal();
        return false; // discontinue emitting timeouts.
 }
 
Index: src/frontends/gtk/GuiImplementation.C
===================================================================
--- src/frontends/gtk/GuiImplementation.C       (revision 14265)
+++ src/frontends/gtk/GuiImplementation.C       (working copy)
@@ -30,12 +30,11 @@
        old_screen_.reset(new GScreen(*old_work_area_.get()));
        work_area_.reset(new GuiWorkArea(old_screen_.get(), 
old_work_area_.get()));
        clipboard_.reset(new GuiClipboard(old_work_area_.get()));
-       guiCursor().connect(work_area_.get());
        
        // FIXME BufferView creation should be independant of WorkArea creation
-       buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
+       buffer_views_[0].reset(new BufferView(view_.get()));
        work_area_->setBufferView(buffer_views_[0].get());
-       view_->setBufferView(buffer_views_[0].get());
+       view_->setWorkArea(work_area_.get());
        return 0;
 }
 
Index: src/frontends/Gui.h
===================================================================
--- src/frontends/Gui.h (revision 14265)
+++ src/frontends/Gui.h (working copy)
@@ -14,12 +14,11 @@
 #ifndef BASE_GUI_H
 #define BASE_GUI_H
 
-#include "frontends/GuiCursor.h"
-
 #include <boost/shared_ptr.hpp>
 
 #include <map>
 
+class BufferView;
 class LyXView;
 
 namespace lyx {
@@ -54,16 +53,9 @@
        ///
        virtual void destroyWorkArea(int id) = 0;
 
-       ///
-       GuiCursor & guiCursor() {return cursor_;}
-
 protected:
        /// view of a buffer. Eventually there will be several.
        std::map<int, boost::shared_ptr<BufferView> > buffer_views_;
-
-private:
-       ///
-       GuiCursor cursor_;
 };
 
 } // namespace frontend
Index: src/frontends/GuiCursor.C
===================================================================
--- src/frontends/GuiCursor.C   (revision 14265)
+++ src/frontends/GuiCursor.C   (working copy)
@@ -1,144 +0,0 @@
-/**
- * \file GuiCursor.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- *
- * Splash screen code added by Angus Leeming
- */
-
-#include <config.h>
-
-#include "frontends/GuiCursor.h"
-
-#include "font_metrics.h"
-#include "lyx_gui.h"
-#include "frontends/Painter.h"
-#include "frontends/WorkArea.h"
-
-#include "BufferView.h"
-#include "buffer.h"
-#include "bufferparams.h"
-#include "coordcache.h"
-#include "cursor.h"
-#include "debug.h"
-#include "language.h"
-#include "LColor.h"
-#include "lyxfont.h"
-#include "lyxrc.h"
-#include "lyxrow.h"
-#include "lyxtext.h"
-#include "metricsinfo.h"
-#include "paragraph.h"
-#include "rowpainter.h"
-#include "version.h"
-
-#include "graphics/GraphicsImage.h"
-#include "graphics/GraphicsLoader.h"
-
-#include "support/filetools.h" // LibFileSearch
-
-using lyx::support::libFileSearch;
-
-using std::endl;
-using std::min;
-using std::max;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-GuiCursor::GuiCursor()
-       : cursor_visible_(false), work_area_(0)
-{
-}
-
-
-GuiCursor::~GuiCursor()
-{
-}
-
-void GuiCursor::connect(WorkArea * work_area)
-{
-       work_area_ = work_area;
-}
-
-
-void GuiCursor::show(BufferView & bv)
-{
-       if (cursor_visible_)
-               return;
-
-       if (!bv.available())
-               return;
-
-       CursorShape shape = BAR_SHAPE;
-
-       LyXText const & text = *bv.getLyXText();
-       LyXFont const & realfont = text.real_current_font;
-       BufferParams const & bp = bv.buffer()->params();
-       bool const samelang = realfont.language() == bp.language;
-       bool const isrtl = realfont.isVisibleRightToLeft();
-
-       if (!samelang || isrtl != bp.language->rightToLeft()) {
-               shape = L_SHAPE;
-               if (isrtl)
-                       shape = REVERSED_L_SHAPE;
-       }
-
-       // The ERT language hack needs fixing up
-       if (realfont.language() == latex_language)
-               shape = BAR_SHAPE;
-
-       LyXFont const font = bv.cursor().getFont();
-       int const asc = font_metrics::maxAscent(font);
-       int const des = font_metrics::maxDescent(font);
-       int h = asc + des;
-       int x = 0;
-       int y = 0;
-       bv.cursor().getPos(x, y);
-       y -= asc;
-       //lyxerr << "Cursor::show x: " << x << " y: " << y << endl;
-
-       BOOST_ASSERT(work_area_);
-
-       // if it doesn't touch the screen, don't try to show it
-       if (y + h < 0 || y >= work_area_->height())
-               return;
-
-       cursor_visible_ = true;
-       work_area_->showCursor(x, y, h, shape);
-}
-
-
-void GuiCursor::hide()
-{
-       if (!cursor_visible_)
-               return;
-
-       cursor_visible_ = false;
-       BOOST_ASSERT(work_area_);
-       work_area_->removeCursor();
-}
-
-
-void GuiCursor::toggle(BufferView & bv)
-{
-       if (cursor_visible_)
-               hide();
-       else
-               show(bv);
-}
-
-
-void GuiCursor::prepare()
-{
-       cursor_visible_ = false;
-}
-
-} // namespace frontend
-} // namespace lyx
Index: src/frontends/GuiCursor.h
===================================================================
--- src/frontends/GuiCursor.h   (revision 14265)
+++ src/frontends/GuiCursor.h   (working copy)
@@ -1,89 +0,0 @@
-// -*- C++ -*-
-/**
- * \file GuiCursor.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-// X11 use a define called CursorShape, and we really want to use
-// that name our selves. Therefore we do something similar to what is done
-// in kde/fixx11h.h:
-namespace X {
-#ifdef CursorShape
-#ifndef FIXX11H_CursorShape
-#define FIXX11H_CursorShape
-int const XCursorShape = CursorShape;
-#undef CursorShape
-int const CursorShape = CursorShape;
-#endif
-#undef CursorShape
-#endif
-
-} // namespace X
-
-#ifndef GUI_CURSOR_H
-#define GUI_CURSOR_H
-
-
-class LyXText;
-class CursorSlice;
-class BufferView;
-class ViewMetricsInfo;
-
-namespace lyx {
-namespace frontend {
-
-class WorkArea;
-
-/// types of cursor in work area
-enum CursorShape {
-       /// normal I-beam
-       BAR_SHAPE,
-       /// L-shape for locked insets of a different language
-       L_SHAPE,
-       /// reverse L-shape for RTL text
-       REVERSED_L_SHAPE
-};
-
-/**
- * GuiCursor - document rendering management
- *
- * The blinking cursor is handled here.
- */
-class GuiCursor {
-public:
-       GuiCursor();
-
-       virtual ~GuiCursor();
-
-       void connect(WorkArea * work_area);
-
-       /// hide the visible cursor, if it is visible
-       void hide();
-
-       /// show the cursor if it is not visible
-       void show(BufferView & bv);
-
-       /// toggle the cursor's visibility
-       void toggle(BufferView & bv);
-
-       /// set cursor_visible_ to false in prep for re-display
-       void prepare();
-
-private:
-       /// is the cursor currently displayed
-       bool cursor_visible_;
-
-       WorkArea * work_area_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // GUI_CURSOR_H
Index: src/frontends/LyXView.C
===================================================================
--- src/frontends/LyXView.C     (revision 14265)
+++ src/frontends/LyXView.C     (working copy)
@@ -17,6 +17,7 @@
 #include "Timeout.h"
 #include "Toolbars.h"
 #include "Menubar.h"
+#include "WorkArea.h"
 
 #include "buffer.h"
 #include "bufferparams.h"
@@ -48,6 +49,7 @@
 #endif
 
 using lyx::frontend::Gui;
+using lyx::frontend::WorkArea;
 
 using lyx::support::makeDisplayPath;
 using lyx::support::onlyFilename;
@@ -64,6 +66,7 @@
        return owner_;
 }
 
+
 LyXView::LyXView(Gui & owner)
        : owner_(owner),
          toolbars_(new Toolbars(*this)),
@@ -72,17 +75,23 @@
          lyxfunc_(new LyXFunc(this)),
          dialogs_(new Dialogs(*this)),
          controlcommand_(new ControlCommandBuffer(*this)),
-         bufferview_(0)
+         work_area_(0)
 {
        lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
 }
 
-void LyXView::setBufferView(BufferView * buffer_view)
+void LyXView::setWorkArea(WorkArea * work_area)
 {
-       bufferview_ = buffer_view;
+       work_area_ = work_area;
 }
 
 
+void LyXView::redrawWorkArea()
+{
+       work_area_->redraw();
+}
+
+
 LyXView::~LyXView()
 {
 }
@@ -106,13 +115,13 @@
 
 Buffer * LyXView::buffer() const
 {
-       return bufferview_->buffer();
+       return work_area_->bufferView().buffer();
 }
 
 
 BufferView * LyXView::view() const
 {
-       return bufferview_;
+       return &work_area_->bufferView();
 }
 
 
@@ -124,7 +133,7 @@
 
 void LyXView::updateToolbars()
 {
-       bool const math = bufferview_->cursor().inMathed();
+       bool const math = work_area_->bufferView().cursor().inMathed();
        bool const table =
                
getLyXFunc().getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
        toolbars_->update(math, table);
@@ -138,6 +147,10 @@
 void LyXView::updateMenubar()
 {
        menubar_->update();
+
+       // FIXME: This is a hack that permits the screen update in case 
+       // when a new file is loaded (BufferView::setBuffer() is called)
+//     work_area_->redraw();
 }
 
 
@@ -171,11 +184,11 @@
                current_layout = 
buffer()->params().getLyXTextClass().defaultLayoutName();
        }
 
-       if (bufferview_->cursor().inMathed())
+       if (work_area_->bufferView().cursor().inMathed())
                return;
 
        string const & layout =
-               bufferview_->cursor().paragraph().layout()->name();
+               work_area_->bufferView().cursor().paragraph().layout()->name();
 
        if (layout != current_layout) {
                toolbars_->setLayout(layout);
@@ -221,9 +234,9 @@
 {
        Buffer const * buffer_ptr = 0;
        if (inset) {
-               buffer_ptr = bufferview_->buffer();
+               buffer_ptr = work_area_->bufferView().buffer();
                // No FitCursor:
-               bufferview_->update(Update::Force);
+               work_area_->bufferView().update(Update::Force);
        }
        return buffer_ptr;
 }
Index: src/frontends/LyXView.h
===================================================================
--- src/frontends/LyXView.h     (revision 14265)
+++ src/frontends/LyXView.h     (working copy)
@@ -35,6 +35,7 @@
 namespace lyx {
 namespace frontend {
 class Gui;
+class WorkArea;
 class ControlCommandBuffer;
 } // namespace frontend
 
@@ -60,7 +61,7 @@
 
        virtual ~LyXView();
 
-       void setBufferView(BufferView * buffer_view);
+       void setWorkArea(lyx::frontend::WorkArea * work_area);
 
        /**
         * This is called after the concrete view has been created.
@@ -152,12 +153,16 @@
        ///
        virtual lyx::frontend::Gui & gui();
 
+       /// Temporary method used by the kernel to redraw the
+       /// work area.
+       virtual void redrawWorkArea();
+
 protected:
-       /// current bufferview (view of a buffer).
+       /// current work area (screen view of a BufferView).
        /**
-       \todo FIXME: this should be moved out of LyXView.
+       \todo FIXME: there is only one workArea per LyXView for now.
        */
-       BufferView * bufferview_;
+       lyx::frontend::WorkArea * work_area_;
 
        /// view's menubar
        boost::scoped_ptr<Menubar> menubar_;
Index: src/frontends/Makefile.am
===================================================================
--- src/frontends/Makefile.am   (revision 14265)
+++ src/frontends/Makefile.am   (working copy)
@@ -32,8 +32,6 @@
        Toolbars.h \
        Clipboard.h \
        Gui.h \
-       GuiCursor.C \
-       GuiCursor.h \
        WorkArea.C \
        WorkArea.h \
        font_metrics.h \
Index: src/frontends/qt3/GuiImplementation.h
===================================================================
--- src/frontends/qt3/GuiImplementation.h       (revision 14265)
+++ src/frontends/qt3/GuiImplementation.h       (working copy)
@@ -75,12 +75,11 @@
                old_screen_.reset(new FScreen(*old_work_area_.get()));
                work_area_.reset(new GuiWorkArea(old_screen_.get(), 
old_work_area_.get()));
                clipboard_.reset(new GuiClipboard(old_work_area_.get()));
-               guiCursor().connect(work_area_.get());
 
                // FIXME BufferView creation should be independant of WorkArea 
creation
-               buffer_views_[0].reset(new BufferView(view_.get(), 
work_area_.get()));
+               buffer_views_[0].reset(new BufferView(view_.get()));
                work_area_->setBufferView(buffer_views_[0].get());
-               view_->setBufferView(buffer_views_[0].get());
+               view_->setWorkArea(work_area_.get());
                return 0;
        }
 
Index: src/frontends/qt3/qscreen.h
===================================================================
--- src/frontends/qt3/qscreen.h (revision 14265)
+++ src/frontends/qt3/qscreen.h (working copy)
@@ -12,7 +12,7 @@
 #ifndef QSCREEN_H
 #define QSCREEN_H
 
-#include "frontends/GuiCursor.h"
+#include "frontends/WorkArea.h"
 
 #include <qcolor.h>
 #include <qpixmap.h>
Index: src/frontends/qt3/qtTimeout.C
===================================================================
--- src/frontends/qt3/qtTimeout.C       (revision 14265)
+++ src/frontends/qt3/qtTimeout.C       (working copy)
@@ -30,7 +30,7 @@
 
 void qtTimeout::timerEvent(QTimerEvent *)
 {
-       emit();
+       emitSignal();
 }
 
 
Index: src/frontends/qt4/GuiImplementation.C
===================================================================
--- src/frontends/qt4/GuiImplementation.C       (revision 14265)
+++ src/frontends/qt4/GuiImplementation.C       (working copy)
@@ -10,10 +10,10 @@
  * Full author contact details are available in file CREDITS.
  */
 
-// This include must be declared before everything else because
-// of boost/Qt/LyX clash...
 #include "GuiView.h"
 
+// This include must be declared before everything else because
+// of boost/Qt/LyX clash...
 #include "GuiImplementation.h"
 #include "GuiWorkArea.h"
 
@@ -70,14 +70,12 @@
        work_areas_[id].reset(new GuiWorkArea(w, h, view));
 
        // FIXME BufferView creation should be independant of WorkArea creation
-       buffer_views_[id].reset(new BufferView(view, work_areas_[id].get()));
+       buffer_views_[id].reset(new BufferView(view));
        work_areas_[id]->setBufferView(buffer_views_[id].get());
-       view->setBufferView(buffer_views_[id].get());
+       view->setWorkArea(work_areas_[id].get());
 
        view->mainWidget()->setCentralWidget(work_areas_[id].get());
 
-       guiCursor().connect(work_areas_[id].get());
-
        return id;
 }
 
Index: src/frontends/qt4/GuiView.C
===================================================================
--- src/frontends/qt4/GuiView.C (revision 14265)
+++ src/frontends/qt4/GuiView.C (working copy)
@@ -27,14 +27,16 @@
 #include "debug.h"
 
 #include "frontends/Toolbars.h"
-
+#include "frontends/WorkArea.h"
 #include "support/filetools.h"
-
 #include "support/convert.h"
-#include <boost/bind.hpp>
+#include "support/lstrings.h"
 
+// This include must be declared before everything else because
+// of boost/Qt/LyX clash...
+#include "GuiImplementation.h"
+
 #include "GuiView.h"
-#include "GuiImplementation.h"
 #include "QLMenubar.h"
 #include "FontLoader.h"
 #include "QCommandBuffer.h"
@@ -46,12 +48,11 @@
 #include <QToolBar>
 #include <QCloseEvent>
 #include <QAction>
-//#include <QMenu>
-//#include <QMenuBar>
 
-#include "support/lstrings.h"
 
+#include <boost/bind.hpp>
 
+
 using std::string;
 using std::endl;
 
Index: src/frontends/qt4/GuiWorkArea.C
===================================================================
--- src/frontends/qt4/GuiWorkArea.C     (revision 14265)
+++ src/frontends/qt4/GuiWorkArea.C     (working copy)
@@ -11,13 +11,9 @@
 
 #include <config.h>
 
-#include <boost/current_function.hpp>
 
-// This include must be declared before everything else because
-// of boost/Qt/LyX clash...
-#include "GuiView.h"
-
 #include "GuiWorkArea.h"
+
 #include "QLPainter.h"
 #include "QLyXKeySym.h"
 
@@ -40,6 +36,7 @@
 #include <QScrollBar>
 
 #include <boost/bind.hpp>
+#include <boost/current_function.hpp>
 
 // Abdel (26/06/2006):
 // On windows-XP the UserGuide PageDown scroll test is faster without event 
pruning (16 s)
@@ -370,7 +367,7 @@
        else {
                boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
                sym->set(e);
-               buffer_view_->workAreaKeyPress(sym, q_key_state(e->state()));
+               processKeySym(sym, q_key_state(e->state()));
        }
 }
 
@@ -400,7 +397,7 @@
                                   << " key=" << ev->key()
                                   << endl;
 
-               buffer_view_->workAreaKeyPress(sym, q_key_state(ev->state()));
+               processKeySym(sym, q_key_state(ev->state()));
                keyeventQueue_.pop();
 
                handle_autos = false;
@@ -479,6 +476,7 @@
                << "\n QPaintEvent h\t" << e->rect().height()
                << endl;
        */
+
        QPainter q(viewport());
        q.drawPixmap(e->rect(), paint_device_, e->rect());
 
Index: src/frontends/qt4/lyx_gui.C
===================================================================
--- src/frontends/qt4/lyx_gui.C (revision 14265)
+++ src/frontends/qt4/lyx_gui.C (working copy)
@@ -29,6 +29,7 @@
 #include "lyxserver.h"
 #include "lyxsocket.h"
 
+
 #include "graphics/LoaderQueue.h"
 
 #include "support/lstrings.h"
@@ -36,8 +37,6 @@
 #include "support/package.h"
 #include "debug.h"
 
-#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
 
 #include "GuiView.h"
 #include "ColorCache.h"
@@ -54,6 +53,8 @@
 #include <QLocale>
 #include <QLibraryInfo>
 
+#include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
 
 
 using lyx::support::ltrim;
Index: src/frontends/qt4/qfont_metrics.C
===================================================================
--- src/frontends/qt4/qfont_metrics.C   (revision 14265)
+++ src/frontends/qt4/qfont_metrics.C   (working copy)
@@ -14,8 +14,8 @@
 #include "frontends/font_metrics.h"
 #include "frontends/lyx_gui.h"
 
+#include "Application.h"
 #include "FontLoader.h"
-#include "Application.h"
 
 #include "language.h"
 
Index: src/frontends/qt4/qtTimeout.C
===================================================================
--- src/frontends/qt4/qtTimeout.C       (revision 14265)
+++ src/frontends/qt4/qtTimeout.C       (working copy)
@@ -29,7 +29,7 @@
 
 void qtTimeout::timerEvent(QTimerEvent *)
 {
-       emit();
+       emitSignal();
 }
 
 
Index: src/frontends/Timeout.C
===================================================================
--- src/frontends/Timeout.C     (revision 14265)
+++ src/frontends/Timeout.C     (working copy)
@@ -45,7 +45,7 @@
 }
 
 
-void Timeout::emit()
+void Timeout::emitSignal()
 {
        pimpl_->reset();
        timeout();
Index: src/frontends/Timeout.h
===================================================================
--- src/frontends/Timeout.h     (revision 14265)
+++ src/frontends/Timeout.h     (working copy)
@@ -41,7 +41,7 @@
        /// signal emitted on timer expiry
        boost::signal<void()> timeout;
        /// emit the signal
-       void emit();
+       void emitSignal();
        /// set the timer type
        Timeout & setType(Type t);
        /// set the timeout value
@@ -69,7 +69,7 @@
 
        protected:
                ///
-               void emit() { owner_.emit(); }
+               void emitSignal() { owner_.emitSignal(); }
                ///
                unsigned int timeout_ms() const { return owner_.timeout_ms; }
 
Index: src/frontends/WorkArea.C
===================================================================
--- src/frontends/WorkArea.C    (revision 14265)
+++ src/frontends/WorkArea.C    (working copy)
@@ -40,12 +40,15 @@
 #include "graphics/GraphicsLoader.h"
 
 #include "support/filetools.h" // LibFileSearch
+#include "support/forkedcontr.h"
 
 #include <boost/utility.hpp>
 #include <boost/bind.hpp>
+#include <boost/current_function.hpp>
 #include <boost/signals/trackable.hpp>
 
 using lyx::support::libFileSearch;
+using lyx::support::ForkedcallsController;
 
 using std::endl;
 using std::min;
@@ -118,8 +121,20 @@
        loader_.reset(file);
 }
 
+namespace {
+
+// All the below connection objects are needed because of a bug in some
+// versions of GCC (<=2.96 are on the suspects list.) By having and assigning
+// to these connections we avoid a segfault upon startup, and also at exit.
+// (Lgb)
+
+boost::signals::connection timecon;
+
+} // anon namespace
+
 WorkArea::WorkArea(BufferView * buffer_view)
-       :  buffer_view_(buffer_view), greyed_out_(true)
+       :  buffer_view_(buffer_view), greyed_out_(true),
+       cursor_visible_(false), cursor_timeout(400)
 {
        // Start loading the pixmap as soon as possible
        if (lyxrc.show_banner) {
@@ -127,6 +142,12 @@
                splash.connect(boost::bind(&WorkArea::checkAndGreyOut, this));
                splash.startLoading();
        }
+
+       // Setup the signals
+       timecon = cursor_timeout.timeout
+               .connect(boost::bind(&WorkArea::toggleCursor, this));
+
+       cursor_timeout.start();
 }
 
 
@@ -136,6 +157,18 @@
 }
 
 
+BufferView & WorkArea::bufferView()
+{
+       return *buffer_view_;
+}
+
+
+BufferView const & WorkArea::bufferView() const
+{
+       return *buffer_view_;
+}
+
+
 void WorkArea::checkAndGreyOut()
 {
        if (greyed_out_)
@@ -143,21 +176,55 @@
 }
 
 
-void WorkArea::redraw(BufferView & bv, ViewMetricsInfo const & vi)
+void WorkArea::redraw()
 {
+       if (!buffer_view_)
+               return;
+
+       if (!buffer_view_->buffer()) {
+               greyOut();
+               return;
+       }
+
+       if (!buffer_view_->needsRedraw())
+               return;
+
+       ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
        greyed_out_ = false;
        getPainter().start();
-       paintText(*buffer_view_, vi);
+       paintText(*buffer_view_, vi, getPainter());
        lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
        int const ymin = std::max(vi.y1, 0);
        int const ymax =
                ( vi.p2 < vi.size - 1 ?  vi.y2 : height() );
        expose(0, ymin, width(), ymax - ymin);
        getPainter().end();
-       theCoords.doneUpdating();
+       buffer_view_->needsRedraw() = false;
+
+       lyxerr[Debug::DEBUG]
+       << "  ymin = " << ymin << "  width() = " << width()
+               << "  ymax-ymin = " << ymax-ymin << std::endl;
 }
 
 
+void WorkArea::processKeySym(LyXKeySymPtr key,
+                                                        key_modifier::state 
state)
+{
+       hideCursor();
+       buffer_view_->workAreaKeyPress(key, state);
+
+       /* This is perhaps a bit of a hack. When we move
+        * around, or type, it's nice to be able to see
+        * the cursor immediately after the keypress. So
+        * we reset the toggle timeout and force the visibility
+        * of the cursor. Note we cannot do this inside
+        * dispatch() itself, because that's called recursively.
+        */
+//     if (buffer_view_->available())
+       toggleCursor();
+}
+
+
 void WorkArea::greyOut()
 {
        greyed_out_ = true;
@@ -189,5 +256,79 @@
        getPainter().end();
 }
 
+
+void WorkArea::showCursor()
+{
+       if (cursor_visible_)
+               return;
+
+       if (!buffer_view_->available())
+               return;
+
+       CursorShape shape = BAR_SHAPE;
+
+       LyXText const & text = *buffer_view_->getLyXText();
+       LyXFont const & realfont = text.real_current_font;
+       BufferParams const & bp = buffer_view_->buffer()->params();
+       bool const samelang = realfont.language() == bp.language;
+       bool const isrtl = realfont.isVisibleRightToLeft();
+
+       if (!samelang || isrtl != bp.language->rightToLeft()) {
+               shape = L_SHAPE;
+               if (isrtl)
+                       shape = REVERSED_L_SHAPE;
+       }
+
+       // The ERT language hack needs fixing up
+       if (realfont.language() == latex_language)
+               shape = BAR_SHAPE;
+
+       LyXFont const font = buffer_view_->cursor().getFont();
+       int const asc = font_metrics::maxAscent(font);
+       int const des = font_metrics::maxDescent(font);
+       int h = asc + des;
+       int x = 0;
+       int y = 0;
+       buffer_view_->cursor().getPos(x, y);
+       y -= asc;
+
+       // if it doesn't touch the screen, don't try to show it
+       if (y + h < 0 || y >= height())
+               return;
+
+       cursor_visible_ = true;
+       showCursor(x, y, h, shape);
+}
+
+
+void WorkArea::hideCursor()
+{
+       if (!cursor_visible_)
+               return;
+
+       cursor_visible_ = false;
+       removeCursor();
+}
+
+
+void WorkArea::toggleCursor()
+{
+       if (buffer_view_->buffer()) {
+
+               if (cursor_visible_)
+                       hideCursor();
+               else
+                       showCursor();
+
+               // Use this opportunity to deal with any child processes that
+               // have finished but are waiting to communicate this fact
+               // to the rest of LyX.
+               ForkedcallsController & fcc = ForkedcallsController::get();
+               fcc.handleCompletedProcesses();
+       }
+
+       cursor_timeout.restart();
+}
+
 } // namespace frontend
 } // namespace lyx
Index: src/frontends/WorkArea.h
===================================================================
--- src/frontends/WorkArea.h    (revision 14265)
+++ src/frontends/WorkArea.h    (working copy)
@@ -14,11 +14,27 @@
 #ifndef BASE_WORKAREA_H
 #define BASE_WORKAREA_H
 
-#include "frontends/GuiCursor.h"
-
 #include "frontends/key_state.h"
 #include "frontends/LyXKeySym.h"
+#include "frontends/Timeout.h"
 
+
+// X11 use a define called CursorShape, and we really want to use
+// that name our selves. Therefore we do something similar to what is done
+// in kde/fixx11h.h:
+namespace X {
+#ifdef CursorShape
+#ifndef FIXX11H_CursorShape
+#define FIXX11H_CursorShape
+int const XCursorShape = CursorShape;
+#undef CursorShape
+int const CursorShape = CursorShape;
+#endif
+#undef CursorShape
+#endif
+} // namespace X
+
+
 class BufferView;
 class ViewMetricsInfo;
 
@@ -27,6 +43,16 @@
 
 class Painter;
 
+/// types of cursor in work area
+enum CursorShape {
+       /// normal I-beam
+       BAR_SHAPE,
+       /// L-shape for locked insets of a different language
+       L_SHAPE,
+       /// reverse L-shape for RTL text
+       REVERSED_L_SHAPE
+};
+
 /**
  * The work area class represents the widget that provides the
  * view onto a document. It is owned by the BufferView, and
@@ -42,6 +68,12 @@
 
        void setBufferView(BufferView * buffer_view);
 
+       ///
+       BufferView & bufferView();
+       ///
+       BufferView const & bufferView() const;
+
+
        /// return the painter object for this work area
        virtual Painter & getPainter() = 0;
 
@@ -60,20 +92,31 @@
        virtual void setScrollbarParams(int height, int pos, int line_height) = 
0;
 
        /// redraw the screen, without using existing pixmap
-       virtual void redraw(BufferView & bv, ViewMetricsInfo const & vi);
+       virtual void redraw();
 
        /// grey out (no buffer)
        void greyOut();
 
-       /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
+protected:
+       /// cause the display of the given area of the work area
+       virtual void expose(int x, int y, int w, int h) = 0;
 
+       void processKeySym(LyXKeySymPtr key, key_modifier::state state);
+
+       /// hide the visible cursor, if it is visible
+       void hideCursor();
+
+       /// show the cursor if it is not visible
+       void showCursor();
+
+       /// toggle the cursor's visibility
+       void toggleCursor();
+
        /// hide the cursor
        virtual void removeCursor() = 0;
 
-protected:
-       /// cause the display of the given area of the work area
-       virtual void expose(int x, int y, int w, int h) = 0;
+       /// paint the cursor and store the background
+       virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
 
        ///
        BufferView * buffer_view_;
@@ -84,6 +127,12 @@
 
        ///
        bool greyed_out_;
+
+       /// is the cursor currently displayed
+       bool cursor_visible_;
+
+       ///
+       Timeout cursor_timeout;
 };
 
 } // namespace frontend
Index: src/frontends/xforms/GuiImplementation.C
===================================================================
--- src/frontends/xforms/GuiImplementation.C    (revision 14265)
+++ src/frontends/xforms/GuiImplementation.C    (working copy)
@@ -32,12 +32,11 @@
        work_area_.reset(new 
GuiWorkArea(boost::static_pointer_cast<XScreen>(old_screen_).get(),
                                         
boost::static_pointer_cast<XWorkArea>(old_work_area_).get()));
        clipboard_.reset(new 
GuiClipboard(boost::static_pointer_cast<XWorkArea>(old_work_area_).get()));
-       guiCursor().connect(work_area_.get());
 
        // FIXME BufferView creation should be independant of WorkArea creation
-       buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
+       buffer_views_[0].reset(new BufferView(view_.get()));
        work_area_->setBufferView(buffer_views_[0].get());
-       view_->setBufferView(buffer_views_[0].get());
+       view_->setWorkArea(work_area_.get());
        return 0;
 }
 
Index: src/frontends/xforms/xformsTimeout.C
===================================================================
--- src/frontends/xforms/xformsTimeout.C        (revision 14265)
+++ src/frontends/xforms/xformsTimeout.C        (working copy)
@@ -45,7 +45,7 @@
 
 void xformsTimeout::emitCB()
 {
-       emit();
+       emitSignal();
 }
 
 
Index: src/frontends/xforms/xscreen.h
===================================================================
--- src/frontends/xforms/xscreen.h      (revision 14265)
+++ src/frontends/xforms/xscreen.h      (working copy)
@@ -15,10 +15,8 @@
 
 #include <X11/Xlib.h> // for Pixmap, GC
 
-#include "frontends/GuiCursor.h"
+#include "frontends/WorkArea.h"
 
-class WorkArea;
-
 namespace lyx {
 namespace frontend {
 
Index: src/insets/insettabular.C
===================================================================
--- src/insets/insettabular.C   (revision 14265)
+++ src/insets/insettabular.C   (working copy)
@@ -586,7 +586,7 @@
 //             //if (hasSelection())
 //             //      cur.selection() = false;
 //             col_type const col = tabular.column_of_cell(cur.idx());
-//             int const t =   cur.bv().top_y() + 
cur.bv().painter().paperHeight();
+//             int const t =   cur.bv().top_y() + cur.bv().width();
 //             if (t < yo() + tabular.getHeightOfTabular()) {
 //                     cur.bv().scrollDocView(t);
 //                     cur.idx() = tabular.getCellBelow(first_visible_cell) + 
col;
@@ -602,7 +602,7 @@
 //             //if (hasSelection())
 //             //      cur.selection() = false;
 //             col_type const col = tabular.column_of_cell(cur.idx());
-//             int const t =   cur.bv().top_y() + 
cur.bv().painter().paperHeight();
+//             int const t =   cur.bv().top_y() + cur.bv().height();
 //             if (yo() < 0) {
 //                     cur.bv().scrollDocView(t);
 //                     if (yo() > 0)
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C       (revision 14265)
+++ src/lyxfunc.C       (working copy)
@@ -739,8 +739,8 @@
                setErrorMessage(flag.message());
        } else {
 
-               if (view()->available())
-                       view()->hideCursor();
+//             if (view()->available())
+//                     view()->hideCursor();
 
                switch (action) {
 
Index: src/metricsinfo.h
===================================================================
--- src/metricsinfo.h   (revision 14265)
+++ src/metricsinfo.h   (working copy)
@@ -106,9 +106,9 @@
 class ViewMetricsInfo
 {
 public:
-       ViewMetricsInfo(lyx::pit_type p1, lyx::pit_type p2, int y1, int y2,
-                       bool singlepar, lyx::pit_type size) : p1(p1), p2(p2),
-                       y1(y1), y2(y2), singlepar(singlepar), size(size) {}
+       ViewMetricsInfo(lyx::pit_type p1 = 0, lyx::pit_type p2 = 0,
+               int y1 = 0, int y2 = 0, bool singlepar = false, lyx::pit_type 
size = 0)
+               : p1(p1), p2(p2), y1(y1), y2(y2), singlepar(singlepar), 
size(size) {}
        lyx::pit_type p1;
        lyx::pit_type p2;
        int y1;
Index: src/rowpainter.C
===================================================================
--- src/rowpainter.C    (revision 14265)
+++ src/rowpainter.C    (working copy)
@@ -873,9 +873,8 @@
 } // namespace anon
 
 
-void paintText(BufferView const & bv, ViewMetricsInfo const & vi)
+void paintText(BufferView const & bv, ViewMetricsInfo const & vi, Painter & 
pain)
 {
-       Painter & pain = bv.painter();
        LyXText * const text = bv.text();
        bool const select = bv.cursor().selection();
 
Index: src/rowpainter.h
===================================================================
--- src/rowpainter.h    (revision 14265)
+++ src/rowpainter.h    (working copy)
@@ -21,9 +21,16 @@
 class PainterInfo;
 class ViewMetricsInfo;
 
+namespace lyx {
+namespace frontend {
+class Painter;
+}
+}
 
+
 /// paint visible paragraph of main text
-void paintText(BufferView const & bv, ViewMetricsInfo const & vi);
+void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
+                          lyx::frontend::Painter & painter);
 
 /// paint the rows of a text inset
 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y);

Reply via email to