Skip to content

Commit cab9232

Browse files
committed
Use wlroots's xcb_connection_t for WXWayland
This function is a new interface with wlroots 0.18, use this xcb connection can do something by the X11 WM client.
1 parent 2770d69 commit cab9232

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qwlroots

src/server/protocols/wxwayland.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class Q_DECL_HIDDEN WXWaylandPrivate : public WWrapObjectPrivate
3131

3232
}
3333
~WXWaylandPrivate() {
34-
if (xcbConnection)
35-
xcb_disconnect(xcbConnection);
34+
3635
}
3736

3837
void init();
@@ -51,7 +50,6 @@ class Q_DECL_HIDDEN WXWaylandPrivate : public WWrapObjectPrivate
5150
qw_compositor *compositor;
5251
bool lazy = true;
5352
QVector<WXWaylandSurface*> surfaceList;
54-
xcb_connection_t *xcbConnection = nullptr;
5553
QVector<xcb_atom_t> atoms;
5654
QList<WXWaylandSurface*> toplevelSurfaces;
5755

@@ -74,21 +72,11 @@ static const QByteArrayView atom_map[WXWayland::AtomCount] = {
7472

7573
void WXWaylandPrivate::init()
7674
{
77-
socket->addClient(waylandClient());
78-
7975
W_Q(WXWayland);
80-
xcbConnection = xcb_connect(q->displayName().constData(), nullptr);
81-
int err = xcb_connection_has_error(xcbConnection);
82-
if (err != 0) {
83-
qFatal("Can't connect to XWayland by xcb_connect");
84-
return;
85-
}
86-
if (!xcbConnection)
87-
return;
8876

8977
xcb_intern_atom_cookie_t cookies[WXWayland::AtomCount];
9078
for (int i = WXWayland::AtomNone + 1; i < WXWayland::AtomCount; ++i) {
91-
cookies[i] = xcb_intern_atom(xcbConnection, 0,
79+
cookies[i] = xcb_intern_atom(q->xcbConnection(), 0,
9280
atom_map[i].length(),
9381
atom_map[i].constData());
9482
}
@@ -97,7 +85,7 @@ void WXWaylandPrivate::init()
9785
for (int i = WXWayland::AtomNone + 1; i < WXWayland::AtomCount; ++i) {
9886
xcb_generic_error_t *error;
9987
xcb_intern_atom_reply_t *reply =
100-
xcb_intern_atom_reply(xcbConnection, cookies[i], &error);
88+
xcb_intern_atom_reply(q->xcbConnection(), cookies[i], &error);
10189
if (reply && !error)
10290
atoms[i] = reply->atom;
10391
free(reply);
@@ -192,7 +180,7 @@ WSeat *WXWayland::seat() const
192180
xcb_connection_t *WXWayland::xcbConnection() const
193181
{
194182
W_DC(WXWayland);
195-
return d->xcbConnection;
183+
return handle()->get_xwm_connection();
196184
}
197185

198186
QVector<WXWaylandSurface*> WXWayland::surfaceList() const
@@ -279,10 +267,16 @@ void WXWayland::create(WServer *server)
279267
QObject::connect(handle, &qw_xwayland::notify_new_surface, this, [d] (wlr_xwayland_surface *surface) {
280268
d->on_new_surface(surface);
281269
});
270+
282271
QObject::connect(handle, &qw_xwayland::notify_ready, this, [this, d] {
283272
d->init();
284273
Q_EMIT ready();
285274
});
275+
276+
auto s = qw_xwayland_server::from(handle->handle()->server);
277+
QObject::connect(s, &qw_xwayland_server::notify_start, this, [d] {
278+
d->socket->addClient(d->waylandClient());
279+
});
286280
}
287281

288282
void WXWayland::destroy(WServer *server)

0 commit comments

Comments
 (0)