30 lines
		
	
	
		
			873 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			873 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
pub(crate) mod monitor;
 | 
						|
pub(crate) mod pidfd;
 | 
						|
pub mod screensaver;
 | 
						|
pub mod subservice;
 | 
						|
pub mod xkb_ext;
 | 
						|
 | 
						|
use log::{debug, info};
 | 
						|
use xcb::{x, XidNew};
 | 
						|
 | 
						|
use bscreensaver_command::bscreensaver_command_response;
 | 
						|
 | 
						|
pub fn send_command_reply(conn: &xcb::Connection, ev: &x::ClientMessageEvent, is_success: bool) {
 | 
						|
    let reply_window = match ev.data() {
 | 
						|
        x::ClientMessageData::Data32(data) => {
 | 
						|
            match unsafe { x::Window::new(data[0]) } {
 | 
						|
                x::WINDOW_NONE => None,
 | 
						|
                wid => Some(wid),
 | 
						|
            }
 | 
						|
        },
 | 
						|
        _ => None,
 | 
						|
    };
 | 
						|
    if let Some(reply_window) = reply_window {
 | 
						|
        if let Err(err) = bscreensaver_command_response(conn, reply_window, is_success) {
 | 
						|
            info!("Failed to send command response: {}", err);
 | 
						|
        }
 | 
						|
    } else {
 | 
						|
        debug!("Command sender did not include a reply window");
 | 
						|
    }
 | 
						|
}
 |