@@ -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
7573void 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
192180xcb_connection_t *WXWayland::xcbConnection () const
193181{
194182 W_DC (WXWayland);
195- return d-> xcbConnection ;
183+ return handle ()-> get_xwm_connection () ;
196184}
197185
198186QVector<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
288282void WXWayland::destroy (WServer *server)
0 commit comments