aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-30 17:27:25 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-30 17:29:57 +0400
commit6f8ad18d9ad3e3a0a5973c14468e8c5ca2f4a952 (patch)
tree32a41002f1e5748dbf2e12ba06d801889a210b41 /src
parenta3aa5fca12b59df0c1ee421b482a51a425e25abd (diff)
downloadniri-6f8ad18d9ad3e3a0a5973c14468e8c5ca2f4a952.tar.gz
niri-6f8ad18d9ad3e3a0a5973c14468e8c5ca2f4a952.tar.bz2
niri-6f8ad18d9ad3e3a0a5973c14468e8c5ca2f4a952.zip
Compute view offset relative to anim target
This enables quickly tapping focus right-left to keep typing in the current window while showing the next window. Resolves https://github.com/YaLTeR/niri/issues/26
Diffstat (limited to 'src')
-rw-r--r--src/layout.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/layout.rs b/src/layout.rs
index f878ed9e..38c076b6 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -1539,6 +1539,12 @@ impl<W: LayoutElement> Workspace<W> {
let current_x = self.view_pos();
+ let final_x = if let Some(anim) = &self.view_offset_anim {
+ current_x - self.view_offset + anim.to().round() as i32
+ } else {
+ current_x
+ };
+
self.active_column_idx = idx;
// A different column was activated; reset the flag.
@@ -1546,7 +1552,7 @@ impl<W: LayoutElement> Workspace<W> {
let new_x = self.column_x(idx) - PADDING;
let new_view_offset = compute_new_view_offset(
- current_x,
+ final_x,
self.working_area.size.w,
new_x,
self.columns[idx].size().w,
@@ -1661,10 +1667,17 @@ impl<W: LayoutElement> Workspace<W> {
if idx == self.active_column_idx {
// We might need to move the view to ensure the resized window is still visible.
let current_x = self.view_pos();
+
+ let final_x = if let Some(anim) = &self.view_offset_anim {
+ current_x - self.view_offset + anim.to().round() as i32
+ } else {
+ current_x
+ };
+
let new_x = self.column_x(idx) - PADDING;
let new_view_offset = compute_new_view_offset(
- current_x,
+ final_x,
self.working_area.size.w,
new_x,
self.columns[idx].size().w,