commit 22030781117909e94bc5705cd1535bc1004efa4d
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Sat Jul 23 01:57:56 2022 +0200
Fix flicker due to changing metrics while selecting with the mouse
This patch has been backported from the lyx-unstable branch
https://gitlab.com/gadmm/lyx-unstable/-/commit/9d7ed42389ba
Actual author is Guillaume Munch.
Fixes bug #8951.
---
src/BufferView.cpp | 11 +++++++++++
src/BufferView.h | 2 ++
src/frontends/qt/GuiWorkArea.cpp | 2 +-
src/insets/Inset.cpp | 7 ++++++-
src/mathed/InsetMathMacro.cpp | 5 ++++-
5 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 72cbb28..6f1b412 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -292,6 +292,8 @@ struct BufferView::Private
bool clickable_inset_;
/// shape of the caret
frontend::CaretGeometry caret_geometry_;
+ ///
+ bool mouse_selecting_ = false;
};
@@ -2466,6 +2468,12 @@ void BufferView::clearLastInset(Inset * inset) const
}
+bool BufferView::mouseSelecting() const
+{
+ return d->mouse_selecting_;
+}
+
+
void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
{
//lyxerr << "[ cmd0 " << cmd0 << "]" << endl;
@@ -2488,6 +2496,9 @@ void BufferView::mouseEventDispatch(FuncRequest const &
cmd0)
d->mouse_position_cache_.x_ = cmd.x();
d->mouse_position_cache_.y_ = cmd.y();
+ d->mouse_selecting_ =
+ cmd.action() == LFUN_MOUSE_MOTION && cmd.button() ==
mouse_button::button1;
+
if (cmd.action() == LFUN_MOUSE_MOTION && cmd.button() ==
mouse_button::none) {
updateHoveredInset();
return;
diff --git a/src/BufferView.h b/src/BufferView.h
index 210200a..ad725f2 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -375,6 +375,8 @@ public:
bool clickableInset() const;
///
void makeDocumentClass();
+ /// Are we currently performing a selection with the mouse?
+ bool mouseSelecting() const;
private:
/// noncopyable
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 900273f..802fbc7 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -429,7 +429,7 @@ void GuiWorkArea::Private::dispatch(FuncRequest const & cmd)
// Skip these when selecting
// FIXME: let GuiView take care of those.
- if (cmd.action() != LFUN_MOUSE_MOTION) {
+ if (notJustMovingTheMouse && !buffer_view_->mouseSelecting()) {
completer_->updateVisibility(false, false);
lyx_view_->updateDialogs();
lyx_view_->updateStatusBar();
diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp
index 7d05c8e..3b00c0c 100644
--- a/src/insets/Inset.cpp
+++ b/src/insets/Inset.cpp
@@ -584,7 +584,12 @@ void Inset::drawMarkers(PainterInfo & pi, int x, int y)
const
bool Inset::editing(BufferView const * bv) const
{
- return bv->cursor().isInside(this);
+ if (bv->mouseSelecting())
+ // Avoid flicker when selecting with the mouse: when so, do not
make
+ // decisions about metrics based on the mouse location.
+ return bv->cursor().realAnchor().isInside(this);
+ else
+ return bv->cursor().isInside(this);
}
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index f6efc70..5de0c1a 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -511,7 +511,10 @@ void InsetMathMacro::cursorPos(BufferView const & bv,
bool InsetMathMacro::editMode(BufferView const * bv) const {
// find this in cursor trace
- Cursor const & cur = bv->cursor();
+ DocIterator const & cur =
+ // Do not move the reference while selecting with the mouse to
avoid
+ // flicker due to changing metrics
+ bv->mouseSelecting() ? bv->cursor().realAnchor() : bv->cursor();
for (size_t i = 0; i != cur.depth(); ++i)
if (&cur[i].inset() == this) {
// look if there is no other macro in edit mode above
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs