Use -displayfd instead of signals for Xwayland readiness

The -displayfd argument is much friendlier to testing and is generally
more stable. As a result, omitting the display argument to the program
will result in Xwayland searching for the next available display. This
also allows integration tests to run simultaneously and when there is
already an X server running on the system.

This commit also changes how the state of the program is communicated
with integration tests (via the RunData trait).
This commit is contained in:
Supreeeme 2024-05-15 23:00:39 -04:00 committed by Shawn Wallace
parent 7976e3ad37
commit b8bd07ce93
5 changed files with 155 additions and 134 deletions

View file

@ -3,5 +3,22 @@ fn main() {
.filter_level(log::LevelFilter::Info)
.parse_default_env()
.init();
xwayland_satellite::main(None, None);
xwayland_satellite::main(RealData(get_display()));
}
#[repr(transparent)]
struct RealData(Option<String>);
impl xwayland_satellite::RunData for RealData {
fn display(&self) -> Option<&str> {
self.0.as_deref()
}
}
fn get_display() -> Option<String> {
let mut args: Vec<_> = std::env::args().collect();
if args.len() > 2 {
panic!("Unexpected arguments: {:?}", &args[2..]);
}
(args.len() == 2).then(|| args.swap_remove(1))
}