Skip to content

Commit d2e21d0

Browse files
committed
fix: wait x11 activate request to done
1 parent 4acb7e1 commit d2e21d0

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/gui/x11.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{error::Error, io};
1+
use std::{error::Error, io, thread, time::Duration};
22

33
use x11rb::{
44
connection::Connection,
@@ -139,6 +139,7 @@ impl X11 {
139139
)?;
140140

141141
self.connection.sync()?;
142+
self.wait_actvate_window()?;
142143

143144
Ok(())
144145
}
@@ -149,4 +150,26 @@ impl X11 {
149150

150151
Ok(())
151152
}
153+
154+
fn wait_actvate_window(&self) -> Result<bool, Box<dyn std::error::Error>> {
155+
loop {
156+
let prop = self
157+
.connection
158+
.get_property(
159+
false,
160+
self.root_id,
161+
self.net_active_window,
162+
AtomEnum::WINDOW,
163+
0,
164+
1,
165+
)?
166+
.reply()?;
167+
168+
if u32::from_ne_bytes(prop.value[0..4].try_into()?) == self.window_id {
169+
return Ok(true);
170+
}
171+
172+
thread::sleep(Duration::from_millis(10));
173+
}
174+
}
152175
}

0 commit comments

Comments
 (0)