mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
This commit removes the needRedraw() interface and simplify the screen update procedure. It also fixes all crash problems.
The performance may suffer a bit because we do the second drawing step in all cases. This could be possibly optimized out by checking the return value of the BufferView::update() method in "lyxfunc.C:1610". But it is maybe better to keep those two parts of the frontend ignorant of each other: the event handling and the drawing. BufferView: * needRedra(), need_redraw_: deleted. * updateMetrics(): now public. * update(): only do the first drawing step. Returns true if a full updateMetrics is needed before drawing on screen. WorkArea: * redraw(): no check on BufferView::needRedraw(), call updateMetrics() unconditionally. * processKeySim(): uneeded "redraw()" call commented out. When/if the call to LyXView::redrawWorkArea() in "lyxfunc.C:1610" is not needed anymore, this line should be uncommented out. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14456 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3c9e9cf03a
commit
93f7adabbb
@ -129,9 +129,9 @@ bool BufferView::fitCursor()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::update(Update::flags flags)
|
||||
bool BufferView::update(Update::flags flags)
|
||||
{
|
||||
pimpl_->update(flags);
|
||||
return pimpl_->update(flags);
|
||||
}
|
||||
|
||||
|
||||
@ -404,13 +404,7 @@ ViewMetricsInfo const & BufferView::viewMetricsInfo()
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::needsRedraw() const
|
||||
void BufferView::updateMetrics(bool singlepar)
|
||||
{
|
||||
return pimpl_->needsRedraw();
|
||||
}
|
||||
|
||||
|
||||
void BufferView::needsRedraw(bool redraw_needed)
|
||||
{
|
||||
pimpl_->needsRedraw(redraw_needed);
|
||||
pimpl_->updateMetrics(singlepar);
|
||||
}
|
||||
|
@ -116,9 +116,10 @@ public:
|
||||
* to do a fitcursor, and to force an update if screen
|
||||
* position changes. \c forceupdate means to force an update
|
||||
* in any case.
|
||||
* \return true if a full updateMetrics() is needed.
|
||||
*/
|
||||
bool update(Update::flags flags = Update::FitCursor | Update::Force);
|
||||
|
||||
void update(Update::flags flags = Update::FitCursor | Update::Force);
|
||||
/// move the screen to fit the cursor. Only to be called with
|
||||
/// good y coordinates (after a bv::metrics)
|
||||
bool fitCursor();
|
||||
@ -223,10 +224,9 @@ public:
|
||||
int length, bool backwards);
|
||||
///
|
||||
ViewMetricsInfo const & viewMetricsInfo();
|
||||
|
||||
///
|
||||
bool needsRedraw() const;
|
||||
void needsRedraw(bool redraw_needed);
|
||||
void updateMetrics(bool singlepar = false);
|
||||
|
||||
private:
|
||||
///
|
||||
class Pimpl;
|
||||
|
@ -128,7 +128,7 @@ T * getInsetByCode(LCursor & cur, InsetBase::Code code)
|
||||
BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner)
|
||||
: bv_(&bv), owner_(owner), buffer_(0), wh_(0),
|
||||
cursor_(bv),
|
||||
multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0), needs_redraw_(false)
|
||||
multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0)
|
||||
{
|
||||
xsel_cache_.set = false;
|
||||
|
||||
@ -652,7 +652,7 @@ ViewMetricsInfo const & BufferView::Pimpl::viewMetricsInfo()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::update(Update::flags flags)
|
||||
bool BufferView::Pimpl::update(Update::flags flags)
|
||||
{
|
||||
// This is close to a hot-path.
|
||||
if (lyxerr.debugging(Debug::DEBUG)) {
|
||||
@ -666,31 +666,20 @@ void BufferView::Pimpl::update(Update::flags flags)
|
||||
|
||||
// Check needed to survive LyX startup
|
||||
if (!buffer_)
|
||||
return;
|
||||
|
||||
// Check if there is already a redraw waiting in the queue.
|
||||
if (needs_redraw_)
|
||||
return;
|
||||
return false;
|
||||
|
||||
// Update macro store
|
||||
buffer_->buildMacros();
|
||||
|
||||
// First drawing step
|
||||
bool singlePar = flags & Update::SinglePar;
|
||||
needs_redraw_ = (flags & (Update::Force | Update::SinglePar));
|
||||
updateMetrics(flags & Update::SinglePar);
|
||||
|
||||
updateMetrics(singlePar);
|
||||
// The second drawing step is done in WorkArea::redraw() if needed.
|
||||
bool const need_second_step =
|
||||
(flags & (Update::Force | Update::FitCursor | Update::MultiParSel))
|
||||
&& (fitCursor() || multiParSel());
|
||||
|
||||
if ((flags & (Update::FitCursor | Update::MultiParSel))
|
||||
&& (fitCursor() || multiParSel())) {
|
||||
needs_redraw_ = true;
|
||||
singlePar = false;
|
||||
}
|
||||
|
||||
if (needs_redraw_) {
|
||||
// Second drawing step
|
||||
updateMetrics(singlePar);
|
||||
}
|
||||
return need_second_step;
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
//
|
||||
bool multiParSel();
|
||||
///
|
||||
void update(Update::flags flags = Update::Force);
|
||||
bool update(Update::flags flags = Update::Force);
|
||||
/// load a buffer into the view
|
||||
bool loadLyXFile(std::string const &, bool);
|
||||
///
|
||||
@ -117,14 +117,8 @@ public:
|
||||
///
|
||||
ViewMetricsInfo const & viewMetricsInfo();
|
||||
///
|
||||
bool needsRedraw() const
|
||||
{
|
||||
return needs_redraw_;
|
||||
}
|
||||
void needsRedraw(bool redraw_needed)
|
||||
{
|
||||
needs_redraw_ = redraw_needed;
|
||||
}
|
||||
void updateMetrics(bool singlepar = false);
|
||||
|
||||
private:
|
||||
///
|
||||
int width_;
|
||||
@ -132,8 +126,6 @@ private:
|
||||
int height_;
|
||||
///
|
||||
ScrollbarParameters scrollbarParameters_;
|
||||
///
|
||||
bool needs_redraw_;
|
||||
|
||||
/// An error list (replaces the error insets)
|
||||
ErrorList errorlist_;
|
||||
@ -164,8 +156,6 @@ private:
|
||||
|
||||
///
|
||||
ViewMetricsInfo metrics_info_;
|
||||
///
|
||||
void updateMetrics(bool singlepar = false);
|
||||
|
||||
///
|
||||
friend class BufferView;
|
||||
|
@ -189,9 +189,7 @@ void WorkArea::redraw()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!buffer_view_->needsRedraw())
|
||||
return;
|
||||
|
||||
buffer_view_->updateMetrics(false);
|
||||
ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
|
||||
greyed_out_ = false;
|
||||
getPainter().start();
|
||||
@ -202,7 +200,6 @@ void WorkArea::redraw()
|
||||
( vi.p2 < vi.size - 1 ? vi.y2 : height() );
|
||||
expose(0, ymin, width(), ymax - ymin);
|
||||
getPainter().end();
|
||||
buffer_view_->needsRedraw(false);
|
||||
|
||||
lyxerr[Debug::DEBUG]
|
||||
<< " ymin = " << ymin << " width() = " << width()
|
||||
@ -225,7 +222,11 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
|
||||
*/
|
||||
// if (buffer_view_->available())
|
||||
toggleCursor();
|
||||
redraw();
|
||||
|
||||
// uneeded "redraw()" call commented out for now.
|
||||
// When/if the call to LyXView::redrawWorkArea() in "lyxfunc.C:1610"
|
||||
// is not needed anymore, this line should be uncommented out
|
||||
//redraw();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user