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 <zhangjide@uniontech.com>
Reviewed-by: Liang Qi <liang.qi@qt.io>
(cherry picked from commit 71c3aab7baae9220b37178711a49746f66975d63)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Liang Qi 2022-10-17 15:11:50 +02:00 committed by Qt Cherry-pick Bot
parent 5bd9843b10
commit f4eb4c5f30

View File

@ -35,6 +35,10 @@
#undef explicit
#include <xcb/xinput.h>
#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<Display *>(xlib_display()));
#endif
xcb_flush(xcb_connection());
}