]> git.lyx.org Git - features.git/commitdiff
Remember correctly pixel ratio used for painting
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 18 Sep 2017 08:58:07 +0000 (10:58 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 15 Feb 2018 11:29:25 +0000 (12:29 +0100)
This avoids endless resize issues on HiDPI systems (e.g. Retina Mac).

Rename pixel_ratio_ to last_pixel_ratio_ to emphasize that this is a
cached value.

Inline needResize method to make the logic clearer in paintEvent.

(cherry picked from commit 6532e5104dfad5416817d89a5f91e53c30cdd523)

src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea_Private.h

index 6520c3aa7c4ed5af6313d1334bb8fa033a8118fb..f4380da5e8c773c0aaa9791ac1808b21df225da5 100644 (file)
@@ -238,7 +238,7 @@ GuiWorkArea::Private::Private(GuiWorkArea * parent)
 : p(parent), buffer_view_(0), lyx_view_(0),
   caret_(0), caret_visible_(false),
   need_resize_(false), preedit_lines_(1),
-  pixel_ratio_(1.0),
+  last_pixel_ratio_(1.0),
   completer_(new GuiCompleter(p, p)), dialog_mode_(false), shell_escape_(false),
   read_only_(false), clean_(true), externally_modified_(false)
 {
@@ -1243,7 +1243,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
        // LYXERR(Debug::PAINTING, "paintEvent begin: x: " << rc.x()
        //      << " y: " << rc.y() << " w: " << rc.width() << " h: " << rc.height());
 
-       if (d->needResize()) {
+       if (d->need_resize_ || pixelRatio() != d->last_pixel_ratio_) {
                d->resizeBufferView();
                if (d->caret_visible_) {
                        d->hideCaret();
@@ -1251,6 +1251,8 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
                }
        }
 
+       d->last_pixel_ratio_ = pixelRatio();
+
        GuiPainter pain(viewport(), pixelRatio());
        d->buffer_view_->draw(pain, d->caret_visible_);
 
index 8be28694cdd2667e34fcd78079f117a5e9e7eabf..ef2bb7e1df40c8c72d4cb73ce8e55aeecfaeaaaf 100644 (file)
@@ -97,10 +97,6 @@ struct GuiWorkArea::Private
 
        void paintPreeditText(GuiPainter & pain);
 
-       bool needResize() const {
-               return need_resize_ || p->pixelRatio() != pixel_ratio_;
-       }
-
        ///
        GuiWorkArea * p;
        ///
@@ -133,7 +129,7 @@ struct GuiWorkArea::Private
        /// 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_;
+       double last_pixel_ratio_;
        ///
        GuiCompleter * completer_;