Add QXcbConnectionGrabber class
Inspired by QMutexLocker Change-Id: I66e31091d2a006db3272b627567d95d3e0b1c4f9 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
parent
0f31a5d91f
commit
3d43d178e6
@ -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
|
||||
|
@ -585,6 +585,15 @@ xcb_generic_event_t *QXcbConnection::checkEvent(T &checker)
|
||||
return 0;
|
||||
}
|
||||
|
||||
class QXcbConnectionGrabber
|
||||
{
|
||||
public:
|
||||
QXcbConnectionGrabber(QXcbConnection *connection);
|
||||
~QXcbConnectionGrabber();
|
||||
void release();
|
||||
private:
|
||||
QXcbConnection *m_connection;
|
||||
};
|
||||
|
||||
#ifdef Q_XCB_DEBUG
|
||||
template <typename cookie_t>
|
||||
|
@ -1141,7 +1141,7 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on)
|
||||
if (desktop_proxy) // *WE* already have one.
|
||||
return false;
|
||||
|
||||
connection()->grabServer();
|
||||
QXcbConnectionGrabber grabber(connection());
|
||||
|
||||
// As per Xdnd4, use XdndProxy
|
||||
xcb_window_t proxy_id = xdndProxy(connection(), w->xcb_window());
|
||||
@ -1157,7 +1157,6 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on)
|
||||
XCB_ATOM_WINDOW, 32, 1, &proxy_id);
|
||||
}
|
||||
|
||||
connection()->ungrabServer();
|
||||
} else {
|
||||
xdnd_widget = w;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user