xcb: Send expose event while shrinking windows

Send synthesized expose event while shrinking the QWindow. This fixes
the regression which can break some applications which need the paint
events while shrinking the QWindow.

Added auto test.

Task-number: QTBUG-54040
Change-Id: Iaa992abba67f428237fa12c6cae56592b8fcadb0
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Reviewed-by: Louai Al-Khanji <louai.al-khanji@qt.io>
This commit is contained in:
Błażej Szczygieł 2016-06-11 18:39:23 +02:00
parent 25f040820c
commit e2665600c0
3 changed files with 29 additions and 0 deletions

View File

@ -2102,6 +2102,15 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
// will make the comparison later.
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
// Send the synthetic expose event on resize only when the window is shrinked,
// because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically.
if (!m_oldWindowSize.isEmpty()
&& (actualGeometry.width() < m_oldWindowSize.width()
|| actualGeometry.height() < m_oldWindowSize.height())) {
QWindowSystemInterface::handleExposeEvent(window(), QRegion(0, 0, actualGeometry.width(), actualGeometry.height()));
}
m_oldWindowSize = actualGeometry.size();
if (m_usingSyncProtocol && m_syncState == SyncReceived)
m_syncState = SyncAndConfigureReceived;

View File

@ -256,6 +256,7 @@ protected:
mutable QMargins m_frameMargins;
QRegion m_exposeRegion;
QSize m_oldWindowSize;
xcb_visualid_t m_visualId;
int m_lastWindowStateEvent;

View File

@ -58,6 +58,7 @@ private slots:
void setVisible();
void eventOrderOnShow();
void resizeEventAfterResize();
void exposeEventOnShrink_QTBUG54040();
void mapGlobal();
void positioning_data();
void positioning();
@ -373,6 +374,24 @@ void tst_QWindow::resizeEventAfterResize()
QTRY_COMPARE(window.received(QEvent::Resize), 2);
}
void tst_QWindow::exposeEventOnShrink_QTBUG54040()
{
Window window;
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.setTitle(QTest::currentTestFunction());
window.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&window));
const int initialExposeCount = window.received(QEvent::Expose);
window.resize(window.width(), window.height() - 5);
QTRY_COMPARE(window.received(QEvent::Expose), initialExposeCount + 1);
window.resize(window.width() - 5, window.height());
QTRY_COMPARE(window.received(QEvent::Expose), initialExposeCount + 2);
window.resize(window.width() - 5, window.height() - 5);
QTRY_COMPARE(window.received(QEvent::Expose), initialExposeCount + 3);
}
void tst_QWindow::positioning_data()
{
QTest::addColumn<int>("windowflags");