Make it possible to use XCB::Atom with non-default xcb_connection_t
Preparation step for having an X11 backend in kwin_wayland which has connection() point to Xwayland and another connection to the parent X server.
This commit is contained in:
parent
e886bd7c78
commit
c1ab92d8b4
1 changed files with 7 additions and 5 deletions
12
xcbutils.h
12
xcbutils.h
|
@ -457,9 +457,10 @@ public:
|
||||||
class Atom
|
class Atom
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Atom(const QByteArray &name, bool onlyIfExists = false)
|
explicit Atom(const QByteArray &name, bool onlyIfExists = false, xcb_connection_t *c = connection())
|
||||||
: m_retrieved(false)
|
: m_connection(c)
|
||||||
, m_cookie(xcb_intern_atom_unchecked(connection(), onlyIfExists, name.length(), name.constData()))
|
, m_retrieved(false)
|
||||||
|
, m_cookie(xcb_intern_atom_unchecked(m_connection, onlyIfExists, name.length(), name.constData()))
|
||||||
, m_atom(XCB_ATOM_NONE)
|
, m_atom(XCB_ATOM_NONE)
|
||||||
, m_name(name)
|
, m_name(name)
|
||||||
{
|
{
|
||||||
|
@ -469,7 +470,7 @@ public:
|
||||||
|
|
||||||
~Atom() {
|
~Atom() {
|
||||||
if (!m_retrieved && m_cookie.sequence) {
|
if (!m_retrieved && m_cookie.sequence) {
|
||||||
xcb_discard_reply(connection(), m_cookie.sequence);
|
xcb_discard_reply(m_connection, m_cookie.sequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,12 +496,13 @@ private:
|
||||||
if (m_retrieved || !m_cookie.sequence) {
|
if (m_retrieved || !m_cookie.sequence) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ScopedCPointer<xcb_intern_atom_reply_t> reply(xcb_intern_atom_reply(connection(), m_cookie, nullptr));
|
ScopedCPointer<xcb_intern_atom_reply_t> reply(xcb_intern_atom_reply(m_connection, m_cookie, nullptr));
|
||||||
if (!reply.isNull()) {
|
if (!reply.isNull()) {
|
||||||
m_atom = reply->atom;
|
m_atom = reply->atom;
|
||||||
}
|
}
|
||||||
m_retrieved = true;
|
m_retrieved = true;
|
||||||
}
|
}
|
||||||
|
xcb_connection_t *m_connection;
|
||||||
bool m_retrieved;
|
bool m_retrieved;
|
||||||
xcb_intern_atom_cookie_t m_cookie;
|
xcb_intern_atom_cookie_t m_cookie;
|
||||||
xcb_atom_t m_atom;
|
xcb_atom_t m_atom;
|
||||||
|
|
Loading…
Reference in a new issue