]> git.lyx.org Git - features.git/commitdiff
fitCursor work
authorAlfredo Braunstein <abraunst@lyx.org>
Thu, 13 Nov 2003 08:50:26 +0000 (08:50 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Thu, 13 Nov 2003 08:50:26 +0000 (08:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8079 a592a061-630c-0410-9148-cb99ea01b6c8

22 files changed:
src/BufferView.C
src/BufferView_pimpl.C
src/ChangeLog
src/cursor.C
src/cursor.h
src/frontends/ChangeLog
src/frontends/screen.C
src/frontends/screen.h
src/insets/ChangeLog
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/updatableinset.C
src/insets/updatableinset.h
src/mathed/ChangeLog
src/mathed/formulabase.C
src/mathed/formulabase.h
src/text.C
src/text3.C

index af246c8a0b41d1e27c9d9692d6c15fc717f6a23b..55b1bfec874ac6fb2aa0c1ddd4fd44047073eb12 100644 (file)
@@ -369,25 +369,6 @@ void BufferView::replaceWord(string const & replacestring)
 }
 
 
-bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
-{
-       lyxerr << "BufferView::fitLockedInsetCursor x: " << x
-               << " y: " << y << std::endl;
-       UpdatableInset * tli =
-               static_cast<UpdatableInset *>(cursor().innerInset());
-       if (tli && available()) {
-               lyxerr << "    text->cursor.y: " << text->cursor.y() << std::endl;
-               lyxerr << "    insetInInsetY: " << tli->insetInInsetY() << std::endl;
-               y += text->cursor.y() + tli->insetInInsetY();
-               if (screen().fitManualCursor(this, text, x, y, asc, desc)) {
-                       updateScrollbar();
-                       return true;
-               }
-       }
-       return false;
-}
-
-
 void BufferView::hideCursor()
 {
        screen().hideCursor();
index 61d686b090556aa4faf4da2ef8a64d4cff4b0e4f..76206336463998a3850529294b69810a25c9225d 100644 (file)
@@ -313,7 +313,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
                        resizeCurrentBuffer();
 
                // FIXME: needed when ?
-               top_y(screen().topCursorVisible(bv_->text));
+               fitCursor();
 
                // Buffer-dependent dialogs should be updated or
                // hidden. This should go here because some dialogs (eg ToC)
@@ -343,42 +343,11 @@ void BufferView::Pimpl::buffer(Buffer * b)
 bool BufferView::Pimpl::fitCursor()
 {
        lyxerr << "BufferView::Pimpl::fitCursor." << endl;
-
-       int x,y;
-       bv_->cursor().getPos(x, y);
-
-       if (y < top_y() || y > top_y() + workarea().workHeight()) {
-               int newtop = y - workarea().workHeight() / 2;
-               newtop = std::max(0, newtop);
-               top_y(newtop);
+       if (screen().fitCursor(bv_)) {
                updateScrollbar();
                return true;
        }
        return false;
-
-// dead code below
-       bool ret;
-#if 0  
-       UpdatableInset * tli =
-               static_cast<UpdatableInset *>(cursor_.innerInset());
-       if (tli) {
-               tli->fitInsetCursor(bv_);
-               ret = true;
-       } else {
-               ret = screen().fitCursor(bv_->text, bv_);
-       }
-#endif
-#if 0
-       ret = screen().fitCursor(bv_->text, bv_);
-#endif
-
-       //dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
-
-       // We need to always update, in case we did a
-       // paste and we stayed anchored to a row, but
-       // the actual height of the doc changed ...
-       updateScrollbar();
-       return ret;
 }
 
 
@@ -446,7 +415,7 @@ void BufferView::Pimpl::resizeCurrentBuffer()
                }
        }
 
-       top_y(screen().topCursorVisible(bv_->text));
+       fitCursor();
 
        switchKeyMap();
        owner_->busy(false);
@@ -973,8 +942,8 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                                        theTempCursor.pop();
                                        bv_->cursor() = theTempCursor;
                                        bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
-                                       bv_->cursor().updatePos();
-                                       bv_->fitCursor();
+                                       if (bv_->fitCursor())
+                                               bv_->update();
                                        return true;
                                default:
                                        lyxerr << "not dispatched by inner inset val: " << res.val() << endl;
@@ -984,24 +953,26 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
 
                // otherwise set cursor to surrounding LyXText
                if (!res.dispatched()) {
-                       lyxerr << "cursor is: " << bv_->cursor() << endl;
+                       lyxerr << "temp cursor is: " << theTempCursor << endl;
                        lyxerr << "dispatching " << cmd1
                               << " to surrounding LyXText "
-                              << bv_->cursor().innerText() << endl;
+                              << theTempCursor.innerText() << endl;
                        bv_->cursor() = theTempCursor;
-                       theTempCursor.dispatch(cmd1);
-                       bv_->update();
-                       bv_->cursor().updatePos();
+                       res = bv_->cursor().innerText()->dispatch(cmd1);
+                       if (bv_->fitCursor() || res.update())
+                               bv_->update();
+                       
                        //return DispatchResult(true, true);
                }
                // see workAreaKeyPress
                cursor_timeout.restart();
                screen().showCursor(*bv_);
 
-               // FIXME: we should skip these when selecting
-               owner_->updateLayoutChoice();
-               owner_->updateToolbar();
-//             fitCursor();
+               // skip these when selecting
+               if (cmd.action != LFUN_MOUSE_MOTION) {
+                       owner_->updateLayoutChoice();
+                       owner_->updateToolbar();
+               }
 
                // slight hack: this is only called currently when we
                // clicked somewhere, so we force through the display
@@ -1295,7 +1266,6 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
                                   string(),
                                   0);
        }
-
        bv_->cursor().innerText()->insertInset(inset);
        update();
 
index 790fba51b3fcc1fe164ca7c42179df0a3f6b2034..ccb6e2bbeff84b831062cabeedecba0ab2873578 100644 (file)
@@ -1,3 +1,10 @@
+2003-11-13  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * BufferView_pimpl.C (fitCursor): call screen().fitCursor()
+       * BufferView.C (fitLockedInsetCursor): remove
+       * cursor.[Ch] (getDim): add
+       * text.C (getRowNearY): add faster version
+       * text3.C: remove some update calls
 
 2003-11-12  Martin Vermeer  <martin.vermeer@hut.fi>
 
index 383e615cb2aa2557b96da9ab95c5e7107498295a..3aa3273cf92e8047340283ebbb04eadc9eacc7d5 100644 (file)
@@ -20,6 +20,7 @@
 #include "lfuns.h"
 #include "lyxtext.h"
 #include "paragraph.h"
+#include "lyxrow.h"
 
 #include "insets/updatableinset.h"
 #include "insets/insettabular.h"
@@ -164,6 +165,19 @@ void LCursor::updatePos()
 }
 
 
+void LCursor::getDim(int & asc, int & desc) const
+{
+       LyXText * txt = innerText();
+       
+       if (txt) {
+               Row const & row = *txt->cursorRow();
+               asc = row.baseline();
+               desc = row.height() - asc;
+       } else
+               innerInset()->getCursorDim(bv_, asc, desc);
+}
+
+
 void LCursor::getPos(int & x, int & y) const
 {
        if (data_.empty()) {
index 6f43f2c0c4f188eba6ae256f63c1165ddb75b305..07efdf737a9d35bd7e86c9fa9bc340be9ff50dfd 100644 (file)
@@ -75,6 +75,8 @@ public:
        LyXText * innerText() const;
        /// returns x,y position
        void getPos(int & x, int & y) const;
+       /// returns cursor dimension
+       void getDim(int & asc, int & desc) const;
        /// cache the absolute coordinate from the top inset
        void updatePos();
        ///
index fad235d0d5dad4370c0d5b1a9c64fa3786a1227b..8324571171639dc07ea6b64f3b8cd4fdc2ddf787 100644 (file)
@@ -1,3 +1,10 @@
+2003-11-13  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * screen.[Ch] (fitCursor): use LCursor::getDim, simplify
+       (fitManualCursor): remove
+       (topCursorVisible): remove
+       
+
 2003-11-11  Alfredo Braunstein  <abraunst@libero.it>
 
        * screen.C (showCursor): use absolute coords form LCursor
index fc8540e09a21781c1e4d3b58f9b3a2fa5d1f329f..7d4299eb7b30c0f97f286795d6ace9be647bde50 100644 (file)
@@ -204,70 +204,39 @@ void LyXScreen::toggleCursor(BufferView & bv)
 }
 
 
-bool LyXScreen::fitManualCursor(BufferView * bv, LyXText *,
-       int x, int y, int asc, int desc)
+bool LyXScreen::fitCursor(BufferView * bv)
 {
-       lyxerr << "LyXScreen::fitManualCursor x: " << x << " y: " << y << std::endl;
-       int const vheight = workarea().workHeight();
-       int const topy = bv->top_y();
-       int newtop = topy;
-
-       if (y + desc - topy >= vheight)
-               newtop = y - 3 * vheight / 4;  // the scroll region must be so big!!
-       else if (y - asc < topy && topy > 0)
-               newtop = y - vheight / 4;
-
-       newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
-
-       if (newtop == topy)
-               return false;
-
-       bv->top_y(newtop);
-       return true;
-}
-
-
-unsigned int LyXScreen::topCursorVisible(LyXText * text)
-{
-       LyXCursor const & cursor = text->cursor;
-       int top_y = text->bv()->top_y();
+       int const top_y = bv->top_y();
+       int const h = workarea().workHeight();
        int newtop = top_y;
-       unsigned int const vheight = workarea().workHeight();
-
-       Row & row = *text->cursorPar()->getRow(cursor.pos());
-
-       if (int(cursor.y() - row.baseline() + row.height() - top_y) >= vheight) {
-               if (row.height() < vheight
-                   && row.height() > vheight / 4) {
-                       newtop = cursor.y()
-                               + row.height()
-                               - row.baseline() - vheight;
-               } else {
-                       // scroll down, the scroll region must be so big!!
-                       newtop = cursor.y() - vheight / 2;
-               }
-
-       } else if (int(cursor.y() - row.baseline()) < top_y && top_y > 0) {
-               if (row.height() < vheight && row.height() > vheight / 4) {
-                       newtop = cursor.y() - row.baseline();
-               } else {
-                       // scroll up
-                       newtop = cursor.y() - vheight / 2;
+       int x, y, asc, desc;
+
+       bv->cursor().getPos(x, y);
+       bv->cursor().getDim(asc, desc);
+       
+       bool const big_row = h / 4 < asc + desc && asc + desc < h;
+
+       if (y + desc - top_y >= h) {
+               if (big_row)
+                       newtop = y + desc - h;
+               else
+                       newtop = y - h / 2;
+
+       } else if (top_y > max(y - asc, 0)) {
+               if (big_row)
+                       newtop = y - asc;
+               else {
+                       newtop = y - h / 2;
                        newtop = min(newtop, top_y);
                }
        }
 
-       return max(newtop, 0);
-}
-
+       newtop = max(newtop, 0);
+       if (newtop == top_y)
+               return false;
 
-bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
-{
-       // Is a change necessary?
-       int const newtop = topCursorVisible(text);
-       bool const result = (newtop != bv->top_y());
        bv->top_y(newtop);
-       return result;
+       return true;
 }
 
 
index 8b8959c5f82f363ed43a5270fcc43f5e948e34ee..2845592450f3fab9536e564d965b441cafbb595c 100644 (file)
@@ -36,42 +36,17 @@ public:
 
        virtual ~LyXScreen();
 
-       /**
-        * fit the cursor onto the visible work area, scrolling if necessary
-        * @param bv the buffer view
-        * @param vheight the height of the visible region
-        * @param base_y the top of the lyxtext to look at
-        * @param x the new x position
-        * @param y the new y position
-        * @param a ascent of the cursor's row
-        * @param d descent of the cursor's row
-        * @return true if the work area needs scrolling as a result
-        */
-       bool fitManualCursor(BufferView * bv, LyXText * text,
-               int x, int y, int a, int d);
-
        /// redraw the screen, without using existing pixmap
        virtual void redraw(BufferView & bv);
 
-       /**
-        * topCursorVisible - get a new "top" to make the cursor visible
-        * in a LyXText
-        *
-        * This helper function calculates a new y co-ordinate for
-        * the top of the containing region such that the cursor contained
-        * within the LyXText is "nicely" visible.
-        */
-       virtual unsigned int topCursorVisible(LyXText *);
-
        /**
         * fitCursor - fit the cursor onto the work area
-        * @param text the text containing the cursor
         * @param bv the bufferview
         * @return true if a change was necessary
         *
         * Scrolls the screen so that the cursor is visible
         */
-       virtual bool fitCursor(LyXText *, BufferView *);
+       virtual bool fitCursor(BufferView *);
 
        /// hide the visible cursor, if it is visible
        void hideCursor();
index d3c92e409bf16798e3388bd42891fc2623730ff3..6b46edea90bc327c709538f32b3e825f78fc5f56 100644 (file)
@@ -1,3 +1,11 @@
+2003-11-13  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * insetcollapsable.[Ch] (fitInsetCursor): remove
+       * insettabular.[Ch] (fitInsetCursor): remove
+       * insettext.[Ch] (fitInsetCursor): remove
+       * updatableinset.[Ch] (fitInsetCursor): remove
+       (getCursorDIm): add virtual
+
 2003-11-12  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * src/insets/Makefile.am:
index 9f57b483dc9db6cfc63f448927bcb45fac979768..72df386bca9bf5ac9b84599859f833c9ee2436a9 100644 (file)
@@ -433,12 +433,6 @@ bool InsetCollapsable::insetAllowed(InsetOld::Code code) const
 }
 
 
-void InsetCollapsable::fitInsetCursor(BufferView * bv) const
-{
-       inset.fitInsetCursor(bv);
-}
-
-
 void InsetCollapsable::setLabelFont(LyXFont & f)
 {
        labelfont_ = f;
index f8f095b719086265e26fbbd4c7e1492da15f97d3..c20185976849a7044e49ee381a2fba6f0075eab4 100644 (file)
@@ -79,8 +79,6 @@ public:
        /// get the screen x,y of the cursor
        void getCursorPos(BufferView *, int & x, int & y) const;
        ///
-       void fitInsetCursor(BufferView * bv) const;
-       ///
        void setFont(BufferView *, LyXFont const &, bool toggleall = false,
                 bool selectall = false);
        ///
index a38ab49e58477a1452a18a49df59c2e9e8a5711b..e8351e5cae793449960d776a40c5f1d4aacbc8c7 100644 (file)
@@ -973,22 +973,6 @@ void InsetTabular::getCursorPos(BufferView *, int & x, int & y) const
 }
 
 
-void InsetTabular::fitInsetCursor(BufferView * bv) const
-{
-       if (the_locking_inset) {
-               the_locking_inset->fitInsetCursor(bv);
-               return;
-       }
-
-       LyXFont font;
-       int const asc = font_metrics::maxAscent(font);
-       int const desc = font_metrics::maxDescent(font);
-       resetPos(bv);
-
-       bv->fitLockedInsetCursor(cursorx_, cursory_, asc, desc);
-}
-
-
 void InsetTabular::setPos(BufferView * bv, int x, int y) const
 {
        cursory_ = 0;
index 28862fb362044a10949b37ae10dd6faf7ad8eb2d..4dde1e33c85429db7ca39408cece312b89437a7a 100644 (file)
@@ -196,8 +196,6 @@ private:
        void drawCellSelection(Painter &, int x, int baseline,
                               int row, int column, int cell) const;
        ///
-       void fitInsetCursor(BufferView *) const;
-       ///
        void setPos(BufferView *, int x, int y) const;
        ///
        DispatchResult moveRight(BufferView *, bool lock);
index b505230851baa5df9a22cfa0813e9c3c23d24407..47f29bb3621649cfe3cc642050115954ef1cd243 100644 (file)
@@ -699,15 +699,6 @@ int InsetText::insetInInsetY() const
 }
 
 
-void InsetText::fitInsetCursor(BufferView * bv) const
-{
-       LyXFont const font = text_.getFont(cpar(), cpos());
-       int const asc = font_metrics::maxAscent(font);
-       int const desc = font_metrics::maxDescent(font);
-       bv->fitLockedInsetCursor(cx(), cy(), asc, desc);
-}
-
-
 DispatchResult InsetText::moveRight(BufferView * bv)
 {
        if (text_.cursorPar()->isRightToLeftPar(bv->buffer()->params()))
index 752ecf3669a8e42b4619f7bb098cd5fa4d168b7a..2d67e152d75d8936846512d3563da53268a1a8cb 100644 (file)
@@ -93,8 +93,6 @@ public:
        ///
        int insetInInsetY() const;
        ///
-       void fitInsetCursor(BufferView *) const;
-       ///
        bool insertInset(BufferView *, InsetOld *);
        ///
        bool insetAllowed(InsetOld::Code) const;
index 8463104b8ddbbf2848ae1e547e73f7b03b374985..7ab4647b4356aa35946e33df7881ffc397c110c4 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "support/lstrings.h"
 
+#include <boost/assert.hpp>
+
 
 using lyx::support::strToDbl;
 using lyx::support::strToInt;
@@ -35,10 +37,6 @@ InsetOld::EDITABLE UpdatableInset::editable() const
 }
 
 
-void UpdatableInset::fitInsetCursor(BufferView *) const
-{}
-
-
 void UpdatableInset::scroll(BufferView * bv, float s) const
 {
        if (!s) {
@@ -107,3 +105,9 @@ UpdatableInset::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
                return DispatchResult(false);
        }
 }
+
+
+void UpdatableInset::getCursorDim(BufferView *, int &, int &) const
+{
+       BOOST_ASSERT(false);
+}
index 361c554716789b0227b35ec6bb8222ee429c42db..f8d124c26c42d2aabfa2755459ad611036753441 100644 (file)
@@ -29,10 +29,10 @@ public:
        ///
        virtual EDITABLE editable() const;
 
-       ///
-       virtual void fitInsetCursor(BufferView *) const;
-       /// FIXME
+       /// return the cursor pos, relative to the inset pos
        virtual void getCursorPos(BufferView *, int &, int &) const {}
+       /// return the cursor dim
+       virtual void getCursorDim(BufferView *, int &, int &) const;
        ///
        virtual bool insertInset(BufferView *, InsetOld *) { return false; }
        ///
index dae1f38efd4692978e1944713d5c9e6312f338d0..a5103425e842cd31464243c64a387f5182b54dd7 100644 (file)
@@ -1,3 +1,6 @@
+2003-11-13  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * formulabase.[Ch] (getCursorDim): add
 
 2003-11-10  André Pönitz  <poenitz@gmx.net>
 
index 7ba15987d9565ebc01ed7797790960723f68c5dc..f815d86ba5dd77a29318b95d77b1ef3286030347 100644 (file)
@@ -186,18 +186,14 @@ void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
 }
 
 
-void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
+void InsetFormulaBase::getCursorDim(BufferView * bv,
+                                   int & asc, int & desc) const
 {
        if (!mathcursor)
                return;
-       int x, y, asc, des;
        asc = 10;
-       des = 2;
+       desc = 2;
        //math_font_max_dim(font_, asc, des);
-       getCursorPos(bv, x, y);
-       //y += yo_;
-       //lyxerr << "fitInsetCursor: x: " << x << " y: " << y << " yo: " << yo_ << endl;
-       bv->fitLockedInsetCursor(x, y, asc, des);
 }
 
 
@@ -745,7 +741,6 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
                toggleInsetSelection(bv);
 
        if (result.dispatched()) {
-               fitInsetCursor(bv);
                revealCodes(bv);
                cmd.view()->stuffClipboard(mathcursor->grabSelection());
        } else {
index f79f69662d8faef4daf0566eb8b8752c1fb76146..14455e69479d82828c6d041a29cdccc1f7941229 100644 (file)
@@ -45,9 +45,9 @@ public:
        /// what appears in the minibuffer when opening
        virtual std::string const editMessage() const;
        ///
-       virtual void fitInsetCursor(BufferView *) const;
-       /// FIXME
        virtual void getCursorPos(BufferView *, int &, int &) const;
+       ///
+       virtual void getCursorDim(BufferView *, int &, int &) const;
        /// get the absolute document x,y of the cursor
        virtual void getCursor(BufferView & bv, int & x, int & y) const;
        ///
index 995c935e1cb36cae77401c8e1fa6935ec1ab931c..a2617f2db424046c98d1abe08ad3115429f35e35 100644 (file)
@@ -1467,18 +1467,20 @@ RowList::iterator
 LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
 {
        //lyxerr << "getRowNearY: y " << y << endl;
-#if 0
-       ParagraphList::iterator const pend = ownerParagraphs().end();
+#if 1
+       ParagraphList::iterator const
+               pend = boost::prior(ownerParagraphs().end());
        pit = ownerParagraphs().begin();
        while (int(pit->y + pit->height) < y && pit != pend)
                ++pit;
 
-       RowList::iterator rit = pit->rows.begin();
-       RowList::iterator const rend = pit->rows.end();
-       while (int(pit->y + rit->y_offset()) < y && rit != rend)
-               ++rit;
+       RowList::iterator rit = pit->rows.end();
+       RowList::iterator const rbegin = pit->rows.begin();
+       do {
+               --rit;
+       } while (rit != rbegin && int(pit->y + rit->y_offset()) > y);
+       
        return rit;
-
 #else
        pit = boost::prior(ownerParagraphs().end());
 
index 4b1cbdf7ff3ecad5a1c6a2c96369e920b5ada8cc..36a10e54f554549f209903196223165a241f72d1 100644 (file)
@@ -227,7 +227,7 @@ namespace {
                if (!lt->selection.set())
                        bv->haveSelection(false);
 
-               bv->update();
+//             bv->update();
                bv->switchKeyMap();
        }
 
@@ -495,8 +495,7 @@ void doInsertInset(LyXText * lt, FuncRequest const & cmd,
                                inset->edit(bv, true);
                        if (gotsel && pastesel)
                                bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
-               }
-               else
+               } else
                        delete inset;
        }
 }
@@ -1290,7 +1289,6 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
                        selection.cursor = cursor;
                        cursorEnd();
                        setSelection();
-                       bv->update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1300,7 +1298,6 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
                        break;
                if (cmd.button() == mouse_button::button1) {
                        selectWord(lyx::WHOLE_WORD_STRICT);
-                       bv->update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1352,15 +1349,15 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
                               << bv->text->cursor.y() << endl;
        #endif
                // This is to allow jumping over large insets
-               if (cursorrow == bv->text->cursorRow()) {
+               if (cursorrow == cursorRow()) {
                        if (cmd.y >= bv->workHeight())
-                               bv->text->cursorDown(false);
+                               cursorDown(false);
                        else if (cmd.y < 0)
-                               bv->text->cursorUp(false);
+                               cursorUp(false);
                }
 
                bv->text->setSelection();
-               bv->update();
+//             bv->update();
                break;
        }
 
@@ -1428,13 +1425,13 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_MOUSE_RELEASE: {
-               // do nothing if we used the mouse wheel
                if (!bv->buffer())
                        break;
 
+               // do nothing if we used the mouse wheel
                if (cmd.button() == mouse_button::button4
                 || cmd.button() == mouse_button::button5)
-                       break;
+                       return DispatchResult(true, false);
 
                selection_possible = false;