]> git.lyx.org Git - lyx.git/commitdiff
Defer construction of temporary cursor.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 16 Apr 2024 16:15:50 +0000 (12:15 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 16 Apr 2024 16:15:50 +0000 (12:15 -0400)
We were doing this on every mouse movement. I.e., for every single
pixel the mouse traverses. It can be expensive if there are a lot
of math insets.

src/BufferView.cpp

index acf80d7871ee27895f9ee615637b78497c99f639..7abaea0d40c1ea00829050c1fbccf57e159d10c7 100644 (file)
@@ -2692,11 +2692,6 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
        // LFUN_FILE_OPEN generated by drag-and-drop.
        FuncRequest cmd = cmd0;
 
-       Cursor old = cursor();
-       Cursor cur(*this);
-       cur.push(buffer_.inset());
-       cur.selection(d->cursor_.selection());
-
        // Either the inset under the cursor or the
        // surrounding Text will handle this event.
 
@@ -2714,6 +2709,11 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
                return;
        }
 
+       Cursor old = cursor();
+       Cursor cur(*this);
+       cur.push(buffer_.inset());
+       cur.selection(d->cursor_.selection());
+
        // Build temporary cursor.
        Inset * inset = d->text_metrics_[&buffer_.text()].editXY(cur, cmd.x(), cmd.y());
        if (inset) {