From aa67d5eb6425e3964b0708ba3af704e3b1199707 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 14 Aug 2008 09:59:04 +0000 Subject: [PATCH] Fix bug 5065: DEPM fails with "cursor follows scrollbar" http://bugzilla.lyx.org/show_bug.cgi?id=5065 * BufferView.cpp (setCursorFromScrollbar): makes sure that the mouse is set using mouseSetCursor (so that dEPM can trigger). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26158 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 90537af888..2620dd65f7 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -606,31 +606,28 @@ void BufferView::setCursorFromScrollbar() int const height = 2 * defaultRowHeight(); int const first = height; int const last = height_ - height; - Cursor & cur = d->cursor_; + int newy = 0; + Cursor const & oldcur = d->cursor_; - switch (cursorStatus(cur)) { + switch (cursorStatus(oldcur)) { case CUR_ABOVE: - // We reset the cursor because cursorStatus() does not - // work when the cursor is within mathed. - cur.reset(buffer_.inset()); - tm.setCursorFromCoordinates(cur, 0, first); - cur.clearSelection(); + newy = first; break; case CUR_BELOW: - // We reset the cursor because cursorStatus() does not - // work when the cursor is within mathed. - cur.reset(buffer_.inset()); - tm.setCursorFromCoordinates(cur, 0, last); - cur.clearSelection(); + newy = last; break; case CUR_INSIDE: - int const y = getPos(cur, cur.boundary()).y_; - int const newy = min(last, max(y, first)); - if (y != newy) { - cur.reset(buffer_.inset()); - tm.setCursorFromCoordinates(cur, 0, newy); - } + int const y = getPos(oldcur, oldcur.boundary()).y_; + newy = min(last, max(y, first)); + if (y == newy) + return; } + // We reset the cursor because cursorStatus() does not + // work when the cursor is within mathed. + Cursor cur(*this); + cur.reset(buffer_.inset()); + tm.setCursorFromCoordinates(cur, 0, newy); + mouseSetCursor(cur); }