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).

(cherry picked from commit a31d3dc67d)
This commit is contained in:
Jean-Marc Lasgouttes 2017-09-14 15:50:30 +02:00
parent 9bb41f0943
commit a1579c583a
6 changed files with 8 additions and 30 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -4348,7 +4348,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;
}

View File

@ -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)
@ -451,7 +451,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.
@ -632,18 +632,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());
}
@ -1370,12 +1358,6 @@ bool GuiWorkArea::isFullScreen() const
}
void GuiWorkArea::scheduleRedraw()
{
d->schedule_redraw_ = true;
}
bool GuiWorkArea::inDialogMode() const
{
return d->dialog_mode_;
@ -1788,7 +1770,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);

View File

@ -60,13 +60,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;

View File

@ -122,8 +122,6 @@ struct GuiWorkArea::Private
///
bool need_resize_;
///
bool schedule_redraw_;
/// the current preedit text of the input method
docstring preedit_string_;