]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea_Private.h
Amend f441590c
[lyx.git] / src / frontends / qt4 / GuiWorkArea_Private.h
index 8b34ede1ad6493c3798f9cced4fef0cb3b9d63f9..5320c5c7133ce9faeeaeeb5478049306c2a1355a 100644 (file)
 #define WORKAREA_PRIVATE_H
 
 #include "FuncRequest.h"
-#include "qt_helpers.h"
 #include "LyXRC.h"
 
-#include "support/docstring.h"
 #include "support/Timeout.h"
 
 #include <QMouseEvent>
@@ -119,14 +117,31 @@ struct GuiWorkArea::Private
        ///
        void setCursorShape(Qt::CursorShape shape);
 
+       bool needResize() const {
+               return need_resize_ || p->pixelRatio() != pixel_ratio_;
+       }
+
        void resetScreen()
        {
                delete screen_;
+               pixel_ratio_ = p->pixelRatio();
                if (lyxrc.use_qimage) {
-                       screen_ = new QImage(p->viewport()->width(), p->viewport()->height(),
-                               QImage::Format_ARGB32_Premultiplied);
+                       QImage *x = 
+                               new QImage(static_cast<int>(pixel_ratio_ * p->viewport()->width()),
+                                                  static_cast<int>(pixel_ratio_ * p->viewport()->height()),
+                                                  QImage::Format_ARGB32_Premultiplied);
+#if QT_VERSION >= 0x050000
+                       x->setDevicePixelRatio(pixel_ratio_);
+#endif
+                       screen_ = x;
                } else {
-                       screen_ = new QPixmap(p->viewport()->width(), p->viewport()->height());
+                       QPixmap *x = 
+                               new QPixmap(static_cast<int>(pixel_ratio_ * p->viewport()->width()),
+                                                       static_cast<int>(pixel_ratio_ * p->viewport()->height()));
+#if QT_VERSION >= 0x050000
+                       x->setDevicePixelRatio(pixel_ratio_);
+#endif
+                       screen_ = x;
                }
        }
        ///
@@ -157,7 +172,10 @@ struct GuiWorkArea::Private
        bool schedule_redraw_;
        ///
        int preedit_lines_;
-
+       /// Ratio between physical pixels and device-independent pixels
+       /// We save the last used value to detect changes of the
+       /// current pixel_ratio of the viewport.
+       double pixel_ratio_;
        ///
        GuiCompleter * completer_;