Skip to content

Commit 7c207e2

Browse files
committed
fix: super-tab handling and handling of empty results for alt-tab mode
1 parent 953a5b6 commit 7c207e2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/app.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ impl CosmicLauncher {
165165
self.input_value.clear();
166166
self.focused = 0;
167167
self.alt_tab = false;
168+
self.wait_for_result = false;
168169

169170
// XXX The close will reset the launcher, but the search will restart it so it's ready
170171
// for the next time it's opened.
@@ -325,6 +326,8 @@ impl cosmic::Application for CosmicLauncher {
325326
(&self.tx, self.launcher_items.get(i.unwrap_or(self.focused)))
326327
{
327328
let _res = tx.blocking_send(launcher::Request::Activate(item.id));
329+
} else {
330+
return self.hide();
328331
}
329332
}
330333
#[allow(clippy::cast_possible_wrap)]
@@ -424,6 +427,9 @@ impl cosmic::Application for CosmicLauncher {
424427
}
425428
}
426429
pop_launcher::Response::Update(mut list) => {
430+
if self.alt_tab && self.wait_for_result && list.is_empty() {
431+
return self.hide();
432+
}
427433
list.sort_by(|a, b| {
428434
let a = i32::from(a.window.is_none());
429435
let b = i32::from(b.window.is_none());
@@ -530,7 +536,7 @@ impl cosmic::Application for CosmicLauncher {
530536
) -> iced::Command<cosmic::app::Message<Self::Message>> {
531537
match msg.msg {
532538
DbusActivationDetails::Activate => {
533-
if self.active_surface {
539+
if self.active_surface || self.wait_for_result {
534540
return self.hide();
535541
} else if self.last_hide.elapsed().as_millis() > 100 {
536542
if let Some(tx) = &self.tx {
@@ -556,6 +562,9 @@ impl cosmic::Application for CosmicLauncher {
556562
tracing::info!("NOT FOUND");
557563
}
558564
if self.active_surface {
565+
if self.launcher_items.is_empty() {
566+
return cosmic::command::message(cosmic::app::message::app(Message::Hide));
567+
}
559568
return cosmic::command::message(cosmic::app::message::app(Message::AltTab));
560569
}
561570

@@ -887,7 +896,7 @@ impl cosmic::Application for CosmicLauncher {
887896
}
888897
Key::Named(Named::Escape) => Some(Message::Hide),
889898
Key::Named(Named::Tab) => Some(Message::TabRelease),
890-
Key::Named(Named::Alt) => Some(Message::AltRelease),
899+
Key::Named(Named::Alt | Named::Super) => Some(Message::AltRelease),
891900
_ => None,
892901
},
893902
cosmic::iced::Event::Keyboard(iced::keyboard::Event::KeyPressed {

0 commit comments

Comments
 (0)