From f4eb4c5f308bc0160ca0391f6fc60e969b7a8daa Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 17 Oct 2022 15:11:50 +0200 Subject: [PATCH] xcb: Flush Display when processing xcb events Only calling xcb_flush() is not enough when users use xlib calls to paint with the Display, for example in QWidget::paintEvent(), and not call XFlush(). This fixes a regression since Qt 4.x. In Qt 4, we use XNextEvent() in x11 event dispatcher which implicitly called XFlush(). In Qt 5 and 6, we use xcb calls. See also https://www.x.org/releases/X11R7.5/doc/man/man3/XFlush.3.html Most client applications need not use this function because the output buffer is automatically flushed as needed by calls to XPending, XNextEvent, and XWindowEvent. Fixes: QTBUG-46681 Fixes: QTBUG-100085 Change-Id: I08dc0800ad0e23f0c2293d0d4e4bd29d92155752 Reviewed-by: JiDe Zhang Reviewed-by: Liang Qi (cherry picked from commit 71c3aab7baae9220b37178711a49746f66975d63) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/xcb/qxcbconnection.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 07509697038..3fdc43a11d1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -35,6 +35,10 @@ #undef explicit #include +#if QT_CONFIG(xcb_xlib) +#include "qt_xlib_wrapper.h" +#endif + QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; @@ -1090,6 +1094,10 @@ void QXcbConnection::processXcbEvents(QEventLoop::ProcessEventsFlags flags) m_eventQueue->flushBufferedEvents(); } +#if QT_CONFIG(xcb_xlib) + qt_XFlush(static_cast(xlib_display())); +#endif + xcb_flush(xcb_connection()); }