]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea_Private.h
QDialogButtonBox for the remaining dialogs.
[lyx.git] / src / frontends / qt4 / GuiWorkArea_Private.h
index de20397c71e7edc2f17da80a8c10b106e9cb0431..83012fa99f10123329936de2a27f254a7387d87e 100644 (file)
 #include <QMouseEvent>
 #include <QTimer>
 
+#ifdef Q_OS_MAC
+/* Qt on macOS 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 this case */
+#define LYX_BACKINGSTORE 1
+#include <QPainter>
+#endif
+
 namespace lyx {
 
 class Buffer;
@@ -99,6 +107,38 @@ struct GuiWorkArea::Private
 
        void paintPreeditText(GuiPainter & pain);
 
+       void resetScreen() {
+#ifdef LYX_BACKINGSTORE
+               int const pr = p->pixelRatio();
+               screen_ = QImage(static_cast<int>(pr * p->viewport()->width()),
+                                static_cast<int>(pr * p->viewport()->height()),
+                                QImage::Format_ARGB32_Premultiplied);
+#  if QT_VERSION >= 0x050000
+               screen_.setDevicePixelRatio(pr);
+#  endif
+#endif
+       }
+
+       QPaintDevice * screenDevice() {
+#ifdef LYX_BACKINGSTORE
+               return &screen_;
+#else
+               return p->viewport();
+#endif
+       }
+
+#ifdef LYX_BACKINGSTORE
+       void updateScreen(QRectF const & rc) {
+               QPainter qpain(p->viewport());
+               double const pr = p->pixelRatio();
+               QRectF const rcs = QRectF(rc.x() * pr, rc.y() * pr,
+                                         rc.width() * pr, rc.height() * pr);
+               qpain.drawImage(rc, screen_, rcs);
+       }
+#else
+       void updateScreen(QRectF const & ) {}
+#endif
+
        ///
        GuiWorkArea * p;
        ///
@@ -106,6 +146,10 @@ struct GuiWorkArea::Private
        ///
        GuiView * lyx_view_;
 
+#ifdef LYX_BACKINGSTORE
+       ///
+       QImage screen_;
+#endif
        ///
        CaretWidget * caret_;
        /// is the caret currently displayed