Michael Gerz wrote:
Dear Jose,

Nov 13th is getting closer (oops, it's already there) and, to my greatest regret, I haven't managed to fix all CT problems.

And I haven't manage to fix some performance problem... But I am very close :-)

Attached patch minimizes considerably the number of metrics updates and screen redraws. The only problem left is that collapsable insets are not correctly open/collapse. Don't try it because this will clear out the Coord cache and leads to redraw problems. If this happen, you will need a full paragraph rebreak anywhere in order to refresh the cache.

I might not be ready for this alpha but I will for the next.

Abdel.

Index: BufferView.C
===================================================================
--- BufferView.C        (revision 15890)
+++ BufferView.C        (working copy)
@@ -362,15 +362,27 @@
        // Update macro store
        buffer_->buildMacros();
 
-       // First drawing step
+       // Now do the first drawing step if needed. This consists on updating
+       // the CoordCache in updateMetrics().
+       // The second drawing step is done in WorkArea::redraw() if needed.
+
+       // Case when no explicit update is requested.
+       if (!(flags & (Update::SinglePar | Update::Force))) {
+               if (fitCursor() || multiParSel()) {
+                       // a CoordCache update is needed
+                       updateMetrics(false);
+                       // tell the frontend to update the screen.
+                       return true;
+               }
+               // no need to do anything.
+               return false;
+       }
+
+       // We are now in the case (Update::SinglePar | Update::Force)
        updateMetrics(flags & Update::SinglePar);
 
-       // The second drawing step is done in WorkArea::redraw() if needed.
-       bool const need_second_step =
-               (flags & (Update::SinglePar | Update::Force | Update::FitCursor 
| Update::MultiParSel))
-               && (fitCursor() || multiParSel());
-
-       return need_second_step;
+       // Don't forget to do check for fitCursor() and multiParSel().
+       return fitCursor() || multiParSel();
 }
 
 
@@ -1050,7 +1062,7 @@
        }
 
        // When the above and the inner function are fixed, we can do this:
-       //return needRedraw;
+       return needRedraw;
        return true;
 }
 
@@ -1204,7 +1216,7 @@
 void BufferView::updateMetrics(bool singlepar)
 {
        // Clear out the position cache in case of full screen redraw.
-       //if (!singlepar)
+       if (!singlepar)
                coord_cache_.clear();
 
        LyXText & buftext = buffer_->text();
Index: insets/insetcollapsable.C
===================================================================
--- insets/insetcollapsable.C   (revision 15890)
+++ insets/insetcollapsable.C   (working copy)
@@ -293,6 +293,10 @@
 
        switch (cmd.action) {
        case LFUN_MOUSE_PRESS:
+               if (cmd.button() == mouse_button::button1 && hitButton(cmd)) {
+                       cur.dispatched();
+                       break;
+               }
                if (status() == Inlined)
                        InsetText::doDispatch(cur, cmd);
                else if (status() == Open && !hitButton(cmd))
@@ -325,6 +329,8 @@
                        setStatus(cur, Open);
                        edit(cur, true);
                        cur.bv().cursor() = cur;
+                       cur.dispatched();
+                       cur.updateFlags(Update::Force | Update::FitCursor);
                        break;
 
                case Open: {
@@ -332,6 +338,8 @@
                                //lyxerr << "InsetCollapsable::lfunMouseRelease 
2" << endl;
                                setStatus(cur, Collapsed);
                                cur.bv().cursor() = cur;
+                               cur.dispatched();
+                               cur.updateFlags(Update::Force | 
Update::FitCursor);
                        } else {
                                //lyxerr << "InsetCollapsable::lfunMouseRelease 
3" << endl;
                                InsetText::doDispatch(cur, cmd);
Index: text3.C
===================================================================
--- text3.C     (revision 15890)
+++ text3.C     (working copy)
@@ -997,6 +997,11 @@
                                
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
                }
 
+               if (cmd.button() == mouse_button::button1) {
+                       needsUpdate = false;
+                       cur.noUpdate();
+               }
+
                break;
        }
 
@@ -1046,8 +1051,14 @@
                        break;
 
                // finish selection
-               if (cmd.button() == mouse_button::button1)
-                       theSelection().haveSelection(cur.selection());
+               if (cmd.button() == mouse_button::button1) {
+                       if (cur.selection())
+                               theSelection().haveSelection(cur.selection());
+                       else {
+                               needsUpdate = false;
+                               cur.noUpdate();
+                       }
+               }
 
                bv->switchKeyMap();
                break;

Reply via email to