Kaydet (Commit) f541da4f authored tarafından Aleksei Nikiforov's avatar Aleksei Nikiforov Kaydeden (comit) Samuel Mehrbrodt

tdf#120777 KDE5: Dialogs get blank when they are resized

On window resize qt5 only redraws changed parts of widgets.
If resize is minor (i.e. height has increased by 1 pixel, for example),
qt5 may consider most parts of widget not changed and skip redrawing them
and redraw only certain widget elements.

But if cairo is used for drawing, on resize previously drawed image of widget
is discarded and new one of different size is created.
New image is empty, but qt5 doesn't issue redraw for whole widget.
To mitigate this issue, data from old image of widget should be copied over
to image of new widget, qt5 will redraw it partially or fully if necessary.

Change-Id: Id950074efece9072bbfc002dfcb6ead813d5aeff
Reviewed-on: https://gerrit.libreoffice.org/62698Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Jenkins
üst 0c33e80b
...@@ -119,11 +119,12 @@ public: ...@@ -119,11 +119,12 @@ public:
double fMiterMinimumAngle, double fMiterMinimumAngle,
bool bPixelSnapHairline); bool bPixelSnapHairline);
private:
void invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags);
void copySource(const SalTwoRect& rTR, cairo_surface_t* source); void copySource(const SalTwoRect& rTR, cairo_surface_t* source);
void copyWithOperator(const SalTwoRect& rTR, cairo_surface_t* source, void copyWithOperator(const SalTwoRect& rTR, cairo_surface_t* source,
cairo_operator_t eOp = CAIRO_OPERATOR_SOURCE); cairo_operator_t eOp = CAIRO_OPERATOR_SOURCE);
private:
void invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags);
void applyColor(cairo_t *cr, Color rColor); void applyColor(cairo_t *cr, Color rColor);
protected: protected:
......
...@@ -24,12 +24,14 @@ ...@@ -24,12 +24,14 @@
#include <Qt5Graphics.hxx> #include <Qt5Graphics.hxx>
#include <Qt5Tools.hxx> #include <Qt5Tools.hxx>
#include <QtCore/QtGlobal>
#include <QtGui/QFocusEvent> #include <QtGui/QFocusEvent>
#include <QtGui/QImage> #include <QtGui/QImage>
#include <QtGui/QKeyEvent> #include <QtGui/QKeyEvent>
#include <QtGui/QMouseEvent> #include <QtGui/QMouseEvent>
#include <QtGui/QPainter> #include <QtGui/QPainter>
#include <QtGui/QPaintEvent> #include <QtGui/QPaintEvent>
#include <QtGui/QResizeEvent>
#include <QtGui/QShowEvent> #include <QtGui/QShowEvent>
#include <QtGui/QWheelEvent> #include <QtGui/QWheelEvent>
#include <QtWidgets/QtWidgets> #include <QtWidgets/QtWidgets>
...@@ -57,7 +59,7 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent) ...@@ -57,7 +59,7 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent)
p.drawImage(pEvent->rect().topLeft(), *m_pFrame->m_pQImage, pEvent->rect()); p.drawImage(pEvent->rect().topLeft(), *m_pFrame->m_pQImage, pEvent->rect());
} }
void Qt5Widget::resizeEvent(QResizeEvent* /*event*/) void Qt5Widget::resizeEvent(QResizeEvent* pEvent)
{ {
if (m_pFrame->m_bUseCairo) if (m_pFrame->m_bUseCairo)
{ {
...@@ -71,7 +73,15 @@ void Qt5Widget::resizeEvent(QResizeEvent* /*event*/) ...@@ -71,7 +73,15 @@ void Qt5Widget::resizeEvent(QResizeEvent* /*event*/)
cairo_surface_set_user_data(pSurface, SvpSalGraphics::getDamageKey(), cairo_surface_set_user_data(pSurface, SvpSalGraphics::getDamageKey(),
&m_pFrame->m_aDamageHandler, nullptr); &m_pFrame->m_aDamageHandler, nullptr);
m_pFrame->m_pSvpGraphics->setSurface(pSurface, basegfx::B2IVector(width, height)); m_pFrame->m_pSvpGraphics->setSurface(pSurface, basegfx::B2IVector(width, height));
UniqueCairoSurface old_surface(m_pFrame->m_pSurface.release());
m_pFrame->m_pSurface.reset(pSurface); m_pFrame->m_pSurface.reset(pSurface);
int min_width = qMin(pEvent->oldSize().width(), pEvent->size().width());
int min_height = qMin(pEvent->oldSize().height(), pEvent->size().height());
SalTwoRect rect(0, 0, min_width, min_height, 0, 0, min_width, min_height);
m_pFrame->m_pSvpGraphics->copySource(rect, old_surface.get());
} }
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment