fix(pop-shell): Implement 'Quit' request handler

This commit is contained in:
Ningvin 2021-12-22 22:05:01 +01:00 committed by GitHub
parent 8eb3104920
commit 3b4136eeef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,7 +45,7 @@ pub async fn main() {
match request {
Ok(request) => match request {
Request::Activate(id) => app.activate(id).await,
Request::Quit(_id) => (),
Request::Quit(id) => app.quit(id).await,
Request::Search(query) => app.search(&query).await,
Request::Exit => break,
_ => (),
@ -98,6 +98,13 @@ impl<W: AsyncWrite + Unpin> App<W> {
}
}
async fn quit(&mut self, id: u32) {
if let Some(id) = self.entries.get(id as usize) {
let entity = id.entity;
let _ = self.call_method("WindowQuit", &(entity,));
}
}
async fn search(&mut self, query: &str) {
let query = query.to_ascii_lowercase();
let haystack = query.split_ascii_whitespace().collect::<Vec<&str>>();