Merge pull request #603 from pop-os/context-focus
fix: disable terminal box when context page is active
This commit is contained in:
commit
c13ec4b41b
2 changed files with 22 additions and 2 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -636,6 +636,9 @@ impl App {
|
||||||
fn update_focus(&self) -> Task<Message> {
|
fn update_focus(&self) -> Task<Message> {
|
||||||
if self.find {
|
if self.find {
|
||||||
widget::text_input::focus(self.find_search_id.clone())
|
widget::text_input::focus(self.find_search_id.clone())
|
||||||
|
} else if self.core.window.show_context {
|
||||||
|
// TODO focus the context page?
|
||||||
|
Task::none()
|
||||||
} else if let Some(terminal_id) = self.terminal_ids.get(&self.pane_model.focused()).cloned()
|
} else if let Some(terminal_id) = self.terminal_ids.get(&self.pane_model.focused()).cloned()
|
||||||
{
|
{
|
||||||
widget::text_input::focus(terminal_id)
|
widget::text_input::focus(terminal_id)
|
||||||
|
|
@ -2656,9 +2659,13 @@ impl Application for App {
|
||||||
Message::ToggleContextPage(context_page) => {
|
Message::ToggleContextPage(context_page) => {
|
||||||
if self.context_page == context_page {
|
if self.context_page == context_page {
|
||||||
self.core.window.show_context = !self.core.window.show_context;
|
self.core.window.show_context = !self.core.window.show_context;
|
||||||
|
self.pane_model.update_terminal_focus();
|
||||||
|
|
||||||
|
return self.update_focus();
|
||||||
} else {
|
} else {
|
||||||
self.context_page = context_page;
|
self.context_page = context_page;
|
||||||
self.core.window.show_context = true;
|
self.core.window.show_context = true;
|
||||||
|
self.pane_model.unfocus_all_terminals();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra work to do to prepare context pages
|
// Extra work to do to prepare context pages
|
||||||
|
|
@ -2716,7 +2723,9 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Message::WindowFocused => {
|
Message::WindowFocused => {
|
||||||
self.pane_model.update_terminal_focus();
|
if !self.core.window.show_context {
|
||||||
|
self.pane_model.update_terminal_focus();
|
||||||
|
}
|
||||||
return self.update_focus();
|
return self.update_focus();
|
||||||
}
|
}
|
||||||
Message::WindowUnfocused => {
|
Message::WindowUnfocused => {
|
||||||
|
|
@ -2829,6 +2838,7 @@ impl Application for App {
|
||||||
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||||
let mut terminal_box = terminal_box(terminal)
|
let mut terminal_box = terminal_box(terminal)
|
||||||
.id(terminal_id)
|
.id(terminal_id)
|
||||||
|
.disabled(self.core.window.show_context)
|
||||||
.on_context_menu(move |menu_state| Message::TabContextMenu(pane, menu_state))
|
.on_context_menu(move |menu_state| Message::TabContextMenu(pane, menu_state))
|
||||||
.on_middle_click(move || Message::MiddleClick(pane, Some(entity_middle_click)))
|
.on_middle_click(move || Message::MiddleClick(pane, Some(entity_middle_click)))
|
||||||
.on_open_hyperlink(Some(Box::new(Message::LaunchUrl)))
|
.on_open_hyperlink(Some(Box::new(Message::LaunchUrl)))
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ pub struct TerminalBox<'a, Message> {
|
||||||
on_window_unfocused: Option<Box<dyn Fn() -> Message + 'a>>,
|
on_window_unfocused: Option<Box<dyn Fn() -> Message + 'a>>,
|
||||||
key_binds: HashMap<KeyBind, Action>,
|
key_binds: HashMap<KeyBind, Action>,
|
||||||
sharp_corners: bool,
|
sharp_corners: bool,
|
||||||
|
disabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message> TerminalBox<'a, Message>
|
impl<'a, Message> TerminalBox<'a, Message>
|
||||||
|
|
@ -91,6 +92,7 @@ where
|
||||||
on_window_focused: None,
|
on_window_focused: None,
|
||||||
on_window_unfocused: None,
|
on_window_unfocused: None,
|
||||||
sharp_corners: false,
|
sharp_corners: false,
|
||||||
|
disabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,6 +171,11 @@ where
|
||||||
self.on_window_unfocused = Some(Box::new(on_window_unfocused));
|
self.on_window_unfocused = Some(Box::new(on_window_unfocused));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn disabled(mut self, disabled: bool) -> Self {
|
||||||
|
self.disabled = disabled;
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn terminal_box<Message>(terminal: &Mutex<Terminal>) -> TerminalBox<'_, Message>
|
pub fn terminal_box<Message>(terminal: &Mutex<Terminal>) -> TerminalBox<'_, Message>
|
||||||
|
|
@ -337,7 +344,7 @@ where
|
||||||
// Render default background
|
// Render default background
|
||||||
{
|
{
|
||||||
let meta = &terminal.metadata_set[terminal.default_attrs().metadata];
|
let meta = &terminal.metadata_set[terminal.default_attrs().metadata];
|
||||||
let background_color = shade(meta.bg, state.is_focused);
|
let background_color = shade(meta.bg, state.is_focused && !self.disabled);
|
||||||
|
|
||||||
renderer.fill_quad(
|
renderer.fill_quad(
|
||||||
Quad {
|
Quad {
|
||||||
|
|
@ -737,6 +744,9 @@ where
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
_viewport: &Rectangle<f32>,
|
_viewport: &Rectangle<f32>,
|
||||||
) -> Status {
|
) -> Status {
|
||||||
|
if self.disabled {
|
||||||
|
return Status::Ignored;
|
||||||
|
}
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
let scrollbar_rect = state.scrollbar_rect.get();
|
let scrollbar_rect = state.scrollbar_rect.get();
|
||||||
let mut terminal = self.terminal.lock().unwrap();
|
let mut terminal = self.terminal.lock().unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue