fix: use Connection::from_socket instead of set_var for wayland connection
Avoids environment mutation (set_var is unsafe in multi-threaded contexts). Uses UnixStream::connect + Connection::from_socket directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
afa2569737
commit
2cd9f50604
1 changed files with 5 additions and 4 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use std::os::fd::{AsFd, FromRawFd, OwnedFd};
|
||||
use std::os::unix::io::IntoRawFd;
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::os::unix::net::{UnixListener, UnixStream};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
|
|
@ -108,9 +108,10 @@ fn main() -> Result<()> {
|
|||
nix::unistd::pipe().context("Failed to create close pipe")?;
|
||||
|
||||
// Connect to the compositor.
|
||||
std::env::set_var("WAYLAND_DISPLAY", &args.wayland_socket);
|
||||
let conn =
|
||||
Connection::connect_to_env().context("Failed to connect to Wayland compositor")?;
|
||||
let wayland_stream = UnixStream::connect(&args.wayland_socket)
|
||||
.with_context(|| format!("Failed to connect to Wayland compositor at {}", args.wayland_socket))?;
|
||||
let conn = Connection::from_socket(wayland_stream)
|
||||
.context("Failed to create Wayland connection")?;
|
||||
|
||||
let (globals, mut event_queue) =
|
||||
registry_queue_init::<State>(&conn).context("Failed to initialize Wayland registry")?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue