mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +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();
|
pimpl_->updateMetrics(singlepar);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BufferView::needsRedraw(bool redraw_needed)
|
|
||||||
{
|
|
||||||
pimpl_->needsRedraw(redraw_needed);
|
|
||||||
}
|
}
|
||||||
|
@ -116,9 +116,10 @@ public:
|
|||||||
* to do a fitcursor, and to force an update if screen
|
* to do a fitcursor, and to force an update if screen
|
||||||
* position changes. \c forceupdate means to force an update
|
* position changes. \c forceupdate means to force an update
|
||||||
* in any case.
|
* 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
|
/// move the screen to fit the cursor. Only to be called with
|
||||||
/// good y coordinates (after a bv::metrics)
|
/// good y coordinates (after a bv::metrics)
|
||||||
bool fitCursor();
|
bool fitCursor();
|
||||||
@ -223,10 +224,9 @@ public:
|
|||||||
int length, bool backwards);
|
int length, bool backwards);
|
||||||
///
|
///
|
||||||
ViewMetricsInfo const & viewMetricsInfo();
|
ViewMetricsInfo const & viewMetricsInfo();
|
||||||
|
|
||||||
///
|
///
|
||||||
bool needsRedraw() const;
|
void updateMetrics(bool singlepar = false);
|
||||||
void needsRedraw(bool redraw_needed);
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
class Pimpl;
|
class Pimpl;
|
||||||
|
@ -128,7 +128,7 @@ T * getInsetByCode(LCursor & cur, InsetBase::Code code)
|
|||||||
BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner)
|
BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner)
|
||||||
: bv_(&bv), owner_(owner), buffer_(0), wh_(0),
|
: bv_(&bv), owner_(owner), buffer_(0), wh_(0),
|
||||||
cursor_(bv),
|
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;
|
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.
|
// This is close to a hot-path.
|
||||||
if (lyxerr.debugging(Debug::DEBUG)) {
|
if (lyxerr.debugging(Debug::DEBUG)) {
|
||||||
@ -666,31 +666,20 @@ void BufferView::Pimpl::update(Update::flags flags)
|
|||||||
|
|
||||||
// Check needed to survive LyX startup
|
// Check needed to survive LyX startup
|
||||||
if (!buffer_)
|
if (!buffer_)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// Check if there is already a redraw waiting in the queue.
|
|
||||||
if (needs_redraw_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Update macro store
|
// Update macro store
|
||||||
buffer_->buildMacros();
|
buffer_->buildMacros();
|
||||||
|
|
||||||
// First drawing step
|
// First drawing step
|
||||||
bool singlePar = flags & Update::SinglePar;
|
updateMetrics(flags & Update::SinglePar);
|
||||||
needs_redraw_ = (flags & (Update::Force | Update::SinglePar));
|
|
||||||
|
|
||||||
updateMetrics(singlePar);
|
// The second drawing step is done in WorkArea::redraw() if needed.
|
||||||
|
bool const need_second_step =
|
||||||
if ((flags & (Update::FitCursor | Update::MultiParSel))
|
(flags & (Update::Force | Update::FitCursor | Update::MultiParSel))
|
||||||
&& (fitCursor() || multiParSel())) {
|
&& (fitCursor() || multiParSel());
|
||||||
needs_redraw_ = true;
|
|
||||||
singlePar = false;
|
return need_second_step;
|
||||||
}
|
|
||||||
|
|
||||||
if (needs_redraw_) {
|
|
||||||
// Second drawing step
|
|
||||||
updateMetrics(singlePar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
//
|
//
|
||||||
bool multiParSel();
|
bool multiParSel();
|
||||||
///
|
///
|
||||||
void update(Update::flags flags = Update::Force);
|
bool update(Update::flags flags = Update::Force);
|
||||||
/// load a buffer into the view
|
/// load a buffer into the view
|
||||||
bool loadLyXFile(std::string const &, bool);
|
bool loadLyXFile(std::string const &, bool);
|
||||||
///
|
///
|
||||||
@ -117,14 +117,8 @@ public:
|
|||||||
///
|
///
|
||||||
ViewMetricsInfo const & viewMetricsInfo();
|
ViewMetricsInfo const & viewMetricsInfo();
|
||||||
///
|
///
|
||||||
bool needsRedraw() const
|
void updateMetrics(bool singlepar = false);
|
||||||
{
|
|
||||||
return needs_redraw_;
|
|
||||||
}
|
|
||||||
void needsRedraw(bool redraw_needed)
|
|
||||||
{
|
|
||||||
needs_redraw_ = redraw_needed;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
int width_;
|
int width_;
|
||||||
@ -132,8 +126,6 @@ private:
|
|||||||
int height_;
|
int height_;
|
||||||
///
|
///
|
||||||
ScrollbarParameters scrollbarParameters_;
|
ScrollbarParameters scrollbarParameters_;
|
||||||
///
|
|
||||||
bool needs_redraw_;
|
|
||||||
|
|
||||||
/// An error list (replaces the error insets)
|
/// An error list (replaces the error insets)
|
||||||
ErrorList errorlist_;
|
ErrorList errorlist_;
|
||||||
@ -164,8 +156,6 @@ private:
|
|||||||
|
|
||||||
///
|
///
|
||||||
ViewMetricsInfo metrics_info_;
|
ViewMetricsInfo metrics_info_;
|
||||||
///
|
|
||||||
void updateMetrics(bool singlepar = false);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
friend class BufferView;
|
friend class BufferView;
|
||||||
|
@ -189,9 +189,7 @@ void WorkArea::redraw()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buffer_view_->needsRedraw())
|
buffer_view_->updateMetrics(false);
|
||||||
return;
|
|
||||||
|
|
||||||
ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
|
ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
|
||||||
greyed_out_ = false;
|
greyed_out_ = false;
|
||||||
getPainter().start();
|
getPainter().start();
|
||||||
@ -202,7 +200,6 @@ void WorkArea::redraw()
|
|||||||
( vi.p2 < vi.size - 1 ? vi.y2 : height() );
|
( vi.p2 < vi.size - 1 ? vi.y2 : height() );
|
||||||
expose(0, ymin, width(), ymax - ymin);
|
expose(0, ymin, width(), ymax - ymin);
|
||||||
getPainter().end();
|
getPainter().end();
|
||||||
buffer_view_->needsRedraw(false);
|
|
||||||
|
|
||||||
lyxerr[Debug::DEBUG]
|
lyxerr[Debug::DEBUG]
|
||||||
<< " ymin = " << ymin << " width() = " << width()
|
<< " ymin = " << ymin << " width() = " << width()
|
||||||
@ -225,7 +222,11 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
|
|||||||
*/
|
*/
|
||||||
// if (buffer_view_->available())
|
// if (buffer_view_->available())
|
||||||
toggleCursor();
|
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