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.

Pick-to: 6.4 6.2 5.15
Fixes: QTBUG-46681
Fixes: QTBUG-100085
Change-Id: I08dc0800ad0e23f0c2293d0d4e4bd29d92155752
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Liang Qi <liang.qi@qt.io>
bb10
Liang Qi 2022-10-17 15:11:50 +02:00
parent be4d339ce7
commit 71c3aab7ba
1 changed files with 8 additions and 0 deletions

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());
}