summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@digia.com>2013-05-14 08:17:13 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-20 08:02:34 +0200
commit3d43d178e61cd38ccc78e2943f6363e464cf3500 (patch)
tree3454eb9ceec2c0cf2369b45aeb32dc3ee7a9a49b /src/plugins/platforms/xcb/qxcbconnection.cpp
parent0f31a5d91f13bd6a574bed8db894a7ebb2813292 (diff)
Add QXcbConnectionGrabber class
Inspired by QMutexLocker Change-Id: I66e31091d2a006db3272b627567d95d3e0b1c4f9 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index db2179c73f..209c7bb187 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -1720,4 +1720,24 @@ bool QXcbConnection::xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event, int o
}
#endif // defined(XCB_USE_XINPUT2) || defined(XCB_USE_XINPUT2_MAEMO)
+QXcbConnectionGrabber::QXcbConnectionGrabber(QXcbConnection *connection)
+ :m_connection(connection)
+{
+ connection->grabServer();
+}
+
+QXcbConnectionGrabber::~QXcbConnectionGrabber()
+{
+ if (m_connection)
+ m_connection->ungrabServer();
+}
+
+void QXcbConnectionGrabber::release()
+{
+ if (m_connection) {
+ m_connection->ungrabServer();
+ m_connection = 0;
+ }
+}
+
QT_END_NAMESPACE