From a732dafc3654c70da0bc15ef5aa274bbe6553ce9 Mon Sep 17 00:00:00 2001 From: Lucy Date: Mon, 27 Jun 2022 13:54:24 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Send=20a=20socket=20as=20`COSMIC=5F?= =?UTF-8?q?SESSION=5FSOCK`=20to=20the=20compositor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comp.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/comp.rs b/src/comp.rs index 37a9977..211e821 100644 --- a/src/comp.rs +++ b/src/comp.rs @@ -1,12 +1,22 @@ +use std::os::unix::prelude::IntoRawFd; + // SPDX-License-Identifier: GPL-3.0-only use crate::process::{ProcessEvent, ProcessHandler}; -use tokio::sync::{mpsc::unbounded_channel, oneshot}; +use tokio::{ + net::UnixStream, + sync::{mpsc::unbounded_channel, oneshot}, +}; use tokio_util::sync::CancellationToken; pub async fn run_compositor(token: CancellationToken, wayland_display_tx: oneshot::Sender) { let mut wayland_display_tx = Some(wayland_display_tx); let (tx, mut rx) = unbounded_channel::(); - ProcessHandler::new(tx, &token).run("cosmic-comp", vec![], vec![]); + let (session, comp) = UnixStream::pair().expect("failed to create pair of unix sockets"); + let comp = comp.into_std().unwrap().into_raw_fd(); + ProcessHandler::new(tx, &token).run("cosmic-comp", vec![], vec![( + "COSMIC_SESSION_SOCK".into(), + comp.to_string(), + )]); while let Some(event) = rx.recv().await { match event { ProcessEvent::Started => {