summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.h
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2018-04-10 11:50:31 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2018-04-14 17:03:10 +0000
commitd5ac11891d8237ca2f02390ffd0ff103578b520e (patch)
tree2ae7eb99d63bbb9ffed440e88731a8d08399b116 /src/plugins/platforms/xcb/qxcbconnection.h
parent7286d9d8dd1f8543007218a91d5c6767a7a7b152 (diff)
xcb: prevent crash with pixmap cursors on XRender-less X servers
We were using xcb_render_* APIs without checking if the server even supports this extension. Attempting to use an extension which is not present will always result in a crash. This patch adds the required guards and refactors how we detect presence of XRender extension. Also instead of falling back to some odd-looking bitmapped version just leave the current cursor unchanged. That is how we did it in Qt4 AFAICT. Task-number: QTBUG-66935 Change-Id: I4f27f1d65a77563ec34f3e0e94492c9236d7f9a6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.h')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index ced5208c81..d9321d94d0 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -478,7 +478,13 @@ public:
bool hasXRandr() const { return has_randr_extension; }
bool hasInputShape() const { return has_input_shape; }
bool hasXKB() const { return has_xkb; }
- bool hasXRender() const { return has_render_extension; }
+ bool hasXRender(int major = -1, int minor = -1) const
+ {
+ if (has_render_extension && major != -1 && minor != -1)
+ return m_xrenderVersion >= qMakePair(major, minor);
+
+ return has_render_extension;
+ }
bool hasXInput2() const { return m_xi2Enabled; }
bool hasShm() const { return has_shm; }
bool hasShmFd() const { return has_shm_fd; }
@@ -707,6 +713,8 @@ private:
bool has_shm = false;
bool has_shm_fd = false;
+ QPair<int, int> m_xrenderVersion;
+
Qt::MouseButtons m_buttonState = 0;
Qt::MouseButton m_button = Qt::NoButton;