Skip to content

Commit

Permalink
fix(server): write xwayland logs to the bug report dir
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed May 3, 2024
1 parent 003fe97 commit 0ba97f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mm-server/src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl Compositor {

// Bind the xwayland sockets.
let xwayland = if state.app_config.xwayland {
Some(XWaylandLoop::new(dh.clone())?)
Some(XWaylandLoop::new(dh.clone(), bug_report_dir.as_deref())?)
} else {
None
};
Expand Down
34 changes: 20 additions & 14 deletions mm-server/src/compositor/xserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: BUSL-1.1

use std::{process::Stdio, time};
use std::{path::Path, process::Stdio, time};

use anyhow::Context;
use smithay::{
Expand All @@ -22,21 +22,28 @@ pub(super) struct XWaylandLoop {
}

impl XWaylandLoop {
pub fn new(dh: wayland_server::DisplayHandle) -> anyhow::Result<Self> {
pub fn new<P>(
dh: wayland_server::DisplayHandle,
bug_report_dir: Option<P>,
) -> anyhow::Result<Self>
where
P: AsRef<Path>,
{
let event_loop: calloop::EventLoop<'_, State> =
calloop::EventLoop::try_new().context("failed to create xwm event loop")?;

let (stdout, stderr) = if let Some(bug_report_dir) = bug_report_dir {
let stdout = std::fs::File::create(bug_report_dir.as_ref().join("xwayland.log"))?;
let stderr = stdout.try_clone()?;
(stdout.into(), stderr.into())
} else {
(Stdio::null(), Stdio::null())
};

let envs = std::iter::empty::<(String, String)>();
let (xwayland, client) = smithay::xwayland::XWayland::spawn(
&dh,
None,
envs,
true,
Stdio::null(),
Stdio::null(),
|_| {},
)
.context("failed to launch Xwayland")?;
let (xwayland, client) =
smithay::xwayland::XWayland::spawn(&dh, None, envs, true, stdout, stderr, |_| {})
.context("failed to launch Xwayland")?;

let x11_display = xwayland.display_number();

Expand All @@ -53,8 +60,7 @@ impl XWaylandLoop {

state.xwm = Some(xwm)
}
})
.unwrap();
})?;

Ok(Self {
x11_display,
Expand Down

0 comments on commit 0ba97f5

Please sign in to comment.