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).
This commit is contained in:
Jean-Marc Lasgouttes 2017-09-14 15:50:30 +02:00
parent 5699791d0f
commit a31d3dc67d
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

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

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

View File

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

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_;