mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Fix up 'Reduce metrics updates from 4 to 1 when loading file'
The missing metrics computation meant that, when loading a file, the workarea would not be scrolled correctly to show the cursor. The resizeBufferView does not create an additional metrics computation, it just triggers it earlier.
This commit is contained in:
parent
23c45f76ad
commit
527984ed2e
@ -214,7 +214,7 @@ struct BufferView::Private
|
|||||||
Private(BufferView & bv) :
|
Private(BufferView & bv) :
|
||||||
update_strategy_(FullScreenUpdate),
|
update_strategy_(FullScreenUpdate),
|
||||||
update_flags_(Update::Force),
|
update_flags_(Update::Force),
|
||||||
cursor_(bv), anchor_pit_(0), anchor_ypos_(0),
|
cursor_(bv), anchor_pit_(0), anchor_ypos_(10000),
|
||||||
wh_(0), inlineCompletionUniqueChars_(0),
|
wh_(0), inlineCompletionUniqueChars_(0),
|
||||||
last_inset_(nullptr), mouse_position_cache_(),
|
last_inset_(nullptr), mouse_position_cache_(),
|
||||||
gui_(nullptr), bookmark_edit_position_(-1),
|
gui_(nullptr), bookmark_edit_position_(-1),
|
||||||
|
@ -2119,6 +2119,7 @@ void GuiView::setBuffer(Buffer * newBuffer, bool switch_to)
|
|||||||
newBuffer->masterBuffer()->updateBuffer();
|
newBuffer->masterBuffer()->updateBuffer();
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
wa = addWorkArea(*newBuffer);
|
wa = addWorkArea(*newBuffer);
|
||||||
|
wa->resizeBufferView();
|
||||||
// scroll to the position when the BufferView was last closed
|
// scroll to the position when the BufferView was last closed
|
||||||
if (lyxrc.use_lastfilepos) {
|
if (lyxrc.use_lastfilepos) {
|
||||||
LastFilePosSection::FilePos filepos =
|
LastFilePosSection::FilePos filepos =
|
||||||
|
@ -455,33 +455,33 @@ void GuiWorkArea::Private::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiWorkArea::Private::resizeBufferView()
|
void GuiWorkArea::resizeBufferView()
|
||||||
{
|
{
|
||||||
// WARNING: Please don't put any code that will trigger a repaint here!
|
// WARNING: Please don't put any code that will trigger a repaint here!
|
||||||
// We are already inside a paint event.
|
// We are already inside a paint event.
|
||||||
p->stopBlinkingCaret();
|
stopBlinkingCaret();
|
||||||
// Warn our container (GuiView).
|
// Warn our container (GuiView).
|
||||||
p->busy(true);
|
busy(true);
|
||||||
|
|
||||||
bool const caret_in_view = buffer_view_->caretInView();
|
bool const caret_in_view = d->buffer_view_->caretInView();
|
||||||
buffer_view_->resize(p->viewport()->width(), p->viewport()->height());
|
d->buffer_view_->resize(viewport()->width(), viewport()->height());
|
||||||
if (caret_in_view)
|
if (caret_in_view)
|
||||||
buffer_view_->showCursor();
|
d->buffer_view_->showCursor();
|
||||||
resetCaret();
|
d->resetCaret();
|
||||||
|
|
||||||
// Update scrollbars which might have changed due different
|
// Update scrollbars which might have changed due different
|
||||||
// BufferView dimension. This is especially important when the
|
// BufferView dimension. This is especially important when the
|
||||||
// BufferView goes from zero-size to the real-size for the first time,
|
// BufferView goes from zero-size to the real-size for the first time,
|
||||||
// as the scrollbar parameters are then set for the first time.
|
// as the scrollbar parameters are then set for the first time.
|
||||||
updateScrollbar();
|
d->updateScrollbar();
|
||||||
|
|
||||||
need_resize_ = false;
|
d->need_resize_ = false;
|
||||||
p->busy(false);
|
busy(false);
|
||||||
// Eventually, restart the caret after the resize event.
|
// Eventually, restart the caret after the resize event.
|
||||||
// We might be resizing even if the focus is on another widget so we only
|
// We might be resizing even if the focus is on another widget so we only
|
||||||
// restart the caret if we have the focus.
|
// restart the caret if we have the focus.
|
||||||
if (p->hasFocus())
|
if (hasFocus())
|
||||||
QTimer::singleShot(50, p, SLOT(startBlinkingCaret()));
|
QTimer::singleShot(50, this, SLOT(startBlinkingCaret()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1393,7 +1393,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
|
|||||||
|
|
||||||
if (d->need_resize_ || pixelRatio() != d->last_pixel_ratio_) {
|
if (d->need_resize_ || pixelRatio() != d->last_pixel_ratio_) {
|
||||||
d->resetScreen();
|
d->resetScreen();
|
||||||
d->resizeBufferView();
|
resizeBufferView();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->last_pixel_ratio_ = pixelRatio();
|
d->last_pixel_ratio_ = pixelRatio();
|
||||||
|
@ -63,6 +63,8 @@ public:
|
|||||||
///
|
///
|
||||||
BufferView const & bufferView() const override;
|
BufferView const & bufferView() const override;
|
||||||
///
|
///
|
||||||
|
void resizeBufferView();
|
||||||
|
///
|
||||||
void scheduleRedraw(bool update_metrics) override;
|
void scheduleRedraw(bool update_metrics) override;
|
||||||
|
|
||||||
/// return true if the key is part of a shortcut
|
/// return true if the key is part of a shortcut
|
||||||
|
@ -77,9 +77,6 @@ struct GuiWorkArea::Private
|
|||||||
///
|
///
|
||||||
~Private();
|
~Private();
|
||||||
|
|
||||||
///
|
|
||||||
void resizeBufferView();
|
|
||||||
|
|
||||||
///
|
///
|
||||||
void dispatch(FuncRequest const & cmd0);
|
void dispatch(FuncRequest const & cmd0);
|
||||||
/// Make caret visible and signal that its geometry needs to be updated
|
/// Make caret visible and signal that its geometry needs to be updated
|
||||||
|
Loading…
Reference in New Issue
Block a user