mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
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.
This commit is contained in:
parent
f5e66ba3c2
commit
2203078111
@ -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;
|
||||
|
@ -375,6 +375,8 @@ public:
|
||||
bool clickableInset() const;
|
||||
///
|
||||
void makeDocumentClass();
|
||||
/// Are we currently performing a selection with the mouse?
|
||||
bool mouseSelecting() const;
|
||||
|
||||
private:
|
||||
/// noncopyable
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user