commit c263463cadc92a9e5b29df97a825328c9300b76a
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Tue Jun 18 14:28:28 2024 +0200
Move DrawStrategy enum to update_flags.h.
Introduce new drawStrategy() and drawStrategyDescription() methods to
frontend::Application.
Show the current draw strategy in About dialog.
---
src/BufferView.cpp | 3 ++-
src/LyXRC.cpp | 12 ++++++------
src/LyXRC.h | 11 ++---------
src/frontends/Application.h | 6 ++++++
src/frontends/qt/GuiAbout.cpp | 5 +++++
src/frontends/qt/GuiApplication.cpp | 28 ++++++++++++++++++++++++----
src/frontends/qt/GuiApplication.h | 5 +++--
src/frontends/qt/GuiWorkArea.cpp | 10 ++--------
src/update_flags.h | 12 ++++++++++++
9 files changed, 62 insertions(+), 30 deletions(-)
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 4e81bcbe3f..8a4d0b2c20 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -58,6 +58,7 @@
#include "mathed/MathRow.h"
#include "frontends/alert.h"
+#include "frontends/Application.h"
#include "frontends/CaretGeometry.h"
#include "frontends/Delegates.h"
#include "frontends/FontMetrics.h"
@@ -592,7 +593,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
flags = (flags & ~Update::FitCursor) | Update::ForceDraw;
}
- if (lyxrc.draw_strategy == LyXRC::DS_FULL)
+ if (theApp()->drawStrategy() == DrawStrategy::Full)
flags = flags | Update::ForceDraw;
// Add flags to the the update flags. These will be reset to None
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index edd9a58240..feda5110c0 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -1144,11 +1144,11 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool
check_format)
if (lexrc.next()) {
string const tmp = lexrc.getString();
if (tmp == "partial")
- draw_strategy = DS_PARTIAL;
+ draw_strategy = DrawStrategy::Partial;
else if (tmp == "backingstore")
- draw_strategy = DS_BACKINGSTORE;
+ draw_strategy =
DrawStrategy::Backingstore;
else if (tmp == "full")
- draw_strategy = DS_FULL;
+ draw_strategy = DrawStrategy::Full;
else {
LYXERR0("Unrecognized draw strategy "
<< tmp <<'"');
}
@@ -2056,13 +2056,13 @@ void LyXRC::write(ostream & os, bool
ignore_system_lyxrc, string const & name) c
draw_strategy != system_lyxrc.draw_strategy) {
string status;
switch (draw_strategy) {
- case DS_FULL:
+ case DrawStrategy::Full:
status = "full";
break;
- case DS_PARTIAL:
+ case DrawStrategy::Partial:
status = "partial";
break;
- case DS_BACKINGSTORE:
+ case DrawStrategy::Backingstore:
status = "backingstore";
break;
}
diff --git a/src/LyXRC.h b/src/LyXRC.h
index 753a6f4f61..e0c2da3178 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -19,6 +19,7 @@
#define LYXRC_H
#include "LyX.h"
+#include "update_flags.h"
#include "support/Length.h"
#include "support/strfwd.h"
@@ -579,16 +580,8 @@ public:
///
BookmarksVisibility bookmarks_visibility = BMK_NONE;
- enum DrawStrategy {
- // draw all
- DS_FULL,
- // draw only what has changed
- DS_PARTIAL,
- // draw in backing store (only what has changed)
- DS_BACKINGSTORE
- };
///
- DrawStrategy draw_strategy = DS_PARTIAL;
+ DrawStrategy draw_strategy = DrawStrategy::Partial;
};
diff --git a/src/frontends/Application.h b/src/frontends/Application.h
index 75298ca67a..4d2d249b23 100644
--- a/src/frontends/Application.h
+++ b/src/frontends/Application.h
@@ -13,6 +13,7 @@
#include "ColorCode.h"
#include "FuncCode.h"
+#include "update_flags.h"
#include "support/strfwd.h"
@@ -203,6 +204,11 @@ public:
/// Like getRgbColor(), but static and slower
static bool getRgbColorUncached(ColorCode col, RGBColor & rgbcol);
+ /// \returns the draw strategy used by the application
+ virtual DrawStrategy drawStrategy() const = 0;
+ /// \returns the description of the draw strategy used by the
application
+ virtual docstring drawStrategyDescription() const = 0;
+
/**
* @return true if LyX uses a dark theme
*/
diff --git a/src/frontends/qt/GuiAbout.cpp b/src/frontends/qt/GuiAbout.cpp
index 0a585f0eac..5ad435952d 100644
--- a/src/frontends/qt/GuiAbout.cpp
+++ b/src/frontends/qt/GuiAbout.cpp
@@ -298,6 +298,11 @@ static QString version(bool const plain = false)
out << "</p><p>";
#endif
out << toqstr(bformat(_("Python detected: %1$s"),
from_utf8(os::python_info())));
+ if (plain)
+ out << '\n';
+ else
+ out << "</p><p>";
+ out << toqstr(bformat(_("Draw strategy: %1$s"),
guiApp->drawStrategyDescription()));
if (!plain)
out << toqstr("</p></body></html>");
return res;
diff --git a/src/frontends/qt/GuiApplication.cpp
b/src/frontends/qt/GuiApplication.cpp
index d903e85f5d..6665631d31 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -2730,16 +2730,36 @@ Menus & GuiApplication::menus()
}
-bool GuiApplication::noPartialDraw() const
+DrawStrategy GuiApplication::drawStrategy() const
{
/* Qt on macOS and Wayland does not respect the
* Qt::WA_OpaquePaintEvent attribute and resets the widget backing
* store at each update. Therefore, if it not good to use
- * "partial" draw strategy in these cases. It is also possible to
- * force the use of the backing store for cases like x11 with
+ * "partial" draw strategy in these cases. It can also be useful
+ * to force the use of the backing store for cases like X11 with
* transparent WM themes.
*/
- return platformName() == "cocoa" || platformName().contains("wayland");
+ if (lyxrc.draw_strategy == DrawStrategy::Partial
+ && (platformName() == "cocoa" ||
platformName().contains("wayland")))
+ return DrawStrategy::Backingstore;
+ else
+ return lyxrc.draw_strategy;
+}
+
+
+docstring GuiApplication::drawStrategyDescription() const
+{
+ switch(drawStrategy()) {
+ case DrawStrategy::Partial:
+ return _("partial draw");
+ break;
+ case DrawStrategy::Backingstore:
+ return _("partial draw on backing store");
+ break;
+ case DrawStrategy::Full:
+ return _("full draw");
+ }
+ return docstring();
}
diff --git a/src/frontends/qt/GuiApplication.h
b/src/frontends/qt/GuiApplication.h
index 67ba9590e5..07a8b167dd 100644
--- a/src/frontends/qt/GuiApplication.h
+++ b/src/frontends/qt/GuiApplication.h
@@ -113,8 +113,9 @@ public:
///
Menus & menus();
- /// \returns true the "partial" draw strategy is known to be broken
- bool noPartialDraw() const;
+ /// \returns the draw strategy used by the application
+ DrawStrategy drawStrategy() const;
+ virtual docstring drawStrategyDescription() const override;
/// \name Methods inherited from QApplication class
//@{
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index c136ffee14..f6c1bb905c 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -130,14 +130,8 @@ SyntheticMouseEvent::SyntheticMouseEvent()
GuiWorkArea::Private::Private(GuiWorkArea * parent)
: p(parent), completer_(new GuiCompleter(p, p))
{
- use_backingstore_ = lyxrc.draw_strategy == LyXRC::DS_BACKINGSTORE
- || (lyxrc.draw_strategy == LyXRC::DS_PARTIAL &&
guiApp->noPartialDraw());
- if (use_backingstore_)
- LYXERR(Debug::WORKAREA, "Drawing strategy: partial draw on
backing store");
- else
- LYXERR(Debug::WORKAREA, "Drawing strategy: "
- << (lyxrc.draw_strategy == LyXRC::DS_PARTIAL ?
"partial draw"
- : "full draw"));
+ use_backingstore_ = guiApp->drawStrategy() ==
DrawStrategy::Backingstore;
+ LYXERR(Debug::WORKAREA, "Drawing strategy: " <<
guiApp->drawStrategyDescription());
int const time = QApplication::cursorFlashTime() / 2;
if (time > 0) {
diff --git a/src/update_flags.h b/src/update_flags.h
index 517bfb62e4..923f450a71 100644
--- a/src/update_flags.h
+++ b/src/update_flags.h
@@ -51,5 +51,17 @@ inline flags operator~(flags const f)
} // namespace Update
+
+// How the work area gets drawn (painted)
+enum class DrawStrategy {
+ // draw all
+ Full,
+ // draw only what has changed
+ Partial,
+ // draw in backing store (only what has changed)
+ Backingstore
+};
+
+
} // namespace lyx
#endif
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs