[LyX/master] Revert "Fixup 5202d44e: make caret geometry update lazy"

Jean-Marc Lasgouttes lasgouttes at lyx.org
Mon Sep 7 13:36:32 UTC 2020


commit b744c3e28a7c42639f31bea67a52e92d15a16f62
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Mon Sep 7 16:00:06 2020 +0200

    Revert "Fixup 5202d44e: make caret geometry update lazy"
    
    Something is wrong with the cursor.
    
    This reverts commit dc35f1ddf49f8944001a916ad2bcbf2965401cc4.
---
 src/frontends/qt/GuiWorkArea.cpp       |   22 ++++++----------------
 src/frontends/qt/GuiWorkArea_Private.h |    2 --
 2 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 40a98c5..a2af82d 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -243,7 +243,7 @@ GuiWorkArea::Private::Private(GuiWorkArea * parent)
   caret_visible_(false), need_resize_(false), preedit_lines_(1),
   last_pixel_ratio_(1.0), completer_(new GuiCompleter(p, p)),
   dialog_mode_(false), shell_escape_(false), read_only_(false),
-  clean_(true), externally_modified_(false), needs_caret_geometry_update_(true)
+  clean_(true), externally_modified_(false)
 {
 /* Qt on macOS and Wayland does not respect the
  * Qt::WA_OpaquePaintEvent attribute and resets the widget backing
@@ -487,8 +487,7 @@ void GuiWorkArea::scheduleRedraw(bool update_metrics)
 
 	// update caret position, because otherwise it has to wait until
 	// the blinking interval is over
-	d->needs_caret_geometry_update_ = true;
-	d->caret_visible_ = true;
+	d->updateCaretGeometry();
 
 	LYXERR(Debug::WORKAREA, "WorkArea::redraw screen");
 	viewport()->update();
@@ -588,8 +587,7 @@ void GuiWorkArea::Private::resizeBufferView()
 	buffer_view_->resize(p->viewport()->width(), p->viewport()->height());
 	if (caret_in_view)
 		buffer_view_->scrollToCursor();
-	needs_caret_geometry_update_ = true;
-	caret_visible_ = true;
+	updateCaretGeometry();
 
 	// Update scrollbars which might have changed due different
 	// BufferView dimension. This is especially important when the
@@ -639,20 +637,18 @@ void GuiWorkArea::Private::updateCaretGeometry()
 		&& completer_->completionAvailable()
 		&& !completer_->popupVisible()
 		&& !completer_->inlineVisible();
+	caret_visible_ = true;
 
 	caret_->update(point.x_, point.y_, h, l_shape, isrtl, completable);
-	needs_caret_geometry_update_ = false;
 }
 
 
-
 void GuiWorkArea::Private::showCaret()
 {
 	if (caret_visible_)
 		return;
 
-	needs_caret_geometry_update_ = true;
-	caret_visible_ = true;
+	updateCaretGeometry();
 	p->viewport()->update();
 }
 
@@ -1360,14 +1356,8 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
 	d->paintPreeditText(pain);
 
 	// and the caret
-	// FIXME: the code would be a little bit simpler if caret geometry
-	// was updated unconditionally. Some profiling is required to see
-	// how expensive this is (especially when idle).
-	if (d->caret_visible_) {
-		if (d->needs_caret_geometry_update_)
-			d->updateCaretGeometry();
+	if (d->caret_visible_)
 		d->caret_->draw(pain, d->buffer_view_->horizScrollOffset());
-	}
 
 	d->updateScreen(ev->rect());
 
diff --git a/src/frontends/qt/GuiWorkArea_Private.h b/src/frontends/qt/GuiWorkArea_Private.h
index 75fad9b..6342eab 100644
--- a/src/frontends/qt/GuiWorkArea_Private.h
+++ b/src/frontends/qt/GuiWorkArea_Private.h
@@ -169,8 +169,6 @@ struct GuiWorkArea::Private
 	bool clean_;
 	///
 	bool externally_modified_;
-	///
-	bool needs_caret_geometry_update_;
 
 }; // GuiWorkArea
 


More information about the lyx-cvs mailing list