Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/gui/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ fn load_tray_icon_rgba(bytes: &[u8]) -> Result<(Vec<u8>, u32, u32), image::Image

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum TrayEvent {
Show,
Settings,
About,
Quit,
Expand Down Expand Up @@ -183,6 +184,9 @@ fn spawn_tray_event_loop(
cx.spawn(async move |async_app| {
while let Ok(event) = rx.recv().await {
match event {
TrayEvent::Show => {
let _ = async_app.update(|cx| send_active_action(window_handle, cx));
}
TrayEvent::Settings => {
let _ = async_app.update(|cx| send_open_settings(window_handle, cx));
}
Expand Down Expand Up @@ -219,6 +223,14 @@ pub(crate) fn start_tray_handler_inner(
}
}

fn send_active_action(window_handle: WindowHandle<Root>, cx: &mut App) {
window_handle
.update(cx, |_, window: &mut gpui::Window, cx| {
window.dispatch_action(Box::new(crate::gui::board::Active), cx);
})
.ok();
}

pub(crate) fn send_open_settings(window_handle: WindowHandle<Root>, cx: &mut App) {
window_handle
.update(cx, |root, window: &mut gpui::Window, cx| {
Expand Down Expand Up @@ -317,7 +329,7 @@ fn tray_event_from_icon_event(event: &TrayIconEvent) -> Option<TrayEvent> {
if let TrayIconEvent::Click { button, .. } = event
&& *button == tray_icon::MouseButton::Left
{
Some(TrayEvent::Settings)
Some(TrayEvent::Show)
} else {
None
}
Expand Down Expand Up @@ -403,7 +415,7 @@ mod tests {
button: tray_icon::MouseButton::Left,
button_state: tray_icon::MouseButtonState::Up,
},
Some(TrayEvent::Settings)
Some(TrayEvent::Show)
)]
#[case(
TrayIconEvent::Click {
Expand Down
Loading