]> git.lyx.org Git - lyx.git/commitdiff
Stabilize mouse selection in mathed
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 4 Apr 2014 13:40:05 +0000 (15:40 +0200)
committerRichard Heck <rgheck@lyx.org>
Mon, 21 Apr 2014 15:51:59 +0000 (11:51 -0400)
Fixes: #9074
src/mathed/InsetMathNest.cpp

index 479a68257ccfbb5146a585101f2377fb104873e2..83e49c43b824b77263e36f436f7126f32ebcf017 100644 (file)
@@ -1567,16 +1567,29 @@ void InsetMathNest::lfunMousePress(Cursor & cur, FuncRequest & cmd)
 void InsetMathNest::lfunMouseMotion(Cursor & cur, FuncRequest & cmd)
 {
        // only select with button 1
-       if (cmd.button() == mouse_button::button1) {
-               Cursor & bvcur = cur.bv().cursor();
-               if (bvcur.realAnchor().hasPart(cur)) {
-                       //lyxerr << "## lfunMouseMotion: cursor: " << cur << endl;
-                       bvcur.setCursor(cur);
-                       bvcur.setSelection(true);
-                       //lyxerr << "MOTION " << bvcur << endl;
-               } else
-                       cur.undispatched();
+       if (cmd.button() != mouse_button::button1)
+               return;
+
+       Cursor & bvcur = cur.bv().cursor();
+
+       // ignore motions deeper nested than the real anchor
+       if (!bvcur.realAnchor().hasPart(cur)) {
+               cur.undispatched();
+               return;
        }
+
+       CursorSlice old = bvcur.top();
+
+       // We continue with our existing selection or start a new one, so don't
+       // reset the anchor.
+       bvcur.setCursor(cur);
+       // Did we actually move?
+       if (cur.top() == old)
+               // We didn't move one iota, so no need to change selection status
+               // or update the screen.
+               cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
+       else
+               bvcur.setSelection();
 }