summaryrefslogtreecommitdiff
path: root/src/x11extras/qx11info_x11.h
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-07-26 14:54:23 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2017-08-29 14:18:29 +0000
commitec2c0f4db6350a304dcf901b9adbadc895864c14 (patch)
treedb8c6df6b3143b67f18feeab78a6d2cccd92b8f1 /src/x11extras/qx11info_x11.h
parent9749c5085dc21d2064177aa748f3a9395592a7cf (diff)
downloadqtx11extras-ec2c0f4db6350a304dcf901b9adbadc895864c14.tar.gz
[ChangeLog][QX11Info] Added new API to peek into the XCB event queue - peekEventQueue(). This enables porting certain Qt4-based applications to Qt5 (those using Xlib's event handling functions to peek into the X11 event queue). In Qt5 we set XCB to be the owner of the X11 event queue with XSetEventQueueOwner(dpy, XCBOwnsEventQueue), which means that only XCB event handling functions can be used to read events from the X server. XCB does not have an equivalent for Xlib's peeker API. For filtering out unwanted native events Qt5 provides QAbstractNativeEventFilter::nativeEventFilter(), but there isn't any API in Qt to just *peek* into the queue while the GUI thread is busy processing a long task. The peekEventQueue() function adds this capability via QX11Info. Manual and auto test included. Task-number: QTBUG-50358 Change-Id: Id31f797f7ff76d011ad7a55a9b6c13756aaaca60 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/x11extras/qx11info_x11.h')
-rw-r--r--src/x11extras/qx11info_x11.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/x11extras/qx11info_x11.h b/src/x11extras/qx11info_x11.h
index ab72686..c0bfbf8 100644
--- a/src/x11extras/qx11info_x11.h
+++ b/src/x11extras/qx11info_x11.h
@@ -43,14 +43,21 @@
#include <QtCore/qnamespace.h>
#include "QtX11Extras/qtx11extrasglobal.h"
+#include <xcb/xcb.h>
+
typedef struct _XDisplay Display;
-struct xcb_connection_t;
QT_BEGIN_NAMESPACE
class Q_X11EXTRAS_EXPORT QX11Info
{
public:
+ enum PeekOption {
+ PeekDefault = 0,
+ PeekFromCachedIndex = 1
+ };
+ Q_DECLARE_FLAGS(PeekOptions, PeekOption)
+
static bool isPlatformX11();
static int appDpiX(int screen=-1);
@@ -75,10 +82,18 @@ public:
static bool isCompositingManagerRunning(int screen = -1);
+ static qint32 generatePeekerId();
+ static bool removePeekerId(qint32 peekerId);
+ typedef bool (*PeekerCallback)(xcb_generic_event_t *event, void *peekerData);
+ static bool peekEventQueue(PeekerCallback peeker, void *peekerData = nullptr,
+ PeekOptions option = PeekDefault, qint32 peekerId = -1);
+
private:
QX11Info();
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QX11Info::PeekOptions)
+
QT_END_NAMESPACE
#endif // QX11INFO_X11_H