[LyX features/biginset] Avoid full metrics computation when entering/leaving inset

2024-04-05 Thread Jean-Marc Lasgouttes
commit 73678dcde977802d5ff3ae07f0226484041fff48
Author: Jean-Marc Lasgouttes 
Date:   Mon Nov 27 15:57:09 2023 +0100

Avoid full metrics computation when entering/leaving inset

Annotate function LFUN_FINISHED_xxx to indicate that they do not
require a full metrics computation.

Remove an "optimization" that meant that when the cursor changed
inset, a full metrics computation was requested.

Part of bug #12297
---
 src/LyXAction.cpp |  8 
 src/Text.cpp  | 33 +
 2 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index b6bb52152c..ece248e61c 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -1655,7 +1655,7 @@ void LyXAction::init()
  * \li Notion: See also #LFUN_FINISHED_FORWARD.
  * \endvar
  */
-   { LFUN_FINISHED_BACKWARD, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_BACKWARD, "", ReadOnly | NoUpdate, Hidden },
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FINISHED_FORWARD
@@ -1668,7 +1668,7 @@ void LyXAction::init()
back into the surrounding text.
  * \endvar
  */
-   { LFUN_FINISHED_FORWARD, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_FORWARD, "", ReadOnly | NoUpdate, Hidden },
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FINISHED_LEFT
@@ -1676,7 +1676,7 @@ void LyXAction::init()
  * \li Notion: See also #LFUN_FINISHED_FORWARD.
  * \endvar
  */
-   { LFUN_FINISHED_LEFT, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_LEFT, "", ReadOnly | NoUpdate, Hidden },
 
 
 /*!
@@ -1685,7 +1685,7 @@ void LyXAction::init()
  * \li Notion: See also #LFUN_FINISHED_FORWARD
  * \endvar
  */
-   { LFUN_FINISHED_RIGHT, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_RIGHT, "", ReadOnly | NoUpdate, Hidden },
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FLEX_INSERT
diff --git a/src/Text.cpp b/src/Text.cpp
index 2684309dec..4749f36d2c 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -6393,23 +6393,24 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
return;
}
-   if (!needsUpdate
-   && () == ()
-   && oldTopSlice.idx() == cur.idx()
-   && !oldSelection // oldSelection is a backup of cur.selection() at 
the beginning of the function.
-   && !cur.selection())
-   // FIXME: it would be better if we could just do this
-   //
-   //if (cur.result().update() != Update::FitCursor)
-   //  cur.noScreenUpdate();
-   //
-   // But some LFUNs do not set Update::FitCursor when needed, so 
we
-   // do it for all. This is not very harmfull as FitCursor will 
provoke
-   // a full redraw only if needed but still, a proper review of 
all LFUN
-   // should be done and this needsUpdate boolean can then be 
removed.
-   cur.screenUpdateFlags(Update::FitCursor);
-   else
+   if (needsUpdate)
cur.screenUpdateFlags(Update::Force | Update::FitCursor);
+   else {
+   // oldSelection is a backup of cur.selection() at the beginning 
of the function.
+   if (!oldSelection && !cur.selection())
+   // FIXME: it would be better if we could just do this
+   //
+   //if (cur.result().update() != Update::FitCursor)
+   //  cur.noScreenUpdate();
+   //
+   // But some LFUNs do not set Update::FitCursor when 
needed, so we
+   // do it for all. This is not very harmfull as 
FitCursor will provoke
+   // a full redraw only if needed but still, a proper 
review of all LFUN
+   // should be done and this needsUpdate boolean can then 
be removed.
+   cur.screenUpdateFlags(Update::FitCursor);
+   else
+   cur.screenUpdateFlags(Update::ForceDraw | 
Update::FitCursor);
+   }
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] Avoid full metrics computation when entering/leaving inset

2023-11-27 Thread Jean-Marc Lasgouttes
The branch, biginset, has been updated.

- Log -

commit 75bd5dcf8abd2d00070ef35675a50b844e5a55a8
Author: Jean-Marc Lasgouttes 
Date:   Mon Nov 27 15:57:09 2023 +0100

Avoid full metrics computation when entering/leaving inset

Annotate function LFUN_FINISHED_xxx to indicate that they do not
require a full metrics computation.

Remove an "optimization" that meant that when the cursor changed
inset, a full metrics computation was requested.

Part of bug #12297

diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 19f1203..fe120c8 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -1655,7 +1655,7 @@ void LyXAction::init()
  * \li Notion: See also #LFUN_FINISHED_FORWARD.
  * \endvar
  */
-   { LFUN_FINISHED_BACKWARD, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_BACKWARD, "", ReadOnly | NoUpdate, Hidden },
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FINISHED_FORWARD
@@ -1668,7 +1668,7 @@ void LyXAction::init()
back into the surrounding text.
  * \endvar
  */
-   { LFUN_FINISHED_FORWARD, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_FORWARD, "", ReadOnly | NoUpdate, Hidden },
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FINISHED_LEFT
@@ -1676,7 +1676,7 @@ void LyXAction::init()
  * \li Notion: See also #LFUN_FINISHED_FORWARD.
  * \endvar
  */
-   { LFUN_FINISHED_LEFT, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_LEFT, "", ReadOnly | NoUpdate, Hidden },
 
 
 /*!
@@ -1685,7 +1685,7 @@ void LyXAction::init()
  * \li Notion: See also #LFUN_FINISHED_FORWARD
  * \endvar
  */
-   { LFUN_FINISHED_RIGHT, "", ReadOnly, Hidden },
+   { LFUN_FINISHED_RIGHT, "", ReadOnly | NoUpdate, Hidden },
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FLEX_INSERT
diff --git a/src/Text.cpp b/src/Text.cpp
index ef5dd26..548e925 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -6341,23 +6341,24 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
return;
}
-   if (!needsUpdate
-   && () == ()
-   && oldTopSlice.idx() == cur.idx()
-   && !oldSelection // oldSelection is a backup of cur.selection() at 
the beginning of the function.
-   && !cur.selection())
-   // FIXME: it would be better if we could just do this
-   //
-   //if (cur.result().update() != Update::FitCursor)
-   //  cur.noScreenUpdate();
-   //
-   // But some LFUNs do not set Update::FitCursor when needed, so 
we
-   // do it for all. This is not very harmfull as FitCursor will 
provoke
-   // a full redraw only if needed but still, a proper review of 
all LFUN
-   // should be done and this needsUpdate boolean can then be 
removed.
-   cur.screenUpdateFlags(Update::FitCursor);
-   else
+   if (needsUpdate)
cur.screenUpdateFlags(Update::Force | Update::FitCursor);
+   else {
+   // oldSelection is a backup of cur.selection() at the beginning 
of the function.
+   if (!oldSelection && !cur.selection())
+   // FIXME: it would be better if we could just do this
+   //
+   //if (cur.result().update() != Update::FitCursor)
+   //  cur.noScreenUpdate();
+   //
+   // But some LFUNs do not set Update::FitCursor when 
needed, so we
+   // do it for all. This is not very harmfull as 
FitCursor will provoke
+   // a full redraw only if needed but still, a proper 
review of all LFUN
+   // should be done and this needsUpdate boolean can then 
be removed.
+   cur.screenUpdateFlags(Update::FitCursor);
+   else
+   cur.screenUpdateFlags(Update::ForceDraw | 
Update::FitCursor);
+   }
 }
 
 

commit 674bf0515a19da5bad8ad1e0c6ca500d01d62ee3
Author: Jean-Marc Lasgouttes 
Date:   Mon Nov 27 15:13:56 2023 +0100

Avoid some full metrics computations related to math previews

When entering/leaving a math hull inset, a Update::Force flag was set,
in case the metrics of the inset would change because of a switch
between normal and preview representation.

When entering the inset, this code is now used only when the inset was
in preview mode.

In both cases, Update::Force is replaced with Update::SinglePar.

Part of bug #12297.

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index d2c2159..3724250 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -903,7 +903,7 @@ bool InsetMathHull::notifyCursorLeaves(Cursor const & old, 
Cursor & cur)
 {
if