commit a31d3dc67dce9655bee9f1b0a2bc2188d7d97453
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Thu Sep 14 15:50:30 2017 +0200
Compute metrics when graphics is updated
Remove the old schedule_redraw_ mechanism that was only useful because
of our synchronous drawing code. Now that actual painting is
scheduled instead of forced, it becomes pointless.
Rename WorkArea::redraw(bool) to scheduleRedraw(bool), to show that
the drawing is not done right away.
In GuiView::updateInset, call scheduleRedraw(true), so that metrics
are correctly computed (this was the whole point of the exercise).
---
src/frontends/WorkArea.h | 4 ++--
src/frontends/WorkAreaManager.cpp | 2 +-
src/frontends/qt4/GuiView.cpp | 2 +-
src/frontends/qt4/GuiWorkArea.cpp | 24 +++---------------------
src/frontends/qt4/GuiWorkArea.h | 4 +---
src/frontends/qt4/GuiWorkArea_Private.h | 2 --
6 files changed, 8 insertions(+), 30 deletions(-)
diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h
index 8e459ca..c215559 100644
--- a/src/frontends/WorkArea.h
+++ b/src/frontends/WorkArea.h
@@ -36,8 +36,8 @@ public:
///
virtual ~WorkArea() {}
- /// redraw the screen, without using existing pixmap
- virtual void redraw(bool update_metrics) = 0;
+ /// Update metrics if needed and schedule a paint event
+ virtual void scheduleRedraw(bool update_metrics) = 0;
/// close this work area.
/// Slot for Buffer::closing signal.
diff --git a/src/frontends/WorkAreaManager.cpp
b/src/frontends/WorkAreaManager.cpp
index b98163c..c79f08b 100644
--- a/src/frontends/WorkAreaManager.cpp
+++ b/src/frontends/WorkAreaManager.cpp
@@ -35,7 +35,7 @@ void WorkAreaManager::remove(WorkArea * wa)
void WorkAreaManager::redrawAll(bool update_metrics)
{
for (WorkArea * wa : work_areas_)
- wa->redraw(update_metrics);
+ wa->scheduleRedraw(update_metrics);
}
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index e1c024e..7644efc 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -4345,7 +4345,7 @@ Buffer const * GuiView::updateInset(Inset const * inset)
continue;
Buffer const * buffer = &(wa->bufferView().buffer());
if (inset_buffer == buffer)
- wa->scheduleRedraw();
+ wa->scheduleRedraw(true);
}
return inset_buffer;
}
diff --git a/src/frontends/qt4/GuiWorkArea.cpp
b/src/frontends/qt4/GuiWorkArea.cpp
index bd3104c..cb9769a 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -237,7 +237,7 @@ SyntheticMouseEvent::SyntheticMouseEvent()
GuiWorkArea::Private::Private(GuiWorkArea * parent)
: p(parent), buffer_view_(0), lyx_view_(0),
caret_(0), caret_visible_(false),
- need_resize_(false), schedule_redraw_(false), preedit_lines_(1),
+ need_resize_(false), preedit_lines_(1),
pixel_ratio_(1.0),
completer_(new GuiCompleter(p, p)), dialog_mode_(false),
shell_escape_(false),
read_only_(false), clean_(true), externally_modified_(false)
@@ -449,7 +449,7 @@ void GuiWorkArea::toggleCaret()
}
-void GuiWorkArea::redraw(bool update_metrics)
+void GuiWorkArea::scheduleRedraw(bool update_metrics)
{
if (!isVisible())
// No need to redraw in this case.
@@ -630,18 +630,6 @@ void GuiWorkArea::Private::showCaret()
caret_->update(point.x_, point.y_, h, l_shape, isrtl, completable);
- if (schedule_redraw_) {
- // This happens when a graphic conversion is finished. As we
don't know
- // the size of the new graphics, it's better the update
everything.
- // We can't use redraw() here because this would trigger a
infinite
- // recursive loop with showCaret().
- buffer_view_->resize(p->viewport()->width(),
p->viewport()->height());
- p->viewport()->update();
- updateScrollbar();
- schedule_redraw_ = false;
- return;
- }
-
p->viewport()->update(caret_->rect());
}
@@ -1352,12 +1340,6 @@ bool GuiWorkArea::isFullScreen() const
}
-void GuiWorkArea::scheduleRedraw()
-{
- d->schedule_redraw_ = true;
-}
-
-
bool GuiWorkArea::inDialogMode() const
{
return d->dialog_mode_;
@@ -1770,7 +1752,7 @@ void TabWorkArea::on_currentTabChanged(int i)
GuiWorkArea * wa = workArea(i);
LASSERT(wa, return);
wa->setUpdatesEnabled(true);
- wa->redraw(true);
+ wa->scheduleRedraw(true);
wa->setFocus();
///
currentWorkAreaChanged(wa);
diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h
index 2a875ad..4fd5249 100644
--- a/src/frontends/qt4/GuiWorkArea.h
+++ b/src/frontends/qt4/GuiWorkArea.h
@@ -59,13 +59,11 @@ public:
/// is GuiView in fullscreen mode?
bool isFullScreen() const;
///
- void scheduleRedraw();
- ///
BufferView & bufferView();
///
BufferView const & bufferView() const;
///
- void redraw(bool update_metrics);
+ void scheduleRedraw(bool update_metrics);
/// return true if the key is part of a shortcut
bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
diff --git a/src/frontends/qt4/GuiWorkArea_Private.h
b/src/frontends/qt4/GuiWorkArea_Private.h
index 199ce25..8be2869 100644
--- a/src/frontends/qt4/GuiWorkArea_Private.h
+++ b/src/frontends/qt4/GuiWorkArea_Private.h
@@ -122,8 +122,6 @@ struct GuiWorkArea::Private
///
bool need_resize_;
- ///
- bool schedule_redraw_;
/// the current preedit text of the input method
docstring preedit_string_;