Client: Don't spam expose events
Only send expose event when the geometry actually changed. Change-Id: Ic06986ce5d11e0ff7a842303f57093b8ff25b9f6 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
46aece5133
commit
52c9c71d91
@ -338,7 +338,9 @@ void QWaylandWindow::setGeometry(const QRect &rect)
|
|||||||
|
|
||||||
mSentInitialResize = true;
|
mSentInitialResize = true;
|
||||||
}
|
}
|
||||||
sendExposeEvent(QRect(QPoint(), geometry().size()));
|
QRect exposeGeometry(QPoint(), geometry().size());
|
||||||
|
if (exposeGeometry != mLastExposeGeometry)
|
||||||
|
sendExposeEvent(exposeGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
|
void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
|
||||||
@ -356,6 +358,7 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
|
|||||||
{
|
{
|
||||||
if (!(mShellSurface && mShellSurface->handleExpose(rect)))
|
if (!(mShellSurface && mShellSurface->handleExpose(rect)))
|
||||||
QWindowSystemInterface::handleExposeEvent(window(), rect);
|
QWindowSystemInterface::handleExposeEvent(window(), rect);
|
||||||
|
mLastExposeGeometry = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,6 +254,7 @@ private:
|
|||||||
void handleScreenChanged();
|
void handleScreenChanged();
|
||||||
|
|
||||||
bool mUpdateRequested = false;
|
bool mUpdateRequested = false;
|
||||||
|
QRect mLastExposeGeometry;
|
||||||
|
|
||||||
static const wl_callback_listener callbackListener;
|
static const wl_callback_listener callbackListener;
|
||||||
static void frameCallback(void *data, struct wl_callback *wl_callback, uint32_t time);
|
static void frameCallback(void *data, struct wl_callback *wl_callback, uint32_t time);
|
||||||
|
@ -58,6 +58,14 @@ public:
|
|||||||
return QWindow::event(event);
|
return QWindow::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exposeEvent(QExposeEvent *event) override
|
||||||
|
{
|
||||||
|
++exposeEventCount;
|
||||||
|
QWindow::exposeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
int exposeEventCount = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void windowStateChangeEventReceived(uint oldState);
|
void windowStateChangeEventReceived(uint oldState);
|
||||||
};
|
};
|
||||||
@ -102,6 +110,7 @@ private slots:
|
|||||||
void windowGeometrySimple();
|
void windowGeometrySimple();
|
||||||
void windowGeometryFixed();
|
void windowGeometryFixed();
|
||||||
void flushUnconfiguredXdgSurface();
|
void flushUnconfiguredXdgSurface();
|
||||||
|
void dontSpamExposeEvents();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MockCompositor *m_compositor = nullptr;
|
MockCompositor *m_compositor = nullptr;
|
||||||
@ -395,6 +404,20 @@ void tst_WaylandClientXdgShellV6::flushUnconfiguredXdgSurface()
|
|||||||
QVERIFY(window.isExposed());
|
QVERIFY(window.isExposed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_WaylandClientXdgShellV6::dontSpamExposeEvents()
|
||||||
|
{
|
||||||
|
TestWindow window;
|
||||||
|
window.show();
|
||||||
|
|
||||||
|
QSharedPointer<MockSurface> surface;
|
||||||
|
QTRY_VERIFY(surface = m_compositor->surface());
|
||||||
|
QTRY_VERIFY(window.exposeEventCount == 0);
|
||||||
|
|
||||||
|
m_compositor->sendShellSurfaceConfigure(surface);
|
||||||
|
QTRY_VERIFY(window.isExposed());
|
||||||
|
QTRY_VERIFY(window.exposeEventCount == 1);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
setenv("XDG_RUNTIME_DIR", ".", 1);
|
setenv("XDG_RUNTIME_DIR", ".", 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user