LyX relies on a a backing store to draw when running under macOS or
Wayland, because Qt arbitrarily overwrites parts of the workarea
before we paint (and we paint only the parts that need to be painted).
However it seems that this is also necessary on X11 when the WM theme
is translucid. Since there is no way that I know of to detect this
situation, this patch adds a LyXRC setting to manually select this
drawing strategy.
Note that using a backing store is not always a good solution, since
this disables subpixel aliasing.
At this point there is no UI for the variable.
Fixes bug #12119
(cherry picked from commit
c213eb7f75d53165f55e64f0149fec833e5b5b5e)
(cherry picked from commit
1ed9257c6dc57fc11990b86d5774ac9a8e70cfa6)
+!Important Change in LyX 2.3.7
+
+The following pref variable was added:
+
+* \draw_strategy partial|backingstore: when this is set to
+ "backingstore", the drawing code will force the use of an
+ intermediate surface, instead of just drawing changed regions on
+ screen. Note that "backingstore" is actually always enforced on
+ macOS and Wayland (default: partial).
+
+
!Important Change in LyX 2.3.1
* A change to how math macros are output can break some documents that use
{ "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
{ "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
{ "\\document_path", LyXRC::RC_DOCUMENTPATH },
+ { "\\draw_strategy", LyXRC::RC_DRAW_STRATEGY },
{ "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
{ "\\escape_chars", LyXRC::RC_ESC_CHARS },
{ "\\example_path", LyXRC::RC_EXAMPLEPATH },
lexrc >> mouse_middlebutton_paste;
break;
+ case RC_DRAW_STRATEGY:
+ if (lexrc.next()) {
+ string const tmp = lexrc.getString();
+ if (tmp == "partial")
+ draw_strategy = DS_PARTIAL;
+ else if (tmp == "backingstore")
+ draw_strategy = DS_BACKINGSTORE;
+ else {
+ draw_strategy = DS_PARTIAL;
+ LYXERR0("Unrecognized draw strategy " << tmp <<'"');
+ }
+ }
+ break;
+
case RC_LAST:
break; // this is just a dummy
}
}
if (tag != RC_LAST)
break;
+ // fall through
+ case RC_DRAW_STRATEGY:
+ if (ignore_system_lyxrc ||
+ draw_strategy != system_lyxrc.draw_strategy) {
+ string status;
+ switch (draw_strategy) {
+ case DS_PARTIAL:
+ status = "partial";
+ break;
+ case DS_BACKINGSTORE:
+ status = "backingstore";
+ break;
+ }
+ os << "\\draw_strategy " << status << '\n';
+ }
+ if (tag != RC_LAST)
+ break;
+ // fall through
os << "\n#\n"
- << "# COLOR SECTION ###################################\n"
- << "#\n\n";
+ << "# COLOR SECTION ###################################\n"
+ << "#\n\n";
// fall through
case RC_SET_COLOR:
package().document_dir() = FileName(lyxrc.document_path);
}
// fall through
+ case LyXRC::RC_DRAW_STRATEGY:
case LyXRC::RC_EDITOR_ALTERNATIVES:
case LyXRC::RC_ESC_CHARS:
case LyXRC::RC_EXAMPLEPATH:
RC_VIEWER_ALTERNATIVES,
RC_VISUAL_CURSOR,
RC_CLOSE_BUFFER_WITH_LAST_VIEW,
+ RC_DRAW_STRATEGY,
RC_LAST
};
int cursor_width;
/// One of: yes, no, ask
std::string close_buffer_with_last_view;
+
+ enum DrawStrategy {
+ // draw all (not implemented yet)
+ // FS_FULL,
+ // draw only what has changed
+ DS_PARTIAL,
+ // draw in backing store (only what has changed)
+ DS_BACKINGSTORE
+ };
+ ///
+ DrawStrategy draw_strategy = DS_PARTIAL;
};
}
+bool GuiApplication::needsBackingStore() const
+{
+ /* Qt on macOS and Wayland does not respect the
+ * Qt::WA_OpaquePaintEvent attribute and resets the widget backing
+ * store at each update. Therefore, we use our own backing store
+ * in these two cases. It is also possible to force the use of the
+ * backing store for cases like x11 with transparent WM themes.
+ */
+#if QT_VERSION >= 0x050000
+ return platformName() == "cocoa" || platformName().contains("wayland");
+#else
+# ifdef Q_OS_MAC
+ return true;
+# else
+ return false;
+# endif // Q_OS_MAC
+#endif // QT_VERSION
+}
+
+
QList<int> GuiApplication::viewIds() const
{
return d->views_.keys();
///
Menus & menus();
+ /// \returns true if painting the workarea requires a backing store.
+ bool needsBackingStore() const;
+
/// \name Methods inherited from QApplication class
//@{
bool notify(QObject * receiver, QEvent * event) override;
dialog_mode_(false), shell_escape_(false), read_only_(false),
clean_(true), externally_modified_(false), needs_caret_geometry_update_(true)
{
-/* Qt on macOS and Wayland does not respect the
- * Qt::WA_OpaquePaintEvent attribute and resets the widget backing
- * store at each update. Therefore, we use our own backing store in
- * these two cases. */
-#if QT_VERSION >= 0x050000
- use_backingstore_ = guiApp->platformName() == "cocoa"
- || guiApp->platformName().contains("wayland");
-#else
-# ifdef Q_OS_MAC
- use_backingstore_ = true;
-# else
- use_backingstore_ = false;
-# endif
-#endif
+ use_backingstore_ = lyxrc.draw_strategy == LyXRC::DS_BACKINGSTORE
+ || guiApp->needsBackingStore();
+ LYXERR(Debug::WORKAREA, "Drawing strategy is: "
+ << (use_backingstore_ ? "backingstore" : "partial"));
int const time = QApplication::cursorFlashTime() / 2;
if (time > 0) {
- Fix broken modifier handling for Qt-5.12 on Mac (bug 12247).
+- Add new pref variable \draw_strategy to fix some cases where display
+ is blinking (bug 12119).
+
* DOCUMENTATION AND LOCALIZATION