-: p(parent), buffer_view_(0), lyx_view_(0),
- caret_(0), caret_visible_(false),
- need_resize_(false), preedit_lines_(1),
- last_pixel_ratio_(1.0),
- completer_(new GuiCompleter(p, p)), dialog_mode_(false), shell_escape_(false),
- read_only_(false), clean_(true), externally_modified_(false)
-{
+: p(parent), buffer_view_(0), lyx_view_(0), caret_(0),
+ caret_visible_(false), need_resize_(false), preedit_lines_(1),
+ last_pixel_ratio_(1.0), completer_(new GuiCompleter(p, p)),
+ dialog_mode_(false), shell_escape_(false), read_only_(false),
+ clean_(true), externally_modified_(false)
+{
+/* 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() == "wayland";
+#else
+# ifdef Q_OS_MAC
+ use_backingstore_ = true;
+# else
+ use_backingstore_ = false;
+# endif
+#endif
+