fix(layout): tab focus (#2197)
* fix(layout): tab focus * style(fmt): rustfmt
This commit is contained in:
parent
0a8e9f13a3
commit
6a2a845086
2 changed files with 25 additions and 7 deletions
|
|
@ -385,9 +385,9 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
|
|||
.as_ref()
|
||||
.unwrap()
|
||||
.senders
|
||||
.send_to_pty(PtyInstruction::GoToTab(
|
||||
.send_to_screen(ScreenInstruction::GoToTab(
|
||||
(focused_tab_index + 1) as u32,
|
||||
client_id,
|
||||
Some(client_id),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1413,6 +1413,10 @@ pub(crate) fn screen_thread_main(
|
|||
copy_options,
|
||||
);
|
||||
|
||||
let mut pending_tab_ids: HashSet<usize> = HashSet::new();
|
||||
let mut pending_tab_switches: HashSet<(usize, ClientId)> = HashSet::new(); // usize is the
|
||||
// tab_index
|
||||
|
||||
loop {
|
||||
let (event, mut err_ctx) = screen
|
||||
.bus
|
||||
|
|
@ -2011,6 +2015,7 @@ pub(crate) fn screen_thread_main(
|
|||
client_id,
|
||||
) => {
|
||||
let tab_index = screen.get_new_tab_index();
|
||||
pending_tab_ids.insert(tab_index);
|
||||
screen.new_tab(tab_index, swap_layouts, client_id)?;
|
||||
screen
|
||||
.bus
|
||||
|
|
@ -2042,11 +2047,17 @@ pub(crate) fn screen_thread_main(
|
|||
tab_index,
|
||||
client_id,
|
||||
)?;
|
||||
pending_tab_ids.remove(&tab_index);
|
||||
if pending_tab_ids.is_empty() {
|
||||
for (tab_index, client_id) in pending_tab_switches.drain() {
|
||||
screen.go_to_tab(tab_index as usize, client_id)?;
|
||||
}
|
||||
}
|
||||
screen.unblock_input()?;
|
||||
screen.render()?;
|
||||
},
|
||||
ScreenInstruction::GoToTab(tab_index, client_id) => {
|
||||
let client_id = if client_id.is_none() {
|
||||
let client_id_to_switch = if client_id.is_none() {
|
||||
None
|
||||
} else if screen
|
||||
.active_tab_indices
|
||||
|
|
@ -2056,10 +2067,17 @@ pub(crate) fn screen_thread_main(
|
|||
} else {
|
||||
screen.active_tab_indices.keys().next().copied()
|
||||
};
|
||||
if let Some(client_id) = client_id {
|
||||
screen.go_to_tab(tab_index as usize, client_id)?;
|
||||
screen.unblock_input()?;
|
||||
screen.render()?;
|
||||
match client_id_to_switch {
|
||||
Some(client_id) => {
|
||||
screen.go_to_tab(tab_index as usize, client_id)?;
|
||||
screen.unblock_input()?;
|
||||
screen.render()?;
|
||||
},
|
||||
None => {
|
||||
if let Some(client_id) = client_id {
|
||||
pending_tab_switches.insert((tab_index as usize, client_id));
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
ScreenInstruction::GoToTabName(tab_name, swap_layouts, create, client_id) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue