|
|
|
@ -5,8 +5,8 @@ use x11rb::{
|
|
|
|
|
connection::Connection,
|
|
|
|
|
protocol::{
|
|
|
|
|
xproto::{
|
|
|
|
|
Atom, AtomEnum, ChangeWindowAttributesAux,
|
|
|
|
|
ConnectionExt, EventMask, Window, InputFocus, ClientMessageData, ClientMessageEvent, self,
|
|
|
|
|
self, Atom, AtomEnum, ChangeWindowAttributesAux, ClientMessageData, ClientMessageEvent,
|
|
|
|
|
ConnectionExt, EventMask, Window,
|
|
|
|
|
},
|
|
|
|
|
Event,
|
|
|
|
|
},
|
|
|
|
@ -66,7 +66,6 @@ pub fn focus_target() {
|
|
|
|
|
if let Ok(target) = (*TARGET.load(std::sync::atomic::Ordering::SeqCst)).lock() {
|
|
|
|
|
if *target != x11rb::NONE {
|
|
|
|
|
if let Ok((conn, _screen_num)) = connect(None) {
|
|
|
|
|
|
|
|
|
|
let net_active_window = get_atom(&conn, "_NET_ACTIVE_WINDOW").unwrap();
|
|
|
|
|
|
|
|
|
|
let event = ClientMessageEvent {
|
|
|
|
@ -75,16 +74,20 @@ pub fn focus_target() {
|
|
|
|
|
sequence: 0,
|
|
|
|
|
window: *target,
|
|
|
|
|
type_: net_active_window,
|
|
|
|
|
data: ClientMessageData::from([
|
|
|
|
|
1,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
]),
|
|
|
|
|
data: ClientMessageData::from([1, x11rb::CURRENT_TIME, 0, 0, 0]),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
conn.send_event(false, conn.setup().roots[_screen_num].root, EventMask::SUBSTRUCTURE_NOTIFY | EventMask::SUBSTRUCTURE_REDIRECT, event).ok();
|
|
|
|
|
if let Ok(cookie) = conn.send_event(
|
|
|
|
|
false,
|
|
|
|
|
conn.setup().roots[_screen_num].root,
|
|
|
|
|
EventMask::SUBSTRUCTURE_NOTIFY | EventMask::SUBSTRUCTURE_REDIRECT,
|
|
|
|
|
event,
|
|
|
|
|
) {
|
|
|
|
|
if let Err(e) = cookie.check() {
|
|
|
|
|
log::error!("Error focusing target: {e:?}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conn.flush().ok();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|