Skip to content

Commit

Permalink
Fix bug to handle dashboard events on popout windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Sep 30, 2024
1 parent aac1fcf commit 7b6c4d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
26 changes: 12 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,20 +779,18 @@ impl Halloy {
},
},
Message::Event(window, event) => {
// Events only enabled for main window
if window == self.main_window.id {
if let Screen::Dashboard(dashboard) = &mut self.screen {
return dashboard
.handle_event(
event,
&self.clients,
&self.version,
&self.config,
&mut self.theme,
&self.main_window,
)
.map(Message::Dashboard);
}
if let Screen::Dashboard(dashboard) = &mut self.screen {
return dashboard
.handle_event(
window,
event,
&self.clients,
&self.version,
&self.config,
&mut self.theme,
&self.main_window,
)
.map(Message::Dashboard);
}

Task::none()
Expand Down
18 changes: 10 additions & 8 deletions src/screen/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use data::environment::RELEASE_WEBSITE;
use data::history::ReadMarker;
use std::collections::HashMap;
use std::path::PathBuf;
use std::slice;
use std::time::{Duration, Instant};
use std::{convert, slice};

use data::config;
use data::file_transfer;
Expand Down Expand Up @@ -55,7 +55,7 @@ pub enum Message {
Shortcut(shortcut::Command),
FileTransfer(file_transfer::task::Update),
SendFileSelected(Server, Nick, Option<PathBuf>),
CloseContextMenu(bool),
CloseContextMenu(window::Id, bool),
ThemeEditor(theme_editor::Message),
ConfigReloaded(Result<Config, config::Error>),
}
Expand Down Expand Up @@ -792,9 +792,9 @@ impl Dashboard {
}
}
}
Message::CloseContextMenu(any_closed) => {
Message::CloseContextMenu(window, any_closed) => {
if !any_closed {
if self.is_pane_maximized() {
if self.is_pane_maximized() && window == main_window.id {
self.panes.main.restore();
} else {
self.focus = None;
Expand Down Expand Up @@ -996,6 +996,7 @@ impl Dashboard {

pub fn handle_event(
&mut self,
window: window::Id,
event: event::Event,
clients: &data::client::Map,
version: &Version,
Expand All @@ -1009,11 +1010,11 @@ impl Dashboard {
Escape => {
// Order of operations
//
// - Close command bar
// - Close command bar (if main window)
// - Close context menu
// - Restore maximized pane
// - Restore maximized pane (if main window)
// - Unfocus
if self.command_bar.is_some() {
if self.command_bar.is_some() && window == main_window.id {
self.toggle_command_bar(
&closed_buffers(self, main_window.id, clients),
version,
Expand All @@ -1022,7 +1023,8 @@ impl Dashboard {
main_window,
)
} else {
context_menu::close(Message::CloseContextMenu)
context_menu::close(convert::identity)
.map(move |any_closed| Message::CloseContextMenu(window, any_closed))
}
}
Copy => selectable_text::selected(Message::SelectedText),
Expand Down

0 comments on commit 7b6c4d9

Please sign in to comment.