Hello,
This patch optimizes the redraw problem pointed out by Edwin. There's
still too much redraw inside insets but this is fixable.
One of the difficult problem that this patch solves is the recursive
descending inside Insets within LyXText::editXY(). The problem was that,
when clicking on a collapsable inset (ex: Foot), a null inset pointer
was returned in any case.
I will commit tomorrow if I don't get any comment until then.
Abdel.
Index: BufferView.C
===================================================================
--- BufferView.C (revision 15743)
+++ BufferView.C (working copy)
@@ -997,20 +997,20 @@
// LFUN_FILE_OPEN generated by drag-and-drop.
FuncRequest cmd = cmd0;
+ // E.g. Qt mouse press when no buffer
if (!buffer_)
return false;
+ bool needRedraw = false;
+
LCursor cur(*this);
cur.push(buffer_->inset());
cur.selection() = cursor_.selection();
+ needRedraw |= cur.selection();
// Doesn't go through lyxfunc, so we need to update
// the layout choice etc. ourselves
- // E.g. Qt mouse press when no buffer
- if (!buffer_)
- return false;
-
// Either the inset under the cursor or the
// surrounding LyXText will handle this event.
@@ -1029,8 +1029,10 @@
// via the temp cursor. If the inset wishes to change the real
// cursor it has to do so explicitly by using
// cur.bv().cursor() = cur; (or similar)
- if (inset)
+ if (inset) {
inset->dispatch(cur, cmd);
+ needRedraw = true;
+ }
// Now dispatch to the temporary cursor. If the real cursor should
// be modified, the inset's dispatch has to do so explicitly.
@@ -1040,12 +1042,12 @@
if (cur.result().dispatched()) {
// Redraw if requested or necessary.
if (cur.result().update())
- update(Update::FitCursor | Update::Force);
+ needRedraw |= update(Update::FitCursor | Update::Force);
else
- update(Update::FitCursor | Update::MultiParSel);
+ needRedraw |= update(Update::FitCursor |
Update::MultiParSel);
}
- return true;
+ return needRedraw;
}
Index: frontends/WorkArea.C
===================================================================
--- frontends/WorkArea.C (revision 15743)
+++ frontends/WorkArea.C (working copy)
@@ -200,7 +200,7 @@
theLyXFunc().setLyXView(&lyx_view_);
- buffer_view_->workAreaDispatch(cmd0);
+ bool needRedraw = buffer_view_->workAreaDispatch(cmd0);
// Skip these when selecting
if (cmd0.action != LFUN_MOUSE_MOTION) {
@@ -214,7 +214,8 @@
// of the new status here.
lyx_view_.clearMessage();
- redraw();
+ if (needRedraw)
+ redraw();
}
Index: text2.C
===================================================================
--- text2.C (revision 15743)
+++ text2.C (working copy)
@@ -988,16 +988,20 @@
// This should be just before or just behind the
// cursor position set above.
- InsetBase * inset2 = pars_[pit].getInset(pos - 1);
- InsetBase * inset3 = pars_[pit].getInset(pos);
+ InsetBase * insetBefore = pars_[pit].getInset(pos - 1);
+ InsetBase * insetBehind = pars_[pit].getInset(pos);
- BOOST_ASSERT((pos != 0 && inset == inset2)
- || inset == inset3);
+ BOOST_ASSERT((pos != 0 && inset == insetBefore)
+ || inset == insetBehind);
// Make sure the cursor points to the position before
// this inset.
- if (inset == pars_[pit].getInset(pos - 1))
+ if (inset == insetBefore)
--cur.pos();
- inset = inset->editXY(cur, x, y);
+
+ InsetBase * insetDeeper = inset->editXY(cur, x, y);
+ if (insetDeeper)
+ inset = insetDeeper;
+
if (cur.top().text() == this)
setCurrentFont(cur);
return inset;