// Kiosk hint for the compositor.
//
// The wizard owns the whole screen and has nothing to switch to, so forge's
// active corners — app switcher, launcher, overview — would only get in the
// way: a stray flick of the pointer into a corner covers the wizard. The
// session announces itself here rather than forge recognising this app by id.

use std::io::Write;
use std::os::unix::net::UnixStream;
use std::path::PathBuf;

fn socket_path() -> Option<PathBuf>
{
	let runtime = std::env::var_os( "XDG_RUNTIME_DIR" )?;
	let display = std::env::var( "WAYLAND_DISPLAY" ).ok()?;
	Some( PathBuf::from( runtime ).join( format!( "forge-{display}.sock" ) ) )
}

/// Best-effort: another compositor, or none, just means the hint goes nowhere.
pub fn set_kiosk( enabled: bool )
{
	let Some( path ) = socket_path() else { return };
	let Ok( mut stream ) = UnixStream::connect( path ) else { return };
	let _ = writeln!( stream, r#"{{"action":"set_kiosk","enabled":{enabled}}}"# );
}
