aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorBrooks Rady <b.j.rady@gmail.com>2021-04-23 04:03:43 +0100
committerGitHub <noreply@github.com>2021-04-23 04:03:43 +0100
commit63da95c50faa98cd127593a57f635f3a8ff1349e (patch)
treec66e6acda2ddb5aa3959c935bb534efb526013f6 /src/client
parentchore(version): 0.5.1 (diff)
parentFixing snapshots (diff)
downloadsl0ppij-63da95c50faa98cd127593a57f635f3a8ff1349e.tar.gz
sl0ppij-63da95c50faa98cd127593a57f635f3a8ff1349e.tar.xz
sl0ppij-63da95c50faa98cd127593a57f635f3a8ff1349e.zip
fix(ui): resolve ambigous pane movements activity history
Adding field active_at and using it to sort panes. This closes #230 by resolving ambiguous movements in favor of the most-recently visited pane.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/panes/plugin_pane.rs15
-rw-r--r--src/client/panes/terminal_pane.rs11
-rw-r--r--src/client/tab.rs12
3 files changed, 32 insertions, 6 deletions
diff --git a/src/client/panes/plugin_pane.rs b/src/client/panes/plugin_pane.rs
index a5b99bb5..21480ac2 100644
--- a/src/client/panes/plugin_pane.rs
+++ b/src/client/panes/plugin_pane.rs
@@ -1,9 +1,10 @@
use crate::{common::SenderWithContext, pty_bus::VteBytes, tab::Pane, wasm_vm::PluginInstruction};
-use std::{sync::mpsc::channel, unimplemented};
-
use crate::panes::{PaneId, PositionAndSize};
+use std::time::Instant;
+use std::{sync::mpsc::channel, unimplemented};
+
pub struct PluginPane {
pub pid: u32,
pub should_render: bool,
@@ -14,6 +15,7 @@ pub struct PluginPane {
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
pub max_height: Option<usize>,
pub max_width: Option<usize>,
+ pub active_at: Instant,
}
impl PluginPane {
@@ -32,6 +34,7 @@ impl PluginPane {
send_plugin_instructions,
max_height: None,
max_width: None,
+ active_at: Instant::now(),
}
}
}
@@ -207,4 +210,12 @@ impl Pane for PluginPane {
fn invisible_borders(&self) -> bool {
self.invisible_borders
}
+
+ fn active_at(&self) -> Instant {
+ self.active_at
+ }
+
+ fn set_active_at(&mut self, time: Instant) {
+ self.active_at = time;
+ }
}
diff --git a/src/client/panes/terminal_pane.rs b/src/client/panes/terminal_pane.rs
index 51f735d4..ddb10889 100644
--- a/src/client/panes/terminal_pane.rs
+++ b/src/client/panes/terminal_pane.rs
@@ -2,6 +2,7 @@ use crate::tab::Pane;
use ::nix::pty::Winsize;
use ::std::os::unix::io::RawFd;
use std::fmt::Debug;
+use std::time::Instant;
use crate::panes::grid::Grid;
use crate::panes::terminal_character::{
@@ -45,6 +46,7 @@ pub struct TerminalPane {
pub position_and_size_override: Option<PositionAndSize>,
pub max_height: Option<usize>,
pub max_width: Option<usize>,
+ pub active_at: Instant,
vte_parser: vte::Parser,
}
@@ -282,6 +284,14 @@ impl Pane for TerminalPane {
self.grid.reset_viewport();
self.grid.should_render = true;
}
+
+ fn active_at(&self) -> Instant {
+ self.active_at
+ }
+
+ fn set_active_at(&mut self, time: Instant) {
+ self.active_at = time;
+ }
}
impl TerminalPane {
@@ -296,6 +306,7 @@ impl TerminalPane {
max_height: None,
max_width: None,
vte_parser: vte::Parser::new(),
+ active_at: Instant::now(),
}
}
pub fn get_x(&self) -> usize {
diff --git a/src/client/tab.rs b/src/client/tab.rs
index 04d53f79..af48d3fe 100644
--- a/src/client/tab.rs
+++ b/src/client/tab.rs
@@ -13,6 +13,7 @@ use crate::wasm_vm::PluginInstruction;
use crate::{boundaries::Boundaries, panes::PluginPane};
use serde::{Deserialize, Serialize};
use std::os::unix::io::RawFd;
+use std::time::Instant;
use std::{
cmp::Reverse,
collections::{BTreeMap, HashSet},
@@ -122,6 +123,8 @@ pub trait Pane {
fn scroll_up(&mut self, count: usize);
fn scroll_down(&mut self, count: usize);
fn clear_scroll(&mut self);
+ fn active_at(&self) -> Instant;
+ fn set_active_at(&mut self, instant: Instant);
fn right_boundary_x_coords(&self) -> usize {
self.x() + self.columns()
@@ -700,6 +703,7 @@ impl Tab {
if !self.panes_to_hide.contains(&pane.pid()) {
match self.active_terminal.unwrap() == pane.pid() {
true => {
+ pane.set_active_at(Instant::now());
boundaries.add_rect(pane.as_ref(), self.mode_info.mode, Some(colors::GREEN))
}
false => boundaries.add_rect(pane.as_ref(), self.mode_info.mode, None),
@@ -1837,7 +1841,7 @@ impl Tab {
.filter(|(_, (_, c))| {
c.is_directly_left_of(active) && c.horizontally_overlaps_with(active)
})
- .max_by_key(|(_, (_, c))| c.get_horizontal_overlap_with(active))
+ .max_by_key(|(_, (_, c))| c.active_at())
.map(|(_, (pid, _))| pid);
match next_index {
Some(&p) => {
@@ -1867,7 +1871,7 @@ impl Tab {
.filter(|(_, (_, c))| {
c.is_directly_below(active) && c.vertically_overlaps_with(active)
})
- .max_by_key(|(_, (_, c))| c.get_vertical_overlap_with(active))
+ .max_by_key(|(_, (_, c))| c.active_at())
.map(|(_, (pid, _))| pid);
match next_index {
Some(&p) => {
@@ -1897,7 +1901,7 @@ impl Tab {
.filter(|(_, (_, c))| {
c.is_directly_above(active) && c.vertically_overlaps_with(active)
})
- .max_by_key(|(_, (_, c))| c.get_vertical_overlap_with(active))
+ .max_by_key(|(_, (_, c))| c.active_at())
.map(|(_, (pid, _))| pid);
match next_index {
Some(&p) => {
@@ -1927,7 +1931,7 @@ impl Tab {
.filter(|(_, (_, c))| {
c.is_directly_right_of(active) && c.horizontally_overlaps_with(active)
})
- .max_by_key(|(_, (_, c))| c.get_horizontal_overlap_with(active))
+ .max_by_key(|(_, (_, c))| c.active_at())
.map(|(_, (pid, _))| pid);
match next_index {
Some(&p) => {